index-CvhOt4Al.js 2.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611
  1. function gne(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 Db=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Zs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var NA={exports:{}},Dg={};var eU;function xne(){if(eU)return Dg;eU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,a){var s=null;if(a!==void 0&&(s=""+a),i.key!==void 0&&(s=""+i.key),"key"in i){a={};for(var o in i)o!=="key"&&(a[o]=i[o])}else a=i;return i=a.ref,{$$typeof:t,type:r,key:s,ref:i!==void 0?i:null,props:a}}return Dg.Fragment=e,Dg.jsx=n,Dg.jsxs=n,Dg}var tU;function vne(){return tU||(tU=1,NA.exports=xne()),NA.exports}var f=vne(),RA={exports:{}},Zt={};var nU;function bne(){if(nU)return Zt;nU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),s=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),c=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function m(H){return H===null||typeof H!="object"?null:(H=g&&H[g]||H["@@iterator"],typeof H=="function"?H:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,v={};function x(H,q,ae){this.props=H,this.context=q,this.refs=v,this.updater=ae||b}x.prototype.isReactComponent={},x.prototype.setState=function(H,q){if(typeof H!="object"&&typeof H!="function"&&H!=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,H,q,"setState")},x.prototype.forceUpdate=function(H){this.updater.enqueueForceUpdate(this,H,"forceUpdate")};function M(){}M.prototype=x.prototype;function w(H,q,ae){this.props=H,this.context=q,this.refs=v,this.updater=ae||b}var C=w.prototype=new M;C.constructor=w,y(C,x.prototype),C.isPureReactComponent=!0;var T=Array.isArray;function R(){}var A={H:null,A:null,T:null,S:null},j=Object.prototype.hasOwnProperty;function N(H,q,ae){var ce=ae.ref;return{$$typeof:t,type:H,key:q,ref:ce!==void 0?ce:null,props:ae}}function k(H,q){return N(H.type,q,H.props)}function F(H){return typeof H=="object"&&H!==null&&H.$$typeof===t}function I(H){var q={"=":"=0",":":"=2"};return"$"+H.replace(/[=:]/g,function(ae){return q[ae]})}var W=/\/+/g;function D(H,q){return typeof H=="object"&&H!==null&&H.key!=null?I(""+H.key):q.toString(36)}function B(H){switch(H.status){case"fulfilled":return H.value;case"rejected":throw H.reason;default:switch(typeof H.status=="string"?H.then(R,R):(H.status="pending",H.then(function(q){H.status==="pending"&&(H.status="fulfilled",H.value=q)},function(q){H.status==="pending"&&(H.status="rejected",H.reason=q)})),H.status){case"fulfilled":return H.value;case"rejected":throw H.reason}}throw H}function G(H,q,ae,ce,xe){var ie=typeof H;(ie==="undefined"||ie==="boolean")&&(H=null);var ve=!1;if(H===null)ve=!0;else switch(ie){case"bigint":case"string":case"number":ve=!0;break;case"object":switch(H.$$typeof){case t:case e:ve=!0;break;case u:return ve=H._init,G(ve(H._payload),q,ae,ce,xe)}}if(ve)return xe=xe(H),ve=ce===""?"."+D(H,0):ce,T(xe)?(ae="",ve!=null&&(ae=ve.replace(W,"$&/")+"/"),G(xe,q,ae,"",function(we){return we})):xe!=null&&(F(xe)&&(xe=k(xe,ae+(xe.key==null||H&&H.key===xe.key?"":(""+xe.key).replace(W,"$&/")+"/")+ve)),q.push(xe)),1;ve=0;var Pe=ce===""?".":ce+":";if(T(H))for(var he=0;he<H.length;he++)ce=H[he],ie=Pe+D(ce,he),ve+=G(ce,q,ae,ie,xe);else if(he=m(H),typeof he=="function")for(H=he.call(H),he=0;!(ce=H.next()).done;)ce=ce.value,ie=Pe+D(ce,he++),ve+=G(ce,q,ae,ie,xe);else if(ie==="object"){if(typeof H.then=="function")return G(B(H),q,ae,ce,xe);throw q=String(H),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys(H).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.")}return ve}function V(H,q,ae){if(H==null)return H;var ce=[],xe=0;return G(H,ce,"","",function(ie){return q.call(ae,ie,xe++)}),ce}function Z(H){if(H._status===-1){var q=H._result;q=q(),q.then(function(ae){(H._status===0||H._status===-1)&&(H._status=1,H._result=ae)},function(ae){(H._status===0||H._status===-1)&&(H._status=2,H._result=ae)}),H._status===-1&&(H._status=0,H._result=q)}if(H._status===1)return H._result.default;throw H._result}var Y=typeof reportError=="function"?reportError:function(H){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var q=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(q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",H);return}console.error(H)},ee={map:V,forEach:function(H,q,ae){V(H,function(){q.apply(this,arguments)},ae)},count:function(H){var q=0;return V(H,function(){q++}),q},toArray:function(H){return V(H,function(q){return q})||[]},only:function(H){if(!F(H))throw Error("React.Children.only expected to receive a single React element child.");return H}};return Zt.Activity=h,Zt.Children=ee,Zt.Component=x,Zt.Fragment=n,Zt.Profiler=i,Zt.PureComponent=w,Zt.StrictMode=r,Zt.Suspense=l,Zt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=A,Zt.__COMPILER_RUNTIME={__proto__:null,c:function(H){return A.H.useMemoCache(H)}},Zt.cache=function(H){return function(){return H.apply(null,arguments)}},Zt.cacheSignal=function(){return null},Zt.cloneElement=function(H,q,ae){if(H==null)throw Error("The argument must be a React element, but you passed "+H+".");var ce=y({},H.props),xe=H.key;if(q!=null)for(ie in q.key!==void 0&&(xe=""+q.key),q)!j.call(q,ie)||ie==="key"||ie==="__self"||ie==="__source"||ie==="ref"&&q.ref===void 0||(ce[ie]=q[ie]);var ie=arguments.length-2;if(ie===1)ce.children=ae;else if(1<ie){for(var ve=Array(ie),Pe=0;Pe<ie;Pe++)ve[Pe]=arguments[Pe+2];ce.children=ve}return N(H.type,xe,ce)},Zt.createContext=function(H){return H={$$typeof:s,_currentValue:H,_currentValue2:H,_threadCount:0,Provider:null,Consumer:null},H.Provider=H,H.Consumer={$$typeof:a,_context:H},H},Zt.createElement=function(H,q,ae){var ce,xe={},ie=null;if(q!=null)for(ce in q.key!==void 0&&(ie=""+q.key),q)j.call(q,ce)&&ce!=="key"&&ce!=="__self"&&ce!=="__source"&&(xe[ce]=q[ce]);var ve=arguments.length-2;if(ve===1)xe.children=ae;else if(1<ve){for(var Pe=Array(ve),he=0;he<ve;he++)Pe[he]=arguments[he+2];xe.children=Pe}if(H&&H.defaultProps)for(ce in ve=H.defaultProps,ve)xe[ce]===void 0&&(xe[ce]=ve[ce]);return N(H,ie,xe)},Zt.createRef=function(){return{current:null}},Zt.forwardRef=function(H){return{$$typeof:o,render:H}},Zt.isValidElement=F,Zt.lazy=function(H){return{$$typeof:u,_payload:{_status:-1,_result:H},_init:Z}},Zt.memo=function(H,q){return{$$typeof:c,type:H,compare:q===void 0?null:q}},Zt.startTransition=function(H){var q=A.T,ae={};A.T=ae;try{var ce=H(),xe=A.S;xe!==null&&xe(ae,ce),typeof ce=="object"&&ce!==null&&typeof ce.then=="function"&&ce.then(R,Y)}catch(ie){Y(ie)}finally{q!==null&&ae.types!==null&&(q.types=ae.types),A.T=q}},Zt.unstable_useCacheRefresh=function(){return A.H.useCacheRefresh()},Zt.use=function(H){return A.H.use(H)},Zt.useActionState=function(H,q,ae){return A.H.useActionState(H,q,ae)},Zt.useCallback=function(H,q){return A.H.useCallback(H,q)},Zt.useContext=function(H){return A.H.useContext(H)},Zt.useDebugValue=function(){},Zt.useDeferredValue=function(H,q){return A.H.useDeferredValue(H,q)},Zt.useEffect=function(H,q){return A.H.useEffect(H,q)},Zt.useEffectEvent=function(H){return A.H.useEffectEvent(H)},Zt.useId=function(){return A.H.useId()},Zt.useImperativeHandle=function(H,q,ae){return A.H.useImperativeHandle(H,q,ae)},Zt.useInsertionEffect=function(H,q){return A.H.useInsertionEffect(H,q)},Zt.useLayoutEffect=function(H,q){return A.H.useLayoutEffect(H,q)},Zt.useMemo=function(H,q){return A.H.useMemo(H,q)},Zt.useOptimistic=function(H,q){return A.H.useOptimistic(H,q)},Zt.useReducer=function(H,q,ae){return A.H.useReducer(H,q,ae)},Zt.useRef=function(H){return A.H.useRef(H)},Zt.useState=function(H){return A.H.useState(H)},Zt.useSyncExternalStore=function(H,q,ae){return A.H.useSyncExternalStore(H,q,ae)},Zt.useTransition=function(){return A.H.useTransition()},Zt.version="19.2.0",Zt}var rU;function ym(){return rU||(rU=1,RA.exports=bne()),RA.exports}var E=ym();const ur=Zs(E),yne=gne({__proto__:null,default:ur},[E]);var PA={exports:{}},Og={},kA={exports:{}},DA={};var iU;function _ne(){return iU||(iU=1,(function(t){function e(G,V){var Z=G.length;G.push(V);e:for(;0<Z;){var Y=Z-1>>>1,ee=G[Y];if(0<i(ee,V))G[Y]=V,G[Z]=ee,Z=Y;else break e}}function n(G){return G.length===0?null:G[0]}function r(G){if(G.length===0)return null;var V=G[0],Z=G.pop();if(Z!==V){G[0]=Z;e:for(var Y=0,ee=G.length,H=ee>>>1;Y<H;){var q=2*(Y+1)-1,ae=G[q],ce=q+1,xe=G[ce];if(0>i(ae,Z))ce<ee&&0>i(xe,ae)?(G[Y]=xe,G[ce]=Z,Y=ce):(G[Y]=ae,G[q]=Z,Y=q);else if(ce<ee&&0>i(xe,Z))G[Y]=xe,G[ce]=Z,Y=ce;else break e}}return V}function i(G,V){var Z=G.sortIndex-V.sortIndex;return Z!==0?Z:G.id-V.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var s=Date,o=s.now();t.unstable_now=function(){return s.now()-o}}var l=[],c=[],u=1,h=null,g=3,m=!1,b=!1,y=!1,v=!1,x=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;function C(G){for(var V=n(c);V!==null;){if(V.callback===null)r(c);else if(V.startTime<=G)r(c),V.sortIndex=V.expirationTime,e(l,V);else break;V=n(c)}}function T(G){if(y=!1,C(G),!b)if(n(l)!==null)b=!0,R||(R=!0,I());else{var V=n(c);V!==null&&B(T,V.startTime-G)}}var R=!1,A=-1,j=5,N=-1;function k(){return v?!0:!(t.unstable_now()-N<j)}function F(){if(v=!1,R){var G=t.unstable_now();N=G;var V=!0;try{e:{b=!1,y&&(y=!1,M(A),A=-1),m=!0;var Z=g;try{t:{for(C(G),h=n(l);h!==null&&!(h.expirationTime>G&&k());){var Y=h.callback;if(typeof Y=="function"){h.callback=null,g=h.priorityLevel;var ee=Y(h.expirationTime<=G);if(G=t.unstable_now(),typeof ee=="function"){h.callback=ee,C(G),V=!0;break t}h===n(l)&&r(l),C(G)}else r(l);h=n(l)}if(h!==null)V=!0;else{var H=n(c);H!==null&&B(T,H.startTime-G),V=!1}}break e}finally{h=null,g=Z,m=!1}V=void 0}}finally{V?I():R=!1}}}var I;if(typeof w=="function")I=function(){w(F)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,D=W.port2;W.port1.onmessage=F,I=function(){D.postMessage(null)}}else I=function(){x(F,0)};function B(G,V){A=x(function(){G(t.unstable_now())},V)}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(G){G.callback=null},t.unstable_forceFrameRate=function(G){0>G||125<G?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):j=0<G?Math.floor(1e3/G):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_next=function(G){switch(g){case 1:case 2:case 3:var V=3;break;default:V=g}var Z=g;g=V;try{return G()}finally{g=Z}},t.unstable_requestPaint=function(){v=!0},t.unstable_runWithPriority=function(G,V){switch(G){case 1:case 2:case 3:case 4:case 5:break;default:G=3}var Z=g;g=G;try{return V()}finally{g=Z}},t.unstable_scheduleCallback=function(G,V,Z){var Y=t.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?Y+Z:Y):Z=Y,G){case 1:var ee=-1;break;case 2:ee=250;break;case 5:ee=1073741823;break;case 4:ee=1e4;break;default:ee=5e3}return ee=Z+ee,G={id:u++,callback:V,priorityLevel:G,startTime:Z,expirationTime:ee,sortIndex:-1},Z>Y?(G.sortIndex=Z,e(c,G),n(l)===null&&G===n(c)&&(y?(M(A),A=-1):y=!0,B(T,Z-Y))):(G.sortIndex=ee,e(l,G),b||m||(b=!0,R||(R=!0,I()))),G},t.unstable_shouldYield=k,t.unstable_wrapCallback=function(G){var V=g;return function(){var Z=g;g=V;try{return G.apply(this,arguments)}finally{g=Z}}}})(DA)),DA}var aU;function Sne(){return aU||(aU=1,kA.exports=_ne()),kA.exports}var OA={exports:{}},Xi={};var sU;function wne(){if(sU)return Xi;sU=1;var t=ym();function e(l){var c="https://react.dev/errors/"+l;if(1<arguments.length){c+="?args[]="+encodeURIComponent(arguments[1]);for(var u=2;u<arguments.length;u++)c+="&args[]="+encodeURIComponent(arguments[u])}return"Minified React error #"+l+"; visit "+c+" 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(l,c,u){var h=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:h==null?null:""+h,children:l,containerInfo:c,implementation:u}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function o(l,c){if(l==="font")return"";if(typeof c=="string")return c==="use-credentials"?c:""}return Xi.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Xi.createPortal=function(l,c){var u=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11)throw Error(e(299));return a(l,c,null,u)},Xi.flushSync=function(l){var c=s.T,u=r.p;try{if(s.T=null,r.p=2,l)return l()}finally{s.T=c,r.p=u,r.d.f()}},Xi.preconnect=function(l,c){typeof l=="string"&&(c?(c=c.crossOrigin,c=typeof c=="string"?c==="use-credentials"?c:"":void 0):c=null,r.d.C(l,c))},Xi.prefetchDNS=function(l){typeof l=="string"&&r.d.D(l)},Xi.preinit=function(l,c){if(typeof l=="string"&&c&&typeof c.as=="string"){var u=c.as,h=o(u,c.crossOrigin),g=typeof c.integrity=="string"?c.integrity:void 0,m=typeof c.fetchPriority=="string"?c.fetchPriority:void 0;u==="style"?r.d.S(l,typeof c.precedence=="string"?c.precedence:void 0,{crossOrigin:h,integrity:g,fetchPriority:m}):u==="script"&&r.d.X(l,{crossOrigin:h,integrity:g,fetchPriority:m,nonce:typeof c.nonce=="string"?c.nonce:void 0})}},Xi.preinitModule=function(l,c){if(typeof l=="string")if(typeof c=="object"&&c!==null){if(c.as==null||c.as==="script"){var u=o(c.as,c.crossOrigin);r.d.M(l,{crossOrigin:u,integrity:typeof c.integrity=="string"?c.integrity:void 0,nonce:typeof c.nonce=="string"?c.nonce:void 0})}}else c==null&&r.d.M(l)},Xi.preload=function(l,c){if(typeof l=="string"&&typeof c=="object"&&c!==null&&typeof c.as=="string"){var u=c.as,h=o(u,c.crossOrigin);r.d.L(l,u,{crossOrigin:h,integrity:typeof c.integrity=="string"?c.integrity:void 0,nonce:typeof c.nonce=="string"?c.nonce:void 0,type:typeof c.type=="string"?c.type:void 0,fetchPriority:typeof c.fetchPriority=="string"?c.fetchPriority:void 0,referrerPolicy:typeof c.referrerPolicy=="string"?c.referrerPolicy:void 0,imageSrcSet:typeof c.imageSrcSet=="string"?c.imageSrcSet:void 0,imageSizes:typeof c.imageSizes=="string"?c.imageSizes:void 0,media:typeof c.media=="string"?c.media:void 0})}},Xi.preloadModule=function(l,c){if(typeof l=="string")if(c){var u=o(c.as,c.crossOrigin);r.d.m(l,{as:typeof c.as=="string"&&c.as!=="script"?c.as:void 0,crossOrigin:u,integrity:typeof c.integrity=="string"?c.integrity:void 0})}else r.d.m(l)},Xi.requestFormReset=function(l){r.d.r(l)},Xi.unstable_batchedUpdates=function(l,c){return l(c)},Xi.useFormState=function(l,c,u){return s.H.useFormState(l,c,u)},Xi.useFormStatus=function(){return s.H.useHostTransitionStatus()},Xi.version="19.2.0",Xi}var oU;function xG(){if(oU)return OA.exports;oU=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(),OA.exports=wne(),OA.exports}var lU;function Mne(){if(lU)return Og;lU=1;var t=Sne(),e=ym(),n=xG();function r(d){var p="https://react.dev/errors/"+d;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)p+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+d+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(d){return!(!d||d.nodeType!==1&&d.nodeType!==9&&d.nodeType!==11)}function a(d){var p=d,_=d;if(d.alternate)for(;p.return;)p=p.return;else{d=p;do p=d,(p.flags&4098)!==0&&(_=p.return),d=p.return;while(d)}return p.tag===3?_:null}function s(d){if(d.tag===13){var p=d.memoizedState;if(p===null&&(d=d.alternate,d!==null&&(p=d.memoizedState)),p!==null)return p.dehydrated}return null}function o(d){if(d.tag===31){var p=d.memoizedState;if(p===null&&(d=d.alternate,d!==null&&(p=d.memoizedState)),p!==null)return p.dehydrated}return null}function l(d){if(a(d)!==d)throw Error(r(188))}function c(d){var p=d.alternate;if(!p){if(p=a(d),p===null)throw Error(r(188));return p!==d?null:d}for(var _=d,S=p;;){var P=_.return;if(P===null)break;var O=P.alternate;if(O===null){if(S=P.return,S!==null){_=S;continue}break}if(P.child===O.child){for(O=P.child;O;){if(O===_)return l(P),d;if(O===S)return l(P),p;O=O.sibling}throw Error(r(188))}if(_.return!==S.return)_=P,S=O;else{for(var X=!1,se=P.child;se;){if(se===_){X=!0,_=P,S=O;break}if(se===S){X=!0,S=P,_=O;break}se=se.sibling}if(!X){for(se=O.child;se;){if(se===_){X=!0,_=O,S=P;break}if(se===S){X=!0,S=O,_=P;break}se=se.sibling}if(!X)throw Error(r(189))}}if(_.alternate!==S)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?d:p}function u(d){var p=d.tag;if(p===5||p===26||p===27||p===6)return d;for(d=d.child;d!==null;){if(p=u(d),p!==null)return p;d=d.sibling}return null}var h=Object.assign,g=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),w=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),A=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),k=Symbol.for("react.memo_cache_sentinel"),F=Symbol.iterator;function I(d){return d===null||typeof d!="object"?null:(d=F&&d[F]||d["@@iterator"],typeof d=="function"?d:null)}var W=Symbol.for("react.client.reference");function D(d){if(d==null)return null;if(typeof d=="function")return d.$$typeof===W?null:d.displayName||d.name||null;if(typeof d=="string")return d;switch(d){case y:return"Fragment";case x:return"Profiler";case v:return"StrictMode";case T:return"Suspense";case R:return"SuspenseList";case N:return"Activity"}if(typeof d=="object")switch(d.$$typeof){case b:return"Portal";case w:return d.displayName||"Context";case M:return(d._context.displayName||"Context")+".Consumer";case C:var p=d.render;return d=d.displayName,d||(d=p.displayName||p.name||"",d=d!==""?"ForwardRef("+d+")":"ForwardRef"),d;case A:return p=d.displayName||null,p!==null?p:D(d.type)||"Memo";case j:p=d._payload,d=d._init;try{return D(d(p))}catch{}}return null}var B=Array.isArray,G=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z={pending:!1,data:null,method:null,action:null},Y=[],ee=-1;function H(d){return{current:d}}function q(d){0>ee||(d.current=Y[ee],Y[ee]=null,ee--)}function ae(d,p){ee++,Y[ee]=d.current,d.current=p}var ce=H(null),xe=H(null),ie=H(null),ve=H(null);function Pe(d,p){switch(ae(ie,p),ae(xe,d),ae(ce,null),p.nodeType){case 9:case 11:d=(d=p.documentElement)&&(d=d.namespaceURI)?w4(d):0;break;default:if(d=p.tagName,p=p.namespaceURI)p=w4(p),d=M4(p,d);else switch(d){case"svg":d=1;break;case"math":d=2;break;default:d=0}}q(ce),ae(ce,d)}function he(){q(ce),q(xe),q(ie)}function we(d){d.memoizedState!==null&&ae(ve,d);var p=ce.current,_=M4(p,d.type);p!==_&&(ae(xe,d),ae(ce,_))}function Le(d){xe.current===d&&(q(ce),q(xe)),ve.current===d&&(q(ve),Ng._currentValue=Z)}var de,lt;function $(d){if(de===void 0)try{throw Error()}catch(_){var p=_.stack.trim().match(/\n( *(at )?)/);de=p&&p[1]||"",lt=-1<_.stack.indexOf(`
  2. at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
  3. `+de+d+lt}var z=!1;function ne(d,p){if(!d||z)return"";z=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var S={DetermineComponentFrameRoot:function(){try{if(p){var ut=function(){throw Error()};if(Object.defineProperty(ut.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ut,[])}catch(nt){var Ge=nt}Reflect.construct(d,[],ut)}else{try{ut.call()}catch(nt){Ge=nt}d.call(ut.prototype)}}else{try{throw Error()}catch(nt){Ge=nt}(ut=d())&&typeof ut.catch=="function"&&ut.catch(function(){})}}catch(nt){if(nt&&Ge&&typeof nt.stack=="string")return[nt.stack,Ge.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 O=S.DetermineComponentFrameRoot(),X=O[0],se=O[1];if(X&&se){var Se=X.split(`
  4. `),He=se.split(`
  5. `);for(P=S=0;S<Se.length&&!Se[S].includes("DetermineComponentFrameRoot");)S++;for(;P<He.length&&!He[P].includes("DetermineComponentFrameRoot");)P++;if(S===Se.length||P===He.length)for(S=Se.length-1,P=He.length-1;1<=S&&0<=P&&Se[S]!==He[P];)P--;for(;1<=S&&0<=P;S--,P--)if(Se[S]!==He[P]){if(S!==1||P!==1)do if(S--,P--,0>P||Se[S]!==He[P]){var at=`
  6. `+Se[S].replace(" at new "," at ");return d.displayName&&at.includes("<anonymous>")&&(at=at.replace("<anonymous>",d.displayName)),at}while(1<=S&&0<=P);break}}}finally{z=!1,Error.prepareStackTrace=_}return(_=d?d.displayName||d.name:"")?$(_):""}function K(d,p){switch(d.tag){case 26:case 27:case 5:return $(d.type);case 16:return $("Lazy");case 13:return d.child!==p&&p!==null?$("Suspense Fallback"):$("Suspense");case 19:return $("SuspenseList");case 0:case 15:return ne(d.type,!1);case 11:return ne(d.type.render,!1);case 1:return ne(d.type,!0);case 31:return $("Activity");default:return""}}function Q(d){try{var p="",_=null;do p+=K(d,_),_=d,d=d.return;while(d);return p}catch(S){return`
  7. Error generating stack: `+S.message+`
  8. `+S.stack}}var oe=Object.prototype.hasOwnProperty,Ne=t.unstable_scheduleCallback,Ee=t.unstable_cancelCallback,re=t.unstable_shouldYield,U=t.unstable_requestPaint,L=t.unstable_now,J=t.unstable_getCurrentPriorityLevel,ge=t.unstable_ImmediatePriority,ye=t.unstable_UserBlockingPriority,me=t.unstable_NormalPriority,et=t.unstable_LowPriority,Ie=t.unstable_IdlePriority,Ke=t.log,st=t.unstable_setDisableYieldValue,je=null,le=null;function Ze(d){if(typeof Ke=="function"&&st(d),le&&typeof le.setStrictMode=="function")try{le.setStrictMode(je,d)}catch{}}var Fe=Math.clz32?Math.clz32:ue,Xe=Math.log,ct=Math.LN2;function ue(d){return d>>>=0,d===0?32:31-(Xe(d)/ct|0)|0}var Qe=256,pe=262144,Oe=4194304;function Ae(d){var p=d&42;if(p!==0)return p;switch(d&-d){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 d&261888;case 262144:case 524288:case 1048576:case 2097152:return d&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return d&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return d}}function be(d,p,_){var S=d.pendingLanes;if(S===0)return 0;var P=0,O=d.suspendedLanes,X=d.pingedLanes;d=d.warmLanes;var se=S&134217727;return se!==0?(S=se&~O,S!==0?P=Ae(S):(X&=se,X!==0?P=Ae(X):_||(_=se&~d,_!==0&&(P=Ae(_))))):(se=S&~O,se!==0?P=Ae(se):X!==0?P=Ae(X):_||(_=S&~d,_!==0&&(P=Ae(_)))),P===0?0:p!==0&&p!==P&&(p&O)===0&&(O=P&-P,_=p&-p,O>=_||O===32&&(_&4194048)!==0)?p:P}function $e(d,p){return(d.pendingLanes&~(d.suspendedLanes&~d.pingedLanes)&p)===0}function ft(d,p){switch(d){case 1:case 2:case 4:case 8:case 64:return p+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return p+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function yt(){var d=Oe;return Oe<<=1,(Oe&62914560)===0&&(Oe=4194304),d}function Pt(d){for(var p=[],_=0;31>_;_++)p.push(d);return p}function cn(d,p){d.pendingLanes|=p,p!==268435456&&(d.suspendedLanes=0,d.pingedLanes=0,d.warmLanes=0)}function Ot(d,p,_,S,P,O){var X=d.pendingLanes;d.pendingLanes=_,d.suspendedLanes=0,d.pingedLanes=0,d.warmLanes=0,d.expiredLanes&=_,d.entangledLanes&=_,d.errorRecoveryDisabledLanes&=_,d.shellSuspendCounter=0;var se=d.entanglements,Se=d.expirationTimes,He=d.hiddenUpdates;for(_=X&~_;0<_;){var at=31-Fe(_),ut=1<<at;se[at]=0,Se[at]=-1;var Ge=He[at];if(Ge!==null)for(He[at]=null,at=0;at<Ge.length;at++){var nt=Ge[at];nt!==null&&(nt.lane&=-536870913)}_&=~ut}S!==0&&Rn(d,S,0),O!==0&&P===0&&d.tag!==0&&(d.suspendedLanes|=O&~(X&~p))}function Rn(d,p,_){d.pendingLanes|=p,d.suspendedLanes&=~p;var S=31-Fe(p);d.entangledLanes|=p,d.entanglements[S]=d.entanglements[S]|1073741824|_&261930}function qn(d,p){var _=d.entangledLanes|=p;for(d=d.entanglements;_;){var S=31-Fe(_),P=1<<S;P&p|d[S]&p&&(d[S]|=p),_&=~P}}function pi(d,p){var _=p&-p;return _=(_&42)!==0?1:Qr(_),(_&(d.suspendedLanes|p))!==0?0:_}function Qr(d){switch(d){case 2:d=1;break;case 8:d=4;break;case 32:d=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:d=128;break;case 268435456:d=134217728;break;default:d=0}return d}function mi(d){return d&=-d,2<d?8<d?(d&134217727)!==0?32:268435456:8:2}function Pi(){var d=V.p;return d!==0?d:(d=window.event,d===void 0?32:q4(d.type))}function qi(d,p){var _=V.p;try{return V.p=d,p()}finally{V.p=_}}var Ir=Math.random().toString(36).slice(2),pr="__reactFiber$"+Ir,Tr="__reactProps$"+Ir,Js="__reactContainer$"+Ir,Lc="__reactEvents$"+Ir,fe="__reactListeners$"+Ir,Ue="__reactHandles$"+Ir,Je="__reactResources$"+Ir,tt="__reactMarker$"+Ir;function Ye(d){delete d[pr],delete d[Tr],delete d[Lc],delete d[fe],delete d[Ue]}function _t(d){var p=d[pr];if(p)return p;for(var _=d.parentNode;_;){if(p=_[Js]||_[pr]){if(_=p.alternate,p.child!==null||_!==null&&_.child!==null)for(d=P4(d);d!==null;){if(_=d[pr])return _;d=P4(d)}return p}d=_,_=d.parentNode}return null}function te(d){if(d=d[pr]||d[Js]){var p=d.tag;if(p===5||p===6||p===13||p===31||p===26||p===27||p===3)return d}return null}function _e(d){var p=d.tag;if(p===5||p===26||p===27||p===6)return d.stateNode;throw Error(r(33))}function ke(d){var p=d[Je];return p||(p=d[Je]={hoistableStyles:new Map,hoistableScripts:new Map}),p}function Re(d){d[tt]=!0}var Me=new Set,it={};function ht(d,p){vt(d,p),vt(d+"Capture",p)}function vt(d,p){for(it[d]=p,d=0;d<p.length;d++)Me.add(p[d])}var xt=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]*$"),kt={},wt={};function mt(d){return oe.call(wt,d)?!0:oe.call(kt,d)?!1:xt.test(d)?wt[d]=!0:(kt[d]=!0,!1)}function qt(d,p,_){if(mt(p))if(_===null)d.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":d.removeAttribute(p);return;case"boolean":var S=p.toLowerCase().slice(0,5);if(S!=="data-"&&S!=="aria-"){d.removeAttribute(p);return}}d.setAttribute(p,""+_)}}function It(d,p,_){if(_===null)d.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":d.removeAttribute(p);return}d.setAttribute(p,""+_)}}function tn(d,p,_,S){if(S===null)d.removeAttribute(_);else{switch(typeof S){case"undefined":case"function":case"symbol":case"boolean":d.removeAttribute(_);return}d.setAttributeNS(p,_,""+S)}}function dn(d){switch(typeof d){case"bigint":case"boolean":case"number":case"string":case"undefined":return d;case"object":return d;default:return""}}function gn(d){var p=d.type;return(d=d.nodeName)&&d.toLowerCase()==="input"&&(p==="checkbox"||p==="radio")}function Lt(d,p,_){var S=Object.getOwnPropertyDescriptor(d.constructor.prototype,p);if(!d.hasOwnProperty(p)&&typeof S<"u"&&typeof S.get=="function"&&typeof S.set=="function"){var P=S.get,O=S.set;return Object.defineProperty(d,p,{configurable:!0,get:function(){return P.call(this)},set:function(X){_=""+X,O.call(this,X)}}),Object.defineProperty(d,p,{enumerable:S.enumerable}),{getValue:function(){return _},setValue:function(X){_=""+X},stopTracking:function(){d._valueTracker=null,delete d[p]}}}}function Yt(d){if(!d._valueTracker){var p=gn(d)?"checked":"value";d._valueTracker=Lt(d,p,""+d[p])}}function Qt(d){if(!d)return!1;var p=d._valueTracker;if(!p)return!0;var _=p.getValue(),S="";return d&&(S=gn(d)?d.checked?"true":"false":d.value),d=S,d!==_?(p.setValue(d),!0):!1}function yr(d){if(d=d||(typeof document<"u"?document:void 0),typeof d>"u")return null;try{return d.activeElement||d.body}catch{return d.body}}var Cr=/[\n"\\]/g;function Nn(d){return d.replace(Cr,function(p){return"\\"+p.charCodeAt(0).toString(16)+" "})}function eo(d,p,_,S,P,O,X,se){d.name="",X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"?d.type=X:d.removeAttribute("type"),p!=null?X==="number"?(p===0&&d.value===""||d.value!=p)&&(d.value=""+dn(p)):d.value!==""+dn(p)&&(d.value=""+dn(p)):X!=="submit"&&X!=="reset"||d.removeAttribute("value"),p!=null?gi(d,X,dn(p)):_!=null?gi(d,X,dn(_)):S!=null&&d.removeAttribute("value"),P==null&&O!=null&&(d.defaultChecked=!!O),P!=null&&(d.checked=P&&typeof P!="function"&&typeof P!="symbol"),se!=null&&typeof se!="function"&&typeof se!="symbol"&&typeof se!="boolean"?d.name=""+dn(se):d.removeAttribute("name")}function Pn(d,p,_,S,P,O,X,se){if(O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"&&(d.type=O),p!=null||_!=null){if(!(O!=="submit"&&O!=="reset"||p!=null)){Yt(d);return}_=_!=null?""+dn(_):"",p=p!=null?""+dn(p):_,se||p===d.value||(d.value=p),d.defaultValue=p}S=S??P,S=typeof S!="function"&&typeof S!="symbol"&&!!S,d.checked=se?d.checked:!!S,d.defaultChecked=!!S,X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"&&(d.name=X),Yt(d)}function gi(d,p,_){p==="number"&&yr(d.ownerDocument)===d||d.defaultValue===""+_||(d.defaultValue=""+_)}function Jr(d,p,_,S){if(d=d.options,p){p={};for(var P=0;P<_.length;P++)p["$"+_[P]]=!0;for(_=0;_<d.length;_++)P=p.hasOwnProperty("$"+d[_].value),d[_].selected!==P&&(d[_].selected=P),P&&S&&(d[_].defaultSelected=!0)}else{for(_=""+dn(_),p=null,P=0;P<d.length;P++){if(d[P].value===_){d[P].selected=!0,S&&(d[P].defaultSelected=!0);return}p!==null||d[P].disabled||(p=d[P])}p!==null&&(p.selected=!0)}}function xi(d,p,_){if(p!=null&&(p=""+dn(p),p!==d.value&&(d.value=p),_==null)){d.defaultValue!==p&&(d.defaultValue=p);return}d.defaultValue=_!=null?""+dn(_):""}function ki(d,p,_,S){if(p==null){if(S!=null){if(_!=null)throw Error(r(92));if(B(S)){if(1<S.length)throw Error(r(93));S=S[0]}_=S}_==null&&(_=""),p=_}_=dn(p),d.defaultValue=_,S=d.textContent,S===_&&S!==""&&S!==null&&(d.value=S),Yt(d)}function Po(d,p){if(p){var _=d.firstChild;if(_&&_===d.lastChild&&_.nodeType===3){_.nodeValue=p;return}}d.textContent=p}var hl=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 yL(d,p,_){var S=p.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?S?d.setProperty(p,""):p==="float"?d.cssFloat="":d[p]="":S?d.setProperty(p,_):typeof _!="number"||_===0||hl.has(p)?p==="float"?d.cssFloat=_:d[p]=(""+_).trim():d[p]=_+"px"}function _L(d,p,_){if(p!=null&&typeof p!="object")throw Error(r(62));if(d=d.style,_!=null){for(var S in _)!_.hasOwnProperty(S)||p!=null&&p.hasOwnProperty(S)||(S.indexOf("--")===0?d.setProperty(S,""):S==="float"?d.cssFloat="":d[S]="");for(var P in p)S=p[P],p.hasOwnProperty(P)&&_[P]!==S&&yL(d,P,S)}else for(var O in p)p.hasOwnProperty(O)&&yL(d,O,p[O])}function EM(d){if(d.indexOf("-")===-1)return!1;switch(d){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 fee=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"]]),hee=/^[\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 Mv(d){return hee.test(""+d)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":d}function pl(){}var AM=null;function TM(d){return d=d.target||d.srcElement||window,d.correspondingUseElement&&(d=d.correspondingUseElement),d.nodeType===3?d.parentNode:d}var Qf=null,Jf=null;function SL(d){var p=te(d);if(p&&(d=p.stateNode)){var _=d[Tr]||null;e:switch(d=p.stateNode,p.type){case"input":if(eo(d,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),p=_.name,_.type==="radio"&&p!=null){for(_=d;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+Nn(""+p)+'"][type="radio"]'),p=0;p<_.length;p++){var S=_[p];if(S!==d&&S.form===d.form){var P=S[Tr]||null;if(!P)throw Error(r(90));eo(S,P.value,P.defaultValue,P.defaultValue,P.checked,P.defaultChecked,P.type,P.name)}}for(p=0;p<_.length;p++)S=_[p],S.form===d.form&&Qt(S)}break e;case"textarea":xi(d,_.value,_.defaultValue);break e;case"select":p=_.value,p!=null&&Jr(d,!!_.multiple,p,!1)}}}var CM=!1;function wL(d,p,_){if(CM)return d(p,_);CM=!0;try{var S=d(p);return S}finally{if(CM=!1,(Qf!==null||Jf!==null)&&(db(),Qf&&(p=Qf,d=Jf,Jf=Qf=null,SL(p),d)))for(p=0;p<d.length;p++)SL(d[p])}}function Wm(d,p){var _=d.stateNode;if(_===null)return null;var S=_[Tr]||null;if(S===null)return null;_=S[p];e:switch(p){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(S=!S.disabled)||(d=d.type,S=!(d==="button"||d==="input"||d==="select"||d==="textarea")),d=!S;break e;default:d=!1}if(d)return null;if(_&&typeof _!="function")throw Error(r(231,p,typeof _));return _}var ml=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),NM=!1;if(ml)try{var qm={};Object.defineProperty(qm,"passive",{get:function(){NM=!0}}),window.addEventListener("test",qm,qm),window.removeEventListener("test",qm,qm)}catch{NM=!1}var Ic=null,RM=null,Ev=null;function ML(){if(Ev)return Ev;var d,p=RM,_=p.length,S,P="value"in Ic?Ic.value:Ic.textContent,O=P.length;for(d=0;d<_&&p[d]===P[d];d++);var X=_-d;for(S=1;S<=X&&p[_-S]===P[O-S];S++);return Ev=P.slice(d,1<S?1-S:void 0)}function Av(d){var p=d.keyCode;return"charCode"in d?(d=d.charCode,d===0&&p===13&&(d=13)):d=p,d===10&&(d=13),32<=d||d===13?d:0}function Tv(){return!0}function EL(){return!1}function Ea(d){function p(_,S,P,O,X){this._reactName=_,this._targetInst=P,this.type=S,this.nativeEvent=O,this.target=X,this.currentTarget=null;for(var se in d)d.hasOwnProperty(se)&&(_=d[se],this[se]=_?_(O):O[se]);return this.isDefaultPrevented=(O.defaultPrevented!=null?O.defaultPrevented:O.returnValue===!1)?Tv:EL,this.isPropagationStopped=EL,this}return h(p.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=Tv)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=Tv)},persist:function(){},isPersistent:Tv}),p}var pd={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(d){return d.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Cv=Ea(pd),Xm=h({},pd,{view:0,detail:0}),pee=Ea(Xm),PM,kM,Km,Nv=h({},Xm,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:OM,button:0,buttons:0,relatedTarget:function(d){return d.relatedTarget===void 0?d.fromElement===d.srcElement?d.toElement:d.fromElement:d.relatedTarget},movementX:function(d){return"movementX"in d?d.movementX:(d!==Km&&(Km&&d.type==="mousemove"?(PM=d.screenX-Km.screenX,kM=d.screenY-Km.screenY):kM=PM=0,Km=d),PM)},movementY:function(d){return"movementY"in d?d.movementY:kM}}),AL=Ea(Nv),mee=h({},Nv,{dataTransfer:0}),gee=Ea(mee),xee=h({},Xm,{relatedTarget:0}),DM=Ea(xee),vee=h({},pd,{animationName:0,elapsedTime:0,pseudoElement:0}),bee=Ea(vee),yee=h({},pd,{clipboardData:function(d){return"clipboardData"in d?d.clipboardData:window.clipboardData}}),_ee=Ea(yee),See=h({},pd,{data:0}),TL=Ea(See),wee={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Mee={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"},Eee={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Aee(d){var p=this.nativeEvent;return p.getModifierState?p.getModifierState(d):(d=Eee[d])?!!p[d]:!1}function OM(){return Aee}var Tee=h({},Xm,{key:function(d){if(d.key){var p=wee[d.key]||d.key;if(p!=="Unidentified")return p}return d.type==="keypress"?(d=Av(d),d===13?"Enter":String.fromCharCode(d)):d.type==="keydown"||d.type==="keyup"?Mee[d.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:OM,charCode:function(d){return d.type==="keypress"?Av(d):0},keyCode:function(d){return d.type==="keydown"||d.type==="keyup"?d.keyCode:0},which:function(d){return d.type==="keypress"?Av(d):d.type==="keydown"||d.type==="keyup"?d.keyCode:0}}),Cee=Ea(Tee),Nee=h({},Nv,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),CL=Ea(Nee),Ree=h({},Xm,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:OM}),Pee=Ea(Ree),kee=h({},pd,{propertyName:0,elapsedTime:0,pseudoElement:0}),Dee=Ea(kee),Oee=h({},Nv,{deltaX:function(d){return"deltaX"in d?d.deltaX:"wheelDeltaX"in d?-d.wheelDeltaX:0},deltaY:function(d){return"deltaY"in d?d.deltaY:"wheelDeltaY"in d?-d.wheelDeltaY:"wheelDelta"in d?-d.wheelDelta:0},deltaZ:0,deltaMode:0}),Lee=Ea(Oee),Iee=h({},pd,{newState:0,oldState:0}),jee=Ea(Iee),Uee=[9,13,27,32],LM=ml&&"CompositionEvent"in window,Ym=null;ml&&"documentMode"in document&&(Ym=document.documentMode);var Fee=ml&&"TextEvent"in window&&!Ym,NL=ml&&(!LM||Ym&&8<Ym&&11>=Ym),RL=" ",PL=!1;function kL(d,p){switch(d){case"keyup":return Uee.indexOf(p.keyCode)!==-1;case"keydown":return p.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function DL(d){return d=d.detail,typeof d=="object"&&"data"in d?d.data:null}var eh=!1;function zee(d,p){switch(d){case"compositionend":return DL(p);case"keypress":return p.which!==32?null:(PL=!0,RL);case"textInput":return d=p.data,d===RL&&PL?null:d;default:return null}}function Bee(d,p){if(eh)return d==="compositionend"||!LM&&kL(d,p)?(d=ML(),Ev=RM=Ic=null,eh=!1,d):null;switch(d){case"paste":return null;case"keypress":if(!(p.ctrlKey||p.altKey||p.metaKey)||p.ctrlKey&&p.altKey){if(p.char&&1<p.char.length)return p.char;if(p.which)return String.fromCharCode(p.which)}return null;case"compositionend":return NL&&p.locale!=="ko"?null:p.data;default:return null}}var Hee={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 OL(d){var p=d&&d.nodeName&&d.nodeName.toLowerCase();return p==="input"?!!Hee[d.type]:p==="textarea"}function LL(d,p,_,S){Qf?Jf?Jf.push(S):Jf=[S]:Qf=S,p=vb(p,"onChange"),0<p.length&&(_=new Cv("onChange","change",null,_,S),d.push({event:_,listeners:p}))}var Zm=null,Qm=null;function $ee(d){x4(d,0)}function Rv(d){var p=_e(d);if(Qt(p))return d}function IL(d,p){if(d==="change")return p}var jL=!1;if(ml){var IM;if(ml){var jM="oninput"in document;if(!jM){var UL=document.createElement("div");UL.setAttribute("oninput","return;"),jM=typeof UL.oninput=="function"}IM=jM}else IM=!1;jL=IM&&(!document.documentMode||9<document.documentMode)}function FL(){Zm&&(Zm.detachEvent("onpropertychange",zL),Qm=Zm=null)}function zL(d){if(d.propertyName==="value"&&Rv(Qm)){var p=[];LL(p,Qm,d,TM(d)),wL($ee,p)}}function Vee(d,p,_){d==="focusin"?(FL(),Zm=p,Qm=_,Zm.attachEvent("onpropertychange",zL)):d==="focusout"&&FL()}function Gee(d){if(d==="selectionchange"||d==="keyup"||d==="keydown")return Rv(Qm)}function Wee(d,p){if(d==="click")return Rv(p)}function qee(d,p){if(d==="input"||d==="change")return Rv(p)}function Xee(d,p){return d===p&&(d!==0||1/d===1/p)||d!==d&&p!==p}var qa=typeof Object.is=="function"?Object.is:Xee;function Jm(d,p){if(qa(d,p))return!0;if(typeof d!="object"||d===null||typeof p!="object"||p===null)return!1;var _=Object.keys(d),S=Object.keys(p);if(_.length!==S.length)return!1;for(S=0;S<_.length;S++){var P=_[S];if(!oe.call(p,P)||!qa(d[P],p[P]))return!1}return!0}function BL(d){for(;d&&d.firstChild;)d=d.firstChild;return d}function HL(d,p){var _=BL(d);d=0;for(var S;_;){if(_.nodeType===3){if(S=d+_.textContent.length,d<=p&&S>=p)return{node:_,offset:p-d};d=S}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=BL(_)}}function $L(d,p){return d&&p?d===p?!0:d&&d.nodeType===3?!1:p&&p.nodeType===3?$L(d,p.parentNode):"contains"in d?d.contains(p):d.compareDocumentPosition?!!(d.compareDocumentPosition(p)&16):!1:!1}function VL(d){d=d!=null&&d.ownerDocument!=null&&d.ownerDocument.defaultView!=null?d.ownerDocument.defaultView:window;for(var p=yr(d.document);p instanceof d.HTMLIFrameElement;){try{var _=typeof p.contentWindow.location.href=="string"}catch{_=!1}if(_)d=p.contentWindow;else break;p=yr(d.document)}return p}function UM(d){var p=d&&d.nodeName&&d.nodeName.toLowerCase();return p&&(p==="input"&&(d.type==="text"||d.type==="search"||d.type==="tel"||d.type==="url"||d.type==="password")||p==="textarea"||d.contentEditable==="true")}var Kee=ml&&"documentMode"in document&&11>=document.documentMode,th=null,FM=null,eg=null,zM=!1;function GL(d,p,_){var S=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;zM||th==null||th!==yr(S)||(S=th,"selectionStart"in S&&UM(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}),eg&&Jm(eg,S)||(eg=S,S=vb(FM,"onSelect"),0<S.length&&(p=new Cv("onSelect","select",null,p,_),d.push({event:p,listeners:S}),p.target=th)))}function md(d,p){var _={};return _[d.toLowerCase()]=p.toLowerCase(),_["Webkit"+d]="webkit"+p,_["Moz"+d]="moz"+p,_}var nh={animationend:md("Animation","AnimationEnd"),animationiteration:md("Animation","AnimationIteration"),animationstart:md("Animation","AnimationStart"),transitionrun:md("Transition","TransitionRun"),transitionstart:md("Transition","TransitionStart"),transitioncancel:md("Transition","TransitionCancel"),transitionend:md("Transition","TransitionEnd")},BM={},WL={};ml&&(WL=document.createElement("div").style,"AnimationEvent"in window||(delete nh.animationend.animation,delete nh.animationiteration.animation,delete nh.animationstart.animation),"TransitionEvent"in window||delete nh.transitionend.transition);function gd(d){if(BM[d])return BM[d];if(!nh[d])return d;var p=nh[d],_;for(_ in p)if(p.hasOwnProperty(_)&&_ in WL)return BM[d]=p[_];return d}var qL=gd("animationend"),XL=gd("animationiteration"),KL=gd("animationstart"),Yee=gd("transitionrun"),Zee=gd("transitionstart"),Qee=gd("transitioncancel"),YL=gd("transitionend"),ZL=new Map,HM="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(" ");HM.push("scrollEnd");function to(d,p){ZL.set(d,p),ht(p,[d])}var Pv=typeof reportError=="function"?reportError:function(d){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var p=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof d=="object"&&d!==null&&typeof d.message=="string"?String(d.message):String(d),error:d});if(!window.dispatchEvent(p))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",d);return}console.error(d)},xs=[],rh=0,$M=0;function kv(){for(var d=rh,p=$M=rh=0;p<d;){var _=xs[p];xs[p++]=null;var S=xs[p];xs[p++]=null;var P=xs[p];xs[p++]=null;var O=xs[p];if(xs[p++]=null,S!==null&&P!==null){var X=S.pending;X===null?P.next=P:(P.next=X.next,X.next=P),S.pending=P}O!==0&&QL(_,P,O)}}function Dv(d,p,_,S){xs[rh++]=d,xs[rh++]=p,xs[rh++]=_,xs[rh++]=S,$M|=S,d.lanes|=S,d=d.alternate,d!==null&&(d.lanes|=S)}function VM(d,p,_,S){return Dv(d,p,_,S),Ov(d)}function xd(d,p){return Dv(d,null,null,p),Ov(d)}function QL(d,p,_){d.lanes|=_;var S=d.alternate;S!==null&&(S.lanes|=_);for(var P=!1,O=d.return;O!==null;)O.childLanes|=_,S=O.alternate,S!==null&&(S.childLanes|=_),O.tag===22&&(d=O.stateNode,d===null||d._visibility&1||(P=!0)),d=O,O=O.return;return d.tag===3?(O=d.stateNode,P&&p!==null&&(P=31-Fe(_),d=O.hiddenUpdates,S=d[P],S===null?d[P]=[p]:S.push(p),p.lane=_|536870912),O):null}function Ov(d){if(50<Sg)throw Sg=0,JE=null,Error(r(185));for(var p=d.return;p!==null;)d=p,p=d.return;return d.tag===3?d.stateNode:null}var ih={};function Jee(d,p,_,S){this.tag=d,this.key=_,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=p,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=S,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Xa(d,p,_,S){return new Jee(d,p,_,S)}function GM(d){return d=d.prototype,!(!d||!d.isReactComponent)}function gl(d,p){var _=d.alternate;return _===null?(_=Xa(d.tag,p,d.key,d.mode),_.elementType=d.elementType,_.type=d.type,_.stateNode=d.stateNode,_.alternate=d,d.alternate=_):(_.pendingProps=p,_.type=d.type,_.flags=0,_.subtreeFlags=0,_.deletions=null),_.flags=d.flags&65011712,_.childLanes=d.childLanes,_.lanes=d.lanes,_.child=d.child,_.memoizedProps=d.memoizedProps,_.memoizedState=d.memoizedState,_.updateQueue=d.updateQueue,p=d.dependencies,_.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext},_.sibling=d.sibling,_.index=d.index,_.ref=d.ref,_.refCleanup=d.refCleanup,_}function JL(d,p){d.flags&=65011714;var _=d.alternate;return _===null?(d.childLanes=0,d.lanes=p,d.child=null,d.subtreeFlags=0,d.memoizedProps=null,d.memoizedState=null,d.updateQueue=null,d.dependencies=null,d.stateNode=null):(d.childLanes=_.childLanes,d.lanes=_.lanes,d.child=_.child,d.subtreeFlags=0,d.deletions=null,d.memoizedProps=_.memoizedProps,d.memoizedState=_.memoizedState,d.updateQueue=_.updateQueue,d.type=_.type,p=_.dependencies,d.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext}),d}function Lv(d,p,_,S,P,O){var X=0;if(S=d,typeof d=="function")GM(d)&&(X=1);else if(typeof d=="string")X=ine(d,_,ce.current)?26:d==="html"||d==="head"||d==="body"?27:5;else e:switch(d){case N:return d=Xa(31,_,p,P),d.elementType=N,d.lanes=O,d;case y:return vd(_.children,P,O,p);case v:X=8,P|=24;break;case x:return d=Xa(12,_,p,P|2),d.elementType=x,d.lanes=O,d;case T:return d=Xa(13,_,p,P),d.elementType=T,d.lanes=O,d;case R:return d=Xa(19,_,p,P),d.elementType=R,d.lanes=O,d;default:if(typeof d=="object"&&d!==null)switch(d.$$typeof){case w:X=10;break e;case M:X=9;break e;case C:X=11;break e;case A:X=14;break e;case j:X=16,S=null;break e}X=29,_=Error(r(130,d===null?"null":typeof d,"")),S=null}return p=Xa(X,_,p,P),p.elementType=d,p.type=S,p.lanes=O,p}function vd(d,p,_,S){return d=Xa(7,d,S,p),d.lanes=_,d}function WM(d,p,_){return d=Xa(6,d,null,p),d.lanes=_,d}function eI(d){var p=Xa(18,null,null,0);return p.stateNode=d,p}function qM(d,p,_){return p=Xa(4,d.children!==null?d.children:[],d.key,p),p.lanes=_,p.stateNode={containerInfo:d.containerInfo,pendingChildren:null,implementation:d.implementation},p}var tI=new WeakMap;function vs(d,p){if(typeof d=="object"&&d!==null){var _=tI.get(d);return _!==void 0?_:(p={value:d,source:p,stack:Q(p)},tI.set(d,p),p)}return{value:d,source:p,stack:Q(p)}}var ah=[],sh=0,Iv=null,tg=0,bs=[],ys=0,jc=null,ko=1,Do="";function xl(d,p){ah[sh++]=tg,ah[sh++]=Iv,Iv=d,tg=p}function nI(d,p,_){bs[ys++]=ko,bs[ys++]=Do,bs[ys++]=jc,jc=d;var S=ko;d=Do;var P=32-Fe(S)-1;S&=~(1<<P),_+=1;var O=32-Fe(p)+P;if(30<O){var X=P-P%5;O=(S&(1<<X)-1).toString(32),S>>=X,P-=X,ko=1<<32-Fe(p)+P|_<<P|S,Do=O+d}else ko=1<<O|_<<P|S,Do=d}function XM(d){d.return!==null&&(xl(d,1),nI(d,1,0))}function KM(d){for(;d===Iv;)Iv=ah[--sh],ah[sh]=null,tg=ah[--sh],ah[sh]=null;for(;d===jc;)jc=bs[--ys],bs[ys]=null,Do=bs[--ys],bs[ys]=null,ko=bs[--ys],bs[ys]=null}function rI(d,p){bs[ys++]=ko,bs[ys++]=Do,bs[ys++]=jc,ko=p.id,Do=p.overflow,jc=d}var Di=null,tr=null,yn=!1,Uc=null,_s=!1,YM=Error(r(519));function Fc(d){var p=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ng(vs(p,d)),YM}function iI(d){var p=d.stateNode,_=d.type,S=d.memoizedProps;switch(p[pr]=d,p[Tr]=S,_){case"dialog":pn("cancel",p),pn("close",p);break;case"iframe":case"object":case"embed":pn("load",p);break;case"video":case"audio":for(_=0;_<Mg.length;_++)pn(Mg[_],p);break;case"source":pn("error",p);break;case"img":case"image":case"link":pn("error",p),pn("load",p);break;case"details":pn("toggle",p);break;case"input":pn("invalid",p),Pn(p,S.value,S.defaultValue,S.checked,S.defaultChecked,S.type,S.name,!0);break;case"select":pn("invalid",p);break;case"textarea":pn("invalid",p),ki(p,S.value,S.defaultValue,S.children)}_=S.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||p.textContent===""+_||S.suppressHydrationWarning===!0||_4(p.textContent,_)?(S.popover!=null&&(pn("beforetoggle",p),pn("toggle",p)),S.onScroll!=null&&pn("scroll",p),S.onScrollEnd!=null&&pn("scrollend",p),S.onClick!=null&&(p.onclick=pl),p=!0):p=!1,p||Fc(d,!0)}function aI(d){for(Di=d.return;Di;)switch(Di.tag){case 5:case 31:case 13:_s=!1;return;case 27:case 3:_s=!0;return;default:Di=Di.return}}function oh(d){if(d!==Di)return!1;if(!yn)return aI(d),yn=!0,!1;var p=d.tag,_;if((_=p!==3&&p!==27)&&((_=p===5)&&(_=d.type,_=!(_!=="form"&&_!=="button")||pA(d.type,d.memoizedProps)),_=!_),_&&tr&&Fc(d),aI(d),p===13){if(d=d.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(r(317));tr=R4(d)}else if(p===31){if(d=d.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(r(317));tr=R4(d)}else p===27?(p=tr,Jc(d.type)?(d=bA,bA=null,tr=d):tr=p):tr=Di?ws(d.stateNode.nextSibling):null;return!0}function bd(){tr=Di=null,yn=!1}function ZM(){var d=Uc;return d!==null&&(Na===null?Na=d:Na.push.apply(Na,d),Uc=null),d}function ng(d){Uc===null?Uc=[d]:Uc.push(d)}var QM=H(null),yd=null,vl=null;function zc(d,p,_){ae(QM,p._currentValue),p._currentValue=_}function bl(d){d._currentValue=QM.current,q(QM)}function JM(d,p,_){for(;d!==null;){var S=d.alternate;if((d.childLanes&p)!==p?(d.childLanes|=p,S!==null&&(S.childLanes|=p)):S!==null&&(S.childLanes&p)!==p&&(S.childLanes|=p),d===_)break;d=d.return}}function eE(d,p,_,S){var P=d.child;for(P!==null&&(P.return=d);P!==null;){var O=P.dependencies;if(O!==null){var X=P.child;O=O.firstContext;e:for(;O!==null;){var se=O;O=P;for(var Se=0;Se<p.length;Se++)if(se.context===p[Se]){O.lanes|=_,se=O.alternate,se!==null&&(se.lanes|=_),JM(O.return,_,d),S||(X=null);break e}O=se.next}}else if(P.tag===18){if(X=P.return,X===null)throw Error(r(341));X.lanes|=_,O=X.alternate,O!==null&&(O.lanes|=_),JM(X,_,d),X=null}else X=P.child;if(X!==null)X.return=P;else for(X=P;X!==null;){if(X===d){X=null;break}if(P=X.sibling,P!==null){P.return=X.return,X=P;break}X=X.return}P=X}}function lh(d,p,_,S){d=null;for(var P=p,O=!1;P!==null;){if(!O){if((P.flags&524288)!==0)O=!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 se=P.type;qa(P.pendingProps.value,X.value)||(d!==null?d.push(se):d=[se])}}else if(P===ve.current){if(X=P.alternate,X===null)throw Error(r(387));X.memoizedState.memoizedState!==P.memoizedState.memoizedState&&(d!==null?d.push(Ng):d=[Ng])}P=P.return}d!==null&&eE(p,d,_,S),p.flags|=262144}function jv(d){for(d=d.firstContext;d!==null;){if(!qa(d.context._currentValue,d.memoizedValue))return!0;d=d.next}return!1}function _d(d){yd=d,vl=null,d=d.dependencies,d!==null&&(d.firstContext=null)}function Oi(d){return sI(yd,d)}function Uv(d,p){return yd===null&&_d(d),sI(d,p)}function sI(d,p){var _=p._currentValue;if(p={context:p,memoizedValue:_,next:null},vl===null){if(d===null)throw Error(r(308));vl=p,d.dependencies={lanes:0,firstContext:p},d.flags|=524288}else vl=vl.next=p;return _}var ete=typeof AbortController<"u"?AbortController:function(){var d=[],p=this.signal={aborted:!1,addEventListener:function(_,S){d.push(S)}};this.abort=function(){p.aborted=!0,d.forEach(function(_){return _()})}},tte=t.unstable_scheduleCallback,nte=t.unstable_NormalPriority,jr={$$typeof:w,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function tE(){return{controller:new ete,data:new Map,refCount:0}}function rg(d){d.refCount--,d.refCount===0&&tte(nte,function(){d.controller.abort()})}var ig=null,nE=0,ch=0,uh=null;function rte(d,p){if(ig===null){var _=ig=[];nE=0,ch=aA(),uh={status:"pending",value:void 0,then:function(S){_.push(S)}}}return nE++,p.then(oI,oI),p}function oI(){if(--nE===0&&ig!==null){uh!==null&&(uh.status="fulfilled");var d=ig;ig=null,ch=0,uh=null;for(var p=0;p<d.length;p++)(0,d[p])()}}function ite(d,p){var _=[],S={status:"pending",value:null,reason:null,then:function(P){_.push(P)}};return d.then(function(){S.status="fulfilled",S.value=p;for(var P=0;P<_.length;P++)(0,_[P])(p)},function(P){for(S.status="rejected",S.reason=P,P=0;P<_.length;P++)(0,_[P])(void 0)}),S}var lI=G.S;G.S=function(d,p){Gj=L(),typeof p=="object"&&p!==null&&typeof p.then=="function"&&rte(d,p),lI!==null&&lI(d,p)};var Sd=H(null);function rE(){var d=Sd.current;return d!==null?d:Xn.pooledCache}function Fv(d,p){p===null?ae(Sd,Sd.current):ae(Sd,p.pool)}function cI(){var d=rE();return d===null?null:{parent:jr._currentValue,pool:d}}var dh=Error(r(460)),iE=Error(r(474)),zv=Error(r(542)),Bv={then:function(){}};function uI(d){return d=d.status,d==="fulfilled"||d==="rejected"}function dI(d,p,_){switch(_=d[_],_===void 0?d.push(p):_!==p&&(p.then(pl,pl),p=_),p.status){case"fulfilled":return p.value;case"rejected":throw d=p.reason,hI(d),d;default:if(typeof p.status=="string")p.then(pl,pl);else{if(d=Xn,d!==null&&100<d.shellSuspendCounter)throw Error(r(482));d=p,d.status="pending",d.then(function(S){if(p.status==="pending"){var P=p;P.status="fulfilled",P.value=S}},function(S){if(p.status==="pending"){var P=p;P.status="rejected",P.reason=S}})}switch(p.status){case"fulfilled":return p.value;case"rejected":throw d=p.reason,hI(d),d}throw Md=p,dh}}function wd(d){try{var p=d._init;return p(d._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(Md=_,dh):_}}var Md=null;function fI(){if(Md===null)throw Error(r(459));var d=Md;return Md=null,d}function hI(d){if(d===dh||d===zv)throw Error(r(483))}var fh=null,ag=0;function Hv(d){var p=ag;return ag+=1,fh===null&&(fh=[]),dI(fh,d,p)}function sg(d,p){p=p.props.ref,d.ref=p!==void 0?p:null}function $v(d,p){throw p.$$typeof===g?Error(r(525)):(d=Object.prototype.toString.call(p),Error(r(31,d==="[object Object]"?"object with keys {"+Object.keys(p).join(", ")+"}":d)))}function pI(d){function p(De,Te){if(d){var Be=De.deletions;Be===null?(De.deletions=[Te],De.flags|=16):Be.push(Te)}}function _(De,Te){if(!d)return null;for(;Te!==null;)p(De,Te),Te=Te.sibling;return null}function S(De){for(var Te=new Map;De!==null;)De.key!==null?Te.set(De.key,De):Te.set(De.index,De),De=De.sibling;return Te}function P(De,Te){return De=gl(De,Te),De.index=0,De.sibling=null,De}function O(De,Te,Be){return De.index=Be,d?(Be=De.alternate,Be!==null?(Be=Be.index,Be<Te?(De.flags|=67108866,Te):Be):(De.flags|=67108866,Te)):(De.flags|=1048576,Te)}function X(De){return d&&De.alternate===null&&(De.flags|=67108866),De}function se(De,Te,Be,ot){return Te===null||Te.tag!==6?(Te=WM(Be,De.mode,ot),Te.return=De,Te):(Te=P(Te,Be),Te.return=De,Te)}function Se(De,Te,Be,ot){var jt=Be.type;return jt===y?at(De,Te,Be.props.children,ot,Be.key):Te!==null&&(Te.elementType===jt||typeof jt=="object"&&jt!==null&&jt.$$typeof===j&&wd(jt)===Te.type)?(Te=P(Te,Be.props),sg(Te,Be),Te.return=De,Te):(Te=Lv(Be.type,Be.key,Be.props,null,De.mode,ot),sg(Te,Be),Te.return=De,Te)}function He(De,Te,Be,ot){return Te===null||Te.tag!==4||Te.stateNode.containerInfo!==Be.containerInfo||Te.stateNode.implementation!==Be.implementation?(Te=qM(Be,De.mode,ot),Te.return=De,Te):(Te=P(Te,Be.children||[]),Te.return=De,Te)}function at(De,Te,Be,ot,jt){return Te===null||Te.tag!==7?(Te=vd(Be,De.mode,ot,jt),Te.return=De,Te):(Te=P(Te,Be),Te.return=De,Te)}function ut(De,Te,Be){if(typeof Te=="string"&&Te!==""||typeof Te=="number"||typeof Te=="bigint")return Te=WM(""+Te,De.mode,Be),Te.return=De,Te;if(typeof Te=="object"&&Te!==null){switch(Te.$$typeof){case m:return Be=Lv(Te.type,Te.key,Te.props,null,De.mode,Be),sg(Be,Te),Be.return=De,Be;case b:return Te=qM(Te,De.mode,Be),Te.return=De,Te;case j:return Te=wd(Te),ut(De,Te,Be)}if(B(Te)||I(Te))return Te=vd(Te,De.mode,Be,null),Te.return=De,Te;if(typeof Te.then=="function")return ut(De,Hv(Te),Be);if(Te.$$typeof===w)return ut(De,Uv(De,Te),Be);$v(De,Te)}return null}function Ge(De,Te,Be,ot){var jt=Te!==null?Te.key:null;if(typeof Be=="string"&&Be!==""||typeof Be=="number"||typeof Be=="bigint")return jt!==null?null:se(De,Te,""+Be,ot);if(typeof Be=="object"&&Be!==null){switch(Be.$$typeof){case m:return Be.key===jt?Se(De,Te,Be,ot):null;case b:return Be.key===jt?He(De,Te,Be,ot):null;case j:return Be=wd(Be),Ge(De,Te,Be,ot)}if(B(Be)||I(Be))return jt!==null?null:at(De,Te,Be,ot,null);if(typeof Be.then=="function")return Ge(De,Te,Hv(Be),ot);if(Be.$$typeof===w)return Ge(De,Te,Uv(De,Be),ot);$v(De,Be)}return null}function nt(De,Te,Be,ot,jt){if(typeof ot=="string"&&ot!==""||typeof ot=="number"||typeof ot=="bigint")return De=De.get(Be)||null,se(Te,De,""+ot,jt);if(typeof ot=="object"&&ot!==null){switch(ot.$$typeof){case m:return De=De.get(ot.key===null?Be:ot.key)||null,Se(Te,De,ot,jt);case b:return De=De.get(ot.key===null?Be:ot.key)||null,He(Te,De,ot,jt);case j:return ot=wd(ot),nt(De,Te,Be,ot,jt)}if(B(ot)||I(ot))return De=De.get(Be)||null,at(Te,De,ot,jt,null);if(typeof ot.then=="function")return nt(De,Te,Be,Hv(ot),jt);if(ot.$$typeof===w)return nt(De,Te,Be,Uv(Te,ot),jt);$v(Te,ot)}return null}function Ct(De,Te,Be,ot){for(var jt=null,wn=null,Dt=Te,en=Te=0,vn=null;Dt!==null&&en<Be.length;en++){Dt.index>en?(vn=Dt,Dt=null):vn=Dt.sibling;var Mn=Ge(De,Dt,Be[en],ot);if(Mn===null){Dt===null&&(Dt=vn);break}d&&Dt&&Mn.alternate===null&&p(De,Dt),Te=O(Mn,Te,en),wn===null?jt=Mn:wn.sibling=Mn,wn=Mn,Dt=vn}if(en===Be.length)return _(De,Dt),yn&&xl(De,en),jt;if(Dt===null){for(;en<Be.length;en++)Dt=ut(De,Be[en],ot),Dt!==null&&(Te=O(Dt,Te,en),wn===null?jt=Dt:wn.sibling=Dt,wn=Dt);return yn&&xl(De,en),jt}for(Dt=S(Dt);en<Be.length;en++)vn=nt(Dt,De,en,Be[en],ot),vn!==null&&(d&&vn.alternate!==null&&Dt.delete(vn.key===null?en:vn.key),Te=O(vn,Te,en),wn===null?jt=vn:wn.sibling=vn,wn=vn);return d&&Dt.forEach(function(iu){return p(De,iu)}),yn&&xl(De,en),jt}function Bt(De,Te,Be,ot){if(Be==null)throw Error(r(151));for(var jt=null,wn=null,Dt=Te,en=Te=0,vn=null,Mn=Be.next();Dt!==null&&!Mn.done;en++,Mn=Be.next()){Dt.index>en?(vn=Dt,Dt=null):vn=Dt.sibling;var iu=Ge(De,Dt,Mn.value,ot);if(iu===null){Dt===null&&(Dt=vn);break}d&&Dt&&iu.alternate===null&&p(De,Dt),Te=O(iu,Te,en),wn===null?jt=iu:wn.sibling=iu,wn=iu,Dt=vn}if(Mn.done)return _(De,Dt),yn&&xl(De,en),jt;if(Dt===null){for(;!Mn.done;en++,Mn=Be.next())Mn=ut(De,Mn.value,ot),Mn!==null&&(Te=O(Mn,Te,en),wn===null?jt=Mn:wn.sibling=Mn,wn=Mn);return yn&&xl(De,en),jt}for(Dt=S(Dt);!Mn.done;en++,Mn=Be.next())Mn=nt(Dt,De,en,Mn.value,ot),Mn!==null&&(d&&Mn.alternate!==null&&Dt.delete(Mn.key===null?en:Mn.key),Te=O(Mn,Te,en),wn===null?jt=Mn:wn.sibling=Mn,wn=Mn);return d&&Dt.forEach(function(mne){return p(De,mne)}),yn&&xl(De,en),jt}function Fn(De,Te,Be,ot){if(typeof Be=="object"&&Be!==null&&Be.type===y&&Be.key===null&&(Be=Be.props.children),typeof Be=="object"&&Be!==null){switch(Be.$$typeof){case m:e:{for(var jt=Be.key;Te!==null;){if(Te.key===jt){if(jt=Be.type,jt===y){if(Te.tag===7){_(De,Te.sibling),ot=P(Te,Be.props.children),ot.return=De,De=ot;break e}}else if(Te.elementType===jt||typeof jt=="object"&&jt!==null&&jt.$$typeof===j&&wd(jt)===Te.type){_(De,Te.sibling),ot=P(Te,Be.props),sg(ot,Be),ot.return=De,De=ot;break e}_(De,Te);break}else p(De,Te);Te=Te.sibling}Be.type===y?(ot=vd(Be.props.children,De.mode,ot,Be.key),ot.return=De,De=ot):(ot=Lv(Be.type,Be.key,Be.props,null,De.mode,ot),sg(ot,Be),ot.return=De,De=ot)}return X(De);case b:e:{for(jt=Be.key;Te!==null;){if(Te.key===jt)if(Te.tag===4&&Te.stateNode.containerInfo===Be.containerInfo&&Te.stateNode.implementation===Be.implementation){_(De,Te.sibling),ot=P(Te,Be.children||[]),ot.return=De,De=ot;break e}else{_(De,Te);break}else p(De,Te);Te=Te.sibling}ot=qM(Be,De.mode,ot),ot.return=De,De=ot}return X(De);case j:return Be=wd(Be),Fn(De,Te,Be,ot)}if(B(Be))return Ct(De,Te,Be,ot);if(I(Be)){if(jt=I(Be),typeof jt!="function")throw Error(r(150));return Be=jt.call(Be),Bt(De,Te,Be,ot)}if(typeof Be.then=="function")return Fn(De,Te,Hv(Be),ot);if(Be.$$typeof===w)return Fn(De,Te,Uv(De,Be),ot);$v(De,Be)}return typeof Be=="string"&&Be!==""||typeof Be=="number"||typeof Be=="bigint"?(Be=""+Be,Te!==null&&Te.tag===6?(_(De,Te.sibling),ot=P(Te,Be),ot.return=De,De=ot):(_(De,Te),ot=WM(Be,De.mode,ot),ot.return=De,De=ot),X(De)):_(De,Te)}return function(De,Te,Be,ot){try{ag=0;var jt=Fn(De,Te,Be,ot);return fh=null,jt}catch(Dt){if(Dt===dh||Dt===zv)throw Dt;var wn=Xa(29,Dt,null,De.mode);return wn.lanes=ot,wn.return=De,wn}finally{}}}var Ed=pI(!0),mI=pI(!1),Bc=!1;function aE(d){d.updateQueue={baseState:d.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function sE(d,p){d=d.updateQueue,p.updateQueue===d&&(p.updateQueue={baseState:d.baseState,firstBaseUpdate:d.firstBaseUpdate,lastBaseUpdate:d.lastBaseUpdate,shared:d.shared,callbacks:null})}function Hc(d){return{lane:d,tag:0,payload:null,callback:null,next:null}}function $c(d,p,_){var S=d.updateQueue;if(S===null)return null;if(S=S.shared,(Cn&2)!==0){var P=S.pending;return P===null?p.next=p:(p.next=P.next,P.next=p),S.pending=p,p=Ov(d),QL(d,null,_),p}return Dv(d,S,p,_),Ov(d)}function og(d,p,_){if(p=p.updateQueue,p!==null&&(p=p.shared,(_&4194048)!==0)){var S=p.lanes;S&=d.pendingLanes,_|=S,p.lanes=_,qn(d,_)}}function oE(d,p){var _=d.updateQueue,S=d.alternate;if(S!==null&&(S=S.updateQueue,_===S)){var P=null,O=null;if(_=_.firstBaseUpdate,_!==null){do{var X={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};O===null?P=O=X:O=O.next=X,_=_.next}while(_!==null);O===null?P=O=p:O=O.next=p}else P=O=p;_={baseState:S.baseState,firstBaseUpdate:P,lastBaseUpdate:O,shared:S.shared,callbacks:S.callbacks},d.updateQueue=_;return}d=_.lastBaseUpdate,d===null?_.firstBaseUpdate=p:d.next=p,_.lastBaseUpdate=p}var lE=!1;function lg(){if(lE){var d=uh;if(d!==null)throw d}}function cg(d,p,_,S){lE=!1;var P=d.updateQueue;Bc=!1;var O=P.firstBaseUpdate,X=P.lastBaseUpdate,se=P.shared.pending;if(se!==null){P.shared.pending=null;var Se=se,He=Se.next;Se.next=null,X===null?O=He:X.next=He,X=Se;var at=d.alternate;at!==null&&(at=at.updateQueue,se=at.lastBaseUpdate,se!==X&&(se===null?at.firstBaseUpdate=He:se.next=He,at.lastBaseUpdate=Se))}if(O!==null){var ut=P.baseState;X=0,at=He=Se=null,se=O;do{var Ge=se.lane&-536870913,nt=Ge!==se.lane;if(nt?(xn&Ge)===Ge:(S&Ge)===Ge){Ge!==0&&Ge===ch&&(lE=!0),at!==null&&(at=at.next={lane:0,tag:se.tag,payload:se.payload,callback:null,next:null});e:{var Ct=d,Bt=se;Ge=p;var Fn=_;switch(Bt.tag){case 1:if(Ct=Bt.payload,typeof Ct=="function"){ut=Ct.call(Fn,ut,Ge);break e}ut=Ct;break e;case 3:Ct.flags=Ct.flags&-65537|128;case 0:if(Ct=Bt.payload,Ge=typeof Ct=="function"?Ct.call(Fn,ut,Ge):Ct,Ge==null)break e;ut=h({},ut,Ge);break e;case 2:Bc=!0}}Ge=se.callback,Ge!==null&&(d.flags|=64,nt&&(d.flags|=8192),nt=P.callbacks,nt===null?P.callbacks=[Ge]:nt.push(Ge))}else nt={lane:Ge,tag:se.tag,payload:se.payload,callback:se.callback,next:null},at===null?(He=at=nt,Se=ut):at=at.next=nt,X|=Ge;if(se=se.next,se===null){if(se=P.shared.pending,se===null)break;nt=se,se=nt.next,nt.next=null,P.lastBaseUpdate=nt,P.shared.pending=null}}while(!0);at===null&&(Se=ut),P.baseState=Se,P.firstBaseUpdate=He,P.lastBaseUpdate=at,O===null&&(P.shared.lanes=0),Xc|=X,d.lanes=X,d.memoizedState=ut}}function gI(d,p){if(typeof d!="function")throw Error(r(191,d));d.call(p)}function xI(d,p){var _=d.callbacks;if(_!==null)for(d.callbacks=null,d=0;d<_.length;d++)gI(_[d],p)}var hh=H(null),Vv=H(0);function vI(d,p){d=Cl,ae(Vv,d),ae(hh,p),Cl=d|p.baseLanes}function cE(){ae(Vv,Cl),ae(hh,hh.current)}function uE(){Cl=Vv.current,q(hh),q(Vv)}var Ka=H(null),Ss=null;function Vc(d){var p=d.alternate;ae(Nr,Nr.current&1),ae(Ka,d),Ss===null&&(p===null||hh.current!==null||p.memoizedState!==null)&&(Ss=d)}function dE(d){ae(Nr,Nr.current),ae(Ka,d),Ss===null&&(Ss=d)}function bI(d){d.tag===22?(ae(Nr,Nr.current),ae(Ka,d),Ss===null&&(Ss=d)):Gc()}function Gc(){ae(Nr,Nr.current),ae(Ka,Ka.current)}function Ya(d){q(Ka),Ss===d&&(Ss=null),q(Nr)}var Nr=H(0);function Gv(d){for(var p=d;p!==null;){if(p.tag===13){var _=p.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||xA(_)||vA(_)))return p}else if(p.tag===19&&(p.memoizedProps.revealOrder==="forwards"||p.memoizedProps.revealOrder==="backwards"||p.memoizedProps.revealOrder==="unstable_legacy-backwards"||p.memoizedProps.revealOrder==="together")){if((p.flags&128)!==0)return p}else if(p.child!==null){p.child.return=p,p=p.child;continue}if(p===d)break;for(;p.sibling===null;){if(p.return===null||p.return===d)return null;p=p.return}p.sibling.return=p.return,p=p.sibling}return null}var yl=0,Jt=null,jn=null,Ur=null,Wv=!1,ph=!1,Ad=!1,qv=0,ug=0,mh=null,ate=0;function _r(){throw Error(r(321))}function fE(d,p){if(p===null)return!1;for(var _=0;_<p.length&&_<d.length;_++)if(!qa(d[_],p[_]))return!1;return!0}function hE(d,p,_,S,P,O){return yl=O,Jt=p,p.memoizedState=null,p.updateQueue=null,p.lanes=0,G.H=d===null||d.memoizedState===null?nj:CE,Ad=!1,O=_(S,P),Ad=!1,ph&&(O=_I(p,_,S,P)),yI(d),O}function yI(d){G.H=hg;var p=jn!==null&&jn.next!==null;if(yl=0,Ur=jn=Jt=null,Wv=!1,ug=0,mh=null,p)throw Error(r(300));d===null||Fr||(d=d.dependencies,d!==null&&jv(d)&&(Fr=!0))}function _I(d,p,_,S){Jt=d;var P=0;do{if(ph&&(mh=null),ug=0,ph=!1,25<=P)throw Error(r(301));if(P+=1,Ur=jn=null,d.updateQueue!=null){var O=d.updateQueue;O.lastEffect=null,O.events=null,O.stores=null,O.memoCache!=null&&(O.memoCache.index=0)}G.H=rj,O=p(_,S)}while(ph);return O}function ste(){var d=G.H,p=d.useState()[0];return p=typeof p.then=="function"?dg(p):p,d=d.useState()[0],(jn!==null?jn.memoizedState:null)!==d&&(Jt.flags|=1024),p}function pE(){var d=qv!==0;return qv=0,d}function mE(d,p,_){p.updateQueue=d.updateQueue,p.flags&=-2053,d.lanes&=~_}function gE(d){if(Wv){for(d=d.memoizedState;d!==null;){var p=d.queue;p!==null&&(p.pending=null),d=d.next}Wv=!1}yl=0,Ur=jn=Jt=null,ph=!1,ug=qv=0,mh=null}function ua(){var d={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ur===null?Jt.memoizedState=Ur=d:Ur=Ur.next=d,Ur}function Rr(){if(jn===null){var d=Jt.alternate;d=d!==null?d.memoizedState:null}else d=jn.next;var p=Ur===null?Jt.memoizedState:Ur.next;if(p!==null)Ur=p,jn=d;else{if(d===null)throw Jt.alternate===null?Error(r(467)):Error(r(310));jn=d,d={memoizedState:jn.memoizedState,baseState:jn.baseState,baseQueue:jn.baseQueue,queue:jn.queue,next:null},Ur===null?Jt.memoizedState=Ur=d:Ur=Ur.next=d}return Ur}function Xv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function dg(d){var p=ug;return ug+=1,mh===null&&(mh=[]),d=dI(mh,d,p),p=Jt,(Ur===null?p.memoizedState:Ur.next)===null&&(p=p.alternate,G.H=p===null||p.memoizedState===null?nj:CE),d}function Kv(d){if(d!==null&&typeof d=="object"){if(typeof d.then=="function")return dg(d);if(d.$$typeof===w)return Oi(d)}throw Error(r(438,String(d)))}function xE(d){var p=null,_=Jt.updateQueue;if(_!==null&&(p=_.memoCache),p==null){var S=Jt.alternate;S!==null&&(S=S.updateQueue,S!==null&&(S=S.memoCache,S!=null&&(p={data:S.data.map(function(P){return P.slice()}),index:0})))}if(p==null&&(p={data:[],index:0}),_===null&&(_=Xv(),Jt.updateQueue=_),_.memoCache=p,_=p.data[p.index],_===void 0)for(_=p.data[p.index]=Array(d),S=0;S<d;S++)_[S]=k;return p.index++,_}function _l(d,p){return typeof p=="function"?p(d):p}function Yv(d){var p=Rr();return vE(p,jn,d)}function vE(d,p,_){var S=d.queue;if(S===null)throw Error(r(311));S.lastRenderedReducer=_;var P=d.baseQueue,O=S.pending;if(O!==null){if(P!==null){var X=P.next;P.next=O.next,O.next=X}p.baseQueue=P=O,S.pending=null}if(O=d.baseState,P===null)d.memoizedState=O;else{p=P.next;var se=X=null,Se=null,He=p,at=!1;do{var ut=He.lane&-536870913;if(ut!==He.lane?(xn&ut)===ut:(yl&ut)===ut){var Ge=He.revertLane;if(Ge===0)Se!==null&&(Se=Se.next={lane:0,revertLane:0,gesture:null,action:He.action,hasEagerState:He.hasEagerState,eagerState:He.eagerState,next:null}),ut===ch&&(at=!0);else if((yl&Ge)===Ge){He=He.next,Ge===ch&&(at=!0);continue}else ut={lane:0,revertLane:He.revertLane,gesture:null,action:He.action,hasEagerState:He.hasEagerState,eagerState:He.eagerState,next:null},Se===null?(se=Se=ut,X=O):Se=Se.next=ut,Jt.lanes|=Ge,Xc|=Ge;ut=He.action,Ad&&_(O,ut),O=He.hasEagerState?He.eagerState:_(O,ut)}else Ge={lane:ut,revertLane:He.revertLane,gesture:He.gesture,action:He.action,hasEagerState:He.hasEagerState,eagerState:He.eagerState,next:null},Se===null?(se=Se=Ge,X=O):Se=Se.next=Ge,Jt.lanes|=ut,Xc|=ut;He=He.next}while(He!==null&&He!==p);if(Se===null?X=O:Se.next=se,!qa(O,d.memoizedState)&&(Fr=!0,at&&(_=uh,_!==null)))throw _;d.memoizedState=O,d.baseState=X,d.baseQueue=Se,S.lastRenderedState=O}return P===null&&(S.lanes=0),[d.memoizedState,S.dispatch]}function bE(d){var p=Rr(),_=p.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=d;var S=_.dispatch,P=_.pending,O=p.memoizedState;if(P!==null){_.pending=null;var X=P=P.next;do O=d(O,X.action),X=X.next;while(X!==P);qa(O,p.memoizedState)||(Fr=!0),p.memoizedState=O,p.baseQueue===null&&(p.baseState=O),_.lastRenderedState=O}return[O,S]}function SI(d,p,_){var S=Jt,P=Rr(),O=yn;if(O){if(_===void 0)throw Error(r(407));_=_()}else _=p();var X=!qa((jn||P).memoizedState,_);if(X&&(P.memoizedState=_,Fr=!0),P=P.queue,SE(EI.bind(null,S,P,d),[d]),P.getSnapshot!==p||X||Ur!==null&&Ur.memoizedState.tag&1){if(S.flags|=2048,gh(9,{destroy:void 0},MI.bind(null,S,P,_,p),null),Xn===null)throw Error(r(349));O||(yl&127)!==0||wI(S,p,_)}return _}function wI(d,p,_){d.flags|=16384,d={getSnapshot:p,value:_},p=Jt.updateQueue,p===null?(p=Xv(),Jt.updateQueue=p,p.stores=[d]):(_=p.stores,_===null?p.stores=[d]:_.push(d))}function MI(d,p,_,S){p.value=_,p.getSnapshot=S,AI(p)&&TI(d)}function EI(d,p,_){return _(function(){AI(p)&&TI(d)})}function AI(d){var p=d.getSnapshot;d=d.value;try{var _=p();return!qa(d,_)}catch{return!0}}function TI(d){var p=xd(d,2);p!==null&&Ra(p,d,2)}function yE(d){var p=ua();if(typeof d=="function"){var _=d;if(d=_(),Ad){Ze(!0);try{_()}finally{Ze(!1)}}}return p.memoizedState=p.baseState=d,p.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:_l,lastRenderedState:d},p}function CI(d,p,_,S){return d.baseState=_,vE(d,jn,typeof S=="function"?S:_l)}function ote(d,p,_,S,P){if(Jv(d))throw Error(r(485));if(d=p.action,d!==null){var O={payload:P,action:d,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(X){O.listeners.push(X)}};G.T!==null?_(!0):O.isTransition=!1,S(O),_=p.pending,_===null?(O.next=p.pending=O,NI(p,O)):(O.next=_.next,p.pending=_.next=O)}}function NI(d,p){var _=p.action,S=p.payload,P=d.state;if(p.isTransition){var O=G.T,X={};G.T=X;try{var se=_(P,S),Se=G.S;Se!==null&&Se(X,se),RI(d,p,se)}catch(He){_E(d,p,He)}finally{O!==null&&X.types!==null&&(O.types=X.types),G.T=O}}else try{O=_(P,S),RI(d,p,O)}catch(He){_E(d,p,He)}}function RI(d,p,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(S){PI(d,p,S)},function(S){return _E(d,p,S)}):PI(d,p,_)}function PI(d,p,_){p.status="fulfilled",p.value=_,kI(p),d.state=_,p=d.pending,p!==null&&(_=p.next,_===p?d.pending=null:(_=_.next,p.next=_,NI(d,_)))}function _E(d,p,_){var S=d.pending;if(d.pending=null,S!==null){S=S.next;do p.status="rejected",p.reason=_,kI(p),p=p.next;while(p!==S)}d.action=null}function kI(d){d=d.listeners;for(var p=0;p<d.length;p++)(0,d[p])()}function DI(d,p){return p}function OI(d,p){if(yn){var _=Xn.formState;if(_!==null){e:{var S=Jt;if(yn){if(tr){t:{for(var P=tr,O=_s;P.nodeType!==8;){if(!O){P=null;break t}if(P=ws(P.nextSibling),P===null){P=null;break t}}O=P.data,P=O==="F!"||O==="F"?P:null}if(P){tr=ws(P.nextSibling),S=P.data==="F!";break e}}Fc(S)}S=!1}S&&(p=_[0])}}return _=ua(),_.memoizedState=_.baseState=p,S={pending:null,lanes:0,dispatch:null,lastRenderedReducer:DI,lastRenderedState:p},_.queue=S,_=JI.bind(null,Jt,S),S.dispatch=_,S=yE(!1),O=TE.bind(null,Jt,!1,S.queue),S=ua(),P={state:p,dispatch:null,action:d,pending:null},S.queue=P,_=ote.bind(null,Jt,P,O,_),P.dispatch=_,S.memoizedState=d,[p,_,!1]}function LI(d){var p=Rr();return II(p,jn,d)}function II(d,p,_){if(p=vE(d,p,DI)[0],d=Yv(_l)[0],typeof p=="object"&&p!==null&&typeof p.then=="function")try{var S=dg(p)}catch(X){throw X===dh?zv:X}else S=p;p=Rr();var P=p.queue,O=P.dispatch;return _!==p.memoizedState&&(Jt.flags|=2048,gh(9,{destroy:void 0},lte.bind(null,P,_),null)),[S,O,d]}function lte(d,p){d.action=p}function jI(d){var p=Rr(),_=jn;if(_!==null)return II(p,_,d);Rr(),p=p.memoizedState,_=Rr();var S=_.queue.dispatch;return _.memoizedState=d,[p,S,!1]}function gh(d,p,_,S){return d={tag:d,create:_,deps:S,inst:p,next:null},p=Jt.updateQueue,p===null&&(p=Xv(),Jt.updateQueue=p),_=p.lastEffect,_===null?p.lastEffect=d.next=d:(S=_.next,_.next=d,d.next=S,p.lastEffect=d),d}function UI(){return Rr().memoizedState}function Zv(d,p,_,S){var P=ua();Jt.flags|=d,P.memoizedState=gh(1|p,{destroy:void 0},_,S===void 0?null:S)}function Qv(d,p,_,S){var P=Rr();S=S===void 0?null:S;var O=P.memoizedState.inst;jn!==null&&S!==null&&fE(S,jn.memoizedState.deps)?P.memoizedState=gh(p,O,_,S):(Jt.flags|=d,P.memoizedState=gh(1|p,O,_,S))}function FI(d,p){Zv(8390656,8,d,p)}function SE(d,p){Qv(2048,8,d,p)}function cte(d){Jt.flags|=4;var p=Jt.updateQueue;if(p===null)p=Xv(),Jt.updateQueue=p,p.events=[d];else{var _=p.events;_===null?p.events=[d]:_.push(d)}}function zI(d){var p=Rr().memoizedState;return cte({ref:p,nextImpl:d}),function(){if((Cn&2)!==0)throw Error(r(440));return p.impl.apply(void 0,arguments)}}function BI(d,p){return Qv(4,2,d,p)}function HI(d,p){return Qv(4,4,d,p)}function $I(d,p){if(typeof p=="function"){d=d();var _=p(d);return function(){typeof _=="function"?_():p(null)}}if(p!=null)return d=d(),p.current=d,function(){p.current=null}}function VI(d,p,_){_=_!=null?_.concat([d]):null,Qv(4,4,$I.bind(null,p,d),_)}function wE(){}function GI(d,p){var _=Rr();p=p===void 0?null:p;var S=_.memoizedState;return p!==null&&fE(p,S[1])?S[0]:(_.memoizedState=[d,p],d)}function WI(d,p){var _=Rr();p=p===void 0?null:p;var S=_.memoizedState;if(p!==null&&fE(p,S[1]))return S[0];if(S=d(),Ad){Ze(!0);try{d()}finally{Ze(!1)}}return _.memoizedState=[S,p],S}function ME(d,p,_){return _===void 0||(yl&1073741824)!==0&&(xn&261930)===0?d.memoizedState=p:(d.memoizedState=_,d=qj(),Jt.lanes|=d,Xc|=d,_)}function qI(d,p,_,S){return qa(_,p)?_:hh.current!==null?(d=ME(d,_,S),qa(d,p)||(Fr=!0),d):(yl&42)===0||(yl&1073741824)!==0&&(xn&261930)===0?(Fr=!0,d.memoizedState=_):(d=qj(),Jt.lanes|=d,Xc|=d,p)}function XI(d,p,_,S,P){var O=V.p;V.p=O!==0&&8>O?O:8;var X=G.T,se={};G.T=se,TE(d,!1,p,_);try{var Se=P(),He=G.S;if(He!==null&&He(se,Se),Se!==null&&typeof Se=="object"&&typeof Se.then=="function"){var at=ite(Se,S);fg(d,p,at,Ja(d))}else fg(d,p,S,Ja(d))}catch(ut){fg(d,p,{then:function(){},status:"rejected",reason:ut},Ja())}finally{V.p=O,X!==null&&se.types!==null&&(X.types=se.types),G.T=X}}function ute(){}function EE(d,p,_,S){if(d.tag!==5)throw Error(r(476));var P=KI(d).queue;XI(d,P,p,Z,_===null?ute:function(){return YI(d),_(S)})}function KI(d){var p=d.memoizedState;if(p!==null)return p;p={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:_l,lastRenderedState:Z},next:null};var _={};return p.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:_l,lastRenderedState:_},next:null},d.memoizedState=p,d=d.alternate,d!==null&&(d.memoizedState=p),p}function YI(d){var p=KI(d);p.next===null&&(p=d.alternate.memoizedState),fg(d,p.next.queue,{},Ja())}function AE(){return Oi(Ng)}function ZI(){return Rr().memoizedState}function QI(){return Rr().memoizedState}function dte(d){for(var p=d.return;p!==null;){switch(p.tag){case 24:case 3:var _=Ja();d=Hc(_);var S=$c(p,d,_);S!==null&&(Ra(S,p,_),og(S,p,_)),p={cache:tE()},d.payload=p;return}p=p.return}}function fte(d,p,_){var S=Ja();_={lane:S,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Jv(d)?ej(p,_):(_=VM(d,p,_,S),_!==null&&(Ra(_,d,S),tj(_,p,S)))}function JI(d,p,_){var S=Ja();fg(d,p,_,S)}function fg(d,p,_,S){var P={lane:S,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(Jv(d))ej(p,P);else{var O=d.alternate;if(d.lanes===0&&(O===null||O.lanes===0)&&(O=p.lastRenderedReducer,O!==null))try{var X=p.lastRenderedState,se=O(X,_);if(P.hasEagerState=!0,P.eagerState=se,qa(se,X))return Dv(d,p,P,0),Xn===null&&kv(),!1}catch{}finally{}if(_=VM(d,p,P,S),_!==null)return Ra(_,d,S),tj(_,p,S),!0}return!1}function TE(d,p,_,S){if(S={lane:2,revertLane:aA(),gesture:null,action:S,hasEagerState:!1,eagerState:null,next:null},Jv(d)){if(p)throw Error(r(479))}else p=VM(d,_,S,2),p!==null&&Ra(p,d,2)}function Jv(d){var p=d.alternate;return d===Jt||p!==null&&p===Jt}function ej(d,p){ph=Wv=!0;var _=d.pending;_===null?p.next=p:(p.next=_.next,_.next=p),d.pending=p}function tj(d,p,_){if((_&4194048)!==0){var S=p.lanes;S&=d.pendingLanes,_|=S,p.lanes=_,qn(d,_)}}var hg={readContext:Oi,use:Kv,useCallback:_r,useContext:_r,useEffect:_r,useImperativeHandle:_r,useLayoutEffect:_r,useInsertionEffect:_r,useMemo:_r,useReducer:_r,useRef:_r,useState:_r,useDebugValue:_r,useDeferredValue:_r,useTransition:_r,useSyncExternalStore:_r,useId:_r,useHostTransitionStatus:_r,useFormState:_r,useActionState:_r,useOptimistic:_r,useMemoCache:_r,useCacheRefresh:_r};hg.useEffectEvent=_r;var nj={readContext:Oi,use:Kv,useCallback:function(d,p){return ua().memoizedState=[d,p===void 0?null:p],d},useContext:Oi,useEffect:FI,useImperativeHandle:function(d,p,_){_=_!=null?_.concat([d]):null,Zv(4194308,4,$I.bind(null,p,d),_)},useLayoutEffect:function(d,p){return Zv(4194308,4,d,p)},useInsertionEffect:function(d,p){Zv(4,2,d,p)},useMemo:function(d,p){var _=ua();p=p===void 0?null:p;var S=d();if(Ad){Ze(!0);try{d()}finally{Ze(!1)}}return _.memoizedState=[S,p],S},useReducer:function(d,p,_){var S=ua();if(_!==void 0){var P=_(p);if(Ad){Ze(!0);try{_(p)}finally{Ze(!1)}}}else P=p;return S.memoizedState=S.baseState=P,d={pending:null,lanes:0,dispatch:null,lastRenderedReducer:d,lastRenderedState:P},S.queue=d,d=d.dispatch=fte.bind(null,Jt,d),[S.memoizedState,d]},useRef:function(d){var p=ua();return d={current:d},p.memoizedState=d},useState:function(d){d=yE(d);var p=d.queue,_=JI.bind(null,Jt,p);return p.dispatch=_,[d.memoizedState,_]},useDebugValue:wE,useDeferredValue:function(d,p){var _=ua();return ME(_,d,p)},useTransition:function(){var d=yE(!1);return d=XI.bind(null,Jt,d.queue,!0,!1),ua().memoizedState=d,[!1,d]},useSyncExternalStore:function(d,p,_){var S=Jt,P=ua();if(yn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=p(),Xn===null)throw Error(r(349));(xn&127)!==0||wI(S,p,_)}P.memoizedState=_;var O={value:_,getSnapshot:p};return P.queue=O,FI(EI.bind(null,S,O,d),[d]),S.flags|=2048,gh(9,{destroy:void 0},MI.bind(null,S,O,_,p),null),_},useId:function(){var d=ua(),p=Xn.identifierPrefix;if(yn){var _=Do,S=ko;_=(S&~(1<<32-Fe(S)-1)).toString(32)+_,p="_"+p+"R_"+_,_=qv++,0<_&&(p+="H"+_.toString(32)),p+="_"}else _=ate++,p="_"+p+"r_"+_.toString(32)+"_";return d.memoizedState=p},useHostTransitionStatus:AE,useFormState:OI,useActionState:OI,useOptimistic:function(d){var p=ua();p.memoizedState=p.baseState=d;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return p.queue=_,p=TE.bind(null,Jt,!0,_),_.dispatch=p,[d,p]},useMemoCache:xE,useCacheRefresh:function(){return ua().memoizedState=dte.bind(null,Jt)},useEffectEvent:function(d){var p=ua(),_={impl:d};return p.memoizedState=_,function(){if((Cn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},CE={readContext:Oi,use:Kv,useCallback:GI,useContext:Oi,useEffect:SE,useImperativeHandle:VI,useInsertionEffect:BI,useLayoutEffect:HI,useMemo:WI,useReducer:Yv,useRef:UI,useState:function(){return Yv(_l)},useDebugValue:wE,useDeferredValue:function(d,p){var _=Rr();return qI(_,jn.memoizedState,d,p)},useTransition:function(){var d=Yv(_l)[0],p=Rr().memoizedState;return[typeof d=="boolean"?d:dg(d),p]},useSyncExternalStore:SI,useId:ZI,useHostTransitionStatus:AE,useFormState:LI,useActionState:LI,useOptimistic:function(d,p){var _=Rr();return CI(_,jn,d,p)},useMemoCache:xE,useCacheRefresh:QI};CE.useEffectEvent=zI;var rj={readContext:Oi,use:Kv,useCallback:GI,useContext:Oi,useEffect:SE,useImperativeHandle:VI,useInsertionEffect:BI,useLayoutEffect:HI,useMemo:WI,useReducer:bE,useRef:UI,useState:function(){return bE(_l)},useDebugValue:wE,useDeferredValue:function(d,p){var _=Rr();return jn===null?ME(_,d,p):qI(_,jn.memoizedState,d,p)},useTransition:function(){var d=bE(_l)[0],p=Rr().memoizedState;return[typeof d=="boolean"?d:dg(d),p]},useSyncExternalStore:SI,useId:ZI,useHostTransitionStatus:AE,useFormState:jI,useActionState:jI,useOptimistic:function(d,p){var _=Rr();return jn!==null?CI(_,jn,d,p):(_.baseState=d,[d,_.queue.dispatch])},useMemoCache:xE,useCacheRefresh:QI};rj.useEffectEvent=zI;function NE(d,p,_,S){p=d.memoizedState,_=_(S,p),_=_==null?p:h({},p,_),d.memoizedState=_,d.lanes===0&&(d.updateQueue.baseState=_)}var RE={enqueueSetState:function(d,p,_){d=d._reactInternals;var S=Ja(),P=Hc(S);P.payload=p,_!=null&&(P.callback=_),p=$c(d,P,S),p!==null&&(Ra(p,d,S),og(p,d,S))},enqueueReplaceState:function(d,p,_){d=d._reactInternals;var S=Ja(),P=Hc(S);P.tag=1,P.payload=p,_!=null&&(P.callback=_),p=$c(d,P,S),p!==null&&(Ra(p,d,S),og(p,d,S))},enqueueForceUpdate:function(d,p){d=d._reactInternals;var _=Ja(),S=Hc(_);S.tag=2,p!=null&&(S.callback=p),p=$c(d,S,_),p!==null&&(Ra(p,d,_),og(p,d,_))}};function ij(d,p,_,S,P,O,X){return d=d.stateNode,typeof d.shouldComponentUpdate=="function"?d.shouldComponentUpdate(S,O,X):p.prototype&&p.prototype.isPureReactComponent?!Jm(_,S)||!Jm(P,O):!0}function aj(d,p,_,S){d=p.state,typeof p.componentWillReceiveProps=="function"&&p.componentWillReceiveProps(_,S),typeof p.UNSAFE_componentWillReceiveProps=="function"&&p.UNSAFE_componentWillReceiveProps(_,S),p.state!==d&&RE.enqueueReplaceState(p,p.state,null)}function Td(d,p){var _=p;if("ref"in p){_={};for(var S in p)S!=="ref"&&(_[S]=p[S])}if(d=d.defaultProps){_===p&&(_=h({},_));for(var P in d)_[P]===void 0&&(_[P]=d[P])}return _}function sj(d){Pv(d)}function oj(d){console.error(d)}function lj(d){Pv(d)}function eb(d,p){try{var _=d.onUncaughtError;_(p.value,{componentStack:p.stack})}catch(S){setTimeout(function(){throw S})}}function cj(d,p,_){try{var S=d.onCaughtError;S(_.value,{componentStack:_.stack,errorBoundary:p.tag===1?p.stateNode:null})}catch(P){setTimeout(function(){throw P})}}function PE(d,p,_){return _=Hc(_),_.tag=3,_.payload={element:null},_.callback=function(){eb(d,p)},_}function uj(d){return d=Hc(d),d.tag=3,d}function dj(d,p,_,S){var P=_.type.getDerivedStateFromError;if(typeof P=="function"){var O=S.value;d.payload=function(){return P(O)},d.callback=function(){cj(p,_,S)}}var X=_.stateNode;X!==null&&typeof X.componentDidCatch=="function"&&(d.callback=function(){cj(p,_,S),typeof P!="function"&&(Kc===null?Kc=new Set([this]):Kc.add(this));var se=S.stack;this.componentDidCatch(S.value,{componentStack:se!==null?se:""})})}function hte(d,p,_,S,P){if(_.flags|=32768,S!==null&&typeof S=="object"&&typeof S.then=="function"){if(p=_.alternate,p!==null&&lh(p,_,P,!0),_=Ka.current,_!==null){switch(_.tag){case 31:case 13:return Ss===null?fb():_.alternate===null&&Sr===0&&(Sr=3),_.flags&=-257,_.flags|=65536,_.lanes=P,S===Bv?_.flags|=16384:(p=_.updateQueue,p===null?_.updateQueue=new Set([S]):p.add(S),nA(d,S,P)),!1;case 22:return _.flags|=65536,S===Bv?_.flags|=16384:(p=_.updateQueue,p===null?(p={transitions:null,markerInstances:null,retryQueue:new Set([S])},_.updateQueue=p):(_=p.retryQueue,_===null?p.retryQueue=new Set([S]):_.add(S)),nA(d,S,P)),!1}throw Error(r(435,_.tag))}return nA(d,S,P),fb(),!1}if(yn)return p=Ka.current,p!==null?((p.flags&65536)===0&&(p.flags|=256),p.flags|=65536,p.lanes=P,S!==YM&&(d=Error(r(422),{cause:S}),ng(vs(d,_)))):(S!==YM&&(p=Error(r(423),{cause:S}),ng(vs(p,_))),d=d.current.alternate,d.flags|=65536,P&=-P,d.lanes|=P,S=vs(S,_),P=PE(d.stateNode,S,P),oE(d,P),Sr!==4&&(Sr=2)),!1;var O=Error(r(520),{cause:S});if(O=vs(O,_),_g===null?_g=[O]:_g.push(O),Sr!==4&&(Sr=2),p===null)return!0;S=vs(S,_),_=p;do{switch(_.tag){case 3:return _.flags|=65536,d=P&-P,_.lanes|=d,d=PE(_.stateNode,S,d),oE(_,d),!1;case 1:if(p=_.type,O=_.stateNode,(_.flags&128)===0&&(typeof p.getDerivedStateFromError=="function"||O!==null&&typeof O.componentDidCatch=="function"&&(Kc===null||!Kc.has(O))))return _.flags|=65536,P&=-P,_.lanes|=P,P=uj(P),dj(P,d,_,S),oE(_,P),!1}_=_.return}while(_!==null);return!1}var kE=Error(r(461)),Fr=!1;function Li(d,p,_,S){p.child=d===null?mI(p,null,_,S):Ed(p,d.child,_,S)}function fj(d,p,_,S,P){_=_.render;var O=p.ref;if("ref"in S){var X={};for(var se in S)se!=="ref"&&(X[se]=S[se])}else X=S;return _d(p),S=hE(d,p,_,X,O,P),se=pE(),d!==null&&!Fr?(mE(d,p,P),Sl(d,p,P)):(yn&&se&&XM(p),p.flags|=1,Li(d,p,S,P),p.child)}function hj(d,p,_,S,P){if(d===null){var O=_.type;return typeof O=="function"&&!GM(O)&&O.defaultProps===void 0&&_.compare===null?(p.tag=15,p.type=O,pj(d,p,O,S,P)):(d=Lv(_.type,null,S,p,p.mode,P),d.ref=p.ref,d.return=p,p.child=d)}if(O=d.child,!zE(d,P)){var X=O.memoizedProps;if(_=_.compare,_=_!==null?_:Jm,_(X,S)&&d.ref===p.ref)return Sl(d,p,P)}return p.flags|=1,d=gl(O,S),d.ref=p.ref,d.return=p,p.child=d}function pj(d,p,_,S,P){if(d!==null){var O=d.memoizedProps;if(Jm(O,S)&&d.ref===p.ref)if(Fr=!1,p.pendingProps=S=O,zE(d,P))(d.flags&131072)!==0&&(Fr=!0);else return p.lanes=d.lanes,Sl(d,p,P)}return DE(d,p,_,S,P)}function mj(d,p,_,S){var P=S.children,O=d!==null?d.memoizedState:null;if(d===null&&p.stateNode===null&&(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),S.mode==="hidden"){if((p.flags&128)!==0){if(O=O!==null?O.baseLanes|_:_,d!==null){for(S=p.child=d.child,P=0;S!==null;)P=P|S.lanes|S.childLanes,S=S.sibling;S=P&~O}else S=0,p.child=null;return gj(d,p,O,_,S)}if((_&536870912)!==0)p.memoizedState={baseLanes:0,cachePool:null},d!==null&&Fv(p,O!==null?O.cachePool:null),O!==null?vI(p,O):cE(),bI(p);else return S=p.lanes=536870912,gj(d,p,O!==null?O.baseLanes|_:_,_,S)}else O!==null?(Fv(p,O.cachePool),vI(p,O),Gc(),p.memoizedState=null):(d!==null&&Fv(p,null),cE(),Gc());return Li(d,p,P,_),p.child}function pg(d,p){return d!==null&&d.tag===22||p.stateNode!==null||(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),p.sibling}function gj(d,p,_,S,P){var O=rE();return O=O===null?null:{parent:jr._currentValue,pool:O},p.memoizedState={baseLanes:_,cachePool:O},d!==null&&Fv(p,null),cE(),bI(p),d!==null&&lh(d,p,S,!0),p.childLanes=P,null}function tb(d,p){return p=rb({mode:p.mode,children:p.children},d.mode),p.ref=d.ref,d.child=p,p.return=d,p}function xj(d,p,_){return Ed(p,d.child,null,_),d=tb(p,p.pendingProps),d.flags|=2,Ya(p),p.memoizedState=null,d}function pte(d,p,_){var S=p.pendingProps,P=(p.flags&128)!==0;if(p.flags&=-129,d===null){if(yn){if(S.mode==="hidden")return d=tb(p,S),p.lanes=536870912,pg(null,d);if(dE(p),(d=tr)?(d=N4(d,_s),d=d!==null&&d.data==="&"?d:null,d!==null&&(p.memoizedState={dehydrated:d,treeContext:jc!==null?{id:ko,overflow:Do}:null,retryLane:536870912,hydrationErrors:null},_=eI(d),_.return=p,p.child=_,Di=p,tr=null)):d=null,d===null)throw Fc(p);return p.lanes=536870912,null}return tb(p,S)}var O=d.memoizedState;if(O!==null){var X=O.dehydrated;if(dE(p),P)if(p.flags&256)p.flags&=-257,p=xj(d,p,_);else if(p.memoizedState!==null)p.child=d.child,p.flags|=128,p=null;else throw Error(r(558));else if(Fr||lh(d,p,_,!1),P=(_&d.childLanes)!==0,Fr||P){if(S=Xn,S!==null&&(X=pi(S,_),X!==0&&X!==O.retryLane))throw O.retryLane=X,xd(d,X),Ra(S,d,X),kE;fb(),p=xj(d,p,_)}else d=O.treeContext,tr=ws(X.nextSibling),Di=p,yn=!0,Uc=null,_s=!1,d!==null&&rI(p,d),p=tb(p,S),p.flags|=4096;return p}return d=gl(d.child,{mode:S.mode,children:S.children}),d.ref=p.ref,p.child=d,d.return=p,d}function nb(d,p){var _=p.ref;if(_===null)d!==null&&d.ref!==null&&(p.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(d===null||d.ref!==_)&&(p.flags|=4194816)}}function DE(d,p,_,S,P){return _d(p),_=hE(d,p,_,S,void 0,P),S=pE(),d!==null&&!Fr?(mE(d,p,P),Sl(d,p,P)):(yn&&S&&XM(p),p.flags|=1,Li(d,p,_,P),p.child)}function vj(d,p,_,S,P,O){return _d(p),p.updateQueue=null,_=_I(p,S,_,P),yI(d),S=pE(),d!==null&&!Fr?(mE(d,p,O),Sl(d,p,O)):(yn&&S&&XM(p),p.flags|=1,Li(d,p,_,O),p.child)}function bj(d,p,_,S,P){if(_d(p),p.stateNode===null){var O=ih,X=_.contextType;typeof X=="object"&&X!==null&&(O=Oi(X)),O=new _(S,O),p.memoizedState=O.state!==null&&O.state!==void 0?O.state:null,O.updater=RE,p.stateNode=O,O._reactInternals=p,O=p.stateNode,O.props=S,O.state=p.memoizedState,O.refs={},aE(p),X=_.contextType,O.context=typeof X=="object"&&X!==null?Oi(X):ih,O.state=p.memoizedState,X=_.getDerivedStateFromProps,typeof X=="function"&&(NE(p,_,X,S),O.state=p.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof O.getSnapshotBeforeUpdate=="function"||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(X=O.state,typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount(),X!==O.state&&RE.enqueueReplaceState(O,O.state,null),cg(p,S,O,P),lg(),O.state=p.memoizedState),typeof O.componentDidMount=="function"&&(p.flags|=4194308),S=!0}else if(d===null){O=p.stateNode;var se=p.memoizedProps,Se=Td(_,se);O.props=Se;var He=O.context,at=_.contextType;X=ih,typeof at=="object"&&at!==null&&(X=Oi(at));var ut=_.getDerivedStateFromProps;at=typeof ut=="function"||typeof O.getSnapshotBeforeUpdate=="function",se=p.pendingProps!==se,at||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(se||He!==X)&&aj(p,O,S,X),Bc=!1;var Ge=p.memoizedState;O.state=Ge,cg(p,S,O,P),lg(),He=p.memoizedState,se||Ge!==He||Bc?(typeof ut=="function"&&(NE(p,_,ut,S),He=p.memoizedState),(Se=Bc||ij(p,_,Se,S,Ge,He,X))?(at||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount()),typeof O.componentDidMount=="function"&&(p.flags|=4194308)):(typeof O.componentDidMount=="function"&&(p.flags|=4194308),p.memoizedProps=S,p.memoizedState=He),O.props=S,O.state=He,O.context=X,S=Se):(typeof O.componentDidMount=="function"&&(p.flags|=4194308),S=!1)}else{O=p.stateNode,sE(d,p),X=p.memoizedProps,at=Td(_,X),O.props=at,ut=p.pendingProps,Ge=O.context,He=_.contextType,Se=ih,typeof He=="object"&&He!==null&&(Se=Oi(He)),se=_.getDerivedStateFromProps,(He=typeof se=="function"||typeof O.getSnapshotBeforeUpdate=="function")||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(X!==ut||Ge!==Se)&&aj(p,O,S,Se),Bc=!1,Ge=p.memoizedState,O.state=Ge,cg(p,S,O,P),lg();var nt=p.memoizedState;X!==ut||Ge!==nt||Bc||d!==null&&d.dependencies!==null&&jv(d.dependencies)?(typeof se=="function"&&(NE(p,_,se,S),nt=p.memoizedState),(at=Bc||ij(p,_,at,S,Ge,nt,Se)||d!==null&&d.dependencies!==null&&jv(d.dependencies))?(He||typeof O.UNSAFE_componentWillUpdate!="function"&&typeof O.componentWillUpdate!="function"||(typeof O.componentWillUpdate=="function"&&O.componentWillUpdate(S,nt,Se),typeof O.UNSAFE_componentWillUpdate=="function"&&O.UNSAFE_componentWillUpdate(S,nt,Se)),typeof O.componentDidUpdate=="function"&&(p.flags|=4),typeof O.getSnapshotBeforeUpdate=="function"&&(p.flags|=1024)):(typeof O.componentDidUpdate!="function"||X===d.memoizedProps&&Ge===d.memoizedState||(p.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||X===d.memoizedProps&&Ge===d.memoizedState||(p.flags|=1024),p.memoizedProps=S,p.memoizedState=nt),O.props=S,O.state=nt,O.context=Se,S=at):(typeof O.componentDidUpdate!="function"||X===d.memoizedProps&&Ge===d.memoizedState||(p.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||X===d.memoizedProps&&Ge===d.memoizedState||(p.flags|=1024),S=!1)}return O=S,nb(d,p),S=(p.flags&128)!==0,O||S?(O=p.stateNode,_=S&&typeof _.getDerivedStateFromError!="function"?null:O.render(),p.flags|=1,d!==null&&S?(p.child=Ed(p,d.child,null,P),p.child=Ed(p,null,_,P)):Li(d,p,_,P),p.memoizedState=O.state,d=p.child):d=Sl(d,p,P),d}function yj(d,p,_,S){return bd(),p.flags|=256,Li(d,p,_,S),p.child}var OE={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function LE(d){return{baseLanes:d,cachePool:cI()}}function IE(d,p,_){return d=d!==null?d.childLanes&~_:0,p&&(d|=Qa),d}function _j(d,p,_){var S=p.pendingProps,P=!1,O=(p.flags&128)!==0,X;if((X=O)||(X=d!==null&&d.memoizedState===null?!1:(Nr.current&2)!==0),X&&(P=!0,p.flags&=-129),X=(p.flags&32)!==0,p.flags&=-33,d===null){if(yn){if(P?Vc(p):Gc(),(d=tr)?(d=N4(d,_s),d=d!==null&&d.data!=="&"?d:null,d!==null&&(p.memoizedState={dehydrated:d,treeContext:jc!==null?{id:ko,overflow:Do}:null,retryLane:536870912,hydrationErrors:null},_=eI(d),_.return=p,p.child=_,Di=p,tr=null)):d=null,d===null)throw Fc(p);return vA(d)?p.lanes=32:p.lanes=536870912,null}var se=S.children;return S=S.fallback,P?(Gc(),P=p.mode,se=rb({mode:"hidden",children:se},P),S=vd(S,P,_,null),se.return=p,S.return=p,se.sibling=S,p.child=se,S=p.child,S.memoizedState=LE(_),S.childLanes=IE(d,X,_),p.memoizedState=OE,pg(null,S)):(Vc(p),jE(p,se))}var Se=d.memoizedState;if(Se!==null&&(se=Se.dehydrated,se!==null)){if(O)p.flags&256?(Vc(p),p.flags&=-257,p=UE(d,p,_)):p.memoizedState!==null?(Gc(),p.child=d.child,p.flags|=128,p=null):(Gc(),se=S.fallback,P=p.mode,S=rb({mode:"visible",children:S.children},P),se=vd(se,P,_,null),se.flags|=2,S.return=p,se.return=p,S.sibling=se,p.child=S,Ed(p,d.child,null,_),S=p.child,S.memoizedState=LE(_),S.childLanes=IE(d,X,_),p.memoizedState=OE,p=pg(null,S));else if(Vc(p),vA(se)){if(X=se.nextSibling&&se.nextSibling.dataset,X)var He=X.dgst;X=He,S=Error(r(419)),S.stack="",S.digest=X,ng({value:S,source:null,stack:null}),p=UE(d,p,_)}else if(Fr||lh(d,p,_,!1),X=(_&d.childLanes)!==0,Fr||X){if(X=Xn,X!==null&&(S=pi(X,_),S!==0&&S!==Se.retryLane))throw Se.retryLane=S,xd(d,S),Ra(X,d,S),kE;xA(se)||fb(),p=UE(d,p,_)}else xA(se)?(p.flags|=192,p.child=d.child,p=null):(d=Se.treeContext,tr=ws(se.nextSibling),Di=p,yn=!0,Uc=null,_s=!1,d!==null&&rI(p,d),p=jE(p,S.children),p.flags|=4096);return p}return P?(Gc(),se=S.fallback,P=p.mode,Se=d.child,He=Se.sibling,S=gl(Se,{mode:"hidden",children:S.children}),S.subtreeFlags=Se.subtreeFlags&65011712,He!==null?se=gl(He,se):(se=vd(se,P,_,null),se.flags|=2),se.return=p,S.return=p,S.sibling=se,p.child=S,pg(null,S),S=p.child,se=d.child.memoizedState,se===null?se=LE(_):(P=se.cachePool,P!==null?(Se=jr._currentValue,P=P.parent!==Se?{parent:Se,pool:Se}:P):P=cI(),se={baseLanes:se.baseLanes|_,cachePool:P}),S.memoizedState=se,S.childLanes=IE(d,X,_),p.memoizedState=OE,pg(d.child,S)):(Vc(p),_=d.child,d=_.sibling,_=gl(_,{mode:"visible",children:S.children}),_.return=p,_.sibling=null,d!==null&&(X=p.deletions,X===null?(p.deletions=[d],p.flags|=16):X.push(d)),p.child=_,p.memoizedState=null,_)}function jE(d,p){return p=rb({mode:"visible",children:p},d.mode),p.return=d,d.child=p}function rb(d,p){return d=Xa(22,d,null,p),d.lanes=0,d}function UE(d,p,_){return Ed(p,d.child,null,_),d=jE(p,p.pendingProps.children),d.flags|=2,p.memoizedState=null,d}function Sj(d,p,_){d.lanes|=p;var S=d.alternate;S!==null&&(S.lanes|=p),JM(d.return,p,_)}function FE(d,p,_,S,P,O){var X=d.memoizedState;X===null?d.memoizedState={isBackwards:p,rendering:null,renderingStartTime:0,last:S,tail:_,tailMode:P,treeForkCount:O}:(X.isBackwards=p,X.rendering=null,X.renderingStartTime=0,X.last=S,X.tail=_,X.tailMode=P,X.treeForkCount=O)}function wj(d,p,_){var S=p.pendingProps,P=S.revealOrder,O=S.tail;S=S.children;var X=Nr.current,se=(X&2)!==0;if(se?(X=X&1|2,p.flags|=128):X&=1,ae(Nr,X),Li(d,p,S,_),S=yn?tg:0,!se&&d!==null&&(d.flags&128)!==0)e:for(d=p.child;d!==null;){if(d.tag===13)d.memoizedState!==null&&Sj(d,_,p);else if(d.tag===19)Sj(d,_,p);else if(d.child!==null){d.child.return=d,d=d.child;continue}if(d===p)break e;for(;d.sibling===null;){if(d.return===null||d.return===p)break e;d=d.return}d.sibling.return=d.return,d=d.sibling}switch(P){case"forwards":for(_=p.child,P=null;_!==null;)d=_.alternate,d!==null&&Gv(d)===null&&(P=_),_=_.sibling;_=P,_===null?(P=p.child,p.child=null):(P=_.sibling,_.sibling=null),FE(p,!1,P,_,O,S);break;case"backwards":case"unstable_legacy-backwards":for(_=null,P=p.child,p.child=null;P!==null;){if(d=P.alternate,d!==null&&Gv(d)===null){p.child=P;break}d=P.sibling,P.sibling=_,_=P,P=d}FE(p,!0,_,null,O,S);break;case"together":FE(p,!1,null,null,void 0,S);break;default:p.memoizedState=null}return p.child}function Sl(d,p,_){if(d!==null&&(p.dependencies=d.dependencies),Xc|=p.lanes,(_&p.childLanes)===0)if(d!==null){if(lh(d,p,_,!1),(_&p.childLanes)===0)return null}else return null;if(d!==null&&p.child!==d.child)throw Error(r(153));if(p.child!==null){for(d=p.child,_=gl(d,d.pendingProps),p.child=_,_.return=p;d.sibling!==null;)d=d.sibling,_=_.sibling=gl(d,d.pendingProps),_.return=p;_.sibling=null}return p.child}function zE(d,p){return(d.lanes&p)!==0?!0:(d=d.dependencies,!!(d!==null&&jv(d)))}function mte(d,p,_){switch(p.tag){case 3:Pe(p,p.stateNode.containerInfo),zc(p,jr,d.memoizedState.cache),bd();break;case 27:case 5:we(p);break;case 4:Pe(p,p.stateNode.containerInfo);break;case 10:zc(p,p.type,p.memoizedProps.value);break;case 31:if(p.memoizedState!==null)return p.flags|=128,dE(p),null;break;case 13:var S=p.memoizedState;if(S!==null)return S.dehydrated!==null?(Vc(p),p.flags|=128,null):(_&p.child.childLanes)!==0?_j(d,p,_):(Vc(p),d=Sl(d,p,_),d!==null?d.sibling:null);Vc(p);break;case 19:var P=(d.flags&128)!==0;if(S=(_&p.childLanes)!==0,S||(lh(d,p,_,!1),S=(_&p.childLanes)!==0),P){if(S)return wj(d,p,_);p.flags|=128}if(P=p.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),ae(Nr,Nr.current),S)break;return null;case 22:return p.lanes=0,mj(d,p,_,p.pendingProps);case 24:zc(p,jr,d.memoizedState.cache)}return Sl(d,p,_)}function Mj(d,p,_){if(d!==null)if(d.memoizedProps!==p.pendingProps)Fr=!0;else{if(!zE(d,_)&&(p.flags&128)===0)return Fr=!1,mte(d,p,_);Fr=(d.flags&131072)!==0}else Fr=!1,yn&&(p.flags&1048576)!==0&&nI(p,tg,p.index);switch(p.lanes=0,p.tag){case 16:e:{var S=p.pendingProps;if(d=wd(p.elementType),p.type=d,typeof d=="function")GM(d)?(S=Td(d,S),p.tag=1,p=bj(null,p,d,S,_)):(p.tag=0,p=DE(null,p,d,S,_));else{if(d!=null){var P=d.$$typeof;if(P===C){p.tag=11,p=fj(null,p,d,S,_);break e}else if(P===A){p.tag=14,p=hj(null,p,d,S,_);break e}}throw p=D(d)||d,Error(r(306,p,""))}}return p;case 0:return DE(d,p,p.type,p.pendingProps,_);case 1:return S=p.type,P=Td(S,p.pendingProps),bj(d,p,S,P,_);case 3:e:{if(Pe(p,p.stateNode.containerInfo),d===null)throw Error(r(387));S=p.pendingProps;var O=p.memoizedState;P=O.element,sE(d,p),cg(p,S,null,_);var X=p.memoizedState;if(S=X.cache,zc(p,jr,S),S!==O.cache&&eE(p,[jr],_,!0),lg(),S=X.element,O.isDehydrated)if(O={element:S,isDehydrated:!1,cache:X.cache},p.updateQueue.baseState=O,p.memoizedState=O,p.flags&256){p=yj(d,p,S,_);break e}else if(S!==P){P=vs(Error(r(424)),p),ng(P),p=yj(d,p,S,_);break e}else{switch(d=p.stateNode.containerInfo,d.nodeType){case 9:d=d.body;break;default:d=d.nodeName==="HTML"?d.ownerDocument.body:d}for(tr=ws(d.firstChild),Di=p,yn=!0,Uc=null,_s=!0,_=mI(p,null,S,_),p.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(bd(),S===P){p=Sl(d,p,_);break e}Li(d,p,S,_)}p=p.child}return p;case 26:return nb(d,p),d===null?(_=L4(p.type,null,p.pendingProps,null))?p.memoizedState=_:yn||(_=p.type,d=p.pendingProps,S=bb(ie.current).createElement(_),S[pr]=p,S[Tr]=d,Ii(S,_,d),Re(S),p.stateNode=S):p.memoizedState=L4(p.type,d.memoizedProps,p.pendingProps,d.memoizedState),null;case 27:return we(p),d===null&&yn&&(S=p.stateNode=k4(p.type,p.pendingProps,ie.current),Di=p,_s=!0,P=tr,Jc(p.type)?(bA=P,tr=ws(S.firstChild)):tr=P),Li(d,p,p.pendingProps.children,_),nb(d,p),d===null&&(p.flags|=4194304),p.child;case 5:return d===null&&yn&&((P=S=tr)&&(S=Gte(S,p.type,p.pendingProps,_s),S!==null?(p.stateNode=S,Di=p,tr=ws(S.firstChild),_s=!1,P=!0):P=!1),P||Fc(p)),we(p),P=p.type,O=p.pendingProps,X=d!==null?d.memoizedProps:null,S=O.children,pA(P,O)?S=null:X!==null&&pA(P,X)&&(p.flags|=32),p.memoizedState!==null&&(P=hE(d,p,ste,null,null,_),Ng._currentValue=P),nb(d,p),Li(d,p,S,_),p.child;case 6:return d===null&&yn&&((d=_=tr)&&(_=Wte(_,p.pendingProps,_s),_!==null?(p.stateNode=_,Di=p,tr=null,d=!0):d=!1),d||Fc(p)),null;case 13:return _j(d,p,_);case 4:return Pe(p,p.stateNode.containerInfo),S=p.pendingProps,d===null?p.child=Ed(p,null,S,_):Li(d,p,S,_),p.child;case 11:return fj(d,p,p.type,p.pendingProps,_);case 7:return Li(d,p,p.pendingProps,_),p.child;case 8:return Li(d,p,p.pendingProps.children,_),p.child;case 12:return Li(d,p,p.pendingProps.children,_),p.child;case 10:return S=p.pendingProps,zc(p,p.type,S.value),Li(d,p,S.children,_),p.child;case 9:return P=p.type._context,S=p.pendingProps.children,_d(p),P=Oi(P),S=S(P),p.flags|=1,Li(d,p,S,_),p.child;case 14:return hj(d,p,p.type,p.pendingProps,_);case 15:return pj(d,p,p.type,p.pendingProps,_);case 19:return wj(d,p,_);case 31:return pte(d,p,_);case 22:return mj(d,p,_,p.pendingProps);case 24:return _d(p),S=Oi(jr),d===null?(P=rE(),P===null&&(P=Xn,O=tE(),P.pooledCache=O,O.refCount++,O!==null&&(P.pooledCacheLanes|=_),P=O),p.memoizedState={parent:S,cache:P},aE(p),zc(p,jr,P)):((d.lanes&_)!==0&&(sE(d,p),cg(p,null,null,_),lg()),P=d.memoizedState,O=p.memoizedState,P.parent!==S?(P={parent:S,cache:S},p.memoizedState=P,p.lanes===0&&(p.memoizedState=p.updateQueue.baseState=P),zc(p,jr,S)):(S=O.cache,zc(p,jr,S),S!==P.cache&&eE(p,[jr],_,!0))),Li(d,p,p.pendingProps.children,_),p.child;case 29:throw p.pendingProps}throw Error(r(156,p.tag))}function wl(d){d.flags|=4}function BE(d,p,_,S,P){if((p=(d.mode&32)!==0)&&(p=!1),p){if(d.flags|=16777216,(P&335544128)===P)if(d.stateNode.complete)d.flags|=8192;else if(Zj())d.flags|=8192;else throw Md=Bv,iE}else d.flags&=-16777217}function Ej(d,p){if(p.type!=="stylesheet"||(p.state.loading&4)!==0)d.flags&=-16777217;else if(d.flags|=16777216,!z4(p))if(Zj())d.flags|=8192;else throw Md=Bv,iE}function ib(d,p){p!==null&&(d.flags|=4),d.flags&16384&&(p=d.tag!==22?yt():536870912,d.lanes|=p,yh|=p)}function mg(d,p){if(!yn)switch(d.tailMode){case"hidden":p=d.tail;for(var _=null;p!==null;)p.alternate!==null&&(_=p),p=p.sibling;_===null?d.tail=null:_.sibling=null;break;case"collapsed":_=d.tail;for(var S=null;_!==null;)_.alternate!==null&&(S=_),_=_.sibling;S===null?p||d.tail===null?d.tail=null:d.tail.sibling=null:S.sibling=null}}function nr(d){var p=d.alternate!==null&&d.alternate.child===d.child,_=0,S=0;if(p)for(var P=d.child;P!==null;)_|=P.lanes|P.childLanes,S|=P.subtreeFlags&65011712,S|=P.flags&65011712,P.return=d,P=P.sibling;else for(P=d.child;P!==null;)_|=P.lanes|P.childLanes,S|=P.subtreeFlags,S|=P.flags,P.return=d,P=P.sibling;return d.subtreeFlags|=S,d.childLanes=_,p}function gte(d,p,_){var S=p.pendingProps;switch(KM(p),p.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return nr(p),null;case 1:return nr(p),null;case 3:return _=p.stateNode,S=null,d!==null&&(S=d.memoizedState.cache),p.memoizedState.cache!==S&&(p.flags|=2048),bl(jr),he(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(d===null||d.child===null)&&(oh(p)?wl(p):d===null||d.memoizedState.isDehydrated&&(p.flags&256)===0||(p.flags|=1024,ZM())),nr(p),null;case 26:var P=p.type,O=p.memoizedState;return d===null?(wl(p),O!==null?(nr(p),Ej(p,O)):(nr(p),BE(p,P,null,S,_))):O?O!==d.memoizedState?(wl(p),nr(p),Ej(p,O)):(nr(p),p.flags&=-16777217):(d=d.memoizedProps,d!==S&&wl(p),nr(p),BE(p,P,d,S,_)),null;case 27:if(Le(p),_=ie.current,P=p.type,d!==null&&p.stateNode!=null)d.memoizedProps!==S&&wl(p);else{if(!S){if(p.stateNode===null)throw Error(r(166));return nr(p),null}d=ce.current,oh(p)?iI(p):(d=k4(P,S,_),p.stateNode=d,wl(p))}return nr(p),null;case 5:if(Le(p),P=p.type,d!==null&&p.stateNode!=null)d.memoizedProps!==S&&wl(p);else{if(!S){if(p.stateNode===null)throw Error(r(166));return nr(p),null}if(O=ce.current,oh(p))iI(p);else{var X=bb(ie.current);switch(O){case 1:O=X.createElementNS("http://www.w3.org/2000/svg",P);break;case 2:O=X.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;default:switch(P){case"svg":O=X.createElementNS("http://www.w3.org/2000/svg",P);break;case"math":O=X.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;case"script":O=X.createElement("div"),O.innerHTML="<script><\/script>",O=O.removeChild(O.firstChild);break;case"select":O=typeof S.is=="string"?X.createElement("select",{is:S.is}):X.createElement("select"),S.multiple?O.multiple=!0:S.size&&(O.size=S.size);break;default:O=typeof S.is=="string"?X.createElement(P,{is:S.is}):X.createElement(P)}}O[pr]=p,O[Tr]=S;e:for(X=p.child;X!==null;){if(X.tag===5||X.tag===6)O.appendChild(X.stateNode);else if(X.tag!==4&&X.tag!==27&&X.child!==null){X.child.return=X,X=X.child;continue}if(X===p)break e;for(;X.sibling===null;){if(X.return===null||X.return===p)break e;X=X.return}X.sibling.return=X.return,X=X.sibling}p.stateNode=O;e:switch(Ii(O,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&&wl(p)}}return nr(p),BE(p,p.type,d===null?null:d.memoizedProps,p.pendingProps,_),null;case 6:if(d&&p.stateNode!=null)d.memoizedProps!==S&&wl(p);else{if(typeof S!="string"&&p.stateNode===null)throw Error(r(166));if(d=ie.current,oh(p)){if(d=p.stateNode,_=p.memoizedProps,S=null,P=Di,P!==null)switch(P.tag){case 27:case 5:S=P.memoizedProps}d[pr]=p,d=!!(d.nodeValue===_||S!==null&&S.suppressHydrationWarning===!0||_4(d.nodeValue,_)),d||Fc(p,!0)}else d=bb(d).createTextNode(S),d[pr]=p,p.stateNode=d}return nr(p),null;case 31:if(_=p.memoizedState,d===null||d.memoizedState!==null){if(S=oh(p),_!==null){if(d===null){if(!S)throw Error(r(318));if(d=p.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(r(557));d[pr]=p}else bd(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;nr(p),d=!1}else _=ZM(),d!==null&&d.memoizedState!==null&&(d.memoizedState.hydrationErrors=_),d=!0;if(!d)return p.flags&256?(Ya(p),p):(Ya(p),null);if((p.flags&128)!==0)throw Error(r(558))}return nr(p),null;case 13:if(S=p.memoizedState,d===null||d.memoizedState!==null&&d.memoizedState.dehydrated!==null){if(P=oh(p),S!==null&&S.dehydrated!==null){if(d===null){if(!P)throw Error(r(318));if(P=p.memoizedState,P=P!==null?P.dehydrated:null,!P)throw Error(r(317));P[pr]=p}else bd(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;nr(p),P=!1}else P=ZM(),d!==null&&d.memoizedState!==null&&(d.memoizedState.hydrationErrors=P),P=!0;if(!P)return p.flags&256?(Ya(p),p):(Ya(p),null)}return Ya(p),(p.flags&128)!==0?(p.lanes=_,p):(_=S!==null,d=d!==null&&d.memoizedState!==null,_&&(S=p.child,P=null,S.alternate!==null&&S.alternate.memoizedState!==null&&S.alternate.memoizedState.cachePool!==null&&(P=S.alternate.memoizedState.cachePool.pool),O=null,S.memoizedState!==null&&S.memoizedState.cachePool!==null&&(O=S.memoizedState.cachePool.pool),O!==P&&(S.flags|=2048)),_!==d&&_&&(p.child.flags|=8192),ib(p,p.updateQueue),nr(p),null);case 4:return he(),d===null&&cA(p.stateNode.containerInfo),nr(p),null;case 10:return bl(p.type),nr(p),null;case 19:if(q(Nr),S=p.memoizedState,S===null)return nr(p),null;if(P=(p.flags&128)!==0,O=S.rendering,O===null)if(P)mg(S,!1);else{if(Sr!==0||d!==null&&(d.flags&128)!==0)for(d=p.child;d!==null;){if(O=Gv(d),O!==null){for(p.flags|=128,mg(S,!1),d=O.updateQueue,p.updateQueue=d,ib(p,d),p.subtreeFlags=0,d=_,_=p.child;_!==null;)JL(_,d),_=_.sibling;return ae(Nr,Nr.current&1|2),yn&&xl(p,S.treeForkCount),p.child}d=d.sibling}S.tail!==null&&L()>cb&&(p.flags|=128,P=!0,mg(S,!1),p.lanes=4194304)}else{if(!P)if(d=Gv(O),d!==null){if(p.flags|=128,P=!0,d=d.updateQueue,p.updateQueue=d,ib(p,d),mg(S,!0),S.tail===null&&S.tailMode==="hidden"&&!O.alternate&&!yn)return nr(p),null}else 2*L()-S.renderingStartTime>cb&&_!==536870912&&(p.flags|=128,P=!0,mg(S,!1),p.lanes=4194304);S.isBackwards?(O.sibling=p.child,p.child=O):(d=S.last,d!==null?d.sibling=O:p.child=O,S.last=O)}return S.tail!==null?(d=S.tail,S.rendering=d,S.tail=d.sibling,S.renderingStartTime=L(),d.sibling=null,_=Nr.current,ae(Nr,P?_&1|2:_&1),yn&&xl(p,S.treeForkCount),d):(nr(p),null);case 22:case 23:return Ya(p),uE(),S=p.memoizedState!==null,d!==null?d.memoizedState!==null!==S&&(p.flags|=8192):S&&(p.flags|=8192),S?(_&536870912)!==0&&(p.flags&128)===0&&(nr(p),p.subtreeFlags&6&&(p.flags|=8192)):nr(p),_=p.updateQueue,_!==null&&ib(p,_.retryQueue),_=null,d!==null&&d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(_=d.memoizedState.cachePool.pool),S=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(S=p.memoizedState.cachePool.pool),S!==_&&(p.flags|=2048),d!==null&&q(Sd),null;case 24:return _=null,d!==null&&(_=d.memoizedState.cache),p.memoizedState.cache!==_&&(p.flags|=2048),bl(jr),nr(p),null;case 25:return null;case 30:return null}throw Error(r(156,p.tag))}function xte(d,p){switch(KM(p),p.tag){case 1:return d=p.flags,d&65536?(p.flags=d&-65537|128,p):null;case 3:return bl(jr),he(),d=p.flags,(d&65536)!==0&&(d&128)===0?(p.flags=d&-65537|128,p):null;case 26:case 27:case 5:return Le(p),null;case 31:if(p.memoizedState!==null){if(Ya(p),p.alternate===null)throw Error(r(340));bd()}return d=p.flags,d&65536?(p.flags=d&-65537|128,p):null;case 13:if(Ya(p),d=p.memoizedState,d!==null&&d.dehydrated!==null){if(p.alternate===null)throw Error(r(340));bd()}return d=p.flags,d&65536?(p.flags=d&-65537|128,p):null;case 19:return q(Nr),null;case 4:return he(),null;case 10:return bl(p.type),null;case 22:case 23:return Ya(p),uE(),d!==null&&q(Sd),d=p.flags,d&65536?(p.flags=d&-65537|128,p):null;case 24:return bl(jr),null;case 25:return null;default:return null}}function Aj(d,p){switch(KM(p),p.tag){case 3:bl(jr),he();break;case 26:case 27:case 5:Le(p);break;case 4:he();break;case 31:p.memoizedState!==null&&Ya(p);break;case 13:Ya(p);break;case 19:q(Nr);break;case 10:bl(p.type);break;case 22:case 23:Ya(p),uE(),d!==null&&q(Sd);break;case 24:bl(jr)}}function gg(d,p){try{var _=p.updateQueue,S=_!==null?_.lastEffect:null;if(S!==null){var P=S.next;_=P;do{if((_.tag&d)===d){S=void 0;var O=_.create,X=_.inst;S=O(),X.destroy=S}_=_.next}while(_!==P)}}catch(se){Dn(p,p.return,se)}}function Wc(d,p,_){try{var S=p.updateQueue,P=S!==null?S.lastEffect:null;if(P!==null){var O=P.next;S=O;do{if((S.tag&d)===d){var X=S.inst,se=X.destroy;if(se!==void 0){X.destroy=void 0,P=p;var Se=_,He=se;try{He()}catch(at){Dn(P,Se,at)}}}S=S.next}while(S!==O)}}catch(at){Dn(p,p.return,at)}}function Tj(d){var p=d.updateQueue;if(p!==null){var _=d.stateNode;try{xI(p,_)}catch(S){Dn(d,d.return,S)}}}function Cj(d,p,_){_.props=Td(d.type,d.memoizedProps),_.state=d.memoizedState;try{_.componentWillUnmount()}catch(S){Dn(d,p,S)}}function xg(d,p){try{var _=d.ref;if(_!==null){switch(d.tag){case 26:case 27:case 5:var S=d.stateNode;break;case 30:S=d.stateNode;break;default:S=d.stateNode}typeof _=="function"?d.refCleanup=_(S):_.current=S}}catch(P){Dn(d,p,P)}}function Oo(d,p){var _=d.ref,S=d.refCleanup;if(_!==null)if(typeof S=="function")try{S()}catch(P){Dn(d,p,P)}finally{d.refCleanup=null,d=d.alternate,d!=null&&(d.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(P){Dn(d,p,P)}else _.current=null}function Nj(d){var p=d.type,_=d.memoizedProps,S=d.stateNode;try{e:switch(p){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){Dn(d,d.return,P)}}function HE(d,p,_){try{var S=d.stateNode;Fte(S,d.type,_,p),S[Tr]=p}catch(P){Dn(d,d.return,P)}}function Rj(d){return d.tag===5||d.tag===3||d.tag===26||d.tag===27&&Jc(d.type)||d.tag===4}function $E(d){e:for(;;){for(;d.sibling===null;){if(d.return===null||Rj(d.return))return null;d=d.return}for(d.sibling.return=d.return,d=d.sibling;d.tag!==5&&d.tag!==6&&d.tag!==18;){if(d.tag===27&&Jc(d.type)||d.flags&2||d.child===null||d.tag===4)continue e;d.child.return=d,d=d.child}if(!(d.flags&2))return d.stateNode}}function VE(d,p,_){var S=d.tag;if(S===5||S===6)d=d.stateNode,p?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(d,p):(p=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,p.appendChild(d),_=_._reactRootContainer,_!=null||p.onclick!==null||(p.onclick=pl));else if(S!==4&&(S===27&&Jc(d.type)&&(_=d.stateNode,p=null),d=d.child,d!==null))for(VE(d,p,_),d=d.sibling;d!==null;)VE(d,p,_),d=d.sibling}function ab(d,p,_){var S=d.tag;if(S===5||S===6)d=d.stateNode,p?_.insertBefore(d,p):_.appendChild(d);else if(S!==4&&(S===27&&Jc(d.type)&&(_=d.stateNode),d=d.child,d!==null))for(ab(d,p,_),d=d.sibling;d!==null;)ab(d,p,_),d=d.sibling}function Pj(d){var p=d.stateNode,_=d.memoizedProps;try{for(var S=d.type,P=p.attributes;P.length;)p.removeAttributeNode(P[0]);Ii(p,S,_),p[pr]=d,p[Tr]=_}catch(O){Dn(d,d.return,O)}}var Ml=!1,zr=!1,GE=!1,kj=typeof WeakSet=="function"?WeakSet:Set,vi=null;function vte(d,p){if(d=d.containerInfo,fA=Ab,d=VL(d),UM(d)){if("selectionStart"in d)var _={start:d.selectionStart,end:d.selectionEnd};else e:{_=(_=d.ownerDocument)&&_.defaultView||window;var S=_.getSelection&&_.getSelection();if(S&&S.rangeCount!==0){_=S.anchorNode;var P=S.anchorOffset,O=S.focusNode;S=S.focusOffset;try{_.nodeType,O.nodeType}catch{_=null;break e}var X=0,se=-1,Se=-1,He=0,at=0,ut=d,Ge=null;t:for(;;){for(var nt;ut!==_||P!==0&&ut.nodeType!==3||(se=X+P),ut!==O||S!==0&&ut.nodeType!==3||(Se=X+S),ut.nodeType===3&&(X+=ut.nodeValue.length),(nt=ut.firstChild)!==null;)Ge=ut,ut=nt;for(;;){if(ut===d)break t;if(Ge===_&&++He===P&&(se=X),Ge===O&&++at===S&&(Se=X),(nt=ut.nextSibling)!==null)break;ut=Ge,Ge=ut.parentNode}ut=nt}_=se===-1||Se===-1?null:{start:se,end:Se}}else _=null}_=_||{start:0,end:0}}else _=null;for(hA={focusedElem:d,selectionRange:_},Ab=!1,vi=p;vi!==null;)if(p=vi,d=p.child,(p.subtreeFlags&1028)!==0&&d!==null)d.return=p,vi=d;else for(;vi!==null;){switch(p=vi,O=p.alternate,d=p.flags,p.tag){case 0:if((d&4)!==0&&(d=p.updateQueue,d=d!==null?d.events:null,d!==null))for(_=0;_<d.length;_++)P=d[_],P.ref.impl=P.nextImpl;break;case 11:case 15:break;case 1:if((d&1024)!==0&&O!==null){d=void 0,_=p,P=O.memoizedProps,O=O.memoizedState,S=_.stateNode;try{var Ct=Td(_.type,P);d=S.getSnapshotBeforeUpdate(Ct,O),S.__reactInternalSnapshotBeforeUpdate=d}catch(Bt){Dn(_,_.return,Bt)}}break;case 3:if((d&1024)!==0){if(d=p.stateNode.containerInfo,_=d.nodeType,_===9)gA(d);else if(_===1)switch(d.nodeName){case"HEAD":case"HTML":case"BODY":gA(d);break;default:d.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((d&1024)!==0)throw Error(r(163))}if(d=p.sibling,d!==null){d.return=p.return,vi=d;break}vi=p.return}}function Dj(d,p,_){var S=_.flags;switch(_.tag){case 0:case 11:case 15:Al(d,_),S&4&&gg(5,_);break;case 1:if(Al(d,_),S&4)if(d=_.stateNode,p===null)try{d.componentDidMount()}catch(X){Dn(_,_.return,X)}else{var P=Td(_.type,p.memoizedProps);p=p.memoizedState;try{d.componentDidUpdate(P,p,d.__reactInternalSnapshotBeforeUpdate)}catch(X){Dn(_,_.return,X)}}S&64&&Tj(_),S&512&&xg(_,_.return);break;case 3:if(Al(d,_),S&64&&(d=_.updateQueue,d!==null)){if(p=null,_.child!==null)switch(_.child.tag){case 27:case 5:p=_.child.stateNode;break;case 1:p=_.child.stateNode}try{xI(d,p)}catch(X){Dn(_,_.return,X)}}break;case 27:p===null&&S&4&&Pj(_);case 26:case 5:Al(d,_),p===null&&S&4&&Nj(_),S&512&&xg(_,_.return);break;case 12:Al(d,_);break;case 31:Al(d,_),S&4&&Ij(d,_);break;case 13:Al(d,_),S&4&&jj(d,_),S&64&&(d=_.memoizedState,d!==null&&(d=d.dehydrated,d!==null&&(_=Tte.bind(null,_),qte(d,_))));break;case 22:if(S=_.memoizedState!==null||Ml,!S){p=p!==null&&p.memoizedState!==null||zr,P=Ml;var O=zr;Ml=S,(zr=p)&&!O?Tl(d,_,(_.subtreeFlags&8772)!==0):Al(d,_),Ml=P,zr=O}break;case 30:break;default:Al(d,_)}}function Oj(d){var p=d.alternate;p!==null&&(d.alternate=null,Oj(p)),d.child=null,d.deletions=null,d.sibling=null,d.tag===5&&(p=d.stateNode,p!==null&&Ye(p)),d.stateNode=null,d.return=null,d.dependencies=null,d.memoizedProps=null,d.memoizedState=null,d.pendingProps=null,d.stateNode=null,d.updateQueue=null}var lr=null,Aa=!1;function El(d,p,_){for(_=_.child;_!==null;)Lj(d,p,_),_=_.sibling}function Lj(d,p,_){if(le&&typeof le.onCommitFiberUnmount=="function")try{le.onCommitFiberUnmount(je,_)}catch{}switch(_.tag){case 26:zr||Oo(_,p),El(d,p,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:zr||Oo(_,p);var S=lr,P=Aa;Jc(_.type)&&(lr=_.stateNode,Aa=!1),El(d,p,_),Ag(_.stateNode),lr=S,Aa=P;break;case 5:zr||Oo(_,p);case 6:if(S=lr,P=Aa,lr=null,El(d,p,_),lr=S,Aa=P,lr!==null)if(Aa)try{(lr.nodeType===9?lr.body:lr.nodeName==="HTML"?lr.ownerDocument.body:lr).removeChild(_.stateNode)}catch(O){Dn(_,p,O)}else try{lr.removeChild(_.stateNode)}catch(O){Dn(_,p,O)}break;case 18:lr!==null&&(Aa?(d=lr,T4(d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d,_.stateNode),Ch(d)):T4(lr,_.stateNode));break;case 4:S=lr,P=Aa,lr=_.stateNode.containerInfo,Aa=!0,El(d,p,_),lr=S,Aa=P;break;case 0:case 11:case 14:case 15:Wc(2,_,p),zr||Wc(4,_,p),El(d,p,_);break;case 1:zr||(Oo(_,p),S=_.stateNode,typeof S.componentWillUnmount=="function"&&Cj(_,p,S)),El(d,p,_);break;case 21:El(d,p,_);break;case 22:zr=(S=zr)||_.memoizedState!==null,El(d,p,_),zr=S;break;default:El(d,p,_)}}function Ij(d,p){if(p.memoizedState===null&&(d=p.alternate,d!==null&&(d=d.memoizedState,d!==null))){d=d.dehydrated;try{Ch(d)}catch(_){Dn(p,p.return,_)}}}function jj(d,p){if(p.memoizedState===null&&(d=p.alternate,d!==null&&(d=d.memoizedState,d!==null&&(d=d.dehydrated,d!==null))))try{Ch(d)}catch(_){Dn(p,p.return,_)}}function bte(d){switch(d.tag){case 31:case 13:case 19:var p=d.stateNode;return p===null&&(p=d.stateNode=new kj),p;case 22:return d=d.stateNode,p=d._retryCache,p===null&&(p=d._retryCache=new kj),p;default:throw Error(r(435,d.tag))}}function sb(d,p){var _=bte(d);p.forEach(function(S){if(!_.has(S)){_.add(S);var P=Cte.bind(null,d,S);S.then(P,P)}})}function Ta(d,p){var _=p.deletions;if(_!==null)for(var S=0;S<_.length;S++){var P=_[S],O=d,X=p,se=X;e:for(;se!==null;){switch(se.tag){case 27:if(Jc(se.type)){lr=se.stateNode,Aa=!1;break e}break;case 5:lr=se.stateNode,Aa=!1;break e;case 3:case 4:lr=se.stateNode.containerInfo,Aa=!0;break e}se=se.return}if(lr===null)throw Error(r(160));Lj(O,X,P),lr=null,Aa=!1,O=P.alternate,O!==null&&(O.return=null),P.return=null}if(p.subtreeFlags&13886)for(p=p.child;p!==null;)Uj(p,d),p=p.sibling}var no=null;function Uj(d,p){var _=d.alternate,S=d.flags;switch(d.tag){case 0:case 11:case 14:case 15:Ta(p,d),Ca(d),S&4&&(Wc(3,d,d.return),gg(3,d),Wc(5,d,d.return));break;case 1:Ta(p,d),Ca(d),S&512&&(zr||_===null||Oo(_,_.return)),S&64&&Ml&&(d=d.updateQueue,d!==null&&(S=d.callbacks,S!==null&&(_=d.shared.hiddenCallbacks,d.shared.hiddenCallbacks=_===null?S:_.concat(S))));break;case 26:var P=no;if(Ta(p,d),Ca(d),S&512&&(zr||_===null||Oo(_,_.return)),S&4){var O=_!==null?_.memoizedState:null;if(S=d.memoizedState,_===null)if(S===null)if(d.stateNode===null){e:{S=d.type,_=d.memoizedProps,P=P.ownerDocument||P;t:switch(S){case"title":O=P.getElementsByTagName("title")[0],(!O||O[tt]||O[pr]||O.namespaceURI==="http://www.w3.org/2000/svg"||O.hasAttribute("itemprop"))&&(O=P.createElement(S),P.head.insertBefore(O,P.querySelector("head > title"))),Ii(O,S,_),O[pr]=d,Re(O),S=O;break e;case"link":var X=U4("link","href",P).get(S+(_.href||""));if(X){for(var se=0;se<X.length;se++)if(O=X[se],O.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&O.getAttribute("rel")===(_.rel==null?null:_.rel)&&O.getAttribute("title")===(_.title==null?null:_.title)&&O.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){X.splice(se,1);break t}}O=P.createElement(S),Ii(O,S,_),P.head.appendChild(O);break;case"meta":if(X=U4("meta","content",P).get(S+(_.content||""))){for(se=0;se<X.length;se++)if(O=X[se],O.getAttribute("content")===(_.content==null?null:""+_.content)&&O.getAttribute("name")===(_.name==null?null:_.name)&&O.getAttribute("property")===(_.property==null?null:_.property)&&O.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&O.getAttribute("charset")===(_.charSet==null?null:_.charSet)){X.splice(se,1);break t}}O=P.createElement(S),Ii(O,S,_),P.head.appendChild(O);break;default:throw Error(r(468,S))}O[pr]=d,Re(O),S=O}d.stateNode=S}else F4(P,d.type,d.stateNode);else d.stateNode=j4(P,S,d.memoizedProps);else O!==S?(O===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):O.count--,S===null?F4(P,d.type,d.stateNode):j4(P,S,d.memoizedProps)):S===null&&d.stateNode!==null&&HE(d,d.memoizedProps,_.memoizedProps)}break;case 27:Ta(p,d),Ca(d),S&512&&(zr||_===null||Oo(_,_.return)),_!==null&&S&4&&HE(d,d.memoizedProps,_.memoizedProps);break;case 5:if(Ta(p,d),Ca(d),S&512&&(zr||_===null||Oo(_,_.return)),d.flags&32){P=d.stateNode;try{Po(P,"")}catch(Ct){Dn(d,d.return,Ct)}}S&4&&d.stateNode!=null&&(P=d.memoizedProps,HE(d,P,_!==null?_.memoizedProps:P)),S&1024&&(GE=!0);break;case 6:if(Ta(p,d),Ca(d),S&4){if(d.stateNode===null)throw Error(r(162));S=d.memoizedProps,_=d.stateNode;try{_.nodeValue=S}catch(Ct){Dn(d,d.return,Ct)}}break;case 3:if(Sb=null,P=no,no=yb(p.containerInfo),Ta(p,d),no=P,Ca(d),S&4&&_!==null&&_.memoizedState.isDehydrated)try{Ch(p.containerInfo)}catch(Ct){Dn(d,d.return,Ct)}GE&&(GE=!1,Fj(d));break;case 4:S=no,no=yb(d.stateNode.containerInfo),Ta(p,d),Ca(d),no=S;break;case 12:Ta(p,d),Ca(d);break;case 31:Ta(p,d),Ca(d),S&4&&(S=d.updateQueue,S!==null&&(d.updateQueue=null,sb(d,S)));break;case 13:Ta(p,d),Ca(d),d.child.flags&8192&&d.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(lb=L()),S&4&&(S=d.updateQueue,S!==null&&(d.updateQueue=null,sb(d,S)));break;case 22:P=d.memoizedState!==null;var Se=_!==null&&_.memoizedState!==null,He=Ml,at=zr;if(Ml=He||P,zr=at||Se,Ta(p,d),zr=at,Ml=He,Ca(d),S&8192)e:for(p=d.stateNode,p._visibility=P?p._visibility&-2:p._visibility|1,P&&(_===null||Se||Ml||zr||Cd(d)),_=null,p=d;;){if(p.tag===5||p.tag===26){if(_===null){Se=_=p;try{if(O=Se.stateNode,P)X=O.style,typeof X.setProperty=="function"?X.setProperty("display","none","important"):X.display="none";else{se=Se.stateNode;var ut=Se.memoizedProps.style,Ge=ut!=null&&ut.hasOwnProperty("display")?ut.display:null;se.style.display=Ge==null||typeof Ge=="boolean"?"":(""+Ge).trim()}}catch(Ct){Dn(Se,Se.return,Ct)}}}else if(p.tag===6){if(_===null){Se=p;try{Se.stateNode.nodeValue=P?"":Se.memoizedProps}catch(Ct){Dn(Se,Se.return,Ct)}}}else if(p.tag===18){if(_===null){Se=p;try{var nt=Se.stateNode;P?C4(nt,!0):C4(Se.stateNode,!1)}catch(Ct){Dn(Se,Se.return,Ct)}}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===d)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===d)break e;for(;p.sibling===null;){if(p.return===null||p.return===d)break e;_===p&&(_=null),p=p.return}_===p&&(_=null),p.sibling.return=p.return,p=p.sibling}S&4&&(S=d.updateQueue,S!==null&&(_=S.retryQueue,_!==null&&(S.retryQueue=null,sb(d,_))));break;case 19:Ta(p,d),Ca(d),S&4&&(S=d.updateQueue,S!==null&&(d.updateQueue=null,sb(d,S)));break;case 30:break;case 21:break;default:Ta(p,d),Ca(d)}}function Ca(d){var p=d.flags;if(p&2){try{for(var _,S=d.return;S!==null;){if(Rj(S)){_=S;break}S=S.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var P=_.stateNode,O=$E(d);ab(d,O,P);break;case 5:var X=_.stateNode;_.flags&32&&(Po(X,""),_.flags&=-33);var se=$E(d);ab(d,se,X);break;case 3:case 4:var Se=_.stateNode.containerInfo,He=$E(d);VE(d,He,Se);break;default:throw Error(r(161))}}catch(at){Dn(d,d.return,at)}d.flags&=-3}p&4096&&(d.flags&=-4097)}function Fj(d){if(d.subtreeFlags&1024)for(d=d.child;d!==null;){var p=d;Fj(p),p.tag===5&&p.flags&1024&&p.stateNode.reset(),d=d.sibling}}function Al(d,p){if(p.subtreeFlags&8772)for(p=p.child;p!==null;)Dj(d,p.alternate,p),p=p.sibling}function Cd(d){for(d=d.child;d!==null;){var p=d;switch(p.tag){case 0:case 11:case 14:case 15:Wc(4,p,p.return),Cd(p);break;case 1:Oo(p,p.return);var _=p.stateNode;typeof _.componentWillUnmount=="function"&&Cj(p,p.return,_),Cd(p);break;case 27:Ag(p.stateNode);case 26:case 5:Oo(p,p.return),Cd(p);break;case 22:p.memoizedState===null&&Cd(p);break;case 30:Cd(p);break;default:Cd(p)}d=d.sibling}}function Tl(d,p,_){for(_=_&&(p.subtreeFlags&8772)!==0,p=p.child;p!==null;){var S=p.alternate,P=d,O=p,X=O.flags;switch(O.tag){case 0:case 11:case 15:Tl(P,O,_),gg(4,O);break;case 1:if(Tl(P,O,_),S=O,P=S.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(He){Dn(S,S.return,He)}if(S=O,P=S.updateQueue,P!==null){var se=S.stateNode;try{var Se=P.shared.hiddenCallbacks;if(Se!==null)for(P.shared.hiddenCallbacks=null,P=0;P<Se.length;P++)gI(Se[P],se)}catch(He){Dn(S,S.return,He)}}_&&X&64&&Tj(O),xg(O,O.return);break;case 27:Pj(O);case 26:case 5:Tl(P,O,_),_&&S===null&&X&4&&Nj(O),xg(O,O.return);break;case 12:Tl(P,O,_);break;case 31:Tl(P,O,_),_&&X&4&&Ij(P,O);break;case 13:Tl(P,O,_),_&&X&4&&jj(P,O);break;case 22:O.memoizedState===null&&Tl(P,O,_),xg(O,O.return);break;case 30:break;default:Tl(P,O,_)}p=p.sibling}}function WE(d,p){var _=null;d!==null&&d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(_=d.memoizedState.cachePool.pool),d=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(d=p.memoizedState.cachePool.pool),d!==_&&(d!=null&&d.refCount++,_!=null&&rg(_))}function qE(d,p){d=null,p.alternate!==null&&(d=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==d&&(p.refCount++,d!=null&&rg(d))}function ro(d,p,_,S){if(p.subtreeFlags&10256)for(p=p.child;p!==null;)zj(d,p,_,S),p=p.sibling}function zj(d,p,_,S){var P=p.flags;switch(p.tag){case 0:case 11:case 15:ro(d,p,_,S),P&2048&&gg(9,p);break;case 1:ro(d,p,_,S);break;case 3:ro(d,p,_,S),P&2048&&(d=null,p.alternate!==null&&(d=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==d&&(p.refCount++,d!=null&&rg(d)));break;case 12:if(P&2048){ro(d,p,_,S),d=p.stateNode;try{var O=p.memoizedProps,X=O.id,se=O.onPostCommit;typeof se=="function"&&se(X,p.alternate===null?"mount":"update",d.passiveEffectDuration,-0)}catch(Se){Dn(p,p.return,Se)}}else ro(d,p,_,S);break;case 31:ro(d,p,_,S);break;case 13:ro(d,p,_,S);break;case 23:break;case 22:O=p.stateNode,X=p.alternate,p.memoizedState!==null?O._visibility&2?ro(d,p,_,S):vg(d,p):O._visibility&2?ro(d,p,_,S):(O._visibility|=2,xh(d,p,_,S,(p.subtreeFlags&10256)!==0||!1)),P&2048&&WE(X,p);break;case 24:ro(d,p,_,S),P&2048&&qE(p.alternate,p);break;default:ro(d,p,_,S)}}function xh(d,p,_,S,P){for(P=P&&((p.subtreeFlags&10256)!==0||!1),p=p.child;p!==null;){var O=d,X=p,se=_,Se=S,He=X.flags;switch(X.tag){case 0:case 11:case 15:xh(O,X,se,Se,P),gg(8,X);break;case 23:break;case 22:var at=X.stateNode;X.memoizedState!==null?at._visibility&2?xh(O,X,se,Se,P):vg(O,X):(at._visibility|=2,xh(O,X,se,Se,P)),P&&He&2048&&WE(X.alternate,X);break;case 24:xh(O,X,se,Se,P),P&&He&2048&&qE(X.alternate,X);break;default:xh(O,X,se,Se,P)}p=p.sibling}}function vg(d,p){if(p.subtreeFlags&10256)for(p=p.child;p!==null;){var _=d,S=p,P=S.flags;switch(S.tag){case 22:vg(_,S),P&2048&&WE(S.alternate,S);break;case 24:vg(_,S),P&2048&&qE(S.alternate,S);break;default:vg(_,S)}p=p.sibling}}var bg=8192;function vh(d,p,_){if(d.subtreeFlags&bg)for(d=d.child;d!==null;)Bj(d,p,_),d=d.sibling}function Bj(d,p,_){switch(d.tag){case 26:vh(d,p,_),d.flags&bg&&d.memoizedState!==null&&ane(_,no,d.memoizedState,d.memoizedProps);break;case 5:vh(d,p,_);break;case 3:case 4:var S=no;no=yb(d.stateNode.containerInfo),vh(d,p,_),no=S;break;case 22:d.memoizedState===null&&(S=d.alternate,S!==null&&S.memoizedState!==null?(S=bg,bg=16777216,vh(d,p,_),bg=S):vh(d,p,_));break;default:vh(d,p,_)}}function Hj(d){var p=d.alternate;if(p!==null&&(d=p.child,d!==null)){p.child=null;do p=d.sibling,d.sibling=null,d=p;while(d!==null)}}function yg(d){var p=d.deletions;if((d.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var S=p[_];vi=S,Vj(S,d)}Hj(d)}if(d.subtreeFlags&10256)for(d=d.child;d!==null;)$j(d),d=d.sibling}function $j(d){switch(d.tag){case 0:case 11:case 15:yg(d),d.flags&2048&&Wc(9,d,d.return);break;case 3:yg(d);break;case 12:yg(d);break;case 22:var p=d.stateNode;d.memoizedState!==null&&p._visibility&2&&(d.return===null||d.return.tag!==13)?(p._visibility&=-3,ob(d)):yg(d);break;default:yg(d)}}function ob(d){var p=d.deletions;if((d.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var S=p[_];vi=S,Vj(S,d)}Hj(d)}for(d=d.child;d!==null;){switch(p=d,p.tag){case 0:case 11:case 15:Wc(8,p,p.return),ob(p);break;case 22:_=p.stateNode,_._visibility&2&&(_._visibility&=-3,ob(p));break;default:ob(p)}d=d.sibling}}function Vj(d,p){for(;vi!==null;){var _=vi;switch(_.tag){case 0:case 11:case 15:Wc(8,_,p);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var S=_.memoizedState.cachePool.pool;S!=null&&S.refCount++}break;case 24:rg(_.memoizedState.cache)}if(S=_.child,S!==null)S.return=_,vi=S;else e:for(_=d;vi!==null;){S=vi;var P=S.sibling,O=S.return;if(Oj(S),S===_){vi=null;break e}if(P!==null){P.return=O,vi=P;break e}vi=O}}}var yte={getCacheForType:function(d){var p=Oi(jr),_=p.data.get(d);return _===void 0&&(_=d(),p.data.set(d,_)),_},cacheSignal:function(){return Oi(jr).controller.signal}},_te=typeof WeakMap=="function"?WeakMap:Map,Cn=0,Xn=null,hn=null,xn=0,kn=0,Za=null,qc=!1,bh=!1,XE=!1,Cl=0,Sr=0,Xc=0,Nd=0,KE=0,Qa=0,yh=0,_g=null,Na=null,YE=!1,lb=0,Gj=0,cb=1/0,ub=null,Kc=null,ei=0,Yc=null,_h=null,Nl=0,ZE=0,QE=null,Wj=null,Sg=0,JE=null;function Ja(){return(Cn&2)!==0&&xn!==0?xn&-xn:G.T!==null?aA():Pi()}function qj(){if(Qa===0)if((xn&536870912)===0||yn){var d=pe;pe<<=1,(pe&3932160)===0&&(pe=262144),Qa=d}else Qa=536870912;return d=Ka.current,d!==null&&(d.flags|=32),Qa}function Ra(d,p,_){(d===Xn&&(kn===2||kn===9)||d.cancelPendingCommit!==null)&&(Sh(d,0),Zc(d,xn,Qa,!1)),cn(d,_),((Cn&2)===0||d!==Xn)&&(d===Xn&&((Cn&2)===0&&(Nd|=_),Sr===4&&Zc(d,xn,Qa,!1)),Lo(d))}function Xj(d,p,_){if((Cn&6)!==0)throw Error(r(327));var S=!_&&(p&127)===0&&(p&d.expiredLanes)===0||$e(d,p),P=S?Mte(d,p):tA(d,p,!0),O=S;do{if(P===0){bh&&!S&&Zc(d,p,0,!1);break}else{if(_=d.current.alternate,O&&!Ste(_)){P=tA(d,p,!1),O=!1;continue}if(P===2){if(O=p,d.errorRecoveryDisabledLanes&O)var X=0;else X=d.pendingLanes&-536870913,X=X!==0?X:X&536870912?536870912:0;if(X!==0){p=X;e:{var se=d;P=_g;var Se=se.current.memoizedState.isDehydrated;if(Se&&(Sh(se,X).flags|=256),X=tA(se,X,!1),X!==2){if(XE&&!Se){se.errorRecoveryDisabledLanes|=O,Nd|=O,P=4;break e}O=Na,Na=P,O!==null&&(Na===null?Na=O:Na.push.apply(Na,O))}P=X}if(O=!1,P!==2)continue}}if(P===1){Sh(d,0),Zc(d,p,0,!0);break}e:{switch(S=d,O=P,O){case 0:case 1:throw Error(r(345));case 4:if((p&4194048)!==p)break;case 6:Zc(S,p,Qa,!qc);break e;case 2:Na=null;break;case 3:case 5:break;default:throw Error(r(329))}if((p&62914560)===p&&(P=lb+300-L(),10<P)){if(Zc(S,p,Qa,!qc),be(S,0,!0)!==0)break e;Nl=p,S.timeoutHandle=E4(Kj.bind(null,S,_,Na,ub,YE,p,Qa,Nd,yh,qc,O,"Throttled",-0,0),P);break e}Kj(S,_,Na,ub,YE,p,Qa,Nd,yh,qc,O,null,-0,0)}}break}while(!0);Lo(d)}function Kj(d,p,_,S,P,O,X,se,Se,He,at,ut,Ge,nt){if(d.timeoutHandle=-1,ut=p.subtreeFlags,ut&8192||(ut&16785408)===16785408){ut={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:pl},Bj(p,O,ut);var Ct=(O&62914560)===O?lb-L():(O&4194048)===O?Gj-L():0;if(Ct=sne(ut,Ct),Ct!==null){Nl=O,d.cancelPendingCommit=Ct(r4.bind(null,d,p,O,_,S,P,X,se,Se,at,ut,null,Ge,nt)),Zc(d,O,X,!He);return}}r4(d,p,O,_,S,P,X,se,Se)}function Ste(d){for(var p=d;;){var _=p.tag;if((_===0||_===11||_===15)&&p.flags&16384&&(_=p.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var S=0;S<_.length;S++){var P=_[S],O=P.getSnapshot;P=P.value;try{if(!qa(O(),P))return!1}catch{return!1}}if(_=p.child,p.subtreeFlags&16384&&_!==null)_.return=p,p=_;else{if(p===d)break;for(;p.sibling===null;){if(p.return===null||p.return===d)return!0;p=p.return}p.sibling.return=p.return,p=p.sibling}}return!0}function Zc(d,p,_,S){p&=~KE,p&=~Nd,d.suspendedLanes|=p,d.pingedLanes&=~p,S&&(d.warmLanes|=p),S=d.expirationTimes;for(var P=p;0<P;){var O=31-Fe(P),X=1<<O;S[O]=-1,P&=~X}_!==0&&Rn(d,_,p)}function db(){return(Cn&6)===0?(wg(0),!1):!0}function eA(){if(hn!==null){if(kn===0)var d=hn.return;else d=hn,vl=yd=null,gE(d),fh=null,ag=0,d=hn;for(;d!==null;)Aj(d.alternate,d),d=d.return;hn=null}}function Sh(d,p){var _=d.timeoutHandle;_!==-1&&(d.timeoutHandle=-1,Hte(_)),_=d.cancelPendingCommit,_!==null&&(d.cancelPendingCommit=null,_()),Nl=0,eA(),Xn=d,hn=_=gl(d.current,null),xn=p,kn=0,Za=null,qc=!1,bh=$e(d,p),XE=!1,yh=Qa=KE=Nd=Xc=Sr=0,Na=_g=null,YE=!1,(p&8)!==0&&(p|=p&32);var S=d.entangledLanes;if(S!==0)for(d=d.entanglements,S&=p;0<S;){var P=31-Fe(S),O=1<<P;p|=d[P],S&=~O}return Cl=p,kv(),_}function Yj(d,p){Jt=null,G.H=hg,p===dh||p===zv?(p=fI(),kn=3):p===iE?(p=fI(),kn=4):kn=p===kE?8:p!==null&&typeof p=="object"&&typeof p.then=="function"?6:1,Za=p,hn===null&&(Sr=1,eb(d,vs(p,d.current)))}function Zj(){var d=Ka.current;return d===null?!0:(xn&4194048)===xn?Ss===null:(xn&62914560)===xn||(xn&536870912)!==0?d===Ss:!1}function Qj(){var d=G.H;return G.H=hg,d===null?hg:d}function Jj(){var d=G.A;return G.A=yte,d}function fb(){Sr=4,qc||(xn&4194048)!==xn&&Ka.current!==null||(bh=!0),(Xc&134217727)===0&&(Nd&134217727)===0||Xn===null||Zc(Xn,xn,Qa,!1)}function tA(d,p,_){var S=Cn;Cn|=2;var P=Qj(),O=Jj();(Xn!==d||xn!==p)&&(ub=null,Sh(d,p)),p=!1;var X=Sr;e:do try{if(kn!==0&&hn!==null){var se=hn,Se=Za;switch(kn){case 8:eA(),X=6;break e;case 3:case 2:case 9:case 6:Ka.current===null&&(p=!0);var He=kn;if(kn=0,Za=null,wh(d,se,Se,He),_&&bh){X=0;break e}break;default:He=kn,kn=0,Za=null,wh(d,se,Se,He)}}wte(),X=Sr;break}catch(at){Yj(d,at)}while(!0);return p&&d.shellSuspendCounter++,vl=yd=null,Cn=S,G.H=P,G.A=O,hn===null&&(Xn=null,xn=0,kv()),X}function wte(){for(;hn!==null;)e4(hn)}function Mte(d,p){var _=Cn;Cn|=2;var S=Qj(),P=Jj();Xn!==d||xn!==p?(ub=null,cb=L()+500,Sh(d,p)):bh=$e(d,p);e:do try{if(kn!==0&&hn!==null){p=hn;var O=Za;t:switch(kn){case 1:kn=0,Za=null,wh(d,p,O,1);break;case 2:case 9:if(uI(O)){kn=0,Za=null,t4(p);break}p=function(){kn!==2&&kn!==9||Xn!==d||(kn=7),Lo(d)},O.then(p,p);break e;case 3:kn=7;break e;case 4:kn=5;break e;case 7:uI(O)?(kn=0,Za=null,t4(p)):(kn=0,Za=null,wh(d,p,O,7));break;case 5:var X=null;switch(hn.tag){case 26:X=hn.memoizedState;case 5:case 27:var se=hn;if(X?z4(X):se.stateNode.complete){kn=0,Za=null;var Se=se.sibling;if(Se!==null)hn=Se;else{var He=se.return;He!==null?(hn=He,hb(He)):hn=null}break t}}kn=0,Za=null,wh(d,p,O,5);break;case 6:kn=0,Za=null,wh(d,p,O,6);break;case 8:eA(),Sr=6;break e;default:throw Error(r(462))}}Ete();break}catch(at){Yj(d,at)}while(!0);return vl=yd=null,G.H=S,G.A=P,Cn=_,hn!==null?0:(Xn=null,xn=0,kv(),Sr)}function Ete(){for(;hn!==null&&!re();)e4(hn)}function e4(d){var p=Mj(d.alternate,d,Cl);d.memoizedProps=d.pendingProps,p===null?hb(d):hn=p}function t4(d){var p=d,_=p.alternate;switch(p.tag){case 15:case 0:p=vj(_,p,p.pendingProps,p.type,void 0,xn);break;case 11:p=vj(_,p,p.pendingProps,p.type.render,p.ref,xn);break;case 5:gE(p);default:Aj(_,p),p=hn=JL(p,Cl),p=Mj(_,p,Cl)}d.memoizedProps=d.pendingProps,p===null?hb(d):hn=p}function wh(d,p,_,S){vl=yd=null,gE(p),fh=null,ag=0;var P=p.return;try{if(hte(d,P,p,_,xn)){Sr=1,eb(d,vs(_,d.current)),hn=null;return}}catch(O){if(P!==null)throw hn=P,O;Sr=1,eb(d,vs(_,d.current)),hn=null;return}p.flags&32768?(yn||S===1?d=!0:bh||(xn&536870912)!==0?d=!1:(qc=d=!0,(S===2||S===9||S===3||S===6)&&(S=Ka.current,S!==null&&S.tag===13&&(S.flags|=16384))),n4(p,d)):hb(p)}function hb(d){var p=d;do{if((p.flags&32768)!==0){n4(p,qc);return}d=p.return;var _=gte(p.alternate,p,Cl);if(_!==null){hn=_;return}if(p=p.sibling,p!==null){hn=p;return}hn=p=d}while(p!==null);Sr===0&&(Sr=5)}function n4(d,p){do{var _=xte(d.alternate,d);if(_!==null){_.flags&=32767,hn=_;return}if(_=d.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!p&&(d=d.sibling,d!==null)){hn=d;return}hn=d=_}while(d!==null);Sr=6,hn=null}function r4(d,p,_,S,P,O,X,se,Se){d.cancelPendingCommit=null;do pb();while(ei!==0);if((Cn&6)!==0)throw Error(r(327));if(p!==null){if(p===d.current)throw Error(r(177));if(O=p.lanes|p.childLanes,O|=$M,Ot(d,_,O,X,se,Se),d===Xn&&(hn=Xn=null,xn=0),_h=p,Yc=d,Nl=_,ZE=O,QE=P,Wj=S,(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?(d.callbackNode=null,d.callbackPriority=0,Nte(me,function(){return l4(),null})):(d.callbackNode=null,d.callbackPriority=0),S=(p.flags&13878)!==0,(p.subtreeFlags&13878)!==0||S){S=G.T,G.T=null,P=V.p,V.p=2,X=Cn,Cn|=4;try{vte(d,p,_)}finally{Cn=X,V.p=P,G.T=S}}ei=1,i4(),a4(),s4()}}function i4(){if(ei===1){ei=0;var d=Yc,p=_h,_=(p.flags&13878)!==0;if((p.subtreeFlags&13878)!==0||_){_=G.T,G.T=null;var S=V.p;V.p=2;var P=Cn;Cn|=4;try{Uj(p,d);var O=hA,X=VL(d.containerInfo),se=O.focusedElem,Se=O.selectionRange;if(X!==se&&se&&se.ownerDocument&&$L(se.ownerDocument.documentElement,se)){if(Se!==null&&UM(se)){var He=Se.start,at=Se.end;if(at===void 0&&(at=He),"selectionStart"in se)se.selectionStart=He,se.selectionEnd=Math.min(at,se.value.length);else{var ut=se.ownerDocument||document,Ge=ut&&ut.defaultView||window;if(Ge.getSelection){var nt=Ge.getSelection(),Ct=se.textContent.length,Bt=Math.min(Se.start,Ct),Fn=Se.end===void 0?Bt:Math.min(Se.end,Ct);!nt.extend&&Bt>Fn&&(X=Fn,Fn=Bt,Bt=X);var De=HL(se,Bt),Te=HL(se,Fn);if(De&&Te&&(nt.rangeCount!==1||nt.anchorNode!==De.node||nt.anchorOffset!==De.offset||nt.focusNode!==Te.node||nt.focusOffset!==Te.offset)){var Be=ut.createRange();Be.setStart(De.node,De.offset),nt.removeAllRanges(),Bt>Fn?(nt.addRange(Be),nt.extend(Te.node,Te.offset)):(Be.setEnd(Te.node,Te.offset),nt.addRange(Be))}}}}for(ut=[],nt=se;nt=nt.parentNode;)nt.nodeType===1&&ut.push({element:nt,left:nt.scrollLeft,top:nt.scrollTop});for(typeof se.focus=="function"&&se.focus(),se=0;se<ut.length;se++){var ot=ut[se];ot.element.scrollLeft=ot.left,ot.element.scrollTop=ot.top}}Ab=!!fA,hA=fA=null}finally{Cn=P,V.p=S,G.T=_}}d.current=p,ei=2}}function a4(){if(ei===2){ei=0;var d=Yc,p=_h,_=(p.flags&8772)!==0;if((p.subtreeFlags&8772)!==0||_){_=G.T,G.T=null;var S=V.p;V.p=2;var P=Cn;Cn|=4;try{Dj(d,p.alternate,p)}finally{Cn=P,V.p=S,G.T=_}}ei=3}}function s4(){if(ei===4||ei===3){ei=0,U();var d=Yc,p=_h,_=Nl,S=Wj;(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?ei=5:(ei=0,_h=Yc=null,o4(d,d.pendingLanes));var P=d.pendingLanes;if(P===0&&(Kc=null),mi(_),p=p.stateNode,le&&typeof le.onCommitFiberRoot=="function")try{le.onCommitFiberRoot(je,p,void 0,(p.current.flags&128)===128)}catch{}if(S!==null){p=G.T,P=V.p,V.p=2,G.T=null;try{for(var O=d.onRecoverableError,X=0;X<S.length;X++){var se=S[X];O(se.value,{componentStack:se.stack})}}finally{G.T=p,V.p=P}}(Nl&3)!==0&&pb(),Lo(d),P=d.pendingLanes,(_&261930)!==0&&(P&42)!==0?d===JE?Sg++:(Sg=0,JE=d):Sg=0,wg(0)}}function o4(d,p){(d.pooledCacheLanes&=p)===0&&(p=d.pooledCache,p!=null&&(d.pooledCache=null,rg(p)))}function pb(){return i4(),a4(),s4(),l4()}function l4(){if(ei!==5)return!1;var d=Yc,p=ZE;ZE=0;var _=mi(Nl),S=G.T,P=V.p;try{V.p=32>_?32:_,G.T=null,_=QE,QE=null;var O=Yc,X=Nl;if(ei=0,_h=Yc=null,Nl=0,(Cn&6)!==0)throw Error(r(331));var se=Cn;if(Cn|=4,$j(O.current),zj(O,O.current,X,_),Cn=se,wg(0,!1),le&&typeof le.onPostCommitFiberRoot=="function")try{le.onPostCommitFiberRoot(je,O)}catch{}return!0}finally{V.p=P,G.T=S,o4(d,p)}}function c4(d,p,_){p=vs(_,p),p=PE(d.stateNode,p,2),d=$c(d,p,2),d!==null&&(cn(d,2),Lo(d))}function Dn(d,p,_){if(d.tag===3)c4(d,d,_);else for(;p!==null;){if(p.tag===3){c4(p,d,_);break}else if(p.tag===1){var S=p.stateNode;if(typeof p.type.getDerivedStateFromError=="function"||typeof S.componentDidCatch=="function"&&(Kc===null||!Kc.has(S))){d=vs(_,d),_=uj(2),S=$c(p,_,2),S!==null&&(dj(_,S,p,d),cn(S,2),Lo(S));break}}p=p.return}}function nA(d,p,_){var S=d.pingCache;if(S===null){S=d.pingCache=new _te;var P=new Set;S.set(p,P)}else P=S.get(p),P===void 0&&(P=new Set,S.set(p,P));P.has(_)||(XE=!0,P.add(_),d=Ate.bind(null,d,p,_),p.then(d,d))}function Ate(d,p,_){var S=d.pingCache;S!==null&&S.delete(p),d.pingedLanes|=d.suspendedLanes&_,d.warmLanes&=~_,Xn===d&&(xn&_)===_&&(Sr===4||Sr===3&&(xn&62914560)===xn&&300>L()-lb?(Cn&2)===0&&Sh(d,0):KE|=_,yh===xn&&(yh=0)),Lo(d)}function u4(d,p){p===0&&(p=yt()),d=xd(d,p),d!==null&&(cn(d,p),Lo(d))}function Tte(d){var p=d.memoizedState,_=0;p!==null&&(_=p.retryLane),u4(d,_)}function Cte(d,p){var _=0;switch(d.tag){case 31:case 13:var S=d.stateNode,P=d.memoizedState;P!==null&&(_=P.retryLane);break;case 19:S=d.stateNode;break;case 22:S=d.stateNode._retryCache;break;default:throw Error(r(314))}S!==null&&S.delete(p),u4(d,_)}function Nte(d,p){return Ne(d,p)}var mb=null,Mh=null,rA=!1,gb=!1,iA=!1,Qc=0;function Lo(d){d!==Mh&&d.next===null&&(Mh===null?mb=Mh=d:Mh=Mh.next=d),gb=!0,rA||(rA=!0,Pte())}function wg(d,p){if(!iA&&gb){iA=!0;do for(var _=!1,S=mb;S!==null;){if(d!==0){var P=S.pendingLanes;if(P===0)var O=0;else{var X=S.suspendedLanes,se=S.pingedLanes;O=(1<<31-Fe(42|d)+1)-1,O&=P&~(X&~se),O=O&201326741?O&201326741|1:O?O|2:0}O!==0&&(_=!0,p4(S,O))}else O=xn,O=be(S,S===Xn?O:0,S.cancelPendingCommit!==null||S.timeoutHandle!==-1),(O&3)===0||$e(S,O)||(_=!0,p4(S,O));S=S.next}while(_);iA=!1}}function Rte(){d4()}function d4(){gb=rA=!1;var d=0;Qc!==0&&Bte()&&(d=Qc);for(var p=L(),_=null,S=mb;S!==null;){var P=S.next,O=f4(S,p);O===0?(S.next=null,_===null?mb=P:_.next=P,P===null&&(Mh=_)):(_=S,(d!==0||(O&3)!==0)&&(gb=!0)),S=P}ei!==0&&ei!==5||wg(d),Qc!==0&&(Qc=0)}function f4(d,p){for(var _=d.suspendedLanes,S=d.pingedLanes,P=d.expirationTimes,O=d.pendingLanes&-62914561;0<O;){var X=31-Fe(O),se=1<<X,Se=P[X];Se===-1?((se&_)===0||(se&S)!==0)&&(P[X]=ft(se,p)):Se<=p&&(d.expiredLanes|=se),O&=~se}if(p=Xn,_=xn,_=be(d,d===p?_:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),S=d.callbackNode,_===0||d===p&&(kn===2||kn===9)||d.cancelPendingCommit!==null)return S!==null&&S!==null&&Ee(S),d.callbackNode=null,d.callbackPriority=0;if((_&3)===0||$e(d,_)){if(p=_&-_,p===d.callbackPriority)return p;switch(S!==null&&Ee(S),mi(_)){case 2:case 8:_=ye;break;case 32:_=me;break;case 268435456:_=Ie;break;default:_=me}return S=h4.bind(null,d),_=Ne(_,S),d.callbackPriority=p,d.callbackNode=_,p}return S!==null&&S!==null&&Ee(S),d.callbackPriority=2,d.callbackNode=null,2}function h4(d,p){if(ei!==0&&ei!==5)return d.callbackNode=null,d.callbackPriority=0,null;var _=d.callbackNode;if(pb()&&d.callbackNode!==_)return null;var S=xn;return S=be(d,d===Xn?S:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),S===0?null:(Xj(d,S,p),f4(d,L()),d.callbackNode!=null&&d.callbackNode===_?h4.bind(null,d):null)}function p4(d,p){if(pb())return null;Xj(d,p,!0)}function Pte(){$te(function(){(Cn&6)!==0?Ne(ge,Rte):d4()})}function aA(){if(Qc===0){var d=ch;d===0&&(d=Qe,Qe<<=1,(Qe&261888)===0&&(Qe=256)),Qc=d}return Qc}function m4(d){return d==null||typeof d=="symbol"||typeof d=="boolean"?null:typeof d=="function"?d:Mv(""+d)}function g4(d,p){var _=p.ownerDocument.createElement("input");return _.name=p.name,_.value=p.value,d.id&&_.setAttribute("form",d.id),p.parentNode.insertBefore(_,p),d=new FormData(d),_.parentNode.removeChild(_),d}function kte(d,p,_,S,P){if(p==="submit"&&_&&_.stateNode===P){var O=m4((P[Tr]||null).action),X=S.submitter;X&&(p=(p=X[Tr]||null)?m4(p.formAction):X.getAttribute("formAction"),p!==null&&(O=p,X=null));var se=new Cv("action","action",null,S,P);d.push({event:se,listeners:[{instance:null,listener:function(){if(S.defaultPrevented){if(Qc!==0){var Se=X?g4(P,X):new FormData(P);EE(_,{pending:!0,data:Se,method:P.method,action:O},null,Se)}}else typeof O=="function"&&(se.preventDefault(),Se=X?g4(P,X):new FormData(P),EE(_,{pending:!0,data:Se,method:P.method,action:O},O,Se))},currentTarget:P}]})}}for(var sA=0;sA<HM.length;sA++){var oA=HM[sA],Dte=oA.toLowerCase(),Ote=oA[0].toUpperCase()+oA.slice(1);to(Dte,"on"+Ote)}to(qL,"onAnimationEnd"),to(XL,"onAnimationIteration"),to(KL,"onAnimationStart"),to("dblclick","onDoubleClick"),to("focusin","onFocus"),to("focusout","onBlur"),to(Yee,"onTransitionRun"),to(Zee,"onTransitionStart"),to(Qee,"onTransitionCancel"),to(YL,"onTransitionEnd"),vt("onMouseEnter",["mouseout","mouseover"]),vt("onMouseLeave",["mouseout","mouseover"]),vt("onPointerEnter",["pointerout","pointerover"]),vt("onPointerLeave",["pointerout","pointerover"]),ht("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ht("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ht("onBeforeInput",["compositionend","keypress","textInput","paste"]),ht("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ht("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ht("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Mg="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(" "),Lte=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Mg));function x4(d,p){p=(p&4)!==0;for(var _=0;_<d.length;_++){var S=d[_],P=S.event;S=S.listeners;e:{var O=void 0;if(p)for(var X=S.length-1;0<=X;X--){var se=S[X],Se=se.instance,He=se.currentTarget;if(se=se.listener,Se!==O&&P.isPropagationStopped())break e;O=se,P.currentTarget=He;try{O(P)}catch(at){Pv(at)}P.currentTarget=null,O=Se}else for(X=0;X<S.length;X++){if(se=S[X],Se=se.instance,He=se.currentTarget,se=se.listener,Se!==O&&P.isPropagationStopped())break e;O=se,P.currentTarget=He;try{O(P)}catch(at){Pv(at)}P.currentTarget=null,O=Se}}}}function pn(d,p){var _=p[Lc];_===void 0&&(_=p[Lc]=new Set);var S=d+"__bubble";_.has(S)||(v4(p,d,2,!1),_.add(S))}function lA(d,p,_){var S=0;p&&(S|=4),v4(_,d,S,p)}var xb="_reactListening"+Math.random().toString(36).slice(2);function cA(d){if(!d[xb]){d[xb]=!0,Me.forEach(function(_){_!=="selectionchange"&&(Lte.has(_)||lA(_,!1,d),lA(_,!0,d))});var p=d.nodeType===9?d:d.ownerDocument;p===null||p[xb]||(p[xb]=!0,lA("selectionchange",!1,p))}}function v4(d,p,_,S){switch(q4(p)){case 2:var P=cne;break;case 8:P=une;break;default:P=MA}_=P.bind(null,p,_,d),P=void 0,!NM||p!=="touchstart"&&p!=="touchmove"&&p!=="wheel"||(P=!0),S?P!==void 0?d.addEventListener(p,_,{capture:!0,passive:P}):d.addEventListener(p,_,!0):P!==void 0?d.addEventListener(p,_,{passive:P}):d.addEventListener(p,_,!1)}function uA(d,p,_,S,P){var O=S;if((p&1)===0&&(p&2)===0&&S!==null)e:for(;;){if(S===null)return;var X=S.tag;if(X===3||X===4){var se=S.stateNode.containerInfo;if(se===P)break;if(X===4)for(X=S.return;X!==null;){var Se=X.tag;if((Se===3||Se===4)&&X.stateNode.containerInfo===P)return;X=X.return}for(;se!==null;){if(X=_t(se),X===null)return;if(Se=X.tag,Se===5||Se===6||Se===26||Se===27){S=O=X;continue e}se=se.parentNode}}S=S.return}wL(function(){var He=O,at=TM(_),ut=[];e:{var Ge=ZL.get(d);if(Ge!==void 0){var nt=Cv,Ct=d;switch(d){case"keypress":if(Av(_)===0)break e;case"keydown":case"keyup":nt=Cee;break;case"focusin":Ct="focus",nt=DM;break;case"focusout":Ct="blur",nt=DM;break;case"beforeblur":case"afterblur":nt=DM;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":nt=AL;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":nt=gee;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":nt=Pee;break;case qL:case XL:case KL:nt=bee;break;case YL:nt=Dee;break;case"scroll":case"scrollend":nt=pee;break;case"wheel":nt=Lee;break;case"copy":case"cut":case"paste":nt=_ee;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":nt=CL;break;case"toggle":case"beforetoggle":nt=jee}var Bt=(p&4)!==0,Fn=!Bt&&(d==="scroll"||d==="scrollend"),De=Bt?Ge!==null?Ge+"Capture":null:Ge;Bt=[];for(var Te=He,Be;Te!==null;){var ot=Te;if(Be=ot.stateNode,ot=ot.tag,ot!==5&&ot!==26&&ot!==27||Be===null||De===null||(ot=Wm(Te,De),ot!=null&&Bt.push(Eg(Te,ot,Be))),Fn)break;Te=Te.return}0<Bt.length&&(Ge=new nt(Ge,Ct,null,_,at),ut.push({event:Ge,listeners:Bt}))}}if((p&7)===0){e:{if(Ge=d==="mouseover"||d==="pointerover",nt=d==="mouseout"||d==="pointerout",Ge&&_!==AM&&(Ct=_.relatedTarget||_.fromElement)&&(_t(Ct)||Ct[Js]))break e;if((nt||Ge)&&(Ge=at.window===at?at:(Ge=at.ownerDocument)?Ge.defaultView||Ge.parentWindow:window,nt?(Ct=_.relatedTarget||_.toElement,nt=He,Ct=Ct?_t(Ct):null,Ct!==null&&(Fn=a(Ct),Bt=Ct.tag,Ct!==Fn||Bt!==5&&Bt!==27&&Bt!==6)&&(Ct=null)):(nt=null,Ct=He),nt!==Ct)){if(Bt=AL,ot="onMouseLeave",De="onMouseEnter",Te="mouse",(d==="pointerout"||d==="pointerover")&&(Bt=CL,ot="onPointerLeave",De="onPointerEnter",Te="pointer"),Fn=nt==null?Ge:_e(nt),Be=Ct==null?Ge:_e(Ct),Ge=new Bt(ot,Te+"leave",nt,_,at),Ge.target=Fn,Ge.relatedTarget=Be,ot=null,_t(at)===He&&(Bt=new Bt(De,Te+"enter",Ct,_,at),Bt.target=Be,Bt.relatedTarget=Fn,ot=Bt),Fn=ot,nt&&Ct)t:{for(Bt=Ite,De=nt,Te=Ct,Be=0,ot=De;ot;ot=Bt(ot))Be++;ot=0;for(var jt=Te;jt;jt=Bt(jt))ot++;for(;0<Be-ot;)De=Bt(De),Be--;for(;0<ot-Be;)Te=Bt(Te),ot--;for(;Be--;){if(De===Te||Te!==null&&De===Te.alternate){Bt=De;break t}De=Bt(De),Te=Bt(Te)}Bt=null}else Bt=null;nt!==null&&b4(ut,Ge,nt,Bt,!1),Ct!==null&&Fn!==null&&b4(ut,Fn,Ct,Bt,!0)}}e:{if(Ge=He?_e(He):window,nt=Ge.nodeName&&Ge.nodeName.toLowerCase(),nt==="select"||nt==="input"&&Ge.type==="file")var wn=IL;else if(OL(Ge))if(jL)wn=qee;else{wn=Gee;var Dt=Vee}else nt=Ge.nodeName,!nt||nt.toLowerCase()!=="input"||Ge.type!=="checkbox"&&Ge.type!=="radio"?He&&EM(He.elementType)&&(wn=IL):wn=Wee;if(wn&&(wn=wn(d,He))){LL(ut,wn,_,at);break e}Dt&&Dt(d,Ge,He),d==="focusout"&&He&&Ge.type==="number"&&He.memoizedProps.value!=null&&gi(Ge,"number",Ge.value)}switch(Dt=He?_e(He):window,d){case"focusin":(OL(Dt)||Dt.contentEditable==="true")&&(th=Dt,FM=He,eg=null);break;case"focusout":eg=FM=th=null;break;case"mousedown":zM=!0;break;case"contextmenu":case"mouseup":case"dragend":zM=!1,GL(ut,_,at);break;case"selectionchange":if(Kee)break;case"keydown":case"keyup":GL(ut,_,at)}var en;if(LM)e:{switch(d){case"compositionstart":var vn="onCompositionStart";break e;case"compositionend":vn="onCompositionEnd";break e;case"compositionupdate":vn="onCompositionUpdate";break e}vn=void 0}else eh?kL(d,_)&&(vn="onCompositionEnd"):d==="keydown"&&_.keyCode===229&&(vn="onCompositionStart");vn&&(NL&&_.locale!=="ko"&&(eh||vn!=="onCompositionStart"?vn==="onCompositionEnd"&&eh&&(en=ML()):(Ic=at,RM="value"in Ic?Ic.value:Ic.textContent,eh=!0)),Dt=vb(He,vn),0<Dt.length&&(vn=new TL(vn,d,null,_,at),ut.push({event:vn,listeners:Dt}),en?vn.data=en:(en=DL(_),en!==null&&(vn.data=en)))),(en=Fee?zee(d,_):Bee(d,_))&&(vn=vb(He,"onBeforeInput"),0<vn.length&&(Dt=new TL("onBeforeInput","beforeinput",null,_,at),ut.push({event:Dt,listeners:vn}),Dt.data=en)),kte(ut,d,He,_,at)}x4(ut,p)})}function Eg(d,p,_){return{instance:d,listener:p,currentTarget:_}}function vb(d,p){for(var _=p+"Capture",S=[];d!==null;){var P=d,O=P.stateNode;if(P=P.tag,P!==5&&P!==26&&P!==27||O===null||(P=Wm(d,_),P!=null&&S.unshift(Eg(d,P,O)),P=Wm(d,p),P!=null&&S.push(Eg(d,P,O))),d.tag===3)return S;d=d.return}return[]}function Ite(d){if(d===null)return null;do d=d.return;while(d&&d.tag!==5&&d.tag!==27);return d||null}function b4(d,p,_,S,P){for(var O=p._reactName,X=[];_!==null&&_!==S;){var se=_,Se=se.alternate,He=se.stateNode;if(se=se.tag,Se!==null&&Se===S)break;se!==5&&se!==26&&se!==27||He===null||(Se=He,P?(He=Wm(_,O),He!=null&&X.unshift(Eg(_,He,Se))):P||(He=Wm(_,O),He!=null&&X.push(Eg(_,He,Se)))),_=_.return}X.length!==0&&d.push({event:p,listeners:X})}var jte=/\r\n?/g,Ute=/\u0000|\uFFFD/g;function y4(d){return(typeof d=="string"?d:""+d).replace(jte,`
  9. `).replace(Ute,"")}function _4(d,p){return p=y4(p),y4(d)===p}function Un(d,p,_,S,P,O){switch(_){case"children":typeof S=="string"?p==="body"||p==="textarea"&&S===""||Po(d,S):(typeof S=="number"||typeof S=="bigint")&&p!=="body"&&Po(d,""+S);break;case"className":It(d,"class",S);break;case"tabIndex":It(d,"tabindex",S);break;case"dir":case"role":case"viewBox":case"width":case"height":It(d,_,S);break;case"style":_L(d,S,O);break;case"data":if(p!=="object"){It(d,"data",S);break}case"src":case"href":if(S===""&&(p!=="a"||_!=="href")){d.removeAttribute(_);break}if(S==null||typeof S=="function"||typeof S=="symbol"||typeof S=="boolean"){d.removeAttribute(_);break}S=Mv(""+S),d.setAttribute(_,S);break;case"action":case"formAction":if(typeof S=="function"){d.setAttribute(_,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof O=="function"&&(_==="formAction"?(p!=="input"&&Un(d,p,"name",P.name,P,null),Un(d,p,"formEncType",P.formEncType,P,null),Un(d,p,"formMethod",P.formMethod,P,null),Un(d,p,"formTarget",P.formTarget,P,null)):(Un(d,p,"encType",P.encType,P,null),Un(d,p,"method",P.method,P,null),Un(d,p,"target",P.target,P,null)));if(S==null||typeof S=="symbol"||typeof S=="boolean"){d.removeAttribute(_);break}S=Mv(""+S),d.setAttribute(_,S);break;case"onClick":S!=null&&(d.onclick=pl);break;case"onScroll":S!=null&&pn("scroll",d);break;case"onScrollEnd":S!=null&&pn("scrollend",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));d.innerHTML=_}}break;case"multiple":d.multiple=S&&typeof S!="function"&&typeof S!="symbol";break;case"muted":d.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"){d.removeAttribute("xlink:href");break}_=Mv(""+S),d.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"?d.setAttribute(_,""+S):d.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"?d.setAttribute(_,""):d.removeAttribute(_);break;case"capture":case"download":S===!0?d.setAttribute(_,""):S!==!1&&S!=null&&typeof S!="function"&&typeof S!="symbol"?d.setAttribute(_,S):d.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":S!=null&&typeof S!="function"&&typeof S!="symbol"&&!isNaN(S)&&1<=S?d.setAttribute(_,S):d.removeAttribute(_);break;case"rowSpan":case"start":S==null||typeof S=="function"||typeof S=="symbol"||isNaN(S)?d.removeAttribute(_):d.setAttribute(_,S);break;case"popover":pn("beforetoggle",d),pn("toggle",d),qt(d,"popover",S);break;case"xlinkActuate":tn(d,"http://www.w3.org/1999/xlink","xlink:actuate",S);break;case"xlinkArcrole":tn(d,"http://www.w3.org/1999/xlink","xlink:arcrole",S);break;case"xlinkRole":tn(d,"http://www.w3.org/1999/xlink","xlink:role",S);break;case"xlinkShow":tn(d,"http://www.w3.org/1999/xlink","xlink:show",S);break;case"xlinkTitle":tn(d,"http://www.w3.org/1999/xlink","xlink:title",S);break;case"xlinkType":tn(d,"http://www.w3.org/1999/xlink","xlink:type",S);break;case"xmlBase":tn(d,"http://www.w3.org/XML/1998/namespace","xml:base",S);break;case"xmlLang":tn(d,"http://www.w3.org/XML/1998/namespace","xml:lang",S);break;case"xmlSpace":tn(d,"http://www.w3.org/XML/1998/namespace","xml:space",S);break;case"is":qt(d,"is",S);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=fee.get(_)||_,qt(d,_,S))}}function dA(d,p,_,S,P,O){switch(_){case"style":_L(d,S,O);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));d.innerHTML=_}}break;case"children":typeof S=="string"?Po(d,S):(typeof S=="number"||typeof S=="bigint")&&Po(d,""+S);break;case"onScroll":S!=null&&pn("scroll",d);break;case"onScrollEnd":S!=null&&pn("scrollend",d);break;case"onClick":S!=null&&(d.onclick=pl);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!it.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(P=_.endsWith("Capture"),p=_.slice(2,P?_.length-7:void 0),O=d[Tr]||null,O=O!=null?O[_]:null,typeof O=="function"&&d.removeEventListener(p,O,P),typeof S=="function")){typeof O!="function"&&O!==null&&(_ in d?d[_]=null:d.hasAttribute(_)&&d.removeAttribute(_)),d.addEventListener(p,S,P);break e}_ in d?d[_]=S:S===!0?d.setAttribute(_,""):qt(d,_,S)}}}function Ii(d,p,_){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":pn("error",d),pn("load",d);var S=!1,P=!1,O;for(O in _)if(_.hasOwnProperty(O)){var X=_[O];if(X!=null)switch(O){case"src":S=!0;break;case"srcSet":P=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:Un(d,p,O,X,_,null)}}P&&Un(d,p,"srcSet",_.srcSet,_,null),S&&Un(d,p,"src",_.src,_,null);return;case"input":pn("invalid",d);var se=O=X=P=null,Se=null,He=null;for(S in _)if(_.hasOwnProperty(S)){var at=_[S];if(at!=null)switch(S){case"name":P=at;break;case"type":X=at;break;case"checked":Se=at;break;case"defaultChecked":He=at;break;case"value":O=at;break;case"defaultValue":se=at;break;case"children":case"dangerouslySetInnerHTML":if(at!=null)throw Error(r(137,p));break;default:Un(d,p,S,at,_,null)}}Pn(d,O,se,Se,He,X,P,!1);return;case"select":pn("invalid",d),S=X=O=null;for(P in _)if(_.hasOwnProperty(P)&&(se=_[P],se!=null))switch(P){case"value":O=se;break;case"defaultValue":X=se;break;case"multiple":S=se;default:Un(d,p,P,se,_,null)}p=O,_=X,d.multiple=!!S,p!=null?Jr(d,!!S,p,!1):_!=null&&Jr(d,!!S,_,!0);return;case"textarea":pn("invalid",d),O=P=S=null;for(X in _)if(_.hasOwnProperty(X)&&(se=_[X],se!=null))switch(X){case"value":S=se;break;case"defaultValue":P=se;break;case"children":O=se;break;case"dangerouslySetInnerHTML":if(se!=null)throw Error(r(91));break;default:Un(d,p,X,se,_,null)}ki(d,S,P,O);return;case"option":for(Se in _)if(_.hasOwnProperty(Se)&&(S=_[Se],S!=null))switch(Se){case"selected":d.selected=S&&typeof S!="function"&&typeof S!="symbol";break;default:Un(d,p,Se,S,_,null)}return;case"dialog":pn("beforetoggle",d),pn("toggle",d),pn("cancel",d),pn("close",d);break;case"iframe":case"object":pn("load",d);break;case"video":case"audio":for(S=0;S<Mg.length;S++)pn(Mg[S],d);break;case"image":pn("error",d),pn("load",d);break;case"details":pn("toggle",d);break;case"embed":case"source":case"link":pn("error",d),pn("load",d);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(He in _)if(_.hasOwnProperty(He)&&(S=_[He],S!=null))switch(He){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:Un(d,p,He,S,_,null)}return;default:if(EM(p)){for(at in _)_.hasOwnProperty(at)&&(S=_[at],S!==void 0&&dA(d,p,at,S,_,void 0));return}}for(se in _)_.hasOwnProperty(se)&&(S=_[se],S!=null&&Un(d,p,se,S,_,null))}function Fte(d,p,_,S){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var P=null,O=null,X=null,se=null,Se=null,He=null,at=null;for(nt in _){var ut=_[nt];if(_.hasOwnProperty(nt)&&ut!=null)switch(nt){case"checked":break;case"value":break;case"defaultValue":Se=ut;default:S.hasOwnProperty(nt)||Un(d,p,nt,null,S,ut)}}for(var Ge in S){var nt=S[Ge];if(ut=_[Ge],S.hasOwnProperty(Ge)&&(nt!=null||ut!=null))switch(Ge){case"type":O=nt;break;case"name":P=nt;break;case"checked":He=nt;break;case"defaultChecked":at=nt;break;case"value":X=nt;break;case"defaultValue":se=nt;break;case"children":case"dangerouslySetInnerHTML":if(nt!=null)throw Error(r(137,p));break;default:nt!==ut&&Un(d,p,Ge,nt,S,ut)}}eo(d,X,se,Se,He,at,O,P);return;case"select":nt=X=se=Ge=null;for(O in _)if(Se=_[O],_.hasOwnProperty(O)&&Se!=null)switch(O){case"value":break;case"multiple":nt=Se;default:S.hasOwnProperty(O)||Un(d,p,O,null,S,Se)}for(P in S)if(O=S[P],Se=_[P],S.hasOwnProperty(P)&&(O!=null||Se!=null))switch(P){case"value":Ge=O;break;case"defaultValue":se=O;break;case"multiple":X=O;default:O!==Se&&Un(d,p,P,O,S,Se)}p=se,_=X,S=nt,Ge!=null?Jr(d,!!_,Ge,!1):!!S!=!!_&&(p!=null?Jr(d,!!_,p,!0):Jr(d,!!_,_?[]:"",!1));return;case"textarea":nt=Ge=null;for(se in _)if(P=_[se],_.hasOwnProperty(se)&&P!=null&&!S.hasOwnProperty(se))switch(se){case"value":break;case"children":break;default:Un(d,p,se,null,S,P)}for(X in S)if(P=S[X],O=_[X],S.hasOwnProperty(X)&&(P!=null||O!=null))switch(X){case"value":Ge=P;break;case"defaultValue":nt=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==O&&Un(d,p,X,P,S,O)}xi(d,Ge,nt);return;case"option":for(var Ct in _)if(Ge=_[Ct],_.hasOwnProperty(Ct)&&Ge!=null&&!S.hasOwnProperty(Ct))switch(Ct){case"selected":d.selected=!1;break;default:Un(d,p,Ct,null,S,Ge)}for(Se in S)if(Ge=S[Se],nt=_[Se],S.hasOwnProperty(Se)&&Ge!==nt&&(Ge!=null||nt!=null))switch(Se){case"selected":d.selected=Ge&&typeof Ge!="function"&&typeof Ge!="symbol";break;default:Un(d,p,Se,Ge,S,nt)}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 Bt in _)Ge=_[Bt],_.hasOwnProperty(Bt)&&Ge!=null&&!S.hasOwnProperty(Bt)&&Un(d,p,Bt,null,S,Ge);for(He in S)if(Ge=S[He],nt=_[He],S.hasOwnProperty(He)&&Ge!==nt&&(Ge!=null||nt!=null))switch(He){case"children":case"dangerouslySetInnerHTML":if(Ge!=null)throw Error(r(137,p));break;default:Un(d,p,He,Ge,S,nt)}return;default:if(EM(p)){for(var Fn in _)Ge=_[Fn],_.hasOwnProperty(Fn)&&Ge!==void 0&&!S.hasOwnProperty(Fn)&&dA(d,p,Fn,void 0,S,Ge);for(at in S)Ge=S[at],nt=_[at],!S.hasOwnProperty(at)||Ge===nt||Ge===void 0&&nt===void 0||dA(d,p,at,Ge,S,nt);return}}for(var De in _)Ge=_[De],_.hasOwnProperty(De)&&Ge!=null&&!S.hasOwnProperty(De)&&Un(d,p,De,null,S,Ge);for(ut in S)Ge=S[ut],nt=_[ut],!S.hasOwnProperty(ut)||Ge===nt||Ge==null&&nt==null||Un(d,p,ut,Ge,S,nt)}function S4(d){switch(d){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function zte(){if(typeof performance.getEntriesByType=="function"){for(var d=0,p=0,_=performance.getEntriesByType("resource"),S=0;S<_.length;S++){var P=_[S],O=P.transferSize,X=P.initiatorType,se=P.duration;if(O&&se&&S4(X)){for(X=0,se=P.responseEnd,S+=1;S<_.length;S++){var Se=_[S],He=Se.startTime;if(He>se)break;var at=Se.transferSize,ut=Se.initiatorType;at&&S4(ut)&&(Se=Se.responseEnd,X+=at*(Se<se?1:(se-He)/(Se-He)))}if(--S,p+=8*(O+X)/(P.duration/1e3),d++,10<d)break}}if(0<d)return p/d/1e6}return navigator.connection&&(d=navigator.connection.downlink,typeof d=="number")?d:5}var fA=null,hA=null;function bb(d){return d.nodeType===9?d:d.ownerDocument}function w4(d){switch(d){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function M4(d,p){if(d===0)switch(p){case"svg":return 1;case"math":return 2;default:return 0}return d===1&&p==="foreignObject"?0:d}function pA(d,p){return d==="textarea"||d==="noscript"||typeof p.children=="string"||typeof p.children=="number"||typeof p.children=="bigint"||typeof p.dangerouslySetInnerHTML=="object"&&p.dangerouslySetInnerHTML!==null&&p.dangerouslySetInnerHTML.__html!=null}var mA=null;function Bte(){var d=window.event;return d&&d.type==="popstate"?d===mA?!1:(mA=d,!0):(mA=null,!1)}var E4=typeof setTimeout=="function"?setTimeout:void 0,Hte=typeof clearTimeout=="function"?clearTimeout:void 0,A4=typeof Promise=="function"?Promise:void 0,$te=typeof queueMicrotask=="function"?queueMicrotask:typeof A4<"u"?function(d){return A4.resolve(null).then(d).catch(Vte)}:E4;function Vte(d){setTimeout(function(){throw d})}function Jc(d){return d==="head"}function T4(d,p){var _=p,S=0;do{var P=_.nextSibling;if(d.removeChild(_),P&&P.nodeType===8)if(_=P.data,_==="/$"||_==="/&"){if(S===0){d.removeChild(P),Ch(p);return}S--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")S++;else if(_==="html")Ag(d.ownerDocument.documentElement);else if(_==="head"){_=d.ownerDocument.head,Ag(_);for(var O=_.firstChild;O;){var X=O.nextSibling,se=O.nodeName;O[tt]||se==="SCRIPT"||se==="STYLE"||se==="LINK"&&O.rel.toLowerCase()==="stylesheet"||_.removeChild(O),O=X}}else _==="body"&&Ag(d.ownerDocument.body);_=P}while(_);Ch(p)}function C4(d,p){var _=d;d=0;do{var S=_.nextSibling;if(_.nodeType===1?p?(_._stashedDisplay=_.style.display,_.style.display="none"):(_.style.display=_._stashedDisplay||"",_.getAttribute("style")===""&&_.removeAttribute("style")):_.nodeType===3&&(p?(_._stashedText=_.nodeValue,_.nodeValue=""):_.nodeValue=_._stashedText||""),S&&S.nodeType===8)if(_=S.data,_==="/$"){if(d===0)break;d--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||d++;_=S}while(_)}function gA(d){var p=d.firstChild;for(p&&p.nodeType===10&&(p=p.nextSibling);p;){var _=p;switch(p=p.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":gA(_),Ye(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}d.removeChild(_)}}function Gte(d,p,_,S){for(;d.nodeType===1;){var P=_;if(d.nodeName.toLowerCase()!==p.toLowerCase()){if(!S&&(d.nodeName!=="INPUT"||d.type!=="hidden"))break}else if(S){if(!d[tt])switch(p){case"meta":if(!d.hasAttribute("itemprop"))break;return d;case"link":if(O=d.getAttribute("rel"),O==="stylesheet"&&d.hasAttribute("data-precedence"))break;if(O!==P.rel||d.getAttribute("href")!==(P.href==null||P.href===""?null:P.href)||d.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin)||d.getAttribute("title")!==(P.title==null?null:P.title))break;return d;case"style":if(d.hasAttribute("data-precedence"))break;return d;case"script":if(O=d.getAttribute("src"),(O!==(P.src==null?null:P.src)||d.getAttribute("type")!==(P.type==null?null:P.type)||d.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin))&&O&&d.hasAttribute("async")&&!d.hasAttribute("itemprop"))break;return d;default:return d}}else if(p==="input"&&d.type==="hidden"){var O=P.name==null?null:""+P.name;if(P.type==="hidden"&&d.getAttribute("name")===O)return d}else return d;if(d=ws(d.nextSibling),d===null)break}return null}function Wte(d,p,_){if(p==="")return null;for(;d.nodeType!==3;)if((d.nodeType!==1||d.nodeName!=="INPUT"||d.type!=="hidden")&&!_||(d=ws(d.nextSibling),d===null))return null;return d}function N4(d,p){for(;d.nodeType!==8;)if((d.nodeType!==1||d.nodeName!=="INPUT"||d.type!=="hidden")&&!p||(d=ws(d.nextSibling),d===null))return null;return d}function xA(d){return d.data==="$?"||d.data==="$~"}function vA(d){return d.data==="$!"||d.data==="$?"&&d.ownerDocument.readyState!=="loading"}function qte(d,p){var _=d.ownerDocument;if(d.data==="$~")d._reactRetry=p;else if(d.data!=="$?"||_.readyState!=="loading")p();else{var S=function(){p(),_.removeEventListener("DOMContentLoaded",S)};_.addEventListener("DOMContentLoaded",S),d._reactRetry=S}}function ws(d){for(;d!=null;d=d.nextSibling){var p=d.nodeType;if(p===1||p===3)break;if(p===8){if(p=d.data,p==="$"||p==="$!"||p==="$?"||p==="$~"||p==="&"||p==="F!"||p==="F")break;if(p==="/$"||p==="/&")return null}}return d}var bA=null;function R4(d){d=d.nextSibling;for(var p=0;d;){if(d.nodeType===8){var _=d.data;if(_==="/$"||_==="/&"){if(p===0)return ws(d.nextSibling);p--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||p++}d=d.nextSibling}return null}function P4(d){d=d.previousSibling;for(var p=0;d;){if(d.nodeType===8){var _=d.data;if(_==="$"||_==="$!"||_==="$?"||_==="$~"||_==="&"){if(p===0)return d;p--}else _!=="/$"&&_!=="/&"||p++}d=d.previousSibling}return null}function k4(d,p,_){switch(p=bb(_),d){case"html":if(d=p.documentElement,!d)throw Error(r(452));return d;case"head":if(d=p.head,!d)throw Error(r(453));return d;case"body":if(d=p.body,!d)throw Error(r(454));return d;default:throw Error(r(451))}}function Ag(d){for(var p=d.attributes;p.length;)d.removeAttributeNode(p[0]);Ye(d)}var Ms=new Map,D4=new Set;function yb(d){return typeof d.getRootNode=="function"?d.getRootNode():d.nodeType===9?d:d.ownerDocument}var Rl=V.d;V.d={f:Xte,r:Kte,D:Yte,C:Zte,L:Qte,m:Jte,X:tne,S:ene,M:nne};function Xte(){var d=Rl.f(),p=db();return d||p}function Kte(d){var p=te(d);p!==null&&p.tag===5&&p.type==="form"?YI(p):Rl.r(d)}var Eh=typeof document>"u"?null:document;function O4(d,p,_){var S=Eh;if(S&&typeof p=="string"&&p){var P=Nn(p);P='link[rel="'+d+'"][href="'+P+'"]',typeof _=="string"&&(P+='[crossorigin="'+_+'"]'),D4.has(P)||(D4.add(P),d={rel:d,crossOrigin:_,href:p},S.querySelector(P)===null&&(p=S.createElement("link"),Ii(p,"link",d),Re(p),S.head.appendChild(p)))}}function Yte(d){Rl.D(d),O4("dns-prefetch",d,null)}function Zte(d,p){Rl.C(d,p),O4("preconnect",d,p)}function Qte(d,p,_){Rl.L(d,p,_);var S=Eh;if(S&&d&&p){var P='link[rel="preload"][as="'+Nn(p)+'"]';p==="image"&&_&&_.imageSrcSet?(P+='[imagesrcset="'+Nn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(P+='[imagesizes="'+Nn(_.imageSizes)+'"]')):P+='[href="'+Nn(d)+'"]';var O=P;switch(p){case"style":O=Ah(d);break;case"script":O=Th(d)}Ms.has(O)||(d=h({rel:"preload",href:p==="image"&&_&&_.imageSrcSet?void 0:d,as:p},_),Ms.set(O,d),S.querySelector(P)!==null||p==="style"&&S.querySelector(Tg(O))||p==="script"&&S.querySelector(Cg(O))||(p=S.createElement("link"),Ii(p,"link",d),Re(p),S.head.appendChild(p)))}}function Jte(d,p){Rl.m(d,p);var _=Eh;if(_&&d){var S=p&&typeof p.as=="string"?p.as:"script",P='link[rel="modulepreload"][as="'+Nn(S)+'"][href="'+Nn(d)+'"]',O=P;switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":O=Th(d)}if(!Ms.has(O)&&(d=h({rel:"modulepreload",href:d},p),Ms.set(O,d),_.querySelector(P)===null)){switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(Cg(O)))return}S=_.createElement("link"),Ii(S,"link",d),Re(S),_.head.appendChild(S)}}}function ene(d,p,_){Rl.S(d,p,_);var S=Eh;if(S&&d){var P=ke(S).hoistableStyles,O=Ah(d);p=p||"default";var X=P.get(O);if(!X){var se={loading:0,preload:null};if(X=S.querySelector(Tg(O)))se.loading=5;else{d=h({rel:"stylesheet",href:d,"data-precedence":p},_),(_=Ms.get(O))&&yA(d,_);var Se=X=S.createElement("link");Re(Se),Ii(Se,"link",d),Se._p=new Promise(function(He,at){Se.onload=He,Se.onerror=at}),Se.addEventListener("load",function(){se.loading|=1}),Se.addEventListener("error",function(){se.loading|=2}),se.loading|=4,_b(X,p,S)}X={type:"stylesheet",instance:X,count:1,state:se},P.set(O,X)}}}function tne(d,p){Rl.X(d,p);var _=Eh;if(_&&d){var S=ke(_).hoistableScripts,P=Th(d),O=S.get(P);O||(O=_.querySelector(Cg(P)),O||(d=h({src:d,async:!0},p),(p=Ms.get(P))&&_A(d,p),O=_.createElement("script"),Re(O),Ii(O,"link",d),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},S.set(P,O))}}function nne(d,p){Rl.M(d,p);var _=Eh;if(_&&d){var S=ke(_).hoistableScripts,P=Th(d),O=S.get(P);O||(O=_.querySelector(Cg(P)),O||(d=h({src:d,async:!0,type:"module"},p),(p=Ms.get(P))&&_A(d,p),O=_.createElement("script"),Re(O),Ii(O,"link",d),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},S.set(P,O))}}function L4(d,p,_,S){var P=(P=ie.current)?yb(P):null;if(!P)throw Error(r(446));switch(d){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(p=Ah(_.href),_=ke(P).hoistableStyles,S=_.get(p),S||(S={type:"style",instance:null,count:0,state:null},_.set(p,S)),S):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){d=Ah(_.href);var O=ke(P).hoistableStyles,X=O.get(d);if(X||(P=P.ownerDocument||P,X={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},O.set(d,X),(O=P.querySelector(Tg(d)))&&!O._p&&(X.instance=O,X.state.loading=5),Ms.has(d)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},Ms.set(d,_),O||rne(P,d,_,X.state))),p&&S===null)throw Error(r(528,""));return X}if(p&&S!==null)throw Error(r(529,""));return null;case"script":return p=_.async,_=_.src,typeof _=="string"&&p&&typeof p!="function"&&typeof p!="symbol"?(p=Th(_),_=ke(P).hoistableScripts,S=_.get(p),S||(S={type:"script",instance:null,count:0,state:null},_.set(p,S)),S):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,d))}}function Ah(d){return'href="'+Nn(d)+'"'}function Tg(d){return'link[rel="stylesheet"]['+d+"]"}function I4(d){return h({},d,{"data-precedence":d.precedence,precedence:null})}function rne(d,p,_,S){d.querySelector('link[rel="preload"][as="style"]['+p+"]")?S.loading=1:(p=d.createElement("link"),S.preload=p,p.addEventListener("load",function(){return S.loading|=1}),p.addEventListener("error",function(){return S.loading|=2}),Ii(p,"link",_),Re(p),d.head.appendChild(p))}function Th(d){return'[src="'+Nn(d)+'"]'}function Cg(d){return"script[async]"+d}function j4(d,p,_){if(p.count++,p.instance===null)switch(p.type){case"style":var S=d.querySelector('style[data-href~="'+Nn(_.href)+'"]');if(S)return p.instance=S,Re(S),S;var P=h({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return S=(d.ownerDocument||d).createElement("style"),Re(S),Ii(S,"style",P),_b(S,_.precedence,d),p.instance=S;case"stylesheet":P=Ah(_.href);var O=d.querySelector(Tg(P));if(O)return p.state.loading|=4,p.instance=O,Re(O),O;S=I4(_),(P=Ms.get(P))&&yA(S,P),O=(d.ownerDocument||d).createElement("link"),Re(O);var X=O;return X._p=new Promise(function(se,Se){X.onload=se,X.onerror=Se}),Ii(O,"link",S),p.state.loading|=4,_b(O,_.precedence,d),p.instance=O;case"script":return O=Th(_.src),(P=d.querySelector(Cg(O)))?(p.instance=P,Re(P),P):(S=_,(P=Ms.get(O))&&(S=h({},_),_A(S,P)),d=d.ownerDocument||d,P=d.createElement("script"),Re(P),Ii(P,"link",S),d.head.appendChild(P),p.instance=P);case"void":return null;default:throw Error(r(443,p.type))}else p.type==="stylesheet"&&(p.state.loading&4)===0&&(S=p.instance,p.state.loading|=4,_b(S,_.precedence,d));return p.instance}function _b(d,p,_){for(var S=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),P=S.length?S[S.length-1]:null,O=P,X=0;X<S.length;X++){var se=S[X];if(se.dataset.precedence===p)O=se;else if(O!==P)break}O?O.parentNode.insertBefore(d,O.nextSibling):(p=_.nodeType===9?_.head:_,p.insertBefore(d,p.firstChild))}function yA(d,p){d.crossOrigin==null&&(d.crossOrigin=p.crossOrigin),d.referrerPolicy==null&&(d.referrerPolicy=p.referrerPolicy),d.title==null&&(d.title=p.title)}function _A(d,p){d.crossOrigin==null&&(d.crossOrigin=p.crossOrigin),d.referrerPolicy==null&&(d.referrerPolicy=p.referrerPolicy),d.integrity==null&&(d.integrity=p.integrity)}var Sb=null;function U4(d,p,_){if(Sb===null){var S=new Map,P=Sb=new Map;P.set(_,S)}else P=Sb,S=P.get(_),S||(S=new Map,P.set(_,S));if(S.has(d))return S;for(S.set(d,null),_=_.getElementsByTagName(d),P=0;P<_.length;P++){var O=_[P];if(!(O[tt]||O[pr]||d==="link"&&O.getAttribute("rel")==="stylesheet")&&O.namespaceURI!=="http://www.w3.org/2000/svg"){var X=O.getAttribute(p)||"";X=d+X;var se=S.get(X);se?se.push(O):S.set(X,[O])}}return S}function F4(d,p,_){d=d.ownerDocument||d,d.head.insertBefore(_,p==="title"?d.querySelector("head > title"):null)}function ine(d,p,_){if(_===1||p.itemProp!=null)return!1;switch(d){case"meta":case"title":return!0;case"style":if(typeof p.precedence!="string"||typeof p.href!="string"||p.href==="")break;return!0;case"link":if(typeof p.rel!="string"||typeof p.href!="string"||p.href===""||p.onLoad||p.onError)break;switch(p.rel){case"stylesheet":return d=p.disabled,typeof p.precedence=="string"&&d==null;default:return!0}case"script":if(p.async&&typeof p.async!="function"&&typeof p.async!="symbol"&&!p.onLoad&&!p.onError&&p.src&&typeof p.src=="string")return!0}return!1}function z4(d){return!(d.type==="stylesheet"&&(d.state.loading&3)===0)}function ane(d,p,_,S){if(_.type==="stylesheet"&&(typeof S.media!="string"||matchMedia(S.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var P=Ah(S.href),O=p.querySelector(Tg(P));if(O){p=O._p,p!==null&&typeof p=="object"&&typeof p.then=="function"&&(d.count++,d=wb.bind(d),p.then(d,d)),_.state.loading|=4,_.instance=O,Re(O);return}O=p.ownerDocument||p,S=I4(S),(P=Ms.get(P))&&yA(S,P),O=O.createElement("link"),Re(O);var X=O;X._p=new Promise(function(se,Se){X.onload=se,X.onerror=Se}),Ii(O,"link",S),_.instance=O}d.stylesheets===null&&(d.stylesheets=new Map),d.stylesheets.set(_,p),(p=_.state.preload)&&(_.state.loading&3)===0&&(d.count++,_=wb.bind(d),p.addEventListener("load",_),p.addEventListener("error",_))}}var SA=0;function sne(d,p){return d.stylesheets&&d.count===0&&Eb(d,d.stylesheets),0<d.count||0<d.imgCount?function(_){var S=setTimeout(function(){if(d.stylesheets&&Eb(d,d.stylesheets),d.unsuspend){var O=d.unsuspend;d.unsuspend=null,O()}},6e4+p);0<d.imgBytes&&SA===0&&(SA=62500*zte());var P=setTimeout(function(){if(d.waitingForImages=!1,d.count===0&&(d.stylesheets&&Eb(d,d.stylesheets),d.unsuspend)){var O=d.unsuspend;d.unsuspend=null,O()}},(d.imgBytes>SA?50:800)+p);return d.unsuspend=_,function(){d.unsuspend=null,clearTimeout(S),clearTimeout(P)}}:null}function wb(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Eb(this,this.stylesheets);else if(this.unsuspend){var d=this.unsuspend;this.unsuspend=null,d()}}}var Mb=null;function Eb(d,p){d.stylesheets=null,d.unsuspend!==null&&(d.count++,Mb=new Map,p.forEach(one,d),Mb=null,wb.call(d))}function one(d,p){if(!(p.state.loading&4)){var _=Mb.get(d);if(_)var S=_.get(null);else{_=new Map,Mb.set(d,_);for(var P=d.querySelectorAll("link[data-precedence],style[data-precedence]"),O=0;O<P.length;O++){var X=P[O];(X.nodeName==="LINK"||X.getAttribute("media")!=="not all")&&(_.set(X.dataset.precedence,X),S=X)}S&&_.set(null,S)}P=p.instance,X=P.getAttribute("data-precedence"),O=_.get(X)||S,O===S&&_.set(null,P),_.set(X,P),this.count++,S=wb.bind(this),P.addEventListener("load",S),P.addEventListener("error",S),O?O.parentNode.insertBefore(P,O.nextSibling):(d=d.nodeType===9?d.head:d,d.insertBefore(P,d.firstChild)),p.state.loading|=4}}var Ng={$$typeof:w,Provider:null,Consumer:null,_currentValue:Z,_currentValue2:Z,_threadCount:0};function lne(d,p,_,S,P,O,X,se,Se){this.tag=1,this.containerInfo=d,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=Pt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pt(0),this.hiddenUpdates=Pt(null),this.identifierPrefix=S,this.onUncaughtError=P,this.onCaughtError=O,this.onRecoverableError=X,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Se,this.incompleteTransitions=new Map}function B4(d,p,_,S,P,O,X,se,Se,He,at,ut){return d=new lne(d,p,_,X,Se,He,at,ut,se),p=1,O===!0&&(p|=24),O=Xa(3,null,null,p),d.current=O,O.stateNode=d,p=tE(),p.refCount++,d.pooledCache=p,p.refCount++,O.memoizedState={element:S,isDehydrated:_,cache:p},aE(O),d}function H4(d){return d?(d=ih,d):ih}function $4(d,p,_,S,P,O){P=H4(P),S.context===null?S.context=P:S.pendingContext=P,S=Hc(p),S.payload={element:_},O=O===void 0?null:O,O!==null&&(S.callback=O),_=$c(d,S,p),_!==null&&(Ra(_,d,p),og(_,d,p))}function V4(d,p){if(d=d.memoizedState,d!==null&&d.dehydrated!==null){var _=d.retryLane;d.retryLane=_!==0&&_<p?_:p}}function wA(d,p){V4(d,p),(d=d.alternate)&&V4(d,p)}function G4(d){if(d.tag===13||d.tag===31){var p=xd(d,67108864);p!==null&&Ra(p,d,67108864),wA(d,67108864)}}function W4(d){if(d.tag===13||d.tag===31){var p=Ja();p=Qr(p);var _=xd(d,p);_!==null&&Ra(_,d,p),wA(d,p)}}var Ab=!0;function cne(d,p,_,S){var P=G.T;G.T=null;var O=V.p;try{V.p=2,MA(d,p,_,S)}finally{V.p=O,G.T=P}}function une(d,p,_,S){var P=G.T;G.T=null;var O=V.p;try{V.p=8,MA(d,p,_,S)}finally{V.p=O,G.T=P}}function MA(d,p,_,S){if(Ab){var P=EA(S);if(P===null)uA(d,p,S,Tb,_),X4(d,S);else if(fne(P,d,p,_,S))S.stopPropagation();else if(X4(d,S),p&4&&-1<dne.indexOf(d)){for(;P!==null;){var O=te(P);if(O!==null)switch(O.tag){case 3:if(O=O.stateNode,O.current.memoizedState.isDehydrated){var X=Ae(O.pendingLanes);if(X!==0){var se=O;for(se.pendingLanes|=2,se.entangledLanes|=2;X;){var Se=1<<31-Fe(X);se.entanglements[1]|=Se,X&=~Se}Lo(O),(Cn&6)===0&&(cb=L()+500,wg(0))}}break;case 31:case 13:se=xd(O,2),se!==null&&Ra(se,O,2),db(),wA(O,2)}if(O=EA(S),O===null&&uA(d,p,S,Tb,_),O===P)break;P=O}P!==null&&S.stopPropagation()}else uA(d,p,S,null,_)}}function EA(d){return d=TM(d),AA(d)}var Tb=null;function AA(d){if(Tb=null,d=_t(d),d!==null){var p=a(d);if(p===null)d=null;else{var _=p.tag;if(_===13){if(d=s(p),d!==null)return d;d=null}else if(_===31){if(d=o(p),d!==null)return d;d=null}else if(_===3){if(p.stateNode.current.memoizedState.isDehydrated)return p.tag===3?p.stateNode.containerInfo:null;d=null}else p!==d&&(d=null)}}return Tb=d,null}function q4(d){switch(d){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(J()){case ge:return 2;case ye:return 8;case me:case et:return 32;case Ie:return 268435456;default:return 32}default:return 32}}var TA=!1,eu=null,tu=null,nu=null,Rg=new Map,Pg=new Map,ru=[],dne="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 X4(d,p){switch(d){case"focusin":case"focusout":eu=null;break;case"dragenter":case"dragleave":tu=null;break;case"mouseover":case"mouseout":nu=null;break;case"pointerover":case"pointerout":Rg.delete(p.pointerId);break;case"gotpointercapture":case"lostpointercapture":Pg.delete(p.pointerId)}}function kg(d,p,_,S,P,O){return d===null||d.nativeEvent!==O?(d={blockedOn:p,domEventName:_,eventSystemFlags:S,nativeEvent:O,targetContainers:[P]},p!==null&&(p=te(p),p!==null&&G4(p)),d):(d.eventSystemFlags|=S,p=d.targetContainers,P!==null&&p.indexOf(P)===-1&&p.push(P),d)}function fne(d,p,_,S,P){switch(p){case"focusin":return eu=kg(eu,d,p,_,S,P),!0;case"dragenter":return tu=kg(tu,d,p,_,S,P),!0;case"mouseover":return nu=kg(nu,d,p,_,S,P),!0;case"pointerover":var O=P.pointerId;return Rg.set(O,kg(Rg.get(O)||null,d,p,_,S,P)),!0;case"gotpointercapture":return O=P.pointerId,Pg.set(O,kg(Pg.get(O)||null,d,p,_,S,P)),!0}return!1}function K4(d){var p=_t(d.target);if(p!==null){var _=a(p);if(_!==null){if(p=_.tag,p===13){if(p=s(_),p!==null){d.blockedOn=p,qi(d.priority,function(){W4(_)});return}}else if(p===31){if(p=o(_),p!==null){d.blockedOn=p,qi(d.priority,function(){W4(_)});return}}else if(p===3&&_.stateNode.current.memoizedState.isDehydrated){d.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}d.blockedOn=null}function Cb(d){if(d.blockedOn!==null)return!1;for(var p=d.targetContainers;0<p.length;){var _=EA(d.nativeEvent);if(_===null){_=d.nativeEvent;var S=new _.constructor(_.type,_);AM=S,_.target.dispatchEvent(S),AM=null}else return p=te(_),p!==null&&G4(p),d.blockedOn=_,!1;p.shift()}return!0}function Y4(d,p,_){Cb(d)&&_.delete(p)}function hne(){TA=!1,eu!==null&&Cb(eu)&&(eu=null),tu!==null&&Cb(tu)&&(tu=null),nu!==null&&Cb(nu)&&(nu=null),Rg.forEach(Y4),Pg.forEach(Y4)}function Nb(d,p){d.blockedOn===p&&(d.blockedOn=null,TA||(TA=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,hne)))}var Rb=null;function Z4(d){Rb!==d&&(Rb=d,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Rb===d&&(Rb=null);for(var p=0;p<d.length;p+=3){var _=d[p],S=d[p+1],P=d[p+2];if(typeof S!="function"){if(AA(S||_)===null)continue;break}var O=te(_);O!==null&&(d.splice(p,3),p-=3,EE(O,{pending:!0,data:P,method:_.method,action:S},S,P))}}))}function Ch(d){function p(Se){return Nb(Se,d)}eu!==null&&Nb(eu,d),tu!==null&&Nb(tu,d),nu!==null&&Nb(nu,d),Rg.forEach(p),Pg.forEach(p);for(var _=0;_<ru.length;_++){var S=ru[_];S.blockedOn===d&&(S.blockedOn=null)}for(;0<ru.length&&(_=ru[0],_.blockedOn===null);)K4(_),_.blockedOn===null&&ru.shift();if(_=(d.ownerDocument||d).$$reactFormReplay,_!=null)for(S=0;S<_.length;S+=3){var P=_[S],O=_[S+1],X=P[Tr]||null;if(typeof O=="function")X||Z4(_);else if(X){var se=null;if(O&&O.hasAttribute("formAction")){if(P=O,X=O[Tr]||null)se=X.formAction;else if(AA(P)!==null)continue}else se=X.action;typeof se=="function"?_[S+1]=se:(_.splice(S,3),S-=3),Z4(_)}}}function Q4(){function d(O){O.canIntercept&&O.info==="react-transition"&&O.intercept({handler:function(){return new Promise(function(X){return P=X})},focusReset:"manual",scroll:"manual"})}function p(){P!==null&&(P(),P=null),S||setTimeout(_,20)}function _(){if(!S&&!navigation.transition){var O=navigation.currentEntry;O&&O.url!=null&&navigation.navigate(O.url,{state:O.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var S=!1,P=null;return navigation.addEventListener("navigate",d),navigation.addEventListener("navigatesuccess",p),navigation.addEventListener("navigateerror",p),setTimeout(_,100),function(){S=!0,navigation.removeEventListener("navigate",d),navigation.removeEventListener("navigatesuccess",p),navigation.removeEventListener("navigateerror",p),P!==null&&(P(),P=null)}}}function CA(d){this._internalRoot=d}Pb.prototype.render=CA.prototype.render=function(d){var p=this._internalRoot;if(p===null)throw Error(r(409));var _=p.current,S=Ja();$4(_,S,d,p,null,null)},Pb.prototype.unmount=CA.prototype.unmount=function(){var d=this._internalRoot;if(d!==null){this._internalRoot=null;var p=d.containerInfo;$4(d.current,2,null,d,null,null),db(),p[Js]=null}};function Pb(d){this._internalRoot=d}Pb.prototype.unstable_scheduleHydration=function(d){if(d){var p=Pi();d={blockedOn:null,target:d,priority:p};for(var _=0;_<ru.length&&p!==0&&p<ru[_].priority;_++);ru.splice(_,0,d),_===0&&K4(d)}};var J4=e.version;if(J4!=="19.2.0")throw Error(r(527,J4,"19.2.0"));V.findDOMNode=function(d){var p=d._reactInternals;if(p===void 0)throw typeof d.render=="function"?Error(r(188)):(d=Object.keys(d).join(","),Error(r(268,d)));return d=c(p),d=d!==null?u(d):null,d=d===null?null:d.stateNode,d};var pne={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:G,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var kb=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!kb.isDisabled&&kb.supportsFiber)try{je=kb.inject(pne),le=kb}catch{}}return Og.createRoot=function(d,p){if(!i(d))throw Error(r(299));var _=!1,S="",P=sj,O=oj,X=lj;return p!=null&&(p.unstable_strictMode===!0&&(_=!0),p.identifierPrefix!==void 0&&(S=p.identifierPrefix),p.onUncaughtError!==void 0&&(P=p.onUncaughtError),p.onCaughtError!==void 0&&(O=p.onCaughtError),p.onRecoverableError!==void 0&&(X=p.onRecoverableError)),p=B4(d,1,!1,null,null,_,S,null,P,O,X,Q4),d[Js]=p.current,cA(d),new CA(p)},Og.hydrateRoot=function(d,p,_){if(!i(d))throw Error(r(299));var S=!1,P="",O=sj,X=oj,se=lj,Se=null;return _!=null&&(_.unstable_strictMode===!0&&(S=!0),_.identifierPrefix!==void 0&&(P=_.identifierPrefix),_.onUncaughtError!==void 0&&(O=_.onUncaughtError),_.onCaughtError!==void 0&&(X=_.onCaughtError),_.onRecoverableError!==void 0&&(se=_.onRecoverableError),_.formState!==void 0&&(Se=_.formState)),p=B4(d,1,!0,p,_??null,S,P,Se,O,X,se,Q4),p.context=H4(null),_=p.current,S=Ja(),S=Qr(S),P=Hc(S),P.callback=null,$c(_,P,S),_=S,p.current.lanes=_,cn(p,_),Lo(p),d[Js]=p.current,cA(d),new Pb(p)},Og.version="19.2.0",Og}var cU;function Ene(){if(cU)return PA.exports;cU=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(),PA.exports=Mne(),PA.exports}var Ane=Ene();const Vt=t=>typeof t=="string",Lg=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},uU=t=>t==null?"":""+t,Tne=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Cne=/###/g,dU=t=>t&&t.indexOf("###")>-1?t.replace(Cne,"."):t,fU=t=>!t||Vt(t),vx=(t,e,n)=>{const r=Vt(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(fU(t))return{};const a=dU(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return fU(t)?{}:{obj:t,k:dU(r[i])}},hU=(t,e,n)=>{const{obj:r,k:i}=vx(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let a=e[e.length-1],s=e.slice(0,e.length-1),o=vx(t,s,Object);for(;o.obj===void 0&&s.length;)a=`${s[s.length-1]}.${a}`,s=s.slice(0,s.length-1),o=vx(t,s,Object),o?.obj&&typeof o.obj[`${o.k}.${a}`]<"u"&&(o.obj=void 0);o.obj[`${o.k}.${a}`]=n},Nne=(t,e,n,r)=>{const{obj:i,k:a}=vx(t,e,Object);i[a]=i[a]||[],i[a].push(n)},F_=(t,e)=>{const{obj:n,k:r}=vx(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Rne=(t,e,n)=>{const r=F_(t,n);return r!==void 0?r:F_(e,n)},vG=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?Vt(t[r])||t[r]instanceof String||Vt(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):vG(t[r],e[r],n):t[r]=e[r]);return t},Nh=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Pne={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const kne=t=>Vt(t)?t.replace(/[&<>"'\/]/g,e=>Pne[e]):t;class Dne{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 One=[" ",",","?","!",";"],Lne=new Dne(20),Ine=(t,e,n)=>{e=e||"",n=n||"";const r=One.filter(s=>e.indexOf(s)<0&&n.indexOf(s)<0);if(r.length===0)return!0;const i=Lne.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},wN=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let a=0;a<r.length;){if(!i||typeof i!="object")return;let s,o="";for(let l=a;l<r.length;++l)if(l!==a&&(o+=n),o+=r[l],s=i[o],s!==void 0){if(["string","number","boolean"].indexOf(typeof s)>-1&&l<r.length-1)continue;a+=l-a+1;break}i=s}return i},$x=t=>t?.replace("_","-"),jne={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 z_{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||jne,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:(Vt(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new z_(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new z_(this.logger,e)}}var Wo=new z_;let KS=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 pU extends KS{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r,i={}){const a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,s=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let o;e.indexOf(".")>-1?o=e.split("."):(o=[e,n],r&&(Array.isArray(r)?o.push(...r):Vt(r)&&a?o.push(...r.split(a)):o.push(r)));const l=F_(this.data,o);return!l&&!n&&!r&&e.indexOf(".")>-1&&(e=o[0],n=o[1],r=o.slice(2).join(".")),l||!s||!Vt(r)?l:wN(this.data?.[e]?.[n],r,a)}addResource(e,n,r,i,a={silent:!1}){const s=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let o=[e,n];r&&(o=o.concat(s?r.split(s):r)),e.indexOf(".")>-1&&(o=e.split("."),i=n,n=o[1]),this.addNamespaces(n),hU(this.data,o,i),a.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const a in r)(Vt(r[a])||Array.isArray(r[a]))&&this.addResource(e,n,a,r[a],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,a,s={silent:!1,skipCopy:!1}){let o=[e,n];e.indexOf(".")>-1&&(o=e.split("."),i=r,r=n,n=o[1]),this.addNamespaces(n);let l=F_(this.data,o)||{};s.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?vG(l,r,a):l={...l,...r},hU(this.data,o,l),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 bG={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 yG=Symbol("i18next/PATH_KEY");function Une(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===yG?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function MN(t,e){const{[yG]:n}=t(Une());return n.join(e?.keySeparator??".")}const mU={},LA=t=>!Vt(t)&&typeof t!="boolean"&&typeof t!="number";class B_ extends KS{constructor(e,n={}){super(),Tne(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Wo.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=LA(i.res);return!(r.returnObjects===!1&&a)}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=n.ns||this.options.defaultNS||[];const s=r&&e.indexOf(r)>-1,o=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Ine(e,r,i);if(s&&!o){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:Vt(a)?[a]:a};const c=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(c[0])>-1)&&(a=c.shift()),e=c.join(i)}return{key:e,namespaces:Vt(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=MN(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const a=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:o,namespaces:l}=this.extractFromKey(e[e.length-1],i),c=l[l.length-1];let u=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;u===void 0&&(u=":");const h=i.lng||this.language,g=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(h?.toLowerCase()==="cimode")return g?a?{res:`${c}${u}${o}`,usedKey:o,exactUsedKey:o,usedLng:h,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:`${c}${u}${o}`:a?{res:o,usedKey:o,exactUsedKey:o,usedLng:h,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:o;const m=this.resolve(e,i);let b=m?.res;const y=m?.usedKey||o,v=m?.exactUsedKey||o,x=["[object Number]","[object Function]","[object RegExp]"],M=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,w=!this.i18nFormat||this.i18nFormat.handleAsObject,C=i.count!==void 0&&!Vt(i.count),T=B_.hasDefaultValue(i),R=C?this.pluralResolver.getSuffix(h,i.count,i):"",A=i.ordinal&&C?this.pluralResolver.getSuffix(h,i.count,{ordinal:!1}):"",j=C&&!i.ordinal&&i.count===0,N=j&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${R}`]||i[`defaultValue${A}`]||i.defaultValue;let k=b;w&&!b&&T&&(k=N);const F=LA(k),I=Object.prototype.toString.apply(k);if(w&&k&&F&&x.indexOf(I)<0&&!(Vt(M)&&Array.isArray(k))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const W=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,k,{...i,ns:l}):`key '${o} (${this.language})' returned an object instead of string.`;return a?(m.res=W,m.usedParams=this.getUsedParamsDetails(i),m):W}if(s){const W=Array.isArray(k),D=W?[]:{},B=W?v:y;for(const G in k)if(Object.prototype.hasOwnProperty.call(k,G)){const V=`${B}${s}${G}`;T&&!b?D[G]=this.translate(V,{...i,defaultValue:LA(N)?N[G]:void 0,joinArrays:!1,ns:l}):D[G]=this.translate(V,{...i,joinArrays:!1,ns:l}),D[G]===V&&(D[G]=k[G])}b=D}}else if(w&&Vt(M)&&Array.isArray(b))b=b.join(M),b&&(b=this.extendTranslation(b,e,i,r));else{let W=!1,D=!1;!this.isValidLookup(b)&&T&&(W=!0,b=N),this.isValidLookup(b)||(D=!0,b=o);const G=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&D?void 0:b,V=T&&N!==b&&this.options.updateMissing;if(D||W||V){if(this.logger.log(V?"updateKey":"missingKey",h,c,o,V?N:b),s){const H=this.resolve(o,{...i,keySeparator:!1});H&&H.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let Z=[];const Y=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Y&&Y[0])for(let H=0;H<Y.length;H++)Z.push(Y[H]);else this.options.saveMissingTo==="all"?Z=this.languageUtils.toResolveHierarchy(i.lng||this.language):Z.push(i.lng||this.language);const ee=(H,q,ae)=>{const ce=T&&ae!==b?ae:G;this.options.missingKeyHandler?this.options.missingKeyHandler(H,c,q,ce,V,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(H,c,q,ce,V,i),this.emit("missingKey",H,c,q,b)};this.options.saveMissing&&(this.options.saveMissingPlurals&&C?Z.forEach(H=>{const q=this.pluralResolver.getSuffixes(H,i);j&&i[`defaultValue${this.options.pluralSeparator}zero`]&&q.indexOf(`${this.options.pluralSeparator}zero`)<0&&q.push(`${this.options.pluralSeparator}zero`),q.forEach(ae=>{ee([H],o+ae,i[`defaultValue${ae}`]||N)})}):ee(Z,o,N))}b=this.extendTranslation(b,e,i,m,r),D&&b===o&&this.options.appendNamespaceToMissingKey&&(b=`${c}${u}${o}`),(D||W)&&this.options.parseMissingKeyHandler&&(b=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}${u}${o}`:o,W?b:void 0,i))}return a?(m.res=b,m.usedParams=this.getUsedParamsDetails(i),m):b}extendTranslation(e,n,r,i,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const l=Vt(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let c;if(l){const h=e.match(this.interpolator.nestingRegexp);c=h&&h.length}let u=r.replace&&!Vt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(u={...this.options.interpolation.defaultVariables,...u}),e=this.interpolator.interpolate(e,u,r.lng||this.language||i.usedLng,r),l){const h=e.match(this.interpolator.nestingRegexp),g=h&&h.length;c<g&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...h)=>a?.[0]===h[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):this.translate(...h,n),r)),r.interpolation&&this.interpolator.reset()}const s=r.postProcess||this.options.postProcess,o=Vt(s)?[s]:s;return e!=null&&o?.length&&r.applyPostProcessor!==!1&&(e=bG.handle(o,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,a,s,o;return Vt(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(r))return;const c=this.extractFromKey(l,n),u=c.key;i=u;let h=c.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const g=n.count!==void 0&&!Vt(n.count),m=g&&!n.ordinal&&n.count===0,b=n.context!==void 0&&(Vt(n.context)||typeof n.context=="number")&&n.context!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);h.forEach(v=>{this.isValidLookup(r)||(o=v,!mU[`${y[0]}-${v}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(mU[`${y[0]}-${v}`]=!0,this.logger.warn(`key "${i}" for languages "${y.join(", ")}" won't get resolved as namespace "${o}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),y.forEach(x=>{if(this.isValidLookup(r))return;s=x;const M=[u];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(M,u,x,v,n);else{let C;g&&(C=this.pluralResolver.getSuffix(x,n.count,n));const T=`${this.options.pluralSeparator}zero`,R=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(g&&(n.ordinal&&C.indexOf(R)===0&&M.push(u+C.replace(R,this.options.pluralSeparator)),M.push(u+C),m&&M.push(u+T)),b){const A=`${u}${this.options.contextSeparator||"_"}${n.context}`;M.push(A),g&&(n.ordinal&&C.indexOf(R)===0&&M.push(A+C.replace(R,this.options.pluralSeparator)),M.push(A+C),m&&M.push(A+T))}}let w;for(;w=M.pop();)this.isValidLookup(r)||(a=w,r=this.getResource(x,v,w,n))}))})}),{res:r,usedKey:i,exactUsedKey:a,usedLng:s,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!Vt(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 gU{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Wo.create("languageUtils")}getScriptPartFromCode(e){if(e=$x(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=$x(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(Vt(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)),Vt(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 Vt(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))):Vt(e)&&a(this.formatLanguageCode(e)),r.forEach(s=>{i.indexOf(s)<0&&a(this.formatLanguageCode(s))}),i}}const xU={zero:0,one:1,two:2,few:3,many:4,other:5},vU={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Fne{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=Wo.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=$x(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!"),vU;if(!e.match(/-|_/))return vU;const l=this.languageUtils.getLanguagePartFromCode(e);s=this.getRule(l,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)=>xU[i]-xU[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 bU=(t,e,n,r=".",i=!0)=>{let a=Rne(t,e,n);return!a&&i&&Vt(n)&&(a=wN(t,n,r),a===void 0&&(a=wN(e,n,r))),a},IA=t=>t.replace(/\$/g,"$$$$");class zne{constructor(e={}){this.logger=Wo.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:a,prefixEscaped:s,suffix:o,suffixEscaped:l,formatSeparator:c,unescapeSuffix:u,unescapePrefix:h,nestingPrefix:g,nestingPrefixEscaped:m,nestingSuffix:b,nestingSuffixEscaped:y,nestingOptionsSeparator:v,maxReplaces:x,alwaysFormat:M}=e.interpolation;this.escape=n!==void 0?n:kne,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?Nh(a):s||"{{",this.suffix=o?Nh(o):l||"}}",this.formatSeparator=c||",",this.unescapePrefix=u?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=g?Nh(g):m||Nh("$t("),this.nestingSuffix=b?Nh(b):y||Nh(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=x||1e3,this.alwaysFormat=M!==void 0?M:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,r,i){let a,s,o;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=m=>{if(m.indexOf(this.formatSeparator)<0){const x=bU(n,l,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(x,void 0,r,{...i,...n,interpolationkey:m}):x}const b=m.split(this.formatSeparator),y=b.shift().trim(),v=b.join(this.formatSeparator).trim();return this.format(bU(n,l,y,this.options.keySeparator,this.options.ignoreJSONStructure),v,r,{...i,...n,interpolationkey:y})};this.resetRegExp();const u=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,h=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>IA(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?IA(this.escape(m)):IA(m)}].forEach(m=>{for(o=0;a=m.regex.exec(e);){const b=a[1].trim();if(s=c(b),s===void 0)if(typeof u=="function"){const v=u(e,a,i);s=Vt(v)?v:""}else if(i&&Object.prototype.hasOwnProperty.call(i,b))s="";else if(h){s=a[0];continue}else this.logger.warn(`missed to pass in variable ${b} for interpolating ${e}`),s="";else!Vt(s)&&!this.useRawValueToEscape&&(s=uU(s));const y=m.safeValue(s);if(e=e.replace(a[0],y),h?(m.regex.lastIndex+=s.length,m.regex.lastIndex-=a[0].length):m.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,a,s;const o=(l,c)=>{const u=this.nestingOptionsSeparator;if(l.indexOf(u)<0)return l;const h=l.split(new RegExp(`${u}[ ]*{`));let g=`{${h[1]}`;l=h[0],g=this.interpolate(g,s);const m=g.match(/'/g),b=g.match(/"/g);((m?.length??0)%2===0&&!b||b.length%2!==0)&&(g=g.replace(/'/g,'"'));try{s=JSON.parse(g),c&&(s={...c,...s})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,y),`${l}${u}${g}`}return s.defaultValue&&s.defaultValue.indexOf(this.prefix)>-1&&delete s.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];s={...r},s=s.replace&&!Vt(s.replace)?s.replace:s,s.applyPostProcessor=!1,delete s.defaultValue;const c=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(c!==-1&&(l=i[1].slice(c).split(this.formatSeparator).map(u=>u.trim()).filter(Boolean),i[1]=i[1].slice(0,c)),a=n(o.call(this,i[1].trim(),s),s),a&&i[0]===e&&!Vt(a))return a;Vt(a)||(a=uU(a)),a||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),a=""),l.length&&(a=l.reduce((u,h)=>this.format(u,h,r.lng,{...r,interpolationkey:i[1].trim()}),a.trim())),e=e.replace(i[0],a),this.regexp.lastIndex=0}return e}}const Bne=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(s=>{if(s){const[o,...l]=s.split(":"),c=l.join(":").trim().replace(/^'+|'+$/g,""),u=o.trim();n[u]||(n[u]=c),c==="false"&&(n[u]=!1),c==="true"&&(n[u]=!0),isNaN(c)||(n[u]=parseInt(c,10))}})}return{formatName:e,formatOptions:n}},yU=t=>{const e={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});const s=r+JSON.stringify(a);let o=e[s];return o||(o=t($x(r),i),e[s]=o),o(n)}},Hne=t=>(e,n,r)=>t($x(n),r)(e);class $ne{constructor(e={}){this.logger=Wo.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?yU:Hne;this.formats={number:r((i,a)=>{const s=new Intl.NumberFormat(i,{...a});return o=>s.format(o)}),currency:r((i,a)=>{const s=new Intl.NumberFormat(i,{...a,style:"currency"});return o=>s.format(o)}),datetime:r((i,a)=>{const s=new Intl.DateTimeFormat(i,{...a});return o=>s.format(o)}),relativetime:r((i,a)=>{const s=new Intl.RelativeTimeFormat(i,{...a});return o=>s.format(o,a.range||"day")}),list:r((i,a)=>{const s=new Intl.ListFormat(i,{...a});return o=>s.format(o)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=yU(n)}format(e,n,r,i={}){const a=n.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&a[0].indexOf(")")<0&&a.find(o=>o.indexOf(")")>-1)){const o=a.findIndex(l=>l.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,o)].join(this.formatSeparator)}return a.reduce((o,l)=>{const{formatName:c,formatOptions:u}=Bne(l);if(this.formats[c]){let h=o;try{const g=i?.formatParams?.[i.interpolationkey]||{},m=g.locale||g.lng||i.locale||i.lng||r;h=this.formats[c](o,m,{...u,...i,...g})}catch(g){this.logger.warn(g)}return h}else this.logger.warn(`there was no format function for ${c}`);return o},e)}}const Vne=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Gne extends KS{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=Wo.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,i.backend,i)}queueLoad(e,n,r,i){const a={},s={},o={},l={};return e.forEach(c=>{let u=!0;n.forEach(h=>{const g=`${c}|${h}`;!r.reload&&this.store.hasResourceBundle(c,h)?this.state[g]=2:this.state[g]<0||(this.state[g]===1?s[g]===void 0&&(s[g]=!0):(this.state[g]=1,u=!1,s[g]===void 0&&(s[g]=!0),a[g]===void 0&&(a[g]=!0),l[h]===void 0&&(l[h]=!0)))}),u||(o[c]=!0)}),(Object.keys(a).length||Object.keys(s).length)&&this.queue.push({pending:s,pendingCount:Object.keys(s).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(a),pending:Object.keys(s),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(l)}}loaded(e,n,r){const i=e.split("|"),a=i[0],s=i[1];n&&this.emit("failedLoading",a,s,n),!n&&r&&this.store.addResourceBundle(a,s,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const o={};this.queue.forEach(l=>{Nne(l.loaded,[a],s),Vne(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(c=>{o[c]||(o[c]={});const u=l.loaded[c];u.length&&u.forEach(h=>{o[c][h]===void 0&&(o[c][h]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(l=>!l.done)}read(e,n,r,i=0,a=this.retryTimeout,s){if(!e.length)return s(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:a,callback:s});return}this.readingCalls++;const o=(c,u)=>{if(this.readingCalls--,this.waitingReads.length>0){const h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}if(c&&u&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,a*2,s)},a);return}s(c,u)},l=this.backend[r].bind(this.backend);if(l.length===2){try{const c=l(e,n);c&&typeof c.then=="function"?c.then(u=>o(null,u)).catch(o):o(null,c)}catch(c){o(c)}return}return l(e,n,o)}prepareLoading(e,n,r={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();Vt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),Vt(n)&&(n=[n]);const a=this.queueLoad(e,n,r,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.toLoad.forEach(s=>{this.loadOne(s)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e,n=""){const r=e.split("|"),i=r[0],a=r[1];this.read(i,a,"read",void 0,void 0,(s,o)=>{s&&this.logger.warn(`${n}loading namespace ${a} for language ${i} failed`,s),!s&&o&&this.logger.log(`${n}loaded namespace ${a} for language ${i}`,o),this.loaded(e,s,o)})}saveMissing(e,n,r,i,a,s={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const l={...s,isUpdate:a},c=this.backend.create.bind(this.backend);if(c.length<6)try{let u;c.length===5?u=c(e,n,r,i,l):u=c(e,n,r,i),u&&typeof u.then=="function"?u.then(h=>o(null,h)).catch(o):o(null,u)}catch(u){o(u)}else c(e,n,r,i,o,l)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const _U=()=>({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]),Vt(t[1])&&(e.defaultValue=t[1]),Vt(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}),SU=t=>(Vt(t.ns)&&(t.ns=[t.ns]),Vt(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),Vt(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),Ob=()=>{},Wne=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class bx extends KS{constructor(e={},n){if(super(),this.options=SU(e),this.services={},this.logger=Wo,this.modules={external:[]},Wne(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&&(Vt(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=_U();this.options={...r,...this.options,...SU(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=c=>c?typeof c=="function"?new c:c:null;if(!this.options.isClone){this.modules.logger?Wo.init(i(this.modules.logger),this.options):Wo.init(null,this.options);let c;this.modules.formatter?c=this.modules.formatter:c=$ne;const u=new gU(this.options);this.store=new pU(this.options.resources,this.options);const h=this.services;h.logger=Wo,h.resourceStore=this.store,h.languageUtils=u,h.pluralResolver=new Fne(u,{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"),c&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(h.formatter=i(c),h.formatter.init&&h.formatter.init(h,this.options),this.options.interpolation.format=h.formatter.format.bind(h.formatter)),h.interpolator=new zne(this.options),h.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},h.backendConnector=new Gne(i(this.modules.backend),h.resourceStore,h,this.options),h.backendConnector.on("*",(m,...b)=>{this.emit(m,...b)}),this.modules.languageDetector&&(h.languageDetector=i(this.modules.languageDetector),h.languageDetector.init&&h.languageDetector.init(h,this.options.detection,this.options)),this.modules.i18nFormat&&(h.i18nFormat=i(this.modules.i18nFormat),h.i18nFormat.init&&h.i18nFormat.init(this)),this.translator=new B_(this.services,this.options),this.translator.on("*",(m,...b)=>{this.emit(m,...b)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Ob),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const c=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);c.length>0&&c[0]!=="dev"&&(this.options.lng=c[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(c=>{this[c]=(...u)=>this.store[c](...u)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(c=>{this[c]=(...u)=>(this.store[c](...u),this)});const o=Lg(),l=()=>{const c=(u,h)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),o.resolve(h),n(u,h)};if(this.languages&&!this.isInitialized)return c(null,this.t.bind(this));this.changeLanguage(this.options.lng,c)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),o}loadResources(e,n=Ob){let r=n;const i=Vt(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const a=[],s=o=>{if(!o||o==="cimode")return;this.services.languageUtils.toResolveHierarchy(o).forEach(c=>{c!=="cimode"&&a.indexOf(c)<0&&a.push(c)})};i?s(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>s(l)),this.options.preload?.forEach?.(o=>s(o)),this.services.backendConnector.load(a,this.options.ns,o=>{!o&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(o)})}else r(null)}reloadResources(e,n,r){const i=Lg();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=Ob),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"&&bG.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=Lg();this.emit("languageChanging",e);const i=o=>{this.language=o,this.languages=this.services.languageUtils.toResolveHierarchy(o),this.resolvedLanguage=void 0,this.setResolvedLanguage(o)},a=(o,l)=>{l?this.isLanguageChangingTo===e&&(i(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,r.resolve((...c)=>this.t(...c)),n&&n(o,(...c)=>this.t(...c))},s=o=>{!e&&!o&&this.services.languageDetector&&(o=[]);const l=Vt(o)?o:o&&o[0],c=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(Vt(o)?[o]:o);c&&(this.language||i(c),this.translator.language||this.translator.changeLanguage(c),this.services.languageDetector?.cacheUserLanguage?.(c)),this.loadResources(c,u=>{a(u,c)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?s(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(s):this.services.languageDetector.detect(s):s(e),r}getFixedT(e,n,r){const i=(a,s,...o)=>{let l;typeof s!="object"?l=this.options.overloadTranslationOptionHandler([a,s].concat(o)):l={...s},l.lng=l.lng||i.lng,l.lngs=l.lngs||i.lngs,l.ns=l.ns||i.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||r||i.keyPrefix);const c=this.options.keySeparator||".";let u;return l.keyPrefix&&Array.isArray(a)?u=a.map(h=>(typeof h=="function"&&(h=MN(h,{...this.options,...s})),`${l.keyPrefix}${c}${h}`)):(typeof a=="function"&&(a=MN(a,{...this.options,...s})),u=l.keyPrefix?`${l.keyPrefix}${c}${a}`:a),this.t(u,l)};return Vt(e)?i.lng=e:i.lngs=e,i.ns=n,i.keyPrefix=r,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,a=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const s=(o,l)=>{const c=this.services.backendConnector.state[`${o}|${l}`];return c===-1||c===0||c===2};if(n.precheck){const o=n.precheck(this,s);if(o!==void 0)return o}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||s(r,e)&&(!i||s(a,e)))}loadNamespaces(e,n){const r=Lg();return this.options.ns?(Vt(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=Lg();Vt(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 gU(_U());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 bx(e,n);return r.createInstance=bx.createInstance,r}cloneInstance(e={},n=Ob){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new bx(i);if((e.debug!==void 0||e.prefix!==void 0)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(o=>{a[o]=this[o]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r){const o=Object.keys(this.store.data).reduce((l,c)=>(l[c]={...this.store.data[c]},l[c]=Object.keys(l[c]).reduce((u,h)=>(u[h]={...l[c][h]},u),l[c]),l),{});a.store=new pU(o,i),a.services.resourceStore=a.store}return a.translator=new B_(a.services,i),a.translator.on("*",(o,...l)=>{a.emit(o,...l)}),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 Ma=bx.createInstance();Ma.createInstance;Ma.dir;Ma.init;Ma.loadResources;Ma.reloadResources;Ma.use;Ma.changeLanguage;Ma.getFixedT;Ma.t;Ma.exists;Ma.setDefaultNamespace;Ma.hasLoadedNamespace;Ma.loadNamespaces;Ma.loadLanguages;const qne=(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);_f(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},wU={},_G=(t,e,n,r)=>{_f(n)&&wU[n]||(_f(n)&&(wU[n]=new Date),qne(t,e,n,r))},SG=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},EN=(t,e,n)=>{t.loadNamespaces(e,SG(t,n))},MU=(t,e,n,r)=>{if(_f(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return EN(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,SG(t,r))},Xne=(t,e,n={})=>!e.languages||!e.languages.length?(_G(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}}),_f=t=>typeof t=="string",Kne=t=>typeof t=="object"&&t!==null,Yne=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Zne={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},Qne=t=>Zne[t],Jne=t=>t.replace(Yne,Qne);let AN={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Jne};const ere=(t={})=>{AN={...AN,...t}},tre=()=>AN;let wG;const nre=t=>{wG=t},rre=()=>wG,ire={type:"3rdParty",init(t){ere(t.options.react),nre(t)}},are=E.createContext();class sre{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var jA={exports:{}},UA={};var EU;function ore(){if(EU)return UA;EU=1;var t=ym();function e(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,a=t.useLayoutEffect,s=t.useDebugValue;function o(h,g){var m=g(),b=r({inst:{value:m,getSnapshot:g}}),y=b[0].inst,v=b[1];return a(function(){y.value=m,y.getSnapshot=g,l(y)&&v({inst:y})},[h,m,g]),i(function(){return l(y)&&v({inst:y}),h(function(){l(y)&&v({inst:y})})},[h]),s(m),m}function l(h){var g=h.getSnapshot;h=h.value;try{var m=g();return!n(h,m)}catch{return!0}}function c(h,g){return g()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:o;return UA.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,UA}var AU;function MG(){return AU||(AU=1,jA.exports=ore()),jA.exports}var kP=MG();const lre=(t,e)=>_f(e)?e:Kne(e)&&_f(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,cre={t:lre,ready:!1},ure=()=>()=>{},DP=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=E.useContext(are)||{},a=n||r||rre();a&&!a.reportNamespaces&&(a.reportNamespaces=new sre),a||_G(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const s=E.useMemo(()=>({...tre(),...a?.options?.react,...e}),[a,e]),{useSuspense:o,keyPrefix:l}=s,c=i||a?.options?.defaultNS,u=_f(c)?[c]:c||["translation"],h=E.useMemo(()=>u,u);a?.reportNamespaces?.addUsedNamespaces?.(h);const g=E.useRef(0),m=E.useCallback(N=>{if(!a)return ure;const{bindI18n:k,bindI18nStore:F}=s,I=()=>{g.current+=1,N()};return k&&a.on(k,I),F&&a.store.on(F,I),()=>{k&&k.split(" ").forEach(W=>a.off(W,I)),F&&F.split(" ").forEach(W=>a.store.off(W,I))}},[a,s]),b=E.useRef(),y=E.useCallback(()=>{if(!a)return cre;const N=!!(a.isInitialized||a.initializedStoreOnce)&&h.every(B=>Xne(B,a,s)),k=e.lng||a.language,F=g.current,I=b.current;if(I&&I.ready===N&&I.lng===k&&I.keyPrefix===l&&I.revision===F)return I;const D={t:a.getFixedT(k,s.nsMode==="fallback"?h:h[0],l),ready:N,lng:k,keyPrefix:l,revision:F};return b.current=D,D},[a,h,l,s,e.lng]),[v,x]=E.useState(0),{t:M,ready:w}=kP.useSyncExternalStore(m,y,y);E.useEffect(()=>{if(a&&!w&&!o){const N=()=>x(k=>k+1);e.lng?MU(a,e.lng,h,N):EN(a,h,N)}},[a,e.lng,h,w,o,v]);const C=a||{},T=E.useRef(null),R=E.useRef(),A=N=>{const k=Object.getOwnPropertyDescriptors(N);k.__original&&delete k.__original;const F=Object.create(Object.getPrototypeOf(N),k);if(!Object.prototype.hasOwnProperty.call(F,"__original"))try{Object.defineProperty(F,"__original",{value:N,writable:!1,enumerable:!1,configurable:!1})}catch{}return F},j=E.useMemo(()=>{const N=C,k=N?.language;let F=N;N&&(T.current&&T.current.__original===N?R.current!==k?(F=A(N),T.current=F,R.current=k):F=T.current:(F=A(N),T.current=F,R.current=k));const I=[M,F,w];return I.t=M,I.i18n=F,I.ready=w,I},[M,C,w,C.resolvedLanguage,C.language,C.languages]);if(a&&o&&!w)throw new Promise(N=>{const k=()=>N();e.lng?MU(a,e.lng,h,k):EN(a,h,k)});return j},{slice:dre,forEach:fre}=[];function hre(t){return fre.call(dre.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function pre(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 TU=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,mre=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(!TU.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!TU.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},CU={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=mre(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 gre={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return CU.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&CU.create(n,t,r,i,a)}},xre={name:"querystring",lookup(t){let{lookupQuerystring:e}=t,n;if(typeof window<"u"){let{search:r}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));const a=r.substring(1).split("&");for(let s=0;s<a.length;s++){const o=a[s].indexOf("=");o>0&&a[s].substring(0,o)===e&&(n=a[s].substring(o+1))}}return n}},vre={name:"hash",lookup(t){let{lookupHash:e,lookupFromHashIndex:n}=t,r;if(typeof window<"u"){const{hash:i}=window.location;if(i&&i.length>2){const a=i.substring(1);if(e){const s=a.split("&");for(let o=0;o<s.length;o++){const l=s[o].indexOf("=");l>0&&s[o].substring(0,l)===e&&(r=s[o].substring(l+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 Rh=null;const NU=()=>{if(Rh!==null)return Rh;try{if(Rh=typeof window<"u"&&window.localStorage!==null,!Rh)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Rh=!1}return Rh};var bre={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&NU())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&NU()&&window.localStorage.setItem(n,t)}};let Ph=null;const RU=()=>{if(Ph!==null)return Ph;try{if(Ph=typeof window<"u"&&window.sessionStorage!==null,!Ph)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Ph=!1}return Ph};var yre={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&RU())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&RU()&&window.sessionStorage.setItem(n,t)}},_re={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}},Sre={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}},wre={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}},Mre={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 EG=!1;try{document.cookie,EG=!0}catch{}const AG=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];EG||AG.splice(1,1);const Ere=()=>({order:AG,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class TG{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=hre(n,this.options||{},Ere()),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(gre),this.addDetector(xre),this.addDetector(bre),this.addDetector(yre),this.addDetector(_re),this.addDetector(Sre),this.addDetector(wre),this.addDetector(Mre),this.addDetector(vre)}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&&!pre(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)}))}}TG.type="languageDetector";const Are={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",settings:"Settings",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",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?"}},Tre={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",settings:"Einstellungen",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",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?"}},Cre={en:{translation:Are},de:{translation:Tre}};Ma.use(TG).use(ire).init({resources:Cre,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const PU=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var kU="popstate";function Nre(t={}){function e(r,i){let{pathname:a,search:s,hash:o}=r.location;return TN("",{pathname:a,search:s,hash:o},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:Vx(i)}return Pre(e,n,null,t)}function gr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function So(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Rre(){return Math.random().toString(36).substring(2,10)}function DU(t,e){return{usr:t.state,key:t.key,idx:e}}function TN(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?_m(e):e,state:n,key:e&&e.key||r||Rre()}}function Vx({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 _m(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 Pre(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,s=i.history,o="POP",l=null,c=u();c==null&&(c=0,s.replaceState({...s.state,idx:c},""));function u(){return(s.state||{idx:null}).idx}function h(){o="POP";let v=u(),x=v==null?null:v-c;c=v,l&&l({action:o,location:y.location,delta:x})}function g(v,x){o="PUSH";let M=TN(y.location,v,x);c=u()+1;let w=DU(M,c),C=y.createHref(M);try{s.pushState(w,"",C)}catch(T){if(T instanceof DOMException&&T.name==="DataCloneError")throw T;i.location.assign(C)}a&&l&&l({action:o,location:y.location,delta:1})}function m(v,x){o="REPLACE";let M=TN(y.location,v,x);c=u();let w=DU(M,c),C=y.createHref(M);s.replaceState(w,"",C),a&&l&&l({action:o,location:y.location,delta:0})}function b(v){return kre(v)}let y={get action(){return o},get location(){return t(i,s)},listen(v){if(l)throw new Error("A history only accepts one active listener");return i.addEventListener(kU,h),l=v,()=>{i.removeEventListener(kU,h),l=null}},createHref(v){return e(i,v)},createURL:b,encodeLocation(v){let x=b(v);return{pathname:x.pathname,search:x.search,hash:x.hash}},push:g,replace:m,go(v){return s.go(v)}};return y}function kre(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),gr(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:Vx(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function CG(t,e,n="/"){return Dre(t,e,n,!1)}function Dre(t,e,n,r){let i=typeof e=="string"?_m(e):e,a=mc(i.pathname||"/",n);if(a==null)return null;let s=NG(t);Ore(s);let o=null;for(let l=0;o==null&&l<s.length;++l){let c=Gre(a);o=$re(s[l],c,r)}return o}function NG(t,e=[],n=[],r="",i=!1){let a=(s,o,l=i,c)=>{let u={relativePath:c===void 0?s.path||"":c,caseSensitive:s.caseSensitive===!0,childrenIndex:o,route:s};if(u.relativePath.startsWith("/")){if(!u.relativePath.startsWith(r)&&l)return;gr(u.relativePath.startsWith(r),`Absolute route path "${u.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),u.relativePath=u.relativePath.slice(r.length)}let h=oc([r,u.relativePath]),g=n.concat(u);s.children&&s.children.length>0&&(gr(s.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),NG(s.children,e,g,h,l)),!(s.path==null&&!s.index)&&e.push({path:h,score:Bre(h,s.index),routesMeta:g})};return t.forEach((s,o)=>{if(s.path===""||!s.path?.includes("?"))a(s,o);else for(let l of RG(s.path))a(s,o,!0,l)}),e}function RG(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=RG(r.join("/")),o=[];return o.push(...s.map(l=>l===""?a:[a,l].join("/"))),i&&o.push(...s),o.map(l=>t.startsWith("/")&&l===""?"/":l)}function Ore(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:Hre(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Lre=/^:[\w-]+$/,Ire=3,jre=2,Ure=1,Fre=10,zre=-2,OU=t=>t==="*";function Bre(t,e){let n=t.split("/"),r=n.length;return n.some(OU)&&(r+=zre),e&&(r+=jre),n.filter(i=>!OU(i)).reduce((i,a)=>i+(Lre.test(a)?Ire:a===""?Ure:Fre),r)}function Hre(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 $re(t,e,n=!1){let{routesMeta:r}=t,i={},a="/",s=[];for(let o=0;o<r.length;++o){let l=r[o],c=o===r.length-1,u=a==="/"?e:e.slice(a.length)||"/",h=H_({path:l.relativePath,caseSensitive:l.caseSensitive,end:c},u),g=l.route;if(!h&&c&&n&&!r[r.length-1].route.index&&(h=H_({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},u)),!h)return null;Object.assign(i,h.params),s.push({params:i,pathname:oc([a,h.pathname]),pathnameBase:Yre(oc([a,h.pathnameBase])),route:g}),h.pathnameBase!=="/"&&(a=oc([a,h.pathnameBase]))}return s}function H_(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=Vre(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let a=i[0],s=a.replace(/(.)\/+$/,"$1"),o=i.slice(1);return{params:r.reduce((c,{paramName:u,isOptional:h},g)=>{if(u==="*"){let b=o[g]||"";s=a.slice(0,a.length-b.length).replace(/(.)\/+$/,"$1")}const m=o[g];return h&&!m?c[u]=void 0:c[u]=(m||"").replace(/%2F/g,"/"),c},{}),pathname:a,pathnameBase:s,pattern:t}}function Vre(t,e=!1,n=!0){So(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let r=[],i="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(s,o,l)=>(r.push({paramName:o,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)")).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 Gre(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return So(!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 mc(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 Wre=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,qre=t=>Wre.test(t);function Xre(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?_m(t):t,a;if(n)if(qre(n))a=n;else{if(n.includes("//")){let s=n;n=n.replace(/\/\/+/g,"/"),So(!1,`Pathnames cannot have embedded double slashes - normalizing ${s} -> ${n}`)}n.startsWith("/")?a=LU(n.substring(1),"/"):a=LU(n,e)}else a=e;return{pathname:a,search:Zre(r),hash:Qre(i)}}function LU(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 FA(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 Kre(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function PG(t){let e=Kre(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function kG(t,e,n,r=!1){let i;typeof t=="string"?i=_m(t):(i={...t},gr(!i.pathname||!i.pathname.includes("?"),FA("?","pathname","search",i)),gr(!i.pathname||!i.pathname.includes("#"),FA("#","pathname","hash",i)),gr(!i.search||!i.search.includes("#"),FA("#","search","hash",i)));let a=t===""||i.pathname==="",s=a?"/":i.pathname,o;if(s==null)o=n;else{let h=e.length-1;if(!r&&s.startsWith("..")){let g=s.split("/");for(;g[0]==="..";)g.shift(),h-=1;i.pathname=g.join("/")}o=h>=0?e[h]:"/"}let l=Xre(i,o),c=s&&s!=="/"&&s.endsWith("/"),u=(a||s===".")&&n.endsWith("/");return!l.pathname.endsWith("/")&&(c||u)&&(l.pathname+="/"),l}var oc=t=>t.join("/").replace(/\/\/+/g,"/"),Yre=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),Zre=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Qre=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function Jre(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 eie=["GET",...DG];new Set(eie);var Sm=E.createContext(null);Sm.displayName="DataRouter";var YS=E.createContext(null);YS.displayName="DataRouterState";E.createContext(!1);var OG=E.createContext({isTransitioning:!1});OG.displayName="ViewTransition";var tie=E.createContext(new Map);tie.displayName="Fetchers";var nie=E.createContext(null);nie.displayName="Await";var dl=E.createContext(null);dl.displayName="Navigation";var I0=E.createContext(null);I0.displayName="Location";var Co=E.createContext({outlet:null,matches:[],isDataRoute:!1});Co.displayName="Route";var OP=E.createContext(null);OP.displayName="RouteError";function rie(t,{relative:e}={}){gr(j0(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=E.useContext(dl),{hash:i,pathname:a,search:s}=U0(t,{relative:e}),o=a;return n!=="/"&&(o=a==="/"?n:oc([n,a])),r.createHref({pathname:o,search:s,hash:i})}function j0(){return E.useContext(I0)!=null}function od(){return gr(j0(),"useLocation() may be used only in the context of a <Router> component."),E.useContext(I0).location}var LG="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function IG(t){E.useContext(dl).static||E.useLayoutEffect(t)}function LP(){let{isDataRoute:t}=E.useContext(Co);return t?bie():iie()}function iie(){gr(j0(),"useNavigate() may be used only in the context of a <Router> component.");let t=E.useContext(Sm),{basename:e,navigator:n}=E.useContext(dl),{matches:r}=E.useContext(Co),{pathname:i}=od(),a=JSON.stringify(PG(r)),s=E.useRef(!1);return IG(()=>{s.current=!0}),E.useCallback((l,c={})=>{if(So(s.current,LG),!s.current)return;if(typeof l=="number"){n.go(l);return}let u=kG(l,JSON.parse(a),i,c.relative==="path");t==null&&e!=="/"&&(u.pathname=u.pathname==="/"?e:oc([e,u.pathname])),(c.replace?n.replace:n.push)(u,c.state,c)},[e,n,a,i,t])}var aie=E.createContext(null);function sie(t){let e=E.useContext(Co).outlet;return E.useMemo(()=>e&&E.createElement(aie.Provider,{value:t},e),[e,t])}function oie(){let{matches:t}=E.useContext(Co),e=t[t.length-1];return e?e.params:{}}function U0(t,{relative:e}={}){let{matches:n}=E.useContext(Co),{pathname:r}=od(),i=JSON.stringify(PG(n));return E.useMemo(()=>kG(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function lie(t,e){return jG(t,e)}function jG(t,e,n,r,i){gr(j0(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=E.useContext(dl),{matches:s}=E.useContext(Co),o=s[s.length-1],l=o?o.params:{},c=o?o.pathname:"/",u=o?o.pathnameBase:"/",h=o&&o.route;{let M=h&&h.path||"";UG(c,!h||M.endsWith("*")||M.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${M}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
  10. Please change the parent <Route path="${M}"> to <Route path="${M==="/"?"*":`${M}/*`}">.`)}let g=od(),m;if(e){let M=typeof e=="string"?_m(e):e;gr(u==="/"||M.pathname?.startsWith(u),`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 "${u}" but pathname "${M.pathname}" was given in the \`location\` prop.`),m=M}else m=g;let b=m.pathname||"/",y=b;if(u!=="/"){let M=u.replace(/^\//,"").split("/");y="/"+b.replace(/^\//,"").split("/").slice(M.length).join("/")}let v=CG(t,{pathname:y});So(h||v!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),So(v==null||v[v.length-1].route.element!==void 0||v[v.length-1].route.Component!==void 0||v[v.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let x=hie(v&&v.map(M=>Object.assign({},M,{params:Object.assign({},l,M.params),pathname:oc([u,a.encodeLocation?a.encodeLocation(M.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathname]),pathnameBase:M.pathnameBase==="/"?u:oc([u,a.encodeLocation?a.encodeLocation(M.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathnameBase])})),s,n,r,i);return e&&x?E.createElement(I0.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:"POP"}},x):x}function cie(){let t=vie(),e=Jre(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},a={padding:"2px 4px",backgroundColor:r},s=null;return console.error("Error handled by React Router default ErrorBoundary:",t),s=E.createElement(E.Fragment,null,E.createElement("p",null,"💿 Hey developer 👋"),E.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",E.createElement("code",{style:a},"ErrorBoundary")," or"," ",E.createElement("code",{style:a},"errorElement")," prop on your route.")),E.createElement(E.Fragment,null,E.createElement("h2",null,"Unexpected Application Error!"),E.createElement("h3",{style:{fontStyle:"italic"}},e),n?E.createElement("pre",{style:i},n):null,s)}var uie=E.createElement(cie,null),die=class extends E.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,e){return e.location!==t.location||e.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:e.error,location:e.location,revalidation:t.revalidation||e.revalidation}}componentDidCatch(t,e){this.props.onError?this.props.onError(t,e):console.error("React Router caught the following error during render",t)}render(){return this.state.error!==void 0?E.createElement(Co.Provider,{value:this.props.routeContext},E.createElement(OP.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function fie({routeContext:t,match:e,children:n}){let r=E.useContext(Sm);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),E.createElement(Co.Provider,{value:t},n)}function hie(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 u=a.findIndex(h=>h.route.id&&s?.[h.route.id]!==void 0);gr(u>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(s).join(",")}`),a=a.slice(0,Math.min(a.length,u+1))}let o=!1,l=-1;if(n)for(let u=0;u<a.length;u++){let h=a[u];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(l=u),h.route.id){let{loaderData:g,errors:m}=n,b=h.route.loader&&!g.hasOwnProperty(h.route.id)&&(!m||m[h.route.id]===void 0);if(h.route.lazy||b){o=!0,l>=0?a=a.slice(0,l+1):a=[a[0]];break}}}let c=n&&r?(u,h)=>{r(u,{location:n.location,params:n.matches?.[0]?.params??{},errorInfo:h})}:void 0;return a.reduceRight((u,h,g)=>{let m,b=!1,y=null,v=null;n&&(m=s&&h.route.id?s[h.route.id]:void 0,y=h.route.errorElement||uie,o&&(l<0&&g===0?(UG("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,v=null):l===g&&(b=!0,v=h.route.hydrateFallbackElement||null)));let x=e.concat(a.slice(0,g+1)),M=()=>{let w;return m?w=y:b?w=v:h.route.Component?w=E.createElement(h.route.Component,null):h.route.element?w=h.route.element:w=u,E.createElement(fie,{match:h,routeContext:{outlet:u,matches:x,isDataRoute:n!=null},children:w})};return n&&(h.route.ErrorBoundary||h.route.errorElement||g===0)?E.createElement(die,{location:n.location,revalidation:n.revalidation,component:y,error:m,children:M(),routeContext:{outlet:null,matches:x,isDataRoute:!0},onError:c}):M()},null)}function IP(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function pie(t){let e=E.useContext(Sm);return gr(e,IP(t)),e}function mie(t){let e=E.useContext(YS);return gr(e,IP(t)),e}function gie(t){let e=E.useContext(Co);return gr(e,IP(t)),e}function jP(t){let e=gie(t),n=e.matches[e.matches.length-1];return gr(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function xie(){return jP("useRouteId")}function vie(){let t=E.useContext(OP),e=mie("useRouteError"),n=jP("useRouteError");return t!==void 0?t:e.errors?.[n]}function bie(){let{router:t}=pie("useNavigate"),e=jP("useNavigate"),n=E.useRef(!1);return IG(()=>{n.current=!0}),E.useCallback(async(i,a={})=>{So(n.current,LG),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var IU={};function UG(t,e,n){!e&&!IU[t]&&(IU[t]=!0,So(!1,n))}E.memo(yie);function yie({routes:t,future:e,state:n,unstable_onError:r}){return jG(t,void 0,n,r,e)}function _ie(t){return sie(t.context)}function Fo(t){gr(!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 Sie({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:a=!1}){gr(!j0(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let s=t.replace(/^\/*/,"/"),o=E.useMemo(()=>({basename:s,navigator:i,static:a,future:{}}),[s,i,a]);typeof n=="string"&&(n=_m(n));let{pathname:l="/",search:c="",hash:u="",state:h=null,key:g="default"}=n,m=E.useMemo(()=>{let b=mc(l,s);return b==null?null:{location:{pathname:b,search:c,hash:u,state:h,key:g},navigationType:r}},[s,l,c,u,h,g,r]);return So(m!=null,`<Router basename="${s}"> is not able to match the URL "${l}${c}${u}" because it does not start with the basename, so the <Router> won't render anything.`),m==null?null:E.createElement(dl.Provider,{value:o},E.createElement(I0.Provider,{children:e,value:m}))}function wie({children:t,location:e}){return lie(CN(t),e)}function CN(t,e=[]){let n=[];return E.Children.forEach(t,(r,i)=>{if(!E.isValidElement(r))return;let a=[...e,i];if(r.type===E.Fragment){n.push.apply(n,CN(r.props.children,a));return}gr(r.type===Fo,`[${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>`),gr(!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=CN(r.props.children,a)),n.push(s)}),n}var m_="get",g_="application/x-www-form-urlencoded";function ZS(t){return t!=null&&typeof t.tagName=="string"}function Mie(t){return ZS(t)&&t.tagName.toLowerCase()==="button"}function Eie(t){return ZS(t)&&t.tagName.toLowerCase()==="form"}function Aie(t){return ZS(t)&&t.tagName.toLowerCase()==="input"}function Tie(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Cie(t,e){return t.button===0&&(!e||e==="_self")&&!Tie(t)}var Lb=null;function Nie(){if(Lb===null)try{new FormData(document.createElement("form"),0),Lb=!1}catch{Lb=!0}return Lb}var Rie=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function zA(t){return t!=null&&!Rie.has(t)?(So(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${g_}"`),null):t}function Pie(t,e){let n,r,i,a,s;if(Eie(t)){let o=t.getAttribute("action");r=o?mc(o,e):null,n=t.getAttribute("method")||m_,i=zA(t.getAttribute("enctype"))||g_,a=new FormData(t)}else if(Mie(t)||Aie(t)&&(t.type==="submit"||t.type==="image")){let o=t.form;if(o==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=t.getAttribute("formaction")||o.getAttribute("action");if(r=l?mc(l,e):null,n=t.getAttribute("formmethod")||o.getAttribute("method")||m_,i=zA(t.getAttribute("formenctype"))||zA(o.getAttribute("enctype"))||g_,a=new FormData(o,t),!Nie()){let{name:c,type:u,value:h}=t;if(u==="image"){let g=c?`${c}.`:"";a.append(`${g}x`,"0"),a.append(`${g}y`,"0")}else c&&a.append(c,h)}}else{if(ZS(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=m_,r=null,i=g_,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 UP(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function kie(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&&mc(r.pathname,e)==="/"?r.pathname=`${e.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function Die(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 Oie(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 Lie(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let s=await Die(a,n);return s.links?s.links():[]}return[]}));return Fie(r.flat(1).filter(Oie).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function jU(t,e,n,r,i,a){let s=(l,c)=>n[c]?l.route.id!==n[c].route.id:!0,o=(l,c)=>n[c].pathname!==l.pathname||n[c].route.path?.endsWith("*")&&n[c].params["*"]!==l.params["*"];return a==="assets"?e.filter((l,c)=>s(l,c)||o(l,c)):a==="data"?e.filter((l,c)=>{let u=r.routes[l.route.id];if(!u||!u.hasLoader)return!1;if(s(l,c)||o(l,c))return!0;if(l.route.shouldRevalidate){let h=l.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:l.params,defaultShouldRevalidate:!0});if(typeof h=="boolean")return h}return!0}):[]}function Iie(t,e,{includeHydrateFallback:n}={}){return jie(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 jie(t){return[...new Set(t)]}function Uie(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function Fie(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify(Uie(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function FG(){let t=E.useContext(Sm);return UP(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function zie(){let t=E.useContext(YS);return UP(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var FP=E.createContext(void 0);FP.displayName="FrameworkContext";function zG(){let t=E.useContext(FP);return UP(t,"You must render this element inside a <HydratedRouter> element"),t}function Bie(t,e){let n=E.useContext(FP),[r,i]=E.useState(!1),[a,s]=E.useState(!1),{onFocus:o,onBlur:l,onMouseEnter:c,onMouseLeave:u,onTouchStart:h}=e,g=E.useRef(null);E.useEffect(()=>{if(t==="render"&&s(!0),t==="viewport"){let y=x=>{x.forEach(M=>{s(M.isIntersecting)})},v=new IntersectionObserver(y,{threshold:.5});return g.current&&v.observe(g.current),()=>{v.disconnect()}}},[t]),E.useEffect(()=>{if(r){let y=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(y)}}},[r]);let m=()=>{i(!0)},b=()=>{i(!1),s(!1)};return n?t!=="intent"?[a,g,{}]:[a,g,{onFocus:Ig(o,m),onBlur:Ig(l,b),onMouseEnter:Ig(c,m),onMouseLeave:Ig(u,b),onTouchStart:Ig(h,m)}]:[!1,g,{}]}function Ig(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Hie({page:t,...e}){let{router:n}=FG(),r=E.useMemo(()=>CG(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?E.createElement(Vie,{page:t,matches:r,...e}):null}function $ie(t){let{manifest:e,routeModules:n}=zG(),[r,i]=E.useState([]);return E.useEffect(()=>{let a=!1;return Lie(t,e,n).then(s=>{a||i(s)}),()=>{a=!0}},[t,e,n]),r}function Vie({page:t,matches:e,...n}){let r=od(),{manifest:i,routeModules:a}=zG(),{basename:s}=FG(),{loaderData:o,matches:l}=zie(),c=E.useMemo(()=>jU(t,e,l,i,r,"data"),[t,e,l,i,r]),u=E.useMemo(()=>jU(t,e,l,i,r,"assets"),[t,e,l,i,r]),h=E.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let b=new Set,y=!1;if(e.forEach(x=>{let M=i.routes[x.route.id];!M||!M.hasLoader||(!c.some(w=>w.route.id===x.route.id)&&x.route.id in o&&a[x.route.id]?.shouldRevalidate||M.hasClientLoader?y=!0:b.add(x.route.id))}),b.size===0)return[];let v=kie(t,s,"data");return y&&b.size>0&&v.searchParams.set("_routes",e.filter(x=>b.has(x.route.id)).map(x=>x.route.id).join(",")),[v.pathname+v.search]},[s,o,r,i,c,e,t,a]),g=E.useMemo(()=>Iie(u,i),[u,i]),m=$ie(u);return E.createElement(E.Fragment,null,h.map(b=>E.createElement("link",{key:b,rel:"prefetch",as:"fetch",href:b,...n})),g.map(b=>E.createElement("link",{key:b,rel:"modulepreload",href:b,...n})),m.map(({key:b,link:y})=>E.createElement("link",{key:b,nonce:n.nonce,...y})))}function Gie(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var BG=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{BG&&(window.__reactRouterVersion="7.9.6")}catch{}function Wie({basename:t,children:e,window:n}){let r=E.useRef();r.current==null&&(r.current=Nre({window:n,v5Compat:!0}));let i=r.current,[a,s]=E.useState({action:i.action,location:i.location}),o=E.useCallback(l=>{E.startTransition(()=>s(l))},[s]);return E.useLayoutEffect(()=>i.listen(o),[i,o]),E.createElement(Sie,{basename:t,children:e,location:a.location,navigationType:a.action,navigator:i})}var HG=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,QS=E.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:a,replace:s,state:o,target:l,to:c,preventScrollReset:u,viewTransition:h,...g},m){let{basename:b}=E.useContext(dl),y=typeof c=="string"&&HG.test(c),v,x=!1;if(typeof c=="string"&&y&&(v=c,BG))try{let N=new URL(window.location.href),k=c.startsWith("//")?new URL(N.protocol+c):new URL(c),F=mc(k.pathname,b);k.origin===N.origin&&F!=null?c=F+k.search+k.hash:x=!0}catch{So(!1,`<Link to="${c}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let M=rie(c,{relative:i}),[w,C,T]=Bie(r,g),R=Kie(c,{replace:s,state:o,target:l,preventScrollReset:u,relative:i,viewTransition:h});function A(N){e&&e(N),N.defaultPrevented||R(N)}let j=E.createElement("a",{...g,...T,href:v||M,onClick:x||a?e:A,ref:Gie(m,C),target:l,"data-discover":!y&&n==="render"?"true":void 0});return w&&!y?E.createElement(E.Fragment,null,j,E.createElement(Hie,{page:M})):j});QS.displayName="Link";var $G=E.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:a,to:s,viewTransition:o,children:l,...c},u){let h=U0(s,{relative:c.relative}),g=od(),m=E.useContext(YS),{navigator:b,basename:y}=E.useContext(dl),v=m!=null&&eae(h)&&o===!0,x=b.encodeLocation?b.encodeLocation(h).pathname:h.pathname,M=g.pathname,w=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(M=M.toLowerCase(),w=w?w.toLowerCase():null,x=x.toLowerCase()),w&&y&&(w=mc(w,y)||w);const C=x!=="/"&&x.endsWith("/")?x.length-1:x.length;let T=M===x||!i&&M.startsWith(x)&&M.charAt(C)==="/",R=w!=null&&(w===x||!i&&w.startsWith(x)&&w.charAt(x.length)==="/"),A={isActive:T,isPending:R,isTransitioning:v},j=T?e:void 0,N;typeof r=="function"?N=r(A):N=[r,T?"active":null,R?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let k=typeof a=="function"?a(A):a;return E.createElement(QS,{...c,"aria-current":j,className:N,ref:u,style:k,to:s,viewTransition:o},typeof l=="function"?l(A):l)});$G.displayName="NavLink";var qie=E.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:s=m_,action:o,onSubmit:l,relative:c,preventScrollReset:u,viewTransition:h,...g},m)=>{let b=Qie(),y=Jie(o,{relative:c}),v=s.toLowerCase()==="get"?"get":"post",x=typeof o=="string"&&HG.test(o),M=w=>{if(l&&l(w),w.defaultPrevented)return;w.preventDefault();let C=w.nativeEvent.submitter,T=C?.getAttribute("formmethod")||s;b(C||w.currentTarget,{fetcherKey:e,method:T,navigate:n,replace:i,state:a,relative:c,preventScrollReset:u,viewTransition:h})};return E.createElement("form",{ref:m,method:v,action:y,onSubmit:r?l:M,...g,"data-discover":!x&&t==="render"?"true":void 0})});qie.displayName="Form";function Xie(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function VG(t){let e=E.useContext(Sm);return gr(e,Xie(t)),e}function Kie(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:s}={}){let o=LP(),l=od(),c=U0(t,{relative:a});return E.useCallback(u=>{if(Cie(u,e)){u.preventDefault();let h=n!==void 0?n:Vx(l)===Vx(c);o(t,{replace:h,state:r,preventScrollReset:i,relative:a,viewTransition:s})}},[l,o,c,n,r,e,t,i,a,s])}var Yie=0,Zie=()=>`__${String(++Yie)}__`;function Qie(){let{router:t}=VG("useSubmit"),{basename:e}=E.useContext(dl),n=xie();return E.useCallback(async(r,i={})=>{let{action:a,method:s,encType:o,formData:l,body:c}=Pie(r,e);if(i.navigate===!1){let u=i.fetcherKey||Zie();await t.fetch(u,n,i.action||a,{preventScrollReset:i.preventScrollReset,formData:l,body:c,formMethod:i.method||s,formEncType:i.encType||o,flushSync:i.flushSync})}else await t.navigate(i.action||a,{preventScrollReset:i.preventScrollReset,formData:l,body:c,formMethod:i.method||s,formEncType:i.encType||o,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[t,e,n])}function Jie(t,{relative:e}={}){let{basename:n}=E.useContext(dl),r=E.useContext(Co);gr(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...U0(t||".",{relative:e})},s=od();if(t==null){a.search=s.search;let o=new URLSearchParams(a.search),l=o.getAll("index");if(l.some(u=>u==="")){o.delete("index"),l.filter(h=>h).forEach(h=>o.append("index",h));let u=o.toString();a.search=u?`?${u}`:""}}return(!t||t===".")&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:oc([n,a.pathname])),Vx(a)}function eae(t,{relative:e}={}){let n=E.useContext(OG);gr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=VG("useViewTransitionState"),i=U0(t,{relative:e});if(!n.isTransitioning)return!1;let a=mc(n.currentLocation.pathname,r)||n.currentLocation.pathname,s=mc(n.nextLocation.pathname,r)||n.nextLocation.pathname;return H_(i.pathname,s)!=null||H_(i.pathname,a)!=null}var ec=xG();const tae=Zs(ec);var wm=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(){}},nae={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},rae=class{#e=nae;#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)}},Qd=new rae;function iae(t){setTimeout(t,0)}var Sf=typeof window>"u"||"Deno"in globalThis;function pa(){}function aae(t,e){return typeof t=="function"?t(e):t}function NN(t){return typeof t=="number"&&t>=0&&t!==1/0}function GG(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Uu(t,e){return typeof t=="function"?t(e):t}function Ds(t,e){return typeof t=="function"?t(e):t}function UU(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:s,stale:o}=t;if(s){if(r){if(e.queryHash!==zP(s,e.options))return!1}else if(!Gx(e.queryKey,s))return!1}if(n!=="all"){const l=e.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof o=="boolean"&&e.isStale()!==o||i&&i!==e.state.fetchStatus||a&&!a(e))}function FU(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(wf(e.options.mutationKey)!==wf(a))return!1}else if(!Gx(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function zP(t,e){return(e?.queryKeyHashFn||wf)(t)}function wf(t){return JSON.stringify(t,(e,n)=>RN(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function Gx(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>Gx(t[n],e[n])):!1}var sae=Object.prototype.hasOwnProperty;function WG(t,e){if(t===e)return t;const n=zU(t)&&zU(e);if(!n&&!(RN(t)&&RN(e)))return e;const i=(n?t:Object.keys(t)).length,a=n?e:Object.keys(e),s=a.length,o=n?new Array(s):{};let l=0;for(let c=0;c<s;c++){const u=n?c:a[c],h=t[u],g=e[u];if(h===g){o[u]=h,(n?c<i:sae.call(t,u))&&l++;continue}if(h===null||g===null||typeof h!="object"||typeof g!="object"){o[u]=g;continue}const m=WG(h,g);o[u]=m,m===h&&l++}return i===s&&l===i?t:o}function $_(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const n in t)if(t[n]!==e[n])return!1;return!0}function zU(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function RN(t){if(!BU(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!BU(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function BU(t){return Object.prototype.toString.call(t)==="[object Object]"}function oae(t){return new Promise(e=>{Qd.setTimeout(e,t)})}function PN(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?WG(t,e):e}function lae(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function cae(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var BP=Symbol();function qG(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===BP?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function XG(t,e){return typeof t=="function"?t(...e):!!t}var uae=class extends wm{#e;#t;#n;constructor(){super(),this.#n=t=>{if(!Sf&&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"}},HP=new uae;function kN(){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 dae=iae;function fae(){let t=[],e=0,n=o=>{o()},r=o=>{o()},i=dae;const a=o=>{e?t.push(o):i(()=>{n(o)})},s=()=>{const o=t;t=[],o.length&&i(()=>{r(()=>{o.forEach(l=>{n(l)})})})};return{batch:o=>{let l;e++;try{l=o()}finally{e--,e||s()}return l},batchCalls:o=>(...l)=>{a(()=>{o(...l)})},schedule:a,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{i=o}}}var ii=fae(),hae=class extends wm{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(!Sf&&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}},V_=new hae;function pae(t){return Math.min(1e3*2**t,3e4)}function KG(t){return(t??"online")==="online"?V_.isOnline():!0}var DN=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function YG(t){let e=!1,n=0,r;const i=kN(),a=()=>i.status!=="pending",s=y=>{if(!a()){const v=new DN(y);g(v),t.onCancel?.(v)}},o=()=>{e=!0},l=()=>{e=!1},c=()=>HP.isFocused()&&(t.networkMode==="always"||V_.isOnline())&&t.canRun(),u=()=>KG(t.networkMode)&&t.canRun(),h=y=>{a()||(r?.(),i.resolve(y))},g=y=>{a()||(r?.(),i.reject(y))},m=()=>new Promise(y=>{r=v=>{(a()||c())&&y(v)},t.onPause?.()}).then(()=>{r=void 0,a()||t.onContinue?.()}),b=()=>{if(a())return;let y;const v=n===0?t.initialPromise:void 0;try{y=v??t.fn()}catch(x){y=Promise.reject(x)}Promise.resolve(y).then(h).catch(x=>{if(a())return;const M=t.retry??(Sf?0:3),w=t.retryDelay??pae,C=typeof w=="function"?w(n,x):w,T=M===!0||typeof M=="number"&&n<M||typeof M=="function"&&M(n,x);if(e||!T){g(x);return}n++,t.onFail?.(n,x),oae(C).then(()=>c()?void 0:m()).then(()=>{e?g(x):b()})})};return{promise:i,status:()=>i.status,cancel:s,continue:()=>(r?.(),i),cancelRetry:o,continueRetry:l,canStart:u,start:()=>(u()?b():m().then(b),i)}}var ZG=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),NN(this.gcTime)&&(this.#e=Qd.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Sf?1/0:300*1e3))}clearGcTimeout(){this.#e&&(Qd.clearTimeout(this.#e),this.#e=void 0)}},mae=class extends ZG{#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=$U(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=$U(this.options);e.data!==void 0&&(this.setState(HU(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=PN(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(pa).catch(pa):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>Ds(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===BP||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Uu(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:!GG(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#a({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(t&&this.setOptions(t),!this.options.queryFn){const o=this.observers.find(l=>l.options.queryFn);o&&this.setOptions(o.options)}const n=new AbortController,r=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{const o=qG(this.options,e),c=(()=>{const u={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(u),u})();return this.#o=!1,this.options.persister?this.options.persister(o,c,this):o(c)},s=(()=>{const o={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(o),o})();this.options.behavior?.onFetch(s,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&this.#a({type:"fetch",meta:s.fetchOptions?.meta}),this.#r=YG({initialPromise:e?.initialPromise,fn:s.fetchFn,onCancel:o=>{o instanceof DN&&o.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(o,l)=>{this.#a({type:"failed",failureCount:o,error:l})},onPause:()=>{this.#a({type:"pause"})},onContinue:()=>{this.#a({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0});try{const o=await this.#r.start();if(o===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(o),this.#n.config.onSuccess?.(o,this),this.#n.config.onSettled?.(o,this.state.error,this),o}catch(o){if(o instanceof DN){if(o.silent)return this.#r.promise;if(o.revert){if(this.state.data===void 0)throw o;return this.state.data}}throw this.#a({type:"error",error:o}),this.#n.config.onError?.(o,this),this.#n.config.onSettled?.(this.state.data,o,this),o}finally{this.scheduleGc()}}#a(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...QG(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...HU(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),ii.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function QG(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:KG(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function HU(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function $U(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 gae=class extends wm{constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=kN(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#n=void 0;#i=void 0;#r;#s;#o;#a;#m;#f;#h;#c;#u;#l;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),VU(this.#t,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ON(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ON(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#y(),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 Ds(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#S(),this.#t.setOptions(this.options),e._defaulted&&!$_(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&GU(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||Ds(this.options.enabled,this.#t)!==Ds(e.enabled,this.#t)||Uu(this.options.staleTime,this.#t)!==Uu(e.staleTime,this.#t))&&this.#g();const i=this.#x();r&&(this.#t!==n||Ds(this.options.enabled,this.#t)!==Ds(e.enabled,this.#t)||i!==this.#l)&&this.#v(i)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),n=this.createResult(e,t);return vae(this,n)&&(this.#i=n,this.#s=this.options,this.#r=this.#t.state),n}getCurrentResult(){return this.#i}trackResult(t,e){return new Proxy(t,{get:(n,r)=>(this.trackProp(r),e?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,r))})}trackProp(t){this.#p.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),n=this.#e.getQueryCache().build(this.#e,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#d({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#d(t){this.#S();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(pa)),e}#g(){this.#y();const t=Uu(this.options.staleTime,this.#t);if(Sf||this.#i.isStale||!NN(t))return;const n=GG(this.#i.dataUpdatedAt,t)+1;this.#c=Qd.setTimeout(()=>{this.#i.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(t){this.#_(),this.#l=t,!(Sf||Ds(this.options.enabled,this.#t)===!1||!NN(this.#l)||this.#l===0)&&(this.#u=Qd.setInterval(()=>{(this.options.refetchIntervalInBackground||HP.isFocused())&&this.#d()},this.#l))}#b(){this.#g(),this.#v(this.#x())}#y(){this.#c&&(Qd.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(Qd.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,l=t!==n?t.state:this.#n,{state:c}=t;let u={...c},h=!1,g;if(e._optimisticResults){const j=this.hasListeners(),N=!j&&VU(t,e),k=j&&GU(t,n,e,r);(N||k)&&(u={...u,...QG(c.data,t.options)}),e._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:m,errorUpdatedAt:b,status:y}=u;g=u.data;let v=!1;if(e.placeholderData!==void 0&&g===void 0&&y==="pending"){let j;i?.isPlaceholderData&&e.placeholderData===s?.placeholderData?(j=i.data,v=!0):j=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,j!==void 0&&(y="success",g=PN(i?.data,j,e),h=!0)}if(e.select&&g!==void 0&&!v)if(i&&g===a?.data&&e.select===this.#m)g=this.#f;else try{this.#m=e.select,g=e.select(g),g=PN(i?.data,g,e),this.#f=g,this.#a=null}catch(j){this.#a=j}this.#a&&(m=this.#a,g=this.#f,b=Date.now(),y="error");const x=u.fetchStatus==="fetching",M=y==="pending",w=y==="error",C=M&&x,T=g!==void 0,A={status:y,fetchStatus:u.fetchStatus,isPending:M,isSuccess:y==="success",isError:w,isInitialLoading:C,isLoading:C,data:g,dataUpdatedAt:u.dataUpdatedAt,error:m,errorUpdatedAt:b,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>l.dataUpdateCount||u.errorUpdateCount>l.errorUpdateCount,isFetching:x,isRefetching:x&&!M,isLoadingError:w&&!T,isPaused:u.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:w&&T,isStale:$P(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Ds(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const j=F=>{A.status==="error"?F.reject(A.error):A.data!==void 0&&F.resolve(A.data)},N=()=>{const F=this.#o=A.promise=kN();j(F)},k=this.#o;switch(k.status){case"pending":t.queryHash===n.queryHash&&j(k);break;case"fulfilled":(A.status==="error"||A.data!==k.value)&&N();break;case"rejected":(A.status!=="error"||A.error!==k.reason)&&N();break}}return A}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.#h=this.#t),$_(e,t))return;this.#i=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#p.size)return!0;const a=new Set(i??this.#p);return this.options.throwOnError&&a.add("error"),Object.keys(this.#i).some(s=>{const o=s;return this.#i[o]!==t[o]&&a.has(o)})};this.#w({listeners:n()})}#S(){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.#b()}#w(t){ii.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function xae(t,e){return Ds(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function VU(t,e){return xae(t,e)||t.state.data!==void 0&&ON(t,e,e.refetchOnMount)}function ON(t,e,n){if(Ds(e.enabled,t)!==!1&&Uu(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&$P(t,e)}return!1}function GU(t,e,n,r){return(t!==e||Ds(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&$P(t,n)}function $P(t,e){return Ds(e.enabled,t)!==!1&&t.isStaleByTime(Uu(e.staleTime,t))}function vae(t,e){return!$_(t.getCurrentResult(),e)}function WU(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,a=e.state.data?.pages||[],s=e.state.data?.pageParams||[];let o={pages:[],pageParams:[]},l=0;const c=async()=>{let u=!1;const h=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(e.signal.aborted?u=!0:e.signal.addEventListener("abort",()=>{u=!0}),e.signal)})},g=qG(e.options,e.fetchOptions),m=async(b,y,v)=>{if(u)return Promise.reject();if(y==null&&b.pages.length)return Promise.resolve(b);const M=(()=>{const R={client:e.client,queryKey:e.queryKey,pageParam:y,direction:v?"backward":"forward",meta:e.options.meta};return h(R),R})(),w=await g(M),{maxPages:C}=e.options,T=v?cae:lae;return{pages:T(b.pages,w,C),pageParams:T(b.pageParams,y,C)}};if(i&&a.length){const b=i==="backward",y=b?bae:qU,v={pages:a,pageParams:s},x=y(r,v);o=await m(v,x,b)}else{const b=t??a.length;do{const y=l===0?s[0]??r.initialPageParam:qU(r,o);if(l>0&&y==null)break;o=await m(o,y),l++}while(l<b)}return o};e.options.persister?e.fetchFn=()=>e.options.persister?.(c,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=c}}}function qU(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 bae(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var yae=class extends ZG{#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||JG(),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=YG({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),ii.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function JG(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var _ae=class extends wm{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 yae({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=Ib(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=Ib(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=Ib(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=Ib(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ii.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=>FU(e,n))}findAll(t={}){return this.getAll().filter(e=>FU(t,e))}notify(t){ii.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return ii.batch(()=>Promise.all(t.map(e=>e.continue().catch(pa))))}};function Ib(t){return t.options.scope?.id}var Sae=class extends wm{#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),$_(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&wf(n.mutationKey)!==wf(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??JG();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){ii.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)})})}},wae=class extends wm{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??zP(r,e);let a=this.get(i);return a||(a=new mae({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(){ii.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=>UU(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>UU(t,n)):e}notify(t){ii.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){ii.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ii.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Mae=class{#e;#t;#n;#i;#r;#s;#o;#a;constructor(t={}){this.#e=t.queryCache||new wae,this.#t=t.mutationCache||new _ae,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#o=HP.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=V_.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(Uu(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=aae(e,a);if(s!==void 0)return this.#e.build(this,r).setData(s,{...n,manual:!0})}setQueriesData(t,e,n){return ii.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;ii.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return ii.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=ii.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(pa).catch(pa)}invalidateQueries(t,e={}){return ii.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=ii.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(pa)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(pa)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(Uu(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(pa).catch(pa)}fetchInfiniteQuery(t){return t.behavior=WU(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(pa).catch(pa)}ensureInfiniteQueryData(t){return t.behavior=WU(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return V_.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(wf(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{Gx(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(wf(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{Gx(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=zP(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===BP&&(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()}},e9=E.createContext(void 0),In=t=>{const e=E.useContext(e9);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Eae=({client:t,children:e})=>(E.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),f.jsx(e9.Provider,{value:t,children:e})),t9=E.createContext(!1),Aae=()=>E.useContext(t9);t9.Provider;function Tae(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Cae=E.createContext(Tae()),Nae=()=>E.useContext(Cae),Rae=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Pae=t=>{E.useEffect(()=>{t.clearReset()},[t])},kae=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||XG(n,[t.error,r])),Dae=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))}},Oae=(t,e)=>t.isLoading&&t.isFetching&&!e,Lae=(t,e)=>t?.suspense&&e.isPending,XU=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function Iae(t,e,n){const r=Aae(),i=Nae(),a=In(),s=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(s),s._optimisticResults=r?"isRestoring":"optimistic",Dae(s),Rae(s,i),Pae(i);const o=!a.getQueryCache().get(s.queryHash),[l]=E.useState(()=>new e(a,s)),c=l.getOptimisticResult(s),u=!r&&t.subscribed!==!1;if(E.useSyncExternalStore(E.useCallback(h=>{const g=u?l.subscribe(ii.batchCalls(h)):pa;return l.updateResult(),g},[l,u]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),E.useEffect(()=>{l.setOptions(s)},[s,l]),Lae(s,c))throw XU(s,l,i);if(kae({result:c,errorResetBoundary:i,throwOnError:s.throwOnError,query:a.getQueryCache().get(s.queryHash),suspense:s.suspense}))throw c.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(s,c),s.experimental_prefetchInRender&&!Sf&&Oae(c,r)&&(o?XU(s,l,i):a.getQueryCache().get(s.queryHash)?.promise)?.catch(pa).finally(()=>{l.updateResult()}),s.notifyOnChangeProps?c:l.trackResult(c)}function Nt(t,e){return Iae(t,gae)}function Rt(t,e){const n=In(),[r]=E.useState(()=>new Sae(n,t));E.useEffect(()=>{r.setOptions(t)},[r,t]);const i=E.useSyncExternalStore(E.useCallback(s=>r.subscribe(ii.batchCalls(s)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=E.useCallback((s,o)=>{r.mutate(s,o).catch(pa)},[r]);if(i.error&&XG(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const jae=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Uae=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),KU=t=>{const e=Uae(t);return e.charAt(0).toUpperCase()+e.slice(1)},n9=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),Fae=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var zae={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 Bae=E.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:s,...o},l)=>E.createElement("svg",{ref:l,...zae,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:n9("lucide",i),...!a&&!Fae(o)&&{"aria-hidden":"true"},...o},[...s.map(([c,u])=>E.createElement(c,u)),...Array.isArray(a)?a:[a]]));const rt=(t,e)=>{const n=E.forwardRef(({className:r,...i},a)=>E.createElement(Bae,{ref:a,iconNode:e,className:n9(`lucide-${jae(KU(t))}`,`lucide-${t}`,r),...i}));return n.displayName=KU(t),n};const Hae=[["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"}]],$ae=rt("archive",Hae);const Vae=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Wx=rt("arrow-down",Vae);const Gae=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],LN=rt("arrow-right",Gae);const Wae=[["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"}]],qae=rt("arrow-up-down",Wae);const Xae=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],$p=rt("arrow-up",Xae);const Kae=[["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"}]],IN=rt("bell",Kae);const Yae=[["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"}]],Zae=rt("bold",Yae);const Qae=[["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"}]],qx=rt("box",Qae);const Jae=[["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"}]],ese=rt("cable",Jae);const tse=[["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"}]],nse=rt("calendar-days",tse);const rse=[["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"}]],el=rt("calendar",rse);const ise=[["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"}]],G_=rt("camera",ise);const ase=[["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"}]],sse=rt("chart-column",ase);const ose=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Mf=rt("check",ose);const lse=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],F0=rt("chevron-down",lse);const cse=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Mm=rt("chevron-right",cse);const use=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ef=rt("chevron-left",use);const dse=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],r9=rt("chevron-up",dse);const fse=[["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"}]],wo=rt("circle-alert",fse);const hse=[["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"}]],YU=rt("circle-arrow-up",hse);const pse=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],gc=rt("circle-check-big",pse);const mse=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],gse=rt("circle-stop",mse);const xse=[["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"}]],z0=rt("circle-x",xse);const vse=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ni=rt("clock",vse);const bse=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],VP=rt("cloud",bse);const yse=[["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"}]],_se=rt("code-xml",yse);const Sse=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],wse=rt("code",Sse);const Mse=[["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"}]],Vp=rt("copy",Mse);const Ese=[["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"}]],ZU=rt("database",Ese);const Ase=[["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"}]],QU=rt("dollar-sign",Ase);const Tse=[["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"}]],tl=rt("download",Tse);const Cse=[["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"}]],GP=rt("droplet",Cse);const Nse=[["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"}]],Rse=rt("droplets",Nse);const Pse=[["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"}]],kse=rt("ellipsis-vertical",Pse);const Dse=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],BA=rt("equal",Dse);const Ose=[["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"}]],xc=rt("external-link",Ose);const Lse=[["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"}]],WP=rt("eye-off",Lse);const Ise=[["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"}]],W_=rt("eye",Ise);const jse=[["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"}]],Use=rt("file-box",jse);const Fse=[["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"}]],JU=rt("file-code",Fse);const zse=[["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"}]],Bse=rt("file-exclamation-point",zse);const Hse=[["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"}]],wp=rt("file-text",Hse);const $se=[["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"}]],i9=rt("file",$se);const Vse=[["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"}]],Rp=rt("film",Vse);const Gse=[["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"}]],Wse=rt("flame",Gse);const qse=[["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"}]],Xse=rt("folder-open",qse);const Kse=[["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"}]],Yse=rt("folder",Kse);const Zse=[["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"}]],a9=rt("funnel",Zse);const Qse=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],qP=rt("gauge",Qse);const Jse=[["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"}]],yx=rt("git-compare",Jse);const eoe=[["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"}]],eF=rt("github",eoe);const toe=[["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"}]],q_=rt("globe",toe);const noe=[["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"}]],XP=rt("grip-vertical",noe);const roe=[["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"}]],s9=rt("hard-drive",roe);const ioe=[["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"}]],JS=rt("image",ioe);const aoe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],o9=rt("info",aoe);const soe=[["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"}]],ooe=rt("italic",soe);const loe=[["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"}]],coe=rt("key",loe);const uoe=[["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"}]],jN=rt("keyboard",uoe);const doe=[["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"}]],Gp=rt("layers",doe);const foe=[["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"}]],l9=rt("layout-grid",foe);const hoe=[["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"}]],poe=rt("layout-list",hoe);const moe=[["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"}]],goe=rt("link-2-off",moe);const xoe=[["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"}]],voe=rt("link-2",xoe);const boe=[["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"}]],c9=rt("link",boe);const yoe=[["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"}]],u9=rt("list-ordered",yoe);const _oe=[["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"}]],KP=rt("list",_oe);const Soe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],$t=rt("loader-circle",Soe);const woe=[["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"}]],tF=rt("log-in",woe);const Moe=[["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"}]],Eoe=rt("log-out",Moe);const Aoe=[["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"}]],Toe=rt("maximize-2",Aoe);const Coe=[["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"}]],Noe=rt("maximize",Coe);const Roe=[["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"}]],Poe=rt("minimize-2",Roe);const koe=[["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"}]],Doe=rt("minimize",koe);const Ooe=[["path",{d:"M5 12h14",key:"1ays0h"}]],nF=rt("minus",Ooe);const Loe=[["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"}]],X_=rt("moon",Loe);const Ioe=[["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"}]],K_=rt("package",Ioe);const joe=[["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"}]],Uoe=rt("pause",joe);const Foe=[["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"}]],YP=rt("pen-line",Foe);const zoe=[["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"}]],d9=rt("pen",zoe);const Boe=[["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"}]],Af=rt("pencil",Boe);const Hoe=[["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"}]],ew=rt("play",Hoe);const $oe=[["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"}]],UN=rt("plug",$oe);const Voe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ra=rt("plus",Voe);const Goe=[["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"}]],f9=rt("power-off",Goe);const Woe=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Wf=rt("power",Woe);const qoe=[["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"}]],nl=rt("printer",qoe);const Xoe=[["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"}]],Koe=rt("qr-code",Xoe);const Yoe=[["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"}]],Mo=rt("refresh-cw",Yoe);const Zoe=[["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"}]],tw=rt("rotate-ccw",Zoe);const Qoe=[["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"}]],Joe=rt("ruler",Qoe);const ele=[["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"}]],qo=rt("save",ele);const tle=[["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"}]],nle=rt("scan-search",tle);const rle=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Xu=rt("search",rle);const ile=[["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"}]],h9=rt("send",ile);const ale=[["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"}]],nw=rt("settings-2",ale);const sle=[["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"}]],ole=rt("settings",sle);const lle=[["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"}]],cle=rt("signal",lle);const ule=[["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"}]],dle=rt("skip-back",ule);const fle=[["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"}]],p9=rt("skip-forward",fle);const hle=[["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"}]],rF=rt("sliders-vertical",hle);const ple=[["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"}]],Xx=rt("sparkles",ple);const mle=[["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"}]],Tf=rt("square-check-big",mle);const gle=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Wp=rt("square",gle);const xle=[["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"}]],Kx=rt("star",xle);const vle=[["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"}]],m9=rt("sticky-note",vle);const ble=[["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"}]],iF=rt("sun",ble);const yle=[["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"}]],Yx=rt("tag",yle);const _le=[["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"}]],Sle=rt("target",_le);const wle=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Mle=rt("terminal",wle);const Ele=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Ale=rt("text-align-center",Ele);const Tle=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Cle=rt("text-align-end",Tle);const Nle=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Rle=rt("text-align-start",Nle);const Ple=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],_x=rt("thermometer",Ple);const kle=[["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"}]],g9=rt("timer",kle);const Dle=[["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"}]],fr=rt("trash-2",Dle);const Ole=[["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"}]],Eo=rt("triangle-alert",Ole);const Lle=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Ile=rt("underline",Lle);const jle=[["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"}]],x9=rt("unlink",jle);const Ule=[["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"}]],Ku=rt("upload",Ule);const Fle=[["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"}]],aF=rt("user",Fle);const zle=[["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"}]],Ble=rt("video",zle);const Hle=[["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"}]],ZP=rt("wifi-off",Hle);const $le=[["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"}]],v9=rt("wifi",$le);const Vle=[["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"}]],qp=rt("wrench",Vle);const Gle=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ln=rt("x",Gle);const Wle=[["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"}]],qle=rt("zoom-in",Wle);const Xle=[["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"}]],b9=rt("zap",Xle);const Kle=[["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"}]],Yle=rt("zoom-out",Kle),y9=E.createContext(void 0);function Zle({children:t}){const[e,n]=E.useState(()=>{const a=localStorage.getItem("theme");return a||(window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark")});E.useEffect(()=>{const a=document.documentElement;e==="dark"?a.classList.add("dark"):a.classList.remove("dark"),localStorage.setItem("theme",e)},[e]);const r=()=>{n(a=>a==="dark"?"light":"dark")},i=a=>{n(a)};return f.jsx(y9.Provider,{value:{theme:e,toggleTheme:r,setTheme:i},children:t})}function _9(){const t=E.useContext(y9);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t}function Ht({children:t,className:e="",onClick:n,onContextMenu:r}){return f.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary ${e}`,onClick:n,onContextMenu:r,children:t})}function Xl({children:t,className:e=""}){return f.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Gt({children:t,className:e=""}){return f.jsx("div",{className:`p-6 ${e}`,children:t})}function Qle(t,e){return[{category:"Navigation",items:t?t.map((r,i)=>({keys:[String(i+1)],description:`Go to ${e(r.labelKey)}`})):[{keys:["1"],description:"Go to Printers"},{keys:["2"],description:"Go to Archives"},{keys:["3"],description:"Go to Queue"},{keys:["4"],description:"Go to Statistics"},{keys:["5"],description:"Go to Cloud Profiles"},{keys:["6"],description:"Go to Settings"}]},{category:"Archives",items:[{keys:["/"],description:"Focus search"},{keys:["U"],description:"Open upload modal"},{keys:["Esc"],description:"Clear selection / blur input"},{keys:["Right-click"],description:"Context menu on cards"}]},{category:"K-Profiles",items:[{keys:["R"],description:"Refresh profiles"},{keys:["N"],description:"New profile"},{keys:["Esc"],description:"Exit selection mode"}]},{category:"General",items:[{keys:["?"],description:"Show this help"}]}]}function sF({children:t}){return f.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 Jle({onClose:t,navItems:e}){const{t:n}=DP(),r=Qle(e,n);return E.useEffect(()=>{const i=a=>{a.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:f.jsx(Ht,{className:"w-full max-w-md",onClick:i=>i.stopPropagation(),children:f.jsxs(Gt,{className:"p-0",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(jN,{className:"w-5 h-5 text-bambu-green"}),f.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),f.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(ln,{className:"w-5 h-5"})})]}),f.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:r.map(i=>f.jsxs("div",{children:[f.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:i.category}),f.jsx("div",{className:"space-y-2",children:i.items.map(a=>f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-white text-sm",children:a.description}),f.jsx("div",{className:"flex gap-1",children:a.keys.map(s=>f.jsx(sF,{children:s},s))})]},a.description))})]},i.category))}),f.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:f.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",f.jsx(sF,{children:"Esc"})," or click outside to close"]})})]})})})}const Pr="/api/v1";async function dt(t,e={}){const n=await fetch(`${Pr}${t}`,{...e,headers:{"Content-Type":"application/json",...e.headers}});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.detail||`HTTP ${n.status}`)}return n.json()}const ze={getPrinters:()=>dt("/printers/"),getPrinter:t=>dt(`/printers/${t}`),createPrinter:t=>dt("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>dt(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:t=>dt(`/printers/${t}`,{method:"DELETE"}),getPrinterStatus:t=>dt(`/printers/${t}/status`),connectPrinter:t=>dt(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>dt(`/printers/${t}/disconnect`,{method:"POST"}),enableMQTTLogging:t=>dt(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>dt(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>dt(`/printers/${t}/logging`),clearMQTTLogs:t=>dt(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>dt(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${Pr}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,deletePrinterFile:(t,e)=>dt(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>dt(`/printers/${t}/storage`),getArchives:(t,e=50,n=0)=>{const r=new URLSearchParams;return t&&r.set("printer_id",String(t)),r.set("limit",String(e)),r.set("offset",String(n)),dt(`/archives/?${r}`)},getArchive:t=>dt(`/archives/${t}`),updateArchive:(t,e)=>dt(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>dt(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>dt(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>dt("/archives/stats"),getArchiveDuplicates:t=>dt(`/archives/${t}/duplicates`),backfillContentHashes:()=>dt("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${Pr}/archives/${t}/thumbnail`,getArchiveDownload:t=>`${Pr}/archives/${t}/download`,getArchiveGcode:t=>`${Pr}/archives/${t}/gcode`,getArchiveTimelapse:t=>`${Pr}/archives/${t}/timelapse`,scanArchiveTimelapse:t=>dt(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>dt(`/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(`${Pr}/archives/${t}/timelapse/upload`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},getArchivePhotoUrl:(t,e)=>`${Pr}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${Pr}/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)=>dt(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${Pr}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${Pr}/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(`${Pr}/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=>dt(`/archives/${t}/source`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${Pr}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>dt(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>dt(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>dt(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${Pr}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${Pr}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,reprintArchive:(t,e)=>dt(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST"}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${Pr}/archives/upload?printer_id=${e}`:`${Pr}/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?`${Pr}/archives/upload-bulk?printer_id=${e}`:`${Pr}/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:()=>dt("/settings/"),updateSettings:t=>dt("/settings/",{method:"PUT",body:JSON.stringify(t)}),resetSettings:()=>dt("/settings/reset",{method:"POST"}),checkFfmpeg:()=>dt("/settings/check-ffmpeg"),getCloudStatus:()=>dt("/cloud/status"),cloudLogin:(t,e,n="global")=>dt("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>dt("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>dt("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>dt("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>dt(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>dt(`/cloud/settings/${t}`),createCloudSetting:t=>dt("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>dt(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>dt(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>dt("/cloud/devices"),getCloudFields:t=>dt(`/cloud/fields/${t}`),getAllCloudFields:()=>dt("/cloud/fields"),getSmartPlugs:()=>dt("/smart-plugs/"),getSmartPlug:t=>dt(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>dt(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>dt("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>dt(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>dt(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>dt(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>dt(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>dt("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),dt(`/queue/?${n}`)},getQueueItem:t=>dt(`/queue/${t}`),addToQueue:t=>dt("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>dt(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>dt(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>dt("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>dt(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>dt(`/queue/${t}/stop`,{method:"POST"}),getKProfiles:(t,e="0.4")=>dt(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>dt(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>dt(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>dt(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>dt(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>dt(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>dt(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>dt(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>dt(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>dt(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>dt(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),listFilaments:()=>dt("/filaments/"),getFilament:t=>dt(`/filaments/${t}`),getFilamentsByType:t=>dt(`/filaments/by-type/${t}`),getNotificationProviders:()=>dt("/notifications/"),getNotificationProvider:t=>dt(`/notifications/${t}`),createNotificationProvider:t=>dt("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>dt(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>dt(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>dt(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>dt("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),getSpoolmanStatus:()=>dt("/spoolman/status"),connectSpoolman:()=>dt("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>dt("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>dt(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>dt("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>dt("/spoolman/spools"),getSpoolmanFilaments:()=>dt("/spoolman/filaments"),getVersion:()=>dt("/updates/version"),checkForUpdates:()=>dt("/updates/check"),applyUpdate:()=>dt("/updates/apply",{method:"POST"}),getUpdateStatus:()=>dt("/updates/status"),getMaintenanceTypes:()=>dt("/maintenance/types"),createMaintenanceType:t=>dt("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>dt(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>dt(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>dt("/maintenance/overview"),getPrinterMaintenance:t=>dt(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>dt(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>dt(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>dt(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>dt("/maintenance/summary"),setPrinterHours:(t,e)=>dt(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),getCameraStreamUrl:(t,e=10)=>`${Pr}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${Pr}/printers/${t}/camera/snapshot`,testCameraConnection:t=>dt(`/printers/${t}/camera/test`)},x_=[{id:"printers",to:"/",icon:nl,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:$ae,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:el,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:sse,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:VP,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:qp,labelKey:"nav.maintenance"},{id:"settings",to:"/settings",icon:ole,labelKey:"nav.settings"}];function ece(){const t=localStorage.getItem("sidebarOrder");if(t)try{const e=JSON.parse(t),n=new Map(x_.map(i=>[i.id,i])),r=[];for(const i of e){const a=n.get(i);a&&(r.push(a),n.delete(i))}for(const i of n.values())r.push(i);return r}catch{return x_}return x_}function tce(t){localStorage.setItem("sidebarOrder",JSON.stringify(t.map(e=>e.id)))}function S9(){return localStorage.getItem("defaultView")||"/"}function nce(t){localStorage.setItem("defaultView",t)}function rce(){const t=LP(),e=od(),{theme:n,toggleTheme:r}=_9(),{t:i}=DP(),[a,s]=E.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[o,l]=E.useState(!1),[c,u]=E.useState(ece),[h,g]=E.useState(null),[m,b]=E.useState(null),y=E.useRef(!1),{data:v}=Nt({queryKey:["version"],queryFn:ze.getVersion,staleTime:1/0}),{data:x}=Nt({queryKey:["settings"],queryFn:ze.getSettings,staleTime:300*1e3}),{data:M}=Nt({queryKey:["updateCheck"],queryFn:ze.checkForUpdates,enabled:x?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3});E.useEffect(()=>{if(!y.current&&e.pathname==="/"){const N=S9();N!=="/"&&(y.current=!0,t(N,{replace:!0}))}},[e.pathname,t]),E.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(a))},[a]);const w=(N,k)=>{g(k),N.dataTransfer.effectAllowed="move",N.dataTransfer.setData("text/plain",String(k))},C=(N,k)=>{N.preventDefault(),N.dataTransfer.dropEffect="move",b(k)},T=()=>{b(null)},R=(N,k)=>{if(N.preventDefault(),h===null||h===k){g(null),b(null);return}const F=[...c],[I]=F.splice(h,1);F.splice(k,0,I),u(F),tce(F),g(null),b(null)},A=()=>{g(null),b(null)},j=E.useCallback(N=>{const k=N.target;if(!(k.tagName==="INPUT"||k.tagName==="TEXTAREA"||k.isContentEditable)&&!N.metaKey&&!N.ctrlKey&&!N.altKey){const F=parseInt(N.key);if(F>=1&&F<=c.length){N.preventDefault(),t(c[F-1].to);return}switch(N.key){case"?":N.preventDefault(),l(!0);break;case"Escape":l(!1);break}}},[t,c]);return E.useEffect(()=>(document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)),[j]),f.jsxs("div",{className:"flex min-h-screen",children:[f.jsxs("aside",{className:`${a?"w-64":"w-16"} bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col fixed inset-y-0 left-0 z-30 transition-all duration-300`,children:[f.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${a?"p-4":"p-2"}`,children:f.jsx("img",{src:n==="dark"?"/img/bambusy_logo_dark.png":"/img/bambusy_logo_light.png",alt:"Bambusy",className:a?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),f.jsx("nav",{className:"flex-1 p-2",children:f.jsx("ul",{className:"space-y-2",children:c.map(({id:N,to:k,icon:F,labelKey:I},W)=>f.jsx("li",{draggable:!0,onDragStart:D=>w(D,W),onDragOver:D=>C(D,W),onDragLeave:T,onDrop:D=>R(D,W),onDragEnd:A,className:`relative ${h===W?"opacity-50":""} ${m===W&&h!==W?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:f.jsxs($G,{to:k,className:({isActive:D})=>`flex items-center ${a?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${D?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:a?void 0:i(I),children:[a&&f.jsx(XP,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),f.jsx(F,{className:"w-5 h-5 flex-shrink-0"}),a&&f.jsx("span",{children:i(I)})]})},N))})}),f.jsx("button",{onClick:()=>s(!a),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(a?"nav.collapseSidebar":"nav.expandSidebar"),children:a?f.jsx(Ef,{className:"w-5 h-5"}):f.jsx(Mm,{className:"w-5 h-5"})}),f.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a?f.jsxs("div",{className:"flex items-center justify-between px-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",v?.version||"..."]}),M?.update_available&&f.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:M.latest_version}),children:[f.jsx(YU,{className:"w-4 h-4"}),f.jsx("span",{children:i("nav.update")})]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("a",{href:"https://github.com/maziggy/bambusy",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:f.jsx(eF,{className:"w-5 h-5"})}),f.jsx("button",{onClick:()=>l(!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:f.jsx(jN,{className:"w-5 h-5"})}),f.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"?f.jsx(iF,{className:"w-5 h-5"}):f.jsx(X_,{className:"w-5 h-5"})})]})]}):f.jsxs("div",{className:"flex flex-col items-center gap-1",children:[M?.update_available&&f.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:M.latest_version}),children:f.jsx(YU,{className:"w-5 h-5"})}),f.jsx("a",{href:"https://github.com/maziggy/bambusy",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:f.jsx(eF,{className:"w-5 h-5"})}),f.jsx("button",{onClick:()=>l(!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:f.jsx(jN,{className:"w-5 h-5"})}),f.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"?f.jsx(iF,{className:"w-5 h-5"}):f.jsx(X_,{className:"w-5 h-5"})})]})})]}),f.jsx("main",{className:`flex-1 bg-bambu-dark overflow-auto ${a?"ml-64":"ml-16"} transition-all duration-300`,children:f.jsx(_ie,{})}),o&&f.jsx(Jle,{onClose:()=>l(!1),navItems:c})]})}function qe({variant:t="primary",size:e="md",className:n="",children:r,...i}){const a="inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 disabled:cursor-not-allowed",s={primary:"bg-bambu-green hover:bg-bambu-green-light text-white focus:ring-bambu-green",secondary:"bg-bambu-dark-tertiary hover:bg-bambu-gray-dark text-white focus:ring-bambu-gray",danger:"bg-red-600 hover:bg-red-700 text-white focus:ring-red-500",ghost:"bg-transparent hover:bg-bambu-dark-tertiary text-bambu-gray-light hover:text-white"},o={sm:"px-3 py-1.5 text-sm gap-1.5",md:"px-4 py-2 text-sm gap-2",lg:"px-6 py-3 text-base gap-2"};return f.jsx("button",{className:`${a} ${s[t]} ${o[e]} ${n}`,...i,children:r})}function ja({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",onConfirm:a,onCancel:s}){E.useEffect(()=>{const c=u=>{u.key==="Escape"&&s()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s]);const l={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 f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:s,children:f.jsx(Ht,{className:"w-full max-w-md",onClick:c=>c.stopPropagation(),children:f.jsxs(Gt,{className:"p-6",children:[f.jsxs("div",{className:"flex items-start gap-4",children:[f.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${l.icon}`,children:f.jsx(Eo,{className:"w-6 h-6"})}),f.jsxs("div",{className:"flex-1",children:[f.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),f.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),f.jsxs("div",{className:"flex gap-3 mt-6",children:[f.jsx(qe,{variant:"secondary",onClick:s,className:"flex-1",children:r}),f.jsx(qe,{onClick:a,className:`flex-1 ${l.button}`,children:n})]})]})})})}const w9=E.createContext(void 0);function sa(){const t=E.useContext(w9);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const ice={success:f.jsx(gc,{className:"w-5 h-5 text-green-400"}),error:f.jsx(z0,{className:"w-5 h-5 text-red-400"}),warning:f.jsx(wo,{className:"w-5 h-5 text-yellow-400"}),info:f.jsx(o9,{className:"w-5 h-5 text-blue-400"})},ace={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"};function sce({children:t}){const[e,n]=E.useState([]),r=E.useCallback((a,s="success")=>{const o=Math.random().toString(36).substr(2,9);n(l=>[...l,{id:o,message:a,type:s}]),setTimeout(()=>{n(l=>l.filter(c=>c.id!==o))},3e3)},[]),i=E.useCallback(a=>{n(s=>s.filter(o=>o.id!==a))},[]);return f.jsxs(w9.Provider,{value:{showToast:r},children:[t,f.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(a=>f.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${ace[a.type]}`,children:[ice[a.type],f.jsx("span",{className:"text-white text-sm",children:a.message}),f.jsx("button",{onClick:()=>i(a.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:f.jsx(ln,{className:"w-4 h-4"})})]},a.id))})]})}function oce(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 oF(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 lce(t,e){if(e)return Yse;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return Use;case"gcode":return wp;case"mp4":case"avi":return Rp;case"png":case"jpg":case"jpeg":return JS;default:return i9}}function cce({printerId:t,printerName:e,onClose:n}){const{showToast:r}=sa(),i=In(),[a,s]=E.useState("/"),[o,l]=E.useState(null),[c,u]=E.useState(""),[h,g]=E.useState(null);E.useEffect(()=>{const A=j=>{j.key==="Escape"&&n()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[n]);const{data:m,isLoading:b,refetch:y}=Nt({queryKey:["printerFiles",t,a],queryFn:()=>ze.getPrinterFiles(t,a)}),{data:v}=Nt({queryKey:["printerStorage",t],queryFn:()=>ze.getPrinterStorage(t),staleTime:3e4}),x=Rt({mutationFn:A=>ze.deletePrinterFile(t,A),onSuccess:(A,j)=>{r(`Deleted: ${j.split("/").pop()}`),i.invalidateQueries({queryKey:["printerFiles",t]}),l(null)},onError:A=>{r(`Delete failed: ${A.message}`,"error")}}),M=A=>{s(A),l(null)},w=()=>{if(a==="/")return;const A=a.split("/").filter(Boolean);A.pop(),s(A.length?"/"+A.join("/"):"/"),l(null)},C=A=>{window.open(ze.getPrinterFileDownloadUrl(t,A),"_blank")},T=A=>{g(A)},R=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return f.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[f.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:A=>A.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(s9,{className:"w-5 h-5 text-bambu-green"}),f.jsxs("div",{children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),f.jsxs("div",{className:"flex items-center gap-4",children:[v&&(v.used_bytes!=null||v.free_bytes!=null)&&f.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[v.used_bytes!=null&&f.jsxs("span",{children:["Used: ",oF(v.used_bytes)]}),v.used_bytes!=null&&v.free_bytes!=null&&f.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),v.free_bytes!=null&&f.jsxs("span",{children:["Free: ",oF(v.free_bytes)]})]}),f.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(ln,{className:"w-5 h-5"})})]})]}),f.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[R.map(A=>f.jsx("button",{onClick:()=>{M(A.path),u("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${a===A.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:A.label},A.path)),f.jsx("div",{className:"flex-1"}),f.jsxs("div",{className:"relative",children:[f.jsx(Xu,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),f.jsx("input",{type:"text",placeholder:"Filter files...",value:c,onChange:A=>u(A.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"})]}),f.jsx(qe,{variant:"secondary",size:"sm",onClick:()=>y(),disabled:b,children:f.jsx(Mo,{className:`w-4 h-4 ${b?"animate-spin":""}`})})]}),f.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[f.jsx("button",{onClick:w,disabled:a==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:f.jsx(Ef,{className:"w-4 h-4"})}),f.jsx("span",{className:"text-bambu-gray font-mono",children:a})]}),f.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:b?f.jsx("div",{className:"flex items-center justify-center py-12",children:f.jsx($t,{className:"w-8 h-8 text-bambu-green animate-spin"})}):m?.files?.length?f.jsx("div",{className:"space-y-1",children:[...m.files].filter(A=>!c||A.name.toLowerCase().includes(c.toLowerCase())).sort((A,j)=>A.is_directory&&!j.is_directory?-1:!A.is_directory&&j.is_directory?1:A.name.localeCompare(j.name)).map(A=>{const j=lce(A.name,A.is_directory),N=o===A.path;return f.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${N?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{A.is_directory?M(A.path):l(N?null:A.path)},children:[f.jsx(j,{className:`w-5 h-5 flex-shrink-0 ${A.is_directory?"text-bambu-green":"text-bambu-gray"}`}),f.jsx("span",{className:"flex-1 text-white truncate",children:A.name}),!A.is_directory&&f.jsx("span",{className:"text-sm text-bambu-gray",children:oce(A.size)}),A.is_directory&&f.jsx(Ef,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},A.path)})}):f.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),f.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[f.jsx("div",{className:"text-sm text-bambu-gray",children:c?`${m?.files?.filter(A=>A.name.toLowerCase().includes(c.toLowerCase())).length||0} of ${m?.files?.length||0} items`:`${m?.files?.length||0} items`}),f.jsxs("div",{className:"flex gap-2",children:[f.jsxs(qe,{variant:"secondary",disabled:!o,onClick:()=>o&&C(o),children:[f.jsx(tl,{className:"w-4 h-4"}),"Download"]}),f.jsxs(qe,{variant:"secondary",disabled:!o||x.isPending,onClick:()=>o&&T(o),className:"text-red-400 hover:text-red-300",children:[x.isPending?f.jsx($t,{className:"w-4 h-4 animate-spin"}):f.jsx(fr,{className:"w-4 h-4"}),"Delete"]})]})]})]}),h&&f.jsx(ja,{title:"Delete File",message:`Delete "${h.split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{x.mutate(h),g(null)},onCancel:()=>g(null)})]})}function uce({printerId:t,printerName:e,onClose:n}){const r=In(),[i,a]=E.useState(!0),[s,o]=E.useState(new Set),[l,c]=E.useState(""),[u,h]=E.useState("all"),g=E.useRef(null),{data:m,isLoading:b,refetch:y}=Nt({queryKey:["mqtt-logs",t],queryFn:()=>ze.getMQTTLogs(t),refetchInterval:1e3}),v=Rt({mutationFn:()=>ze.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),x=Rt({mutationFn:()=>ze.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),M=Rt({mutationFn:()=>ze.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});E.useEffect(()=>{const N=k=>{k.key==="Escape"&&n()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[n]),E.useEffect(()=>{i&&g.current&&(g.current.scrollTop=g.current.scrollHeight)},[m?.logs,i]);const w=N=>{o(k=>{const F=new Set(k);return F.has(N)?F.delete(N):F.add(N),F})},C=N=>new Date(N).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),T=(N,k)=>{if(N==null)return"<empty>";const F=typeof N=="string"?JSON.parse(N):N,I=JSON.stringify(F,null,k?2:0);return!k&&I.length>100?I.substring(0,100)+"...":I},R=m?.logging_enabled??!1,A=m?.logs??[],j=E.useMemo(()=>A.filter(N=>{if(u!=="all"&&N.direction!==u)return!1;if(l.trim()){const k=l.toLowerCase(),F=N.topic.toLowerCase().includes(k),W=JSON.stringify(N.payload).toLowerCase().includes(k);return F||W}return!0}),[A,l,u]);return f.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:f.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),f.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(ln,{className:"w-5 h-5"})})]}),f.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[R?f.jsxs(qe,{size:"sm",variant:"secondary",onClick:()=>x.mutate(),disabled:x.isPending,children:[f.jsx(Wp,{className:"w-4 h-4"}),"Stop"]}):f.jsxs(qe,{size:"sm",onClick:()=>v.mutate(),disabled:v.isPending,children:[f.jsx(ew,{className:"w-4 h-4"}),"Start Logging"]}),f.jsxs(qe,{size:"sm",variant:"secondary",onClick:()=>M.mutate(),disabled:M.isPending||A.length===0,children:[f.jsx(fr,{className:"w-4 h-4"}),"Clear"]}),f.jsx(qe,{size:"sm",variant:"secondary",onClick:()=>y(),disabled:b,children:f.jsx(Mo,{className:`w-4 h-4 ${b?"animate-spin":""}`})}),f.jsx("div",{className:"flex-1"}),f.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:i,onChange:N=>a(N.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),f.jsxs("span",{className:"text-sm text-bambu-gray",children:[j.length,"/",A.length]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"relative flex-1",children:[f.jsx(Xu,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),f.jsx("input",{type:"text",placeholder:"Search topic or payload...",value:l,onChange:N=>c(N.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"}),l&&f.jsx("button",{onClick:()=>c(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:f.jsx(ln,{className:"w-4 h-4"})})]}),f.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[f.jsx("button",{onClick:()=>h("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${u==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),f.jsxs("button",{onClick:()=>h("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${u==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[f.jsx(Wx,{className:"w-3 h-3"}),"In"]}),f.jsxs("button",{onClick:()=>h("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${u==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[f.jsx($p,{className:"w-3 h-3"}),"Out"]})]})]})]}),f.jsx("div",{ref:g,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:A.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[f.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!R&&f.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):j.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[f.jsx("p",{className:"mb-2",children:"No messages match your filter"}),f.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):f.jsx("div",{className:"space-y-1",children:j.map((N,k)=>{const F=s.has(k),I=N.direction==="in";return f.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${F?"bg-bambu-dark-secondary":""}`,onClick:()=>w(k),children:[f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsx("span",{className:"text-bambu-gray shrink-0",children:C(N.timestamp)}),f.jsx("span",{className:`shrink-0 ${I?"text-blue-400":"text-green-400"}`,title:I?"Incoming":"Outgoing",children:I?f.jsx(Wx,{className:"w-3 h-3"}):f.jsx($p,{className:"w-3 h-3"})}),f.jsx("span",{className:"text-purple-400 shrink-0",children:N.topic})]}),F?f.jsx("pre",{className:"mt-2 p-3 bg-gray-900 border border-gray-700 rounded text-green-400 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto text-xs",children:T(N.payload,!0)}):f.jsx("pre",{className:"mt-1 text-white/80 truncate",children:T(N.payload,!1)})]},k)})})}),f.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[f.jsx("div",{className:"text-sm text-bambu-gray",children:R?f.jsxs("span",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):f.jsx("span",{children:"Logging stopped"})}),f.jsx(qe,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const dce={"0700_5500_0002_0001":"A binding error occurred between AMS and the extruder. Please perform AMS initialization again.","0500_0300_0002_000E":"Some modules are incompatible with the printer firmware version. Please update firmware.","0300_0100_0002_0054":"The heatbed temperature is abnormal. The sensor may be disconnected or damaged.","0500_0100_0005_0005":"Motor driver overheated. Let the printer cool down.","0500_0100_0005_0006":"Motor driver communication error.","0700_0100_0007_0001":"AMS communication error.","0700_0100_0007_0002":"AMS filament runout.","0700_0100_0007_0003":"AMS filament not detected.","0C00_0100_000C_0003":"First layer inspection failed.","0C00_0100_000C_0004":"Nozzle clog detected.","0C00_0100_000C_8000":"Foreign object detected on print bed.","0500_0100_0005_0000":"Motor X axis lost steps.","0500_0100_0005_0001":"Motor Y axis lost steps.","0500_0100_0005_0002":"Motor Z axis lost steps."};function fce(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:Eo};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:Eo};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:wo};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:o9}}}function M9(t,e){const n=(t>>24&255).toString(16).padStart(2,"0").toUpperCase(),r=(t>>16&255).toString(16).padStart(2,"0").toUpperCase(),i=(t>>8&255).toString(16).padStart(2,"0").toUpperCase(),a=(t&255).toString(16).padStart(2,"0").toUpperCase(),s=(e>>24&255).toString(16).padStart(2,"0").toUpperCase(),o=(e>>16&255).toString(16).padStart(2,"0").toUpperCase(),l=(e>>8&255).toString(16).padStart(2,"0").toUpperCase(),c=(e&255).toString(16).padStart(2,"0").toUpperCase();return`${n}${r}_${i}${a}_${s}${o}_${l}${c}`}function hce(t,e,n){const r=M9(t,e);return`https://wiki.bambulab.com/en/${n.toLowerCase().includes("h2")?"h2":"x1"}/troubleshooting/hmscode/${r}`}function pce({printerName:t,errors:e,onClose:n}){return console.log("HMSErrorModal errors:",JSON.stringify(e,null,2)),E.useEffect(()=>{const r=i=>{i.key==="Escape"&&n()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[n]),f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:f.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Eo,{className:"w-5 h-5 text-orange-400"}),f.jsxs("h2",{className:"text-lg font-semibold text-white",children:["HMS Errors - ",t]})]}),f.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:f.jsx(ln,{className:"w-5 h-5 text-bambu-gray"})})]}),f.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:e.length===0?f.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[f.jsx(wo,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),f.jsx("p",{children:"No HMS errors"})]}):f.jsx("div",{className:"space-y-3",children:e.map((r,i)=>{const{label:a,color:s,bgColor:o,Icon:l}=fce(r.severity),c=parseInt(r.code.replace("0x",""),16)||0,u=M9(r.attr,c),h=dce[u]||"Unknown error. Click the link below for details.",g=hce(r.attr,c,t),m=`HMS_${u.replace(/_/g,"-")}`;return f.jsx("div",{className:`p-4 rounded-lg ${o} border border-white/10`,children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx(l,{className:`w-5 h-5 ${s} flex-shrink-0 mt-0.5`}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx("span",{className:`font-mono text-sm ${s}`,children:m}),f.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${o} ${s}`,children:a})]}),f.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:h}),f.jsxs("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[f.jsx(xc,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${r.code}-${i}`)})})}),f.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:f.jsx("p",{className:"text-xs text-bambu-gray",children:"HMS (Health Management System) monitors printer health. Clear errors on the printer to dismiss them here."})})]})})}function mce(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 gce({printerId:t}){const{data:e}=Nt({queryKey:["queue",t,"pending"],queryFn:()=>ze.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:f.jsx(QS,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:f.jsxs("div",{className:"flex items-center justify-between gap-3",children:[f.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[f.jsx(el,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),f.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[f.jsx(Ni,{className:"w-3 h-3"}),mce(n?.scheduled_time||null)]}),r>1&&f.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),f.jsx(Mm,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function xce({side:t}){const{theme:e}=_9(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return f.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 lF({className:t}){return f.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:f.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 vce({className:t}){return f.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f.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"}),f.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 bce({className:t}){return f.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f.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"}),f.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 yce({className:t}){return f.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f.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"}),f.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function _ce({className:t}){return f.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),f.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),f.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function Sce({className:t}){return f.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),f.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),f.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 wce({humidity:t,goodThreshold:e=40,fairThreshold:n=60}){const r=typeof t=="string"?parseInt(t,10):t,i=typeof e=="number"?e:40,a=typeof n=="number"?n:60;let s,o;isNaN(r)?(s="#C3C2C1",o="Unknown"):r<=i?(s="#22a352",o="Good"):r<=a?(s="#d4a017",o="Fair"):(s="#c62828",o="Bad");let l;return isNaN(r)||r<=i?l=lF:r<=a?l=vce:l=bce,f.jsxs("div",{className:"flex items-center justify-end gap-1",title:`Humidity: ${r}% - ${o}`,children:[f.jsx(l,{className:"w-3 h-4"}),f.jsxs("span",{className:"text-xs font-medium tabular-nums w-8 text-right",style:{color:s},children:[r,"%"]})]})}function Mce({temp:t,goodThreshold:e=28,fairThreshold:n=35}){const r=typeof e=="number"?e:28,i=typeof n=="number"?n:35;let a,s;return t<=r?(a="#22a352",s=yce):t<=i?(a="#d4a017",s=_ce):(a="#c62828",s=Sce),f.jsxs("span",{className:"flex items-center gap-1",title:"Temperature",children:[f.jsx(s,{className:"w-3 h-4"}),f.jsxs("span",{className:"tabular-nums w-12 text-right",style:{color:a},children:[t,"°C"]})]})}function Ece(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 Ace(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function Tce(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 Cce(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 Nce(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 Rce({url:t,printName:e}){const[n,r]=E.useState(!1),[i,a]=E.useState(!1),[s,o]=E.useState(!1);return f.jsxs(f.Fragment,{children:[f.jsx("div",{className:`w-20 h-20 flex-shrink-0 rounded-lg overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${t&&n?"cursor-pointer":""}`,onClick:()=>t&&n&&o(!0),children:t&&!i?f.jsxs(f.Fragment,{children:[f.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>r(!0),onError:()=>a(!0)}),!n&&f.jsx(qx,{className:"w-8 h-8 text-bambu-gray"})]}):f.jsx(qx,{className:"w-8 h-8 text-bambu-gray"})}),s&&t&&f.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>o(!1),children:f.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[f.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&f.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function Pce({printers:t}){const e=In(),n=E.useMemo(()=>{let i=0,a=0,s=0,o=0;return t?.forEach(l=>{const c=e.getQueryData(["printerStatus",l.id]);c===void 0?o++:c.connected?c.state==="RUNNING"?i++:a++:s++}),{printing:i,idle:a,offline:s,loading:o,total:t?.length||0}},[t,e]),[,r]=E.useState(0);return E.useEffect(()=>{const i=e.getQueryCache().subscribe(()=>{r(a=>a+1)});return()=>i()},[e]),t?.length?f.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[n.printing>0&&f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),f.jsxs("span",{className:"text-bambu-gray",children:[f.jsx("span",{className:"text-white font-medium",children:n.printing})," printing"]})]}),n.idle>0&&f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),f.jsxs("span",{className:"text-bambu-gray",children:[f.jsx("span",{className:"text-white font-medium",children:n.idle})," idle"]})]}),n.offline>0&&f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),f.jsxs("span",{className:"text-bambu-gray",children:[f.jsx("span",{className:"text-white font-medium",children:n.offline})," offline"]})]})]}):null}function cF({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",amsThresholds:i}){const a=In(),s=LP(),[o,l]=E.useState(!1),[c,u]=E.useState(!1),[h,g]=E.useState(!1),[m,b]=E.useState(!1),[y,v]=E.useState(!1),[x,M]=E.useState(!1),[w,C]=E.useState(!1),[T,R]=E.useState(!1),{data:A}=Nt({queryKey:["printerStatus",t.id],queryFn:()=>ze.getPrinterStatus(t.id),refetchInterval:3e4}),[j,N]=E.useState(null);E.useEffect(()=>{A?.wifi_signal!=null&&N(A.wifi_signal)},[A?.wifi_signal]);const k=A?.wifi_signal??j,F=E.useRef({});E.useEffect(()=>{A?.ams_extruder_map&&Object.keys(A.ams_extruder_map).length>0&&(F.current=A.ams_extruder_map)},[A?.ams_extruder_map]);const I=A?.ams_extruder_map&&Object.keys(A.ams_extruder_map).length>0?A.ams_extruder_map:F.current,W=E.useRef([]);E.useEffect(()=>{A?.ams&&A.ams.length>0&&(W.current=A.ams)},[A?.ams]);const D=A?.ams&&A.ams.length>0?A.ams:W.current,{data:B}=Nt({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>ze.getSmartPlugByPrinter(t.id)}),{data:G}=Nt({queryKey:["smartPlugStatus",B?.id],queryFn:()=>B?ze.getSmartPlugStatus(B.id):null,enabled:!!B,refetchInterval:1e4}),{data:V}=Nt({queryKey:["queue",t.id,"pending"],queryFn:()=>ze.getQueue(t.id,"pending")}),Z=V?.length||0,{data:Y}=Nt({queryKey:["archives",t.id,"last"],queryFn:()=>ze.getArchives(t.id,1,0),enabled:A?.connected&&A?.state!=="RUNNING"}),ee=Y?.[0],H=e&&A&&!A.connected,q=Rt({mutationFn:()=>ze.deletePrinter(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["printers"]})}}),ae=Rt({mutationFn:()=>ze.connectPrinter(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["printerStatus",t.id]})}}),ce=Rt({mutationFn:ie=>B?ze.controlSmartPlug(B.id,ie):Promise.reject("No plug"),onSuccess:()=>{a.invalidateQueries({queryKey:["smartPlugStatus",B?.id]})}}),xe=Rt({mutationFn:ie=>B?ze.updateSmartPlug(B.id,{auto_off:ie}):Promise.reject("No plug"),onSuccess:()=>{a.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),a.invalidateQueries({queryKey:["smart-plugs"]})}});return H?null:f.jsxs(Ht,{className:"relative",children:[f.jsxs(Gt,{children:[f.jsxs("div",{className:r==="compact"?"mb-2":"mb-4",children:[f.jsxs("div",{className:"flex items-start justify-between gap-2",children:[f.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[f.jsx("img",{src:Cce(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"}`}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:`font-semibold text-white ${r==="compact"?"text-base truncate":"text-lg"}`,children:t.name}),r==="compact"&&f.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${A?.connected?"bg-bambu-green":"bg-red-500"}`,title:A?.connected?"Connected":"Offline"})]}),f.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&A?.nozzles&&A.nozzles[0]?.nozzle_diameter&&f.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:A.nozzles[0].nozzle_type||"Nozzle",children:["• ",A.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&f.jsxs("span",{className:"ml-2 text-bambu-gray",children:[f.jsx(Ni,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),f.jsxs("div",{className:"relative flex-shrink-0",children:[f.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>l(!o),children:f.jsx(kse,{className:"w-4 h-4"})}),o&&f.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:[f.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{g(!0),l(!1)},children:[f.jsx(Af,{className:"w-4 h-4"}),"Edit"]}),f.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{ae.mutate(),l(!1)},children:[f.jsx(Mo,{className:"w-4 h-4"}),"Reconnect"]}),f.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{v(!0),l(!1)},children:[f.jsx(Mle,{className:"w-4 h-4"}),"MQTT Debug"]}),f.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:()=>{u(!0),l(!1)},children:[f.jsx(fr,{className:"w-4 h-4"}),"Delete"]})]})]})]}),r==="expanded"&&f.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[f.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${A?.connected?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[A?.connected?f.jsx(c9,{className:"w-3 h-3"}):f.jsx(x9,{className:"w-3 h-3"}),A?.connected?"Connected":"Offline"]}),A?.connected&&k!=null&&f.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 - ${Nce(k).label}`,children:[f.jsx(cle,{className:"w-3 h-3"}),k,"dBm"]}),A?.connected&&f.jsxs("button",{onClick:()=>R(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${A.hms_errors&&A.hms_errors.length>0?A.hms_errors.some(ie=>ie.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:[f.jsx(Eo,{className:"w-3 h-3"}),A.hms_errors&&A.hms_errors.length>0?A.hms_errors.length:"OK"]}),n&&f.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:[f.jsx(qp,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),Z>0&&f.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:`${Z} print${Z>1?"s":""} in queue`,children:[f.jsx(Gp,{className:"w-3 h-3"}),Z]})]})]}),c&&f.jsx(ja,{title:"Delete Printer",message:`Are you sure you want to delete "${t.name}"? This will also remove all connection settings.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{q.mutate(),u(!1)},onCancel:()=>u(!1)}),A?.connected&&f.jsxs(f.Fragment,{children:[r==="compact"?f.jsx("div",{className:"mt-2",children:A.state==="RUNNING"?f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:f.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${A.progress||0}%`}})}),f.jsxs("span",{className:"text-xs text-white",children:[Math.round(A.progress||0),"%"]})]}):f.jsx("p",{className:"text-xs text-bambu-gray capitalize",children:A.state?.toLowerCase()||"Idle"})}):f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg",children:f.jsxs("div",{className:"flex gap-3",children:[f.jsx(Rce,{url:A.state==="RUNNING"?A.cover_url:null,printName:A.state==="RUNNING"&&(A.subtask_name||A.current_print)||void 0}),f.jsx("div",{className:"flex-1 min-w-0",children:A.current_print&&A.state==="RUNNING"?f.jsxs(f.Fragment,{children:[f.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Printing"}),f.jsx("p",{className:"text-white text-sm mb-2 truncate",children:A.subtask_name||A.current_print}),f.jsxs("div",{className:"flex items-center justify-between text-sm",children:[f.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:f.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${A.progress||0}%`}})}),f.jsxs("span",{className:"text-white",children:[Math.round(A.progress||0),"%"]})]}),f.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[A.remaining_time!=null&&A.remaining_time>0&&f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"flex items-center gap-1",children:[f.jsx(Ni,{className:"w-3 h-3"}),Ace(A.remaining_time*60)]}),f.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",Tce(A.remaining_time)]})]}),A.layer_num!=null&&A.total_layers!=null&&A.total_layers>0&&f.jsxs("span",{className:"flex items-center gap-1",children:[f.jsx(Gp,{className:"w-3 h-3"}),A.layer_num,"/",A.total_layers]})]})]}):f.jsxs(f.Fragment,{children:[f.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),f.jsx("p",{className:"text-white text-sm mb-2 capitalize",children:A.state?.toLowerCase()||"Idle"}),f.jsxs("div",{className:"flex items-center justify-between text-sm",children:[f.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:f.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),f.jsx("span",{className:"text-bambu-gray",children:"—"})]}),ee?f.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:ee.print_name||ee.filename,children:["Last: ",ee.print_name||ee.filename,ee.completed_at&&f.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",new Date(ee.completed_at).toLocaleDateString([],{month:"short",day:"numeric"})]})]}):f.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})}),A.state!=="RUNNING"&&f.jsx(gce,{printerId:t.id})]}),A.temperatures&&r==="expanded"&&f.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[f.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[f.jsx(_x,{className:"w-4 h-4 mx-auto mb-1 text-orange-400"}),A.temperatures.nozzle_2!==void 0?f.jsxs(f.Fragment,{children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"Left / Right"}),f.jsxs("p",{className:"text-sm text-white",children:[Math.round(A.temperatures.nozzle||0),"°C / ",Math.round(A.temperatures.nozzle_2||0),"°C"]})]}):f.jsxs(f.Fragment,{children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"Nozzle"}),f.jsxs("p",{className:"text-sm text-white",children:[Math.round(A.temperatures.nozzle||0),"°C"]})]})]}),f.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[f.jsx(_x,{className:"w-4 h-4 mx-auto mb-1 text-blue-400"}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Bed"}),f.jsxs("p",{className:"text-sm text-white",children:[Math.round(A.temperatures.bed||0),"°C"]})]}),A.temperatures.chamber!==void 0&&f.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[f.jsx(_x,{className:"w-4 h-4 mx-auto mb-1 text-green-400"}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Chamber"}),f.jsxs("p",{className:"text-sm text-white",children:[Math.round(A.temperatures.chamber||0),"°C"]})]})]}),D&&D.length>0&&r==="expanded"&&f.jsxs("div",{className:"mt-3 p-2 bg-bambu-dark rounded-lg",children:[f.jsx("div",{className:"space-y-2",children:D.map(ie=>{const ve=ie.id>=128?ie.id-128:ie.id,Pe=I[String(ve)],he=Pe!==void 0?Pe:ve,we=t.nozzle_count===2||A?.temperatures?.nozzle_2!==void 0,Le=he===1,de=he===0;return f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[we&&(Le||de)&&f.jsx(xce,{side:Le?"L":"R"}),f.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:Ece(ie.id,ie.tray.length)}),f.jsx("div",{className:"flex gap-1",children:ie.tray.map((lt,$)=>f.jsx("div",{className:`w-5 h-5 rounded-full border border-white/20 ${lt.tray_type?"":"ams-empty-slot"}`,style:{backgroundColor:lt.tray_color?`#${lt.tray_color}`:lt.tray_type?"#333":void 0},title:lt.tray_type?`${lt.tray_sub_brands||lt.tray_type}${lt.remain?` (${lt.remain}%)`:""}`:"Empty slot"},`${ie.id}-${$}`))})]}),(ie.humidity!=null||ie.temp!=null)&&f.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[ie.humidity!=null&&f.jsx("div",{className:"w-14 text-right",children:f.jsx(wce,{humidity:ie.humidity,goodThreshold:i?.humidityGood,fairThreshold:i?.humidityFair})}),ie.temp!=null&&f.jsx(Mce,{temp:ie.temp,goodThreshold:i?.tempGood,fairThreshold:i?.tempFair})]})]},ie.id)})}),A.vt_tray&&A.vt_tray.tray_type&&f.jsxs("div",{className:"flex items-center gap-2 pt-2 mt-2 border-t border-bambu-dark-tertiary",children:[f.jsx("span",{className:"text-xs text-bambu-gray w-10",children:"Ext"}),f.jsx("div",{className:"w-5 h-5 rounded-full border border-white/20",style:{backgroundColor:A.vt_tray.tray_color?`#${A.vt_tray.tray_color}`:"#333"},title:A.vt_tray.tray_sub_brands||A.vt_tray.tray_type||"External"})]})]})]}),B&&r==="expanded"&&f.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx(b9,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),f.jsx("span",{className:"text-sm text-white truncate",children:B.name}),G&&f.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${G.state==="ON"?"bg-bambu-green/20 text-bambu-green":G.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:G.state||"?"}),G?.energy?.power!=null&&G.state==="ON"&&f.jsxs("span",{className:"text-xs text-yellow-400 font-medium flex-shrink-0",children:[G.energy.power,"W"]})]}),f.jsx("div",{className:"flex-1"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs("button",{onClick:()=>M(!0),disabled:ce.isPending||G?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${G?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[f.jsx(Wf,{className:"w-3 h-3"}),"On"]}),f.jsxs("button",{onClick:()=>C(!0),disabled:ce.isPending||G?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${G?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[f.jsx(f9,{className:"w-3 h-3"}),"Off"]})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f.jsx("span",{className:`text-xs hidden sm:inline ${B.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:B.auto_off_executed?"Auto-off done":"Auto-off"}),f.jsx("button",{onClick:()=>xe.mutate(!B.auto_off),disabled:xe.isPending||B.auto_off_executed,title:B.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 ${B.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":B.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:f.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${B.auto_off||B.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]})}),r==="expanded"&&f.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-between",children:[f.jsxs("div",{className:"text-xs text-bambu-gray",children:[f.jsx("p",{children:t.ip_address}),f.jsx("p",{className:"truncate",children:t.serial_number})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(qe,{variant:"secondary",size:"sm",onClick:()=>{window.open(`/camera/${t.id}`,`camera-${t.id}`,"width=640,height=400,menubar=no,toolbar=no,location=no,status=no")},disabled:!A?.connected,title:"Open camera in new window",children:f.jsx(Ble,{className:"w-4 h-4"})}),f.jsxs(qe,{variant:"secondary",size:"sm",onClick:()=>b(!0),title:"Browse printer files",children:[f.jsx(s9,{className:"w-4 h-4"}),"Files"]})]})]})]}),m&&f.jsx(cce,{printerId:t.id,printerName:t.name,onClose:()=>b(!1)}),y&&f.jsx(uce,{printerId:t.id,printerName:t.name,onClose:()=>v(!1)}),x&&B&&f.jsx(ja,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{ce.mutate("on"),M(!1)},onCancel:()=>M(!1)}),w&&B&&f.jsx(ja,{title:"Power Off Printer",message:A?.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:()=>{ce.mutate("off"),C(!1)},onCancel:()=>C(!1)}),T&&f.jsx(pce,{printerName:t.name,errors:A?.hms_errors||[],onClose:()=>R(!1)}),h&&f.jsx(Dce,{printer:t,onClose:()=>g(!1)})]})}function kce({onClose:t,onAdd:e}){const[n,r]=E.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0});return E.useEffect(()=>{const i=a=>{a.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:f.jsx(Ht,{className:"w-full max-w-md",onClick:i=>i.stopPropagation(),children:f.jsxs(Gt,{children:[f.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),f.jsxs("form",{onSubmit:i=>{i.preventDefault(),e(n)},className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),f.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:n.name,onChange:i=>r({...n,name:i.target.value}),placeholder:"My Printer"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),f.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:n.ip_address,onChange:i=>r({...n,ip_address:i.target.value}),placeholder:"192.168.1.100"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),f.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:n.serial_number,onChange:i=>r({...n,serial_number:i.target.value}),placeholder:"01P00A000000000"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),f.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:n.access_code,onChange:i=>r({...n,access_code:i.target.value}),placeholder:"From printer settings"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),f.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:n.model||"",onChange:i=>r({...n,model:i.target.value}),children:[f.jsx("option",{value:"",children:"Select model..."}),f.jsxs("optgroup",{label:"H2 Series",children:[f.jsx("option",{value:"H2C",children:"H2C"}),f.jsx("option",{value:"H2D",children:"H2D"}),f.jsx("option",{value:"H2S",children:"H2S"})]}),f.jsxs("optgroup",{label:"X1 Series",children:[f.jsx("option",{value:"X1E",children:"X1E"}),f.jsx("option",{value:"X1C",children:"X1 Carbon"}),f.jsx("option",{value:"X1",children:"X1"})]}),f.jsxs("optgroup",{label:"P Series",children:[f.jsx("option",{value:"P2S",children:"P2S"}),f.jsx("option",{value:"P1S",children:"P1S"}),f.jsx("option",{value:"P1P",children:"P1P"})]}),f.jsxs("optgroup",{label:"A1 Series",children:[f.jsx("option",{value:"A1",children:"A1"}),f.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox",id:"auto_archive",checked:n.auto_archive,onChange:i=>r({...n,auto_archive:i.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),f.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),f.jsxs("div",{className:"flex gap-3 pt-4",children:[f.jsx(qe,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),f.jsx(qe,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function Dce({printer:t,onClose:e}){const n=In(),[r,i]=E.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),a=Rt({mutationFn:o=>ze.updatePrinter(t.id,o),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});E.useEffect(()=>{const o=l=>{l.key==="Escape"&&e()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]);const s=o=>{o.preventDefault();const l={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&&(l.access_code=r.access_code),a.mutate(l)};return f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:f.jsx(Ht,{className:"w-full max-w-md",onClick:o=>o.stopPropagation(),children:f.jsxs(Gt,{children:[f.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Edit Printer"}),f.jsxs("form",{onSubmit:s,className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),f.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.name,onChange:o=>i({...r,name:o.target.value}),placeholder:"My Printer"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),f.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.ip_address,onChange:o=>i({...r,ip_address:o.target.value}),placeholder:"192.168.1.100"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),f.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}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Serial number cannot be changed"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),f.jsx("input",{type:"password",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.access_code,onChange:o=>i({...r,access_code:o.target.value}),placeholder:"Leave empty to keep current"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model"}),f.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.model,onChange:o=>i({...r,model:o.target.value}),children:[f.jsx("option",{value:"",children:"Select model..."}),f.jsxs("optgroup",{label:"H2 Series",children:[f.jsx("option",{value:"H2C",children:"H2C"}),f.jsx("option",{value:"H2D",children:"H2D"}),f.jsx("option",{value:"H2S",children:"H2S"})]}),f.jsxs("optgroup",{label:"X1 Series",children:[f.jsx("option",{value:"X1E",children:"X1E"}),f.jsx("option",{value:"X1C",children:"X1 Carbon"}),f.jsx("option",{value:"X1",children:"X1"})]}),f.jsxs("optgroup",{label:"P Series",children:[f.jsx("option",{value:"P2S",children:"P2S"}),f.jsx("option",{value:"P1S",children:"P1S"}),f.jsx("option",{value:"P1P",children:"P1P"})]}),f.jsxs("optgroup",{label:"A1 Series",children:[f.jsx("option",{value:"A1",children:"A1"}),f.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),f.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.location,onChange:o=>i({...r,location:o.target.value}),placeholder:"e.g., Workshop, Office, Basement"}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Used to group printers on the dashboard"})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:r.auto_archive,onChange:o=>i({...r,auto_archive:o.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),f.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),f.jsxs("div",{className:"flex gap-3 pt-4",children:[f.jsx(qe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),f.jsx(qe,{type:"submit",className:"flex-1",disabled:a.isPending,children:a.isPending?"Saving...":"Save Changes"})]})]})]})})})}function Oce(t){const{data:e}=Nt({queryKey:["printerStatus",t],queryFn:()=>ze.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function Lce({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=Oce(t.id),{data:a}=Nt({queryKey:["smartPlugStatus",e.id],queryFn:()=>ze.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?f.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),a&&f.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||"?"})]}),f.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:[f.jsx(Wf,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function Ice(){const[t,e]=E.useState(!1),[n,r]=E.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,a]=E.useState(!1),[s,o]=E.useState(null),[l,c]=E.useState(()=>localStorage.getItem("printerSortBy")||"name"),[u,h]=E.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[g,m]=E.useState(()=>localStorage.getItem("printerViewMode")||"expanded"),b=In(),{data:y,isLoading:v}=Nt({queryKey:["printers"],queryFn:ze.getPrinters}),{data:x}=Nt({queryKey:["settings"],queryFn:ze.getSettings}),{data:M}=Nt({queryKey:["smart-plugs"],queryFn:ze.getSmartPlugs}),{data:w}=Nt({queryKey:["maintenanceOverview"],queryFn:ze.getMaintenanceOverview,staleTime:60*1e3}),C=w?.reduce((D,B)=>(D[B.printer_id]={due_count:B.due_count,warning_count:B.warning_count,total_print_hours:B.total_print_hours},D),{})||{},T=M?.reduce((D,B)=>(B.printer_id&&(D[B.printer_id]=B),D),{})||{},R=Rt({mutationFn:ze.createPrinter,onSuccess:()=>{b.invalidateQueries({queryKey:["printers"]}),e(!1)}}),A=Rt({mutationFn:D=>ze.controlSmartPlug(D,"on"),onSuccess:()=>{b.invalidateQueries({queryKey:["smart-plugs"]}),o(null)},onError:()=>{o(null)}}),j=()=>{const D=!n;r(D),localStorage.setItem("hideDisconnectedPrinters",String(D))},N=D=>{c(D),localStorage.setItem("printerSortBy",D)},k=()=>{const D=!u;h(D),localStorage.setItem("printerSortAsc",String(D))},F=()=>{const D=g==="expanded"?"compact":"expanded";m(D),localStorage.setItem("printerViewMode",D)},I=E.useMemo(()=>{if(!y)return[];const D=[...y];switch(l){case"name":D.sort((B,G)=>B.name.localeCompare(G.name));break;case"model":D.sort((B,G)=>(B.model||"").localeCompare(G.model||""));break;case"location":D.sort((B,G)=>{const V=B.location||"",Z=G.location||"";return!V&&Z?1:V&&!Z?-1:V.localeCompare(Z)||B.name.localeCompare(G.name)});break;case"status":D.sort((B,G)=>{const V=b.getQueryData(["printerStatus",B.id]),Z=b.getQueryData(["printerStatus",G.id]),Y=ee=>ee?.connected?ee.state==="RUNNING"?0:1:2;return Y(V)-Y(Z)});break}return u||D.reverse(),D},[y,l,u,b]),W=E.useMemo(()=>{if(l!=="location")return null;const D={};return I.forEach(B=>{const G=B.location||"Ungrouped";D[G]||(D[G]=[]),D[G].push(B)}),D},[l,I]);return f.jsxs("div",{className:"p-8",children:[f.jsxs("div",{className:"flex items-center justify-between mb-6",children:[f.jsxs("div",{children:[f.jsx("h1",{className:"text-2xl font-bold text-white",children:"Printers"}),f.jsx(Pce,{printers:y})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs("select",{value:l,onChange:D=>N(D.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:[f.jsx("option",{value:"name",children:"Name"}),f.jsx("option",{value:"status",children:"Status"}),f.jsx("option",{value:"model",children:"Model"}),f.jsx("option",{value:"location",children:"Location"})]}),f.jsx("button",{onClick:k,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:u?"Sort descending":"Sort ascending",children:u?f.jsx($p,{className:"w-4 h-4 text-bambu-gray"}):f.jsx(Wx,{className:"w-4 h-4 text-bambu-gray"})})]}),f.jsx("button",{onClick:F,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:g==="expanded"?"Switch to compact view":"Switch to expanded view",children:g==="expanded"?f.jsx(poe,{className:"w-5 h-5 text-bambu-gray"}):f.jsx(l9,{className:"w-5 h-5 text-bambu-gray"})}),f.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),f.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:n,onChange:j,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(T).length>0&&f.jsxs("div",{className:"relative",children:[f.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:[f.jsx(Wf,{className:"w-4 h-4"}),"Power On",f.jsx(F0,{className:`w-3 h-3 transition-transform ${i?"rotate-180":""}`})]}),i&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),f.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:[f.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 dark:text-bambu-gray border-b border-gray-200 dark:border-bambu-dark-tertiary",children:"Offline printers with smart plugs"}),y?.filter(D=>T[D.id]).map(D=>f.jsx(Lce,{printer:D,plug:T[D.id],onPowerOn:B=>{o(B),A.mutate(B)},isPowering:s===T[D.id]?.id},D.id)),y?.filter(D=>T[D.id]).length===0&&f.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),f.jsxs(qe,{onClick:()=>e(!0),children:[f.jsx(ra,{className:"w-4 h-4"}),"Add Printer"]})]})]}),v?f.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):y?.length===0?f.jsx(Ht,{children:f.jsxs(Gt,{className:"text-center py-12",children:[f.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),f.jsxs(qe,{onClick:()=>e(!0),children:[f.jsx(ra,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):W?f.jsx("div",{className:"space-y-6",children:Object.entries(W).map(([D,B])=>f.jsxs("div",{children:[f.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[f.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),D,f.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",B.length,")"]})]}),f.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:B.map(G=>f.jsx(cF,{printer:G,hideIfDisconnected:n,maintenanceInfo:C[G.id],viewMode:g,amsThresholds:x?{humidityGood:Number(x.ams_humidity_good)||40,humidityFair:Number(x.ams_humidity_fair)||60,tempGood:Number(x.ams_temp_good)||28,tempFair:Number(x.ams_temp_fair)||35}:void 0},G.id))})]},D))}):f.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:I.map(D=>f.jsx(cF,{printer:D,hideIfDisconnected:n,maintenanceInfo:C[D.id],viewMode:g,amsThresholds:x?{humidityGood:Number(x.ams_humidity_good)||40,humidityFair:Number(x.ams_humidity_fair)||60,tempGood:Number(x.ams_temp_good)||28,tempFair:Number(x.ams_temp_fair)||35}:void 0},D.id))}),t&&f.jsx(kce,{onClose:()=>e(!1),onAdd:D=>R.mutate(D)})]})}const QP="181",Pp={ROTATE:0,DOLLY:1,PAN:2},Mp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},jce=0,uF=1,Uce=2,E9=1,Fce=2,Gl=3,Yu=0,Ua=1,Vo=2,lc=0,kp=1,dF=2,fF=3,hF=4,zce=5,Wd=100,Bce=101,Hce=102,$ce=103,Vce=104,Gce=200,Wce=201,qce=202,Xce=203,FN=204,zN=205,Kce=206,Yce=207,Zce=208,Qce=209,Jce=210,eue=211,tue=212,nue=213,rue=214,BN=0,HN=1,$N=2,Xp=3,VN=4,GN=5,WN=6,qN=7,JP=0,iue=1,aue=2,Fu=0,sue=1,oue=2,lue=3,cue=4,uue=5,due=6,fue=7,A9=300,Kp=301,Yp=302,XN=303,KN=304,rw=306,YN=1e3,tc=1001,ZN=1002,ds=1003,hue=1004,jb=1005,Hs=1006,HA=1007,Jd=1008,rl=1009,T9=1010,C9=1011,Zx=1012,ek=1013,Cf=1014,nc=1015,Em=1016,tk=1017,nk=1018,Qx=1020,N9=35902,R9=35899,P9=1021,k9=1022,xo=1023,Jx=1026,e0=1027,D9=1028,rk=1029,ik=1030,ak=1031,sk=1033,v_=33776,b_=33777,y_=33778,__=33779,QN=35840,JN=35841,e3=35842,t3=35843,n3=36196,r3=37492,i3=37496,a3=37808,s3=37809,o3=37810,l3=37811,c3=37812,u3=37813,d3=37814,f3=37815,h3=37816,p3=37817,m3=37818,g3=37819,x3=37820,v3=37821,b3=36492,y3=36494,_3=36495,S3=36283,w3=36284,M3=36285,E3=36286,pue=3200,mue=3201,O9=0,gue=1,Cu="",Os="srgb",Zp="srgb-linear",Y_="linear",Bn="srgb",kh=7680,pF=519,xue=512,vue=513,bue=514,L9=515,yue=516,_ue=517,Sue=518,wue=519,mF=35044,gF="300 es",Xo=2e3,Z_=2001;function I9(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Q_(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Mue(){const t=Q_("canvas");return t.style.display="block",t}const xF={};function vF(...t){const e="THREE."+t.shift();console.log(e,...t)}function Xt(...t){const e="THREE."+t.shift();console.warn(e,...t)}function Dr(...t){const e="THREE."+t.shift();console.error(e,...t)}function t0(...t){const e=t.join(" ");e in xF||(xF[e]=!0,Xt(...t))}function Eue(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 qf=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 Ki=["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"],S_=Math.PI/180,A3=180/Math.PI;function B0(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Ki[t&255]+Ki[t>>8&255]+Ki[t>>16&255]+Ki[t>>24&255]+"-"+Ki[e&255]+Ki[e>>8&255]+"-"+Ki[e>>16&15|64]+Ki[e>>24&255]+"-"+Ki[n&63|128]+Ki[n>>8&255]+"-"+Ki[n>>16&255]+Ki[n>>24&255]+Ki[r&255]+Ki[r>>8&255]+Ki[r>>16&255]+Ki[r>>24&255]).toLowerCase()}function mn(t,e,n){return Math.max(e,Math.min(n,t))}function Aue(t,e){return(t%e+e)%e}function $A(t,e,n){return(1-n)*t+n*e}function jg(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 Pa(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 Tue={DEG2RAD:S_};let sn=class j9{constructor(e=0,n=0){j9.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=mn(this.x,e.x,n.x),this.y=mn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=mn(this.x,e,n),this.y=mn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(mn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(mn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,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}},Nf=class{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,s,o){let l=r[i+0],c=r[i+1],u=r[i+2],h=r[i+3],g=a[s+0],m=a[s+1],b=a[s+2],y=a[s+3];if(o<=0){e[n+0]=l,e[n+1]=c,e[n+2]=u,e[n+3]=h;return}if(o>=1){e[n+0]=g,e[n+1]=m,e[n+2]=b,e[n+3]=y;return}if(h!==y||l!==g||c!==m||u!==b){let v=l*g+c*m+u*b+h*y;v<0&&(g=-g,m=-m,b=-b,y=-y,v=-v);let x=1-o;if(v<.9995){const M=Math.acos(v),w=Math.sin(M);x=Math.sin(x*M)/w,o=Math.sin(o*M)/w,l=l*x+g*o,c=c*x+m*o,u=u*x+b*o,h=h*x+y*o}else{l=l*x+g*o,c=c*x+m*o,u=u*x+b*o,h=h*x+y*o;const M=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=M,c*=M,u*=M,h*=M}}e[n]=l,e[n+1]=c,e[n+2]=u,e[n+3]=h}static multiplyQuaternionsFlat(e,n,r,i,a,s){const o=r[i],l=r[i+1],c=r[i+2],u=r[i+3],h=a[s],g=a[s+1],m=a[s+2],b=a[s+3];return e[n]=o*b+u*h+l*m-c*g,e[n+1]=l*b+u*g+c*h-o*m,e[n+2]=c*b+u*m+o*g-l*h,e[n+3]=u*b-o*h-l*g-c*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,a=e._z,s=e._order,o=Math.cos,l=Math.sin,c=o(r/2),u=o(i/2),h=o(a/2),g=l(r/2),m=l(i/2),b=l(a/2);switch(s){case"XYZ":this._x=g*u*h+c*m*b,this._y=c*m*h-g*u*b,this._z=c*u*b+g*m*h,this._w=c*u*h-g*m*b;break;case"YXZ":this._x=g*u*h+c*m*b,this._y=c*m*h-g*u*b,this._z=c*u*b-g*m*h,this._w=c*u*h+g*m*b;break;case"ZXY":this._x=g*u*h-c*m*b,this._y=c*m*h+g*u*b,this._z=c*u*b+g*m*h,this._w=c*u*h-g*m*b;break;case"ZYX":this._x=g*u*h-c*m*b,this._y=c*m*h+g*u*b,this._z=c*u*b-g*m*h,this._w=c*u*h+g*m*b;break;case"YZX":this._x=g*u*h+c*m*b,this._y=c*m*h+g*u*b,this._z=c*u*b-g*m*h,this._w=c*u*h-g*m*b;break;case"XZY":this._x=g*u*h-c*m*b,this._y=c*m*h-g*u*b,this._z=c*u*b+g*m*h,this._w=c*u*h+g*m*b;break;default:Xt("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],a=n[8],s=n[1],o=n[5],l=n[9],c=n[2],u=n[6],h=n[10],g=r+o+h;if(g>0){const m=.5/Math.sqrt(g+1);this._w=.25/m,this._x=(u-l)*m,this._y=(a-c)*m,this._z=(s-i)*m}else if(r>o&&r>h){const m=2*Math.sqrt(1+r-o-h);this._w=(u-l)/m,this._x=.25*m,this._y=(i+s)/m,this._z=(a+c)/m}else if(o>h){const m=2*Math.sqrt(1+o-r-h);this._w=(a-c)/m,this._x=(i+s)/m,this._y=.25*m,this._z=(l+u)/m}else{const m=2*Math.sqrt(1+h-r-o);this._w=(s-i)/m,this._x=(a+c)/m,this._y=(l+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(mn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,s=e._w,o=n._x,l=n._y,c=n._z,u=n._w;return this._x=r*u+s*o+i*c-a*l,this._y=i*u+s*l+a*o-r*c,this._z=a*u+s*c+r*l-i*o,this._w=s*u-r*o-i*l-a*c,this._onChangeCallback(),this}slerp(e,n){if(n<=0)return this;if(n>=1)return this.copy(e);let r=e._x,i=e._y,a=e._z,s=e._w,o=this.dot(e);o<0&&(r=-r,i=-i,a=-a,s=-s,o=-o);let l=1-n;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,n=Math.sin(n*c)/u,this._x=this._x*l+r*n,this._y=this._y*l+i*n,this._z=this._z*l+a*n,this._w=this._w*l+s*n,this._onChangeCallback()}else this._x=this._x*l+r*n,this._y=this._y*l+i*n,this._z=this._z*l+a*n,this._w=this._w*l+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}},We=class U9{constructor(e=0,n=0,r=0){U9.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(bF.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(bF.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,s=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*s,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*s,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*s,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,s=e.y,o=e.z,l=e.w,c=2*(s*i-o*r),u=2*(o*n-a*i),h=2*(a*r-s*n);return this.x=n+l*c+s*h-o*u,this.y=r+l*u+o*c-a*h,this.z=i+l*h+a*u-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=mn(this.x,e.x,n.x),this.y=mn(this.y,e.y,n.y),this.z=mn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=mn(this.x,e,n),this.y=mn(this.y,e,n),this.z=mn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(mn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,s=n.x,o=n.y,l=n.z;return this.x=i*l-a*o,this.y=a*s-r*l,this.z=r*o-i*s,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return VA.copy(this).projectOnVector(e),this.sub(VA)}reflect(e){return this.sub(VA.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(mn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,n=Math.random()*2-1,r=Math.sqrt(1-n*n);return this.x=r*Math.cos(e),this.y=n,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const VA=new We,bF=new Nf;let un=class F9{constructor(e,n,r,i,a,s,o,l,c){F9.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,l,c)}set(e,n,r,i,a,s,o,l,c){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=n,u[4]=a,u[5]=l,u[6]=r,u[7]=s,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],o=r[3],l=r[6],c=r[1],u=r[4],h=r[7],g=r[2],m=r[5],b=r[8],y=i[0],v=i[3],x=i[6],M=i[1],w=i[4],C=i[7],T=i[2],R=i[5],A=i[8];return a[0]=s*y+o*M+l*T,a[3]=s*v+o*w+l*R,a[6]=s*x+o*C+l*A,a[1]=c*y+u*M+h*T,a[4]=c*v+u*w+h*R,a[7]=c*x+u*C+h*A,a[2]=g*y+m*M+b*T,a[5]=g*v+m*w+b*R,a[8]=g*x+m*C+b*A,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return n*s*u-n*o*c-r*a*u+r*o*l+i*a*c-i*s*l}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=u*s-o*c,g=o*l-u*a,m=c*a-s*l,b=n*h+r*g+i*m;if(b===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/b;return e[0]=h*y,e[1]=(i*c-u*r)*y,e[2]=(o*r-i*s)*y,e[3]=g*y,e[4]=(u*n-i*l)*y,e[5]=(i*a-o*n)*y,e[6]=m*y,e[7]=(r*l-c*n)*y,e[8]=(s*n-r*a)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,s,o){const l=Math.cos(a),c=Math.sin(a);return this.set(r*l,r*c,-r*(l*s+c*o)+s+e,-i*c,i*l,-i*(-c*s+l*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(GA.makeScale(e,n)),this}rotate(e){return this.premultiply(GA.makeRotation(-e)),this}translate(e,n){return this.premultiply(GA.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 GA=new un,yF=new un().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),_F=new un().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Cue(){const t={enabled:!0,workingColorSpace:Zp,spaces:{},convert:function(i,a,s){return this.enabled===!1||a===s||!a||!s||(this.spaces[a].transfer===Bn&&(i.r=cc(i.r),i.g=cc(i.g),i.b=cc(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===Bn&&(i.r=Dp(i.r),i.g=Dp(i.g),i.b=Dp(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===Cu?Y_: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 t0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return t0("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({[Zp]:{primaries:e,whitePoint:r,transfer:Y_,toXYZ:yF,fromXYZ:_F,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Os},outputColorSpaceConfig:{drawingBufferColorSpace:Os}},[Os]:{primaries:e,whitePoint:r,transfer:Bn,toXYZ:yF,fromXYZ:_F,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Os}}}),t}const En=Cue();function cc(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Dp(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Dh,Nue=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{Dh===void 0&&(Dh=Q_("canvas")),Dh.width=e.width,Dh.height=e.height;const i=Dh.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=Dh}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=Q_("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]=cc(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(cc(n[r]/255)*255):n[r]=cc(n[r]);return{data:n,width:e.width,height:e.height}}else return Xt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Rue=0,ok=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Rue++}),this.uuid=B0(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let s=0,o=i.length;s<o;s++)i[s].isDataTexture?a.push(WA(i[s].image)):a.push(WA(i[s]))}else a=WA(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function WA(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Nue.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Xt("Texture: Unable to serialize Texture."),{})}let Pue=0;const qA=new We;let No=class w_ extends qf{constructor(e=w_.DEFAULT_IMAGE,n=w_.DEFAULT_MAPPING,r=tc,i=tc,a=Hs,s=Jd,o=xo,l=rl,c=w_.DEFAULT_ANISOTROPY,u=Cu){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Pue++}),this.uuid=B0(),this.name="",this.source=new ok(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new sn(0,0),this.repeat=new sn(1,1),this.center=new sn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new un,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,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(qA).x}get height(){return this.source.getSize(qA).y}get depth(){return this.source.getSize(qA).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){Xt(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Xt(`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!==A9)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case YN:e.x=e.x-Math.floor(e.x);break;case tc:e.x=e.x<0?0:1;break;case ZN: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 YN:e.y=e.y-Math.floor(e.y);break;case tc:e.y=e.y<0?0:1;break;case ZN: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++}};No.DEFAULT_IMAGE=null;No.DEFAULT_MAPPING=A9;No.DEFAULT_ANISOTROPY=1;let Vr=class z9{constructor(e=0,n=0,r=0,i=1){z9.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 l=e.elements,c=l[0],u=l[4],h=l[8],g=l[1],m=l[5],b=l[9],y=l[2],v=l[6],x=l[10];if(Math.abs(u-g)<.01&&Math.abs(h-y)<.01&&Math.abs(b-v)<.01){if(Math.abs(u+g)<.1&&Math.abs(h+y)<.1&&Math.abs(b+v)<.1&&Math.abs(c+m+x-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(c+1)/2,C=(m+1)/2,T=(x+1)/2,R=(u+g)/4,A=(h+y)/4,j=(b+v)/4;return w>C&&w>T?w<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(w),i=R/r,a=A/r):C>T?C<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(C),r=R/i,a=j/i):T<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(T),r=A/a,i=j/a),this.set(r,i,a,n),this}let M=Math.sqrt((v-b)*(v-b)+(h-y)*(h-y)+(g-u)*(g-u));return Math.abs(M)<.001&&(M=1),this.x=(v-b)/M,this.y=(h-y)/M,this.z=(g-u)/M,this.w=Math.acos((c+m+x-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=mn(this.x,e.x,n.x),this.y=mn(this.y,e.y,n.y),this.z=mn(this.z,e.z,n.z),this.w=mn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=mn(this.x,e,n),this.y=mn(this.y,e,n),this.z=mn(this.z,e,n),this.w=mn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(mn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},kue=class extends qf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Hs,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 Vr(0,0,e,n),this.scissorTest=!1,this.viewport=new Vr(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new No(i);this.textures=[];const s=r.count;for(let o=0;o<s;o++)this.textures[o]=a.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const n={minFilter:Hs,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 ok(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Rf=class extends kue{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},B9=class extends No{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=ds,this.minFilter=ds,this.wrapR=tc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Due=class extends No{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=ds,this.minFilter=ds,this.wrapR=tc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Pf=class{constructor(e=new We(1/0,1/0,1/0),n=new We(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(io.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(io.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=io.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=a.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,io):io.fromBufferAttribute(a,s),io.applyMatrix4(e.matrixWorld),this.expandByPoint(io);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Ub.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Ub.copy(r.boundingBox)),Ub.applyMatrix4(e.matrixWorld),this.union(Ub)}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,io),io.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ug),Fb.subVectors(this.max,Ug),Oh.subVectors(e.a,Ug),Lh.subVectors(e.b,Ug),Ih.subVectors(e.c,Ug),au.subVectors(Lh,Oh),su.subVectors(Ih,Lh),Rd.subVectors(Oh,Ih);let n=[0,-au.z,au.y,0,-su.z,su.y,0,-Rd.z,Rd.y,au.z,0,-au.x,su.z,0,-su.x,Rd.z,0,-Rd.x,-au.y,au.x,0,-su.y,su.x,0,-Rd.y,Rd.x,0];return!XA(n,Oh,Lh,Ih,Fb)||(n=[1,0,0,0,1,0,0,0,1],!XA(n,Oh,Lh,Ih,Fb))?!1:(zb.crossVectors(au,su),n=[zb.x,zb.y,zb.z],XA(n,Oh,Lh,Ih,Fb))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,io).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(io).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Pl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Pl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Pl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Pl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Pl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Pl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Pl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Pl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Pl),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 Pl=[new We,new We,new We,new We,new We,new We,new We,new We],io=new We,Ub=new Pf,Oh=new We,Lh=new We,Ih=new We,au=new We,su=new We,Rd=new We,Ug=new We,Fb=new We,zb=new We,Pd=new We;function XA(t,e,n,r,i){for(let a=0,s=t.length-3;a<=s;a+=3){Pd.fromArray(t,a);const o=i.x*Math.abs(Pd.x)+i.y*Math.abs(Pd.y)+i.z*Math.abs(Pd.z),l=e.dot(Pd),c=n.dot(Pd),u=r.dot(Pd);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const Oue=new Pf,Fg=new We,KA=new We;let iw=class{constructor(e=new We,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):Oue.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;Fg.subVectors(e,this.center);const n=Fg.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Fg,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):(KA.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Fg.copy(e.center).add(KA)),this.expandByPoint(Fg.copy(e.center).sub(KA))),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 kl=new We,YA=new We,Bb=new We,ou=new We,ZA=new We,Hb=new We,QA=new We;let lk=class{constructor(e=new We,n=new We(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,kl)),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=kl.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(kl.copy(this.origin).addScaledVector(this.direction,n),kl.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){YA.copy(e).add(n).multiplyScalar(.5),Bb.copy(n).sub(e).normalize(),ou.copy(this.origin).sub(YA);const a=e.distanceTo(n)*.5,s=-this.direction.dot(Bb),o=ou.dot(this.direction),l=-ou.dot(Bb),c=ou.lengthSq(),u=Math.abs(1-s*s);let h,g,m,b;if(u>0)if(h=s*l-o,g=s*o-l,b=a*u,h>=0)if(g>=-b)if(g<=b){const y=1/u;h*=y,g*=y,m=h*(h+s*g+2*o)+g*(s*h+g+2*l)+c}else g=a,h=Math.max(0,-(s*g+o)),m=-h*h+g*(g+2*l)+c;else g=-a,h=Math.max(0,-(s*g+o)),m=-h*h+g*(g+2*l)+c;else g<=-b?(h=Math.max(0,-(-s*a+o)),g=h>0?-a:Math.min(Math.max(-a,-l),a),m=-h*h+g*(g+2*l)+c):g<=b?(h=0,g=Math.min(Math.max(-a,-l),a),m=g*(g+2*l)+c):(h=Math.max(0,-(s*a+o)),g=h>0?a:Math.min(Math.max(-a,-l),a),m=-h*h+g*(g+2*l)+c);else g=s>0?-a:a,h=Math.max(0,-(s*g+o)),m=-h*h+g*(g+2*l)+c;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(YA).addScaledVector(Bb,g),m}intersectSphere(e,n){kl.subVectors(e.center,this.origin);const r=kl.dot(this.direction),i=kl.dot(kl)-r*r,a=e.radius*e.radius;if(i>a)return null;const s=Math.sqrt(a-i),o=r-s,l=r+s;return l<0?null:o<0?this.at(l,n):this.at(o,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,s,o,l;const c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,g=this.origin;return c>=0?(r=(e.min.x-g.x)*c,i=(e.max.x-g.x)*c):(r=(e.max.x-g.x)*c,i=(e.min.x-g.x)*c),u>=0?(a=(e.min.y-g.y)*u,s=(e.max.y-g.y)*u):(a=(e.max.y-g.y)*u,s=(e.min.y-g.y)*u),r>s||a>i||((a>r||isNaN(r))&&(r=a),(s<i||isNaN(i))&&(i=s),h>=0?(o=(e.min.z-g.z)*h,l=(e.max.z-g.z)*h):(o=(e.max.z-g.z)*h,l=(e.min.z-g.z)*h),r>l||o>i)||((o>r||r!==r)&&(r=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,kl)!==null}intersectTriangle(e,n,r,i,a){ZA.subVectors(n,e),Hb.subVectors(r,e),QA.crossVectors(ZA,Hb);let s=this.direction.dot(QA),o;if(s>0){if(i)return null;o=1}else if(s<0)o=-1,s=-s;else return null;ou.subVectors(this.origin,e);const l=o*this.direction.dot(Hb.crossVectors(ou,Hb));if(l<0)return null;const c=o*this.direction.dot(ZA.cross(ou));if(c<0||l+c>s)return null;const u=-o*ou.dot(QA);return u<0?null:this.at(u/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)}},Xr=class T3{constructor(e,n,r,i,a,s,o,l,c,u,h,g,m,b,y,v){T3.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,l,c,u,h,g,m,b,y,v)}set(e,n,r,i,a,s,o,l,c,u,h,g,m,b,y,v){const x=this.elements;return x[0]=e,x[4]=n,x[8]=r,x[12]=i,x[1]=a,x[5]=s,x[9]=o,x[13]=l,x[2]=c,x[6]=u,x[10]=h,x[14]=g,x[3]=m,x[7]=b,x[11]=y,x[15]=v,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new T3().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/jh.setFromMatrixColumn(e,0).length(),a=1/jh.setFromMatrixColumn(e,1).length(),s=1/jh.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*s,n[9]=r[9]*s,n[10]=r[10]*s,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,a=e.z,s=Math.cos(r),o=Math.sin(r),l=Math.cos(i),c=Math.sin(i),u=Math.cos(a),h=Math.sin(a);if(e.order==="XYZ"){const g=s*u,m=s*h,b=o*u,y=o*h;n[0]=l*u,n[4]=-l*h,n[8]=c,n[1]=m+b*c,n[5]=g-y*c,n[9]=-o*l,n[2]=y-g*c,n[6]=b+m*c,n[10]=s*l}else if(e.order==="YXZ"){const g=l*u,m=l*h,b=c*u,y=c*h;n[0]=g+y*o,n[4]=b*o-m,n[8]=s*c,n[1]=s*h,n[5]=s*u,n[9]=-o,n[2]=m*o-b,n[6]=y+g*o,n[10]=s*l}else if(e.order==="ZXY"){const g=l*u,m=l*h,b=c*u,y=c*h;n[0]=g-y*o,n[4]=-s*h,n[8]=b+m*o,n[1]=m+b*o,n[5]=s*u,n[9]=y-g*o,n[2]=-s*c,n[6]=o,n[10]=s*l}else if(e.order==="ZYX"){const g=s*u,m=s*h,b=o*u,y=o*h;n[0]=l*u,n[4]=b*c-m,n[8]=g*c+y,n[1]=l*h,n[5]=y*c+g,n[9]=m*c-b,n[2]=-c,n[6]=o*l,n[10]=s*l}else if(e.order==="YZX"){const g=s*l,m=s*c,b=o*l,y=o*c;n[0]=l*u,n[4]=y-g*h,n[8]=b*h+m,n[1]=h,n[5]=s*u,n[9]=-o*u,n[2]=-c*u,n[6]=m*h+b,n[10]=g-y*h}else if(e.order==="XZY"){const g=s*l,m=s*c,b=o*l,y=o*c;n[0]=l*u,n[4]=-h,n[8]=c*u,n[1]=g*h+y,n[5]=s*u,n[9]=m*h-b,n[2]=b*h-m,n[6]=o*u,n[10]=y*h+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(Lue,e,Iue)}lookAt(e,n,r){const i=this.elements;return es.subVectors(e,n),es.lengthSq()===0&&(es.z=1),es.normalize(),lu.crossVectors(r,es),lu.lengthSq()===0&&(Math.abs(r.z)===1?es.x+=1e-4:es.z+=1e-4,es.normalize(),lu.crossVectors(r,es)),lu.normalize(),$b.crossVectors(es,lu),i[0]=lu.x,i[4]=$b.x,i[8]=es.x,i[1]=lu.y,i[5]=$b.y,i[9]=es.y,i[2]=lu.z,i[6]=$b.z,i[10]=es.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],o=r[4],l=r[8],c=r[12],u=r[1],h=r[5],g=r[9],m=r[13],b=r[2],y=r[6],v=r[10],x=r[14],M=r[3],w=r[7],C=r[11],T=r[15],R=i[0],A=i[4],j=i[8],N=i[12],k=i[1],F=i[5],I=i[9],W=i[13],D=i[2],B=i[6],G=i[10],V=i[14],Z=i[3],Y=i[7],ee=i[11],H=i[15];return a[0]=s*R+o*k+l*D+c*Z,a[4]=s*A+o*F+l*B+c*Y,a[8]=s*j+o*I+l*G+c*ee,a[12]=s*N+o*W+l*V+c*H,a[1]=u*R+h*k+g*D+m*Z,a[5]=u*A+h*F+g*B+m*Y,a[9]=u*j+h*I+g*G+m*ee,a[13]=u*N+h*W+g*V+m*H,a[2]=b*R+y*k+v*D+x*Z,a[6]=b*A+y*F+v*B+x*Y,a[10]=b*j+y*I+v*G+x*ee,a[14]=b*N+y*W+v*V+x*H,a[3]=M*R+w*k+C*D+T*Z,a[7]=M*A+w*F+C*B+T*Y,a[11]=M*j+w*I+C*G+T*ee,a[15]=M*N+w*W+C*V+T*H,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],s=e[1],o=e[5],l=e[9],c=e[13],u=e[2],h=e[6],g=e[10],m=e[14],b=e[3],y=e[7],v=e[11],x=e[15];return b*(+a*l*h-i*c*h-a*o*g+r*c*g+i*o*m-r*l*m)+y*(+n*l*m-n*c*g+a*s*g-i*s*m+i*c*u-a*l*u)+v*(+n*c*h-n*o*m-a*s*h+r*s*m+a*o*u-r*c*u)+x*(-i*o*u-n*l*h+n*o*g+i*s*h-r*s*g+r*l*u)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=e[9],g=e[10],m=e[11],b=e[12],y=e[13],v=e[14],x=e[15],M=h*v*c-y*g*c+y*l*m-o*v*m-h*l*x+o*g*x,w=b*g*c-u*v*c-b*l*m+s*v*m+u*l*x-s*g*x,C=u*y*c-b*h*c+b*o*m-s*y*m-u*o*x+s*h*x,T=b*h*l-u*y*l-b*o*g+s*y*g+u*o*v-s*h*v,R=n*M+r*w+i*C+a*T;if(R===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/R;return e[0]=M*A,e[1]=(y*g*a-h*v*a-y*i*m+r*v*m+h*i*x-r*g*x)*A,e[2]=(o*v*a-y*l*a+y*i*c-r*v*c-o*i*x+r*l*x)*A,e[3]=(h*l*a-o*g*a-h*i*c+r*g*c+o*i*m-r*l*m)*A,e[4]=w*A,e[5]=(u*v*a-b*g*a+b*i*m-n*v*m-u*i*x+n*g*x)*A,e[6]=(b*l*a-s*v*a-b*i*c+n*v*c+s*i*x-n*l*x)*A,e[7]=(s*g*a-u*l*a+u*i*c-n*g*c-s*i*m+n*l*m)*A,e[8]=C*A,e[9]=(b*h*a-u*y*a-b*r*m+n*y*m+u*r*x-n*h*x)*A,e[10]=(s*y*a-b*o*a+b*r*c-n*y*c-s*r*x+n*o*x)*A,e[11]=(u*o*a-s*h*a-u*r*c+n*h*c+s*r*m-n*o*m)*A,e[12]=T*A,e[13]=(u*y*i-b*h*i+b*r*g-n*y*g-u*r*v+n*h*v)*A,e[14]=(b*o*i-s*y*i-b*r*l+n*y*l+s*r*v-n*o*v)*A,e[15]=(s*h*i-u*o*i+u*r*l-n*h*l-s*r*g+n*o*g)*A,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,s=e.x,o=e.y,l=e.z,c=a*s,u=a*o;return this.set(c*s+r,c*o-i*l,c*l+i*o,0,c*o+i*l,u*o+r,u*l-i*s,0,c*l-i*o,u*l+i*s,a*l*l+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,s){return this.set(1,r,a,0,e,1,s,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,s=n._y,o=n._z,l=n._w,c=a+a,u=s+s,h=o+o,g=a*c,m=a*u,b=a*h,y=s*u,v=s*h,x=o*h,M=l*c,w=l*u,C=l*h,T=r.x,R=r.y,A=r.z;return i[0]=(1-(y+x))*T,i[1]=(m+C)*T,i[2]=(b-w)*T,i[3]=0,i[4]=(m-C)*R,i[5]=(1-(g+x))*R,i[6]=(v+M)*R,i[7]=0,i[8]=(b+w)*A,i[9]=(v-M)*A,i[10]=(1-(g+y))*A,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=jh.set(i[0],i[1],i[2]).length();const s=jh.set(i[4],i[5],i[6]).length(),o=jh.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],ao.copy(this);const c=1/a,u=1/s,h=1/o;return ao.elements[0]*=c,ao.elements[1]*=c,ao.elements[2]*=c,ao.elements[4]*=u,ao.elements[5]*=u,ao.elements[6]*=u,ao.elements[8]*=h,ao.elements[9]*=h,ao.elements[10]*=h,n.setFromRotationMatrix(ao),r.x=a,r.y=s,r.z=o,this}makePerspective(e,n,r,i,a,s,o=Xo,l=!1){const c=this.elements,u=2*a/(n-e),h=2*a/(r-i),g=(n+e)/(n-e),m=(r+i)/(r-i);let b,y;if(l)b=a/(s-a),y=s*a/(s-a);else if(o===Xo)b=-(s+a)/(s-a),y=-2*s*a/(s-a);else if(o===Z_)b=-s/(s-a),y=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=g,c[12]=0,c[1]=0,c[5]=h,c[9]=m,c[13]=0,c[2]=0,c[6]=0,c[10]=b,c[14]=y,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,a,s,o=Xo,l=!1){const c=this.elements,u=2/(n-e),h=2/(r-i),g=-(n+e)/(n-e),m=-(r+i)/(r-i);let b,y;if(l)b=1/(s-a),y=s/(s-a);else if(o===Xo)b=-2/(s-a),y=-(s+a)/(s-a);else if(o===Z_)b=-1/(s-a),y=-a/(s-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=0,c[12]=g,c[1]=0,c[5]=h,c[9]=0,c[13]=m,c[2]=0,c[6]=0,c[10]=b,c[14]=y,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 jh=new We,ao=new Xr,Lue=new We(0,0,0),Iue=new We(1,1,1),lu=new We,$b=new We,es=new We,SF=new Xr,wF=new Nf;let Zu=class H9{constructor(e=0,n=0,r=0,i=H9.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],s=i[4],o=i[8],l=i[1],c=i[5],u=i[9],h=i[2],g=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(mn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(g,c),this._z=0);break;case"YXZ":this._x=Math.asin(-mn(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,a),this._z=0);break;case"ZXY":this._x=Math.asin(mn(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-h,m),this._z=Math.atan2(-s,c)):(this._y=0,this._z=Math.atan2(l,a));break;case"ZYX":this._y=Math.asin(-mn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(g,m),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-s,c));break;case"YZX":this._z=Math.asin(mn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,a)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-mn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(g,c),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-u,m),this._y=0);break;default:Xt("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return SF.makeRotationFromQuaternion(e),this.setFromRotationMatrix(SF,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return wF.setFromEuler(this),this.setFromQuaternion(wF,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}};Zu.DEFAULT_ORDER="XYZ";let $9=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}},jue=0;const MF=new We,Uh=new Nf,Dl=new Xr,Vb=new We,zg=new We,Uue=new We,Fue=new Nf,EF=new We(1,0,0),AF=new We(0,1,0),TF=new We(0,0,1),CF={type:"added"},zue={type:"removed"},Fh={type:"childadded",child:null},JA={type:"childremoved",child:null};let ms=class M_ extends qf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:jue++}),this.uuid=B0(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=M_.DEFAULT_UP.clone();const e=new We,n=new Zu,r=new Nf,i=new We(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 Xr},normalMatrix:{value:new un}}),this.matrix=new Xr,this.matrixWorld=new Xr,this.matrixAutoUpdate=M_.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=M_.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new $9,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 Uh.setFromAxisAngle(e,n),this.quaternion.multiply(Uh),this}rotateOnWorldAxis(e,n){return Uh.setFromAxisAngle(e,n),this.quaternion.premultiply(Uh),this}rotateX(e){return this.rotateOnAxis(EF,e)}rotateY(e){return this.rotateOnAxis(AF,e)}rotateZ(e){return this.rotateOnAxis(TF,e)}translateOnAxis(e,n){return MF.copy(e).applyQuaternion(this.quaternion),this.position.add(MF.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(EF,e)}translateY(e){return this.translateOnAxis(AF,e)}translateZ(e){return this.translateOnAxis(TF,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Dl.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?Vb.copy(e):Vb.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),zg.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Dl.lookAt(zg,Vb,this.up):Dl.lookAt(Vb,zg,this.up),this.quaternion.setFromRotationMatrix(Dl),i&&(Dl.extractRotation(i.matrixWorld),Uh.setFromRotationMatrix(Dl),this.quaternion.premultiply(Uh.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Dr("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(CF),Fh.child=e,this.dispatchEvent(Fh),Fh.child=null):Dr("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(zue),JA.child=e,this.dispatchEvent(JA),JA.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),Dl.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Dl.multiply(e.parent.matrixWorld)),e.applyMatrix4(Dl),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(CF),Fh.child=e,this.dispatchEvent(Fh),Fh.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(zg,e,Uue),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(zg,Fue,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(e)}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){const i=this.children;for(let a=0,s=i.length;a<s;a++)i[a].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function a(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const h=l[c];a(e.shapes,h)}else a(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(a(e.materials,this.material[l]));i.material=o}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(a(e.animations,l))}}if(n){const o=s(e.geometries),l=s(e.materials),c=s(e.textures),u=s(e.images),h=s(e.shapes),g=s(e.skeletons),m=s(e.animations),b=s(e.nodes);o.length>0&&(r.geometries=o),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),u.length>0&&(r.images=u),h.length>0&&(r.shapes=h),g.length>0&&(r.skeletons=g),m.length>0&&(r.animations=m),b.length>0&&(r.nodes=b)}return r.object=i,r;function s(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}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}};ms.DEFAULT_UP=new We(0,1,0);ms.DEFAULT_MATRIX_AUTO_UPDATE=!0;ms.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const so=new We,Ol=new We,eT=new We,Ll=new We,zh=new We,Bh=new We,NF=new We,tT=new We,nT=new We,rT=new We,iT=new Vr,aT=new Vr,sT=new Vr;let Bg=class xp{constructor(e=new We,n=new We,r=new We){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),so.subVectors(e,n),i.cross(so);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){so.subVectors(i,n),Ol.subVectors(r,n),eT.subVectors(e,n);const s=so.dot(so),o=so.dot(Ol),l=so.dot(eT),c=Ol.dot(Ol),u=Ol.dot(eT),h=s*c-o*o;if(h===0)return a.set(0,0,0),null;const g=1/h,m=(c*l-o*u)*g,b=(s*u-o*l)*g;return a.set(1-m-b,b,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Ll)===null?!1:Ll.x>=0&&Ll.y>=0&&Ll.x+Ll.y<=1}static getInterpolation(e,n,r,i,a,s,o,l){return this.getBarycoord(e,n,r,i,Ll)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(a,Ll.x),l.addScaledVector(s,Ll.y),l.addScaledVector(o,Ll.z),l)}static getInterpolatedAttribute(e,n,r,i,a,s){return iT.setScalar(0),aT.setScalar(0),sT.setScalar(0),iT.fromBufferAttribute(e,n),aT.fromBufferAttribute(e,r),sT.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(iT,a.x),s.addScaledVector(aT,a.y),s.addScaledVector(sT,a.z),s}static isFrontFacing(e,n,r,i){return so.subVectors(r,n),Ol.subVectors(e,n),so.cross(Ol).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 so.subVectors(this.c,this.b),Ol.subVectors(this.a,this.b),so.cross(Ol).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return xp.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return xp.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return xp.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return xp.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return xp.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,a=this.c;let s,o;zh.subVectors(i,r),Bh.subVectors(a,r),tT.subVectors(e,r);const l=zh.dot(tT),c=Bh.dot(tT);if(l<=0&&c<=0)return n.copy(r);nT.subVectors(e,i);const u=zh.dot(nT),h=Bh.dot(nT);if(u>=0&&h<=u)return n.copy(i);const g=l*h-u*c;if(g<=0&&l>=0&&u<=0)return s=l/(l-u),n.copy(r).addScaledVector(zh,s);rT.subVectors(e,a);const m=zh.dot(rT),b=Bh.dot(rT);if(b>=0&&m<=b)return n.copy(a);const y=m*c-l*b;if(y<=0&&c>=0&&b<=0)return o=c/(c-b),n.copy(r).addScaledVector(Bh,o);const v=u*b-m*h;if(v<=0&&h-u>=0&&m-b>=0)return NF.subVectors(a,i),o=(h-u)/(h-u+(m-b)),n.copy(i).addScaledVector(NF,o);const x=1/(v+y+g);return s=y*x,o=g*x,n.copy(r).addScaledVector(zh,s).addScaledVector(Bh,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const V9={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},cu={h:0,s:0,l:0},Gb={h:0,s:0,l:0};function oT(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 bn=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=Os){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,En.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=En.workingColorSpace){return this.r=e,this.g=n,this.b=r,En.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=En.workingColorSpace){if(e=Aue(e,1),n=mn(n,0,1),r=mn(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,s=2*r-a;this.r=oT(s,a,e+1/3),this.g=oT(s,a,e),this.b=oT(s,a,e-1/3)}return En.colorSpaceToWorking(this,i),this}setStyle(e,n=Os){function r(a){a!==void 0&&parseFloat(a)<1&&Xt("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:Xt("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);Xt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Os){const r=V9[e.toLowerCase()];return r!==void 0?this.setHex(r,n):Xt("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=cc(e.r),this.g=cc(e.g),this.b=cc(e.b),this}copyLinearToSRGB(e){return this.r=Dp(e.r),this.g=Dp(e.g),this.b=Dp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Os){return En.workingToColorSpace(Yi.copy(this),e),Math.round(mn(Yi.r*255,0,255))*65536+Math.round(mn(Yi.g*255,0,255))*256+Math.round(mn(Yi.b*255,0,255))}getHexString(e=Os){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=En.workingColorSpace){En.workingToColorSpace(Yi.copy(this),n);const r=Yi.r,i=Yi.g,a=Yi.b,s=Math.max(r,i,a),o=Math.min(r,i,a);let l,c;const u=(o+s)/2;if(o===s)l=0,c=0;else{const h=s-o;switch(c=u<=.5?h/(s+o):h/(2-s-o),s){case r:l=(i-a)/h+(i<a?6:0);break;case i:l=(a-r)/h+2;break;case a:l=(r-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,n=En.workingColorSpace){return En.workingToColorSpace(Yi.copy(this),n),e.r=Yi.r,e.g=Yi.g,e.b=Yi.b,e}getStyle(e=Os){En.workingToColorSpace(Yi.copy(this),e);const n=Yi.r,r=Yi.g,i=Yi.b;return e!==Os?`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(cu),this.setHSL(cu.h+e,cu.s+n,cu.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(cu),e.getHSL(Gb);const r=$A(cu.h,Gb.h,n),i=$A(cu.s,Gb.s,n),a=$A(cu.l,Gb.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 Yi=new bn;bn.NAMES=V9;let Bue=0,Am=class extends qf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Bue++}),this.uuid=B0(),this.name="",this.type="Material",this.blending=kp,this.side=Yu,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=FN,this.blendDst=zN,this.blendEquation=Wd,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new bn(0,0,0),this.blendAlpha=0,this.depthFunc=Xp,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=pF,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=kh,this.stencilZFail=kh,this.stencilZPass=kh,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){Xt(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Xt(`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!==kp&&(r.blending=this.blending),this.side!==Yu&&(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!==FN&&(r.blendSrc=this.blendSrc),this.blendDst!==zN&&(r.blendDst=this.blendDst),this.blendEquation!==Wd&&(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!==Xp&&(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!==pF&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==kh&&(r.stencilFail=this.stencilFail),this.stencilZFail!==kh&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==kh&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(a){const s=[];for(const o in a){const l=a[o];delete l.metadata,s.push(l)}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++}},ck=class extends Am{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new bn(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 Zu,this.combine=JP,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 Br=new We,Wb=new sn;let Hue=0,Vs=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:Hue++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=mF,this.updateRanges=[],this.gpuType=nc,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++)Wb.fromBufferAttribute(this,n),Wb.applyMatrix3(e),this.setXY(n,Wb.x,Wb.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Br.fromBufferAttribute(this,n),Br.applyMatrix3(e),this.setXYZ(n,Br.x,Br.y,Br.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Br.fromBufferAttribute(this,n),Br.applyMatrix4(e),this.setXYZ(n,Br.x,Br.y,Br.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Br.fromBufferAttribute(this,n),Br.applyNormalMatrix(e),this.setXYZ(n,Br.x,Br.y,Br.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Br.fromBufferAttribute(this,n),Br.transformDirection(e),this.setXYZ(n,Br.x,Br.y,Br.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=jg(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Pa(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=jg(n,this.array)),n}setX(e,n){return this.normalized&&(n=Pa(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=jg(n,this.array)),n}setY(e,n){return this.normalized&&(n=Pa(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=jg(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Pa(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=jg(n,this.array)),n}setW(e,n){return this.normalized&&(n=Pa(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Pa(n,this.array),r=Pa(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=Pa(n,this.array),r=Pa(r,this.array),i=Pa(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=Pa(n,this.array),r=Pa(r,this.array),i=Pa(i,this.array),a=Pa(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!==mF&&(e.usage=this.usage),e}},G9=class extends Vs{constructor(e,n,r){super(new Uint16Array(e),n,r)}},W9=class extends Vs{constructor(e,n,r){super(new Uint32Array(e),n,r)}},yo=class extends Vs{constructor(e,n,r){super(new Float32Array(e),n,r)}},$ue=0;const Es=new Xr,lT=new ms,Hh=new We,ts=new Pf,Hg=new Pf,bi=new We;let fl=class q9 extends qf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:$ue++}),this.uuid=B0(),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(I9(e)?W9:G9)(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 un().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 Es.makeRotationFromQuaternion(e),this.applyMatrix4(Es),this}rotateX(e){return Es.makeRotationX(e),this.applyMatrix4(Es),this}rotateY(e){return Es.makeRotationY(e),this.applyMatrix4(Es),this}rotateZ(e){return Es.makeRotationZ(e),this.applyMatrix4(Es),this}translate(e,n,r){return Es.makeTranslation(e,n,r),this.applyMatrix4(Es),this}scale(e,n,r){return Es.makeScale(e,n,r),this.applyMatrix4(Es),this}lookAt(e){return lT.lookAt(e),lT.updateMatrix(),this.applyMatrix4(lT.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Hh).negate(),this.translate(Hh.x,Hh.y,Hh.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 yo(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&&Xt("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 Pf);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Dr("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new We(-1/0,-1/0,-1/0),new We(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];ts.setFromBufferAttribute(a),this.morphTargetsRelative?(bi.addVectors(this.boundingBox.min,ts.min),this.boundingBox.expandByPoint(bi),bi.addVectors(this.boundingBox.max,ts.max),this.boundingBox.expandByPoint(bi)):(this.boundingBox.expandByPoint(ts.min),this.boundingBox.expandByPoint(ts.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Dr('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 iw);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Dr("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new We,1/0);return}if(e){const r=this.boundingSphere.center;if(ts.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const o=n[a];Hg.setFromBufferAttribute(o),this.morphTargetsRelative?(bi.addVectors(ts.min,Hg.min),ts.expandByPoint(bi),bi.addVectors(ts.max,Hg.max),ts.expandByPoint(bi)):(ts.expandByPoint(Hg.min),ts.expandByPoint(Hg.max))}ts.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)bi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(bi));if(n)for(let a=0,s=n.length;a<s;a++){const o=n[a],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)bi.fromBufferAttribute(o,c),l&&(Hh.fromBufferAttribute(e,c),bi.add(Hh)),i=Math.max(i,r.distanceToSquared(bi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Dr('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){Dr("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 Vs(new Float32Array(4*r.count),4));const s=this.getAttribute("tangent"),o=[],l=[];for(let j=0;j<r.count;j++)o[j]=new We,l[j]=new We;const c=new We,u=new We,h=new We,g=new sn,m=new sn,b=new sn,y=new We,v=new We;function x(j,N,k){c.fromBufferAttribute(r,j),u.fromBufferAttribute(r,N),h.fromBufferAttribute(r,k),g.fromBufferAttribute(a,j),m.fromBufferAttribute(a,N),b.fromBufferAttribute(a,k),u.sub(c),h.sub(c),m.sub(g),b.sub(g);const F=1/(m.x*b.y-b.x*m.y);isFinite(F)&&(y.copy(u).multiplyScalar(b.y).addScaledVector(h,-m.y).multiplyScalar(F),v.copy(h).multiplyScalar(m.x).addScaledVector(u,-b.x).multiplyScalar(F),o[j].add(y),o[N].add(y),o[k].add(y),l[j].add(v),l[N].add(v),l[k].add(v))}let M=this.groups;M.length===0&&(M=[{start:0,count:e.count}]);for(let j=0,N=M.length;j<N;++j){const k=M[j],F=k.start,I=k.count;for(let W=F,D=F+I;W<D;W+=3)x(e.getX(W+0),e.getX(W+1),e.getX(W+2))}const w=new We,C=new We,T=new We,R=new We;function A(j){T.fromBufferAttribute(i,j),R.copy(T);const N=o[j];w.copy(N),w.sub(T.multiplyScalar(T.dot(N))).normalize(),C.crossVectors(R,N);const F=C.dot(l[j])<0?-1:1;s.setXYZW(j,w.x,w.y,w.z,F)}for(let j=0,N=M.length;j<N;++j){const k=M[j],F=k.start,I=k.count;for(let W=F,D=F+I;W<D;W+=3)A(e.getX(W+0)),A(e.getX(W+1)),A(e.getX(W+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new Vs(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,m=r.count;g<m;g++)r.setXYZ(g,0,0,0);const i=new We,a=new We,s=new We,o=new We,l=new We,c=new We,u=new We,h=new We;if(e)for(let g=0,m=e.count;g<m;g+=3){const b=e.getX(g+0),y=e.getX(g+1),v=e.getX(g+2);i.fromBufferAttribute(n,b),a.fromBufferAttribute(n,y),s.fromBufferAttribute(n,v),u.subVectors(s,a),h.subVectors(i,a),u.cross(h),o.fromBufferAttribute(r,b),l.fromBufferAttribute(r,y),c.fromBufferAttribute(r,v),o.add(u),l.add(u),c.add(u),r.setXYZ(b,o.x,o.y,o.z),r.setXYZ(y,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z)}else for(let g=0,m=n.count;g<m;g+=3)i.fromBufferAttribute(n,g+0),a.fromBufferAttribute(n,g+1),s.fromBufferAttribute(n,g+2),u.subVectors(s,a),h.subVectors(i,a),u.cross(h),r.setXYZ(g+0,u.x,u.y,u.z),r.setXYZ(g+1,u.x,u.y,u.z),r.setXYZ(g+2,u.x,u.y,u.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)bi.fromBufferAttribute(e,n),bi.normalize(),e.setXYZ(n,bi.x,bi.y,bi.z)}toNonIndexed(){function e(o,l){const c=o.array,u=o.itemSize,h=o.normalized,g=new c.constructor(l.length*u);let m=0,b=0;for(let y=0,v=l.length;y<v;y++){o.isInterleavedBufferAttribute?m=l[y]*o.data.stride+o.offset:m=l[y]*u;for(let x=0;x<u;x++)g[b++]=c[m++]}return new Vs(g,u,h)}if(this.index===null)return Xt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new q9,r=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,r);n.setAttribute(o,c)}const a=this.morphAttributes;for(const o in a){const l=[],c=a[o];for(let u=0,h=c.length;u<h;u++){const g=c[u],m=e(g,r);l.push(m)}n.morphAttributes[o]=l}n.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let o=0,l=s.length;o<l;o++){const c=s[o];n.addGroup(c.start,c.count,c.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 l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);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 l in r){const c=r[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let a=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let h=0,g=c.length;h<g;h++){const m=c[h];u.push(m.toJSON(e.data))}u.length>0&&(i[l]=u,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const c in i){const u=i[c];this.setAttribute(c,u.clone(n))}const a=e.morphAttributes;for(const c in a){const u=[],h=a[c];for(let g=0,m=h.length;g<m;g++)u.push(h[g].clone(n));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let c=0,u=s.length;c<u;c++){const h=s[c];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const RF=new Xr,kd=new lk,qb=new iw,PF=new We,Xb=new We,Kb=new We,Yb=new We,cT=new We,Zb=new We,kF=new We,Qb=new We;let il=class extends ms{constructor(e=new fl,n=new ck){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,s=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(a&&o){Zb.set(0,0,0);for(let l=0,c=a.length;l<c;l++){const u=o[l],h=a[l];u!==0&&(cT.fromBufferAttribute(h,e),s?Zb.addScaledVector(cT,u):Zb.addScaledVector(cT.sub(n),u))}n.add(Zb)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),qb.copy(r.boundingSphere),qb.applyMatrix4(a),kd.copy(e.ray).recast(e.near),!(qb.containsPoint(kd.origin)===!1&&(kd.intersectSphere(qb,PF)===null||kd.origin.distanceToSquared(PF)>(e.far-e.near)**2))&&(RF.copy(a).invert(),kd.copy(e.ray).applyMatrix4(RF),!(r.boundingBox!==null&&kd.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,kd)))}_computeIntersections(e,n,r){let i;const a=this.geometry,s=this.material,o=a.index,l=a.attributes.position,c=a.attributes.uv,u=a.attributes.uv1,h=a.attributes.normal,g=a.groups,m=a.drawRange;if(o!==null)if(Array.isArray(s))for(let b=0,y=g.length;b<y;b++){const v=g[b],x=s[v.materialIndex],M=Math.max(v.start,m.start),w=Math.min(o.count,Math.min(v.start+v.count,m.start+m.count));for(let C=M,T=w;C<T;C+=3){const R=o.getX(C),A=o.getX(C+1),j=o.getX(C+2);i=Jb(this,x,e,r,c,u,h,R,A,j),i&&(i.faceIndex=Math.floor(C/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const b=Math.max(0,m.start),y=Math.min(o.count,m.start+m.count);for(let v=b,x=y;v<x;v+=3){const M=o.getX(v),w=o.getX(v+1),C=o.getX(v+2);i=Jb(this,s,e,r,c,u,h,M,w,C),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}else if(l!==void 0)if(Array.isArray(s))for(let b=0,y=g.length;b<y;b++){const v=g[b],x=s[v.materialIndex],M=Math.max(v.start,m.start),w=Math.min(l.count,Math.min(v.start+v.count,m.start+m.count));for(let C=M,T=w;C<T;C+=3){const R=C,A=C+1,j=C+2;i=Jb(this,x,e,r,c,u,h,R,A,j),i&&(i.faceIndex=Math.floor(C/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const b=Math.max(0,m.start),y=Math.min(l.count,m.start+m.count);for(let v=b,x=y;v<x;v+=3){const M=v,w=v+1,C=v+2;i=Jb(this,s,e,r,c,u,h,M,w,C),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}}};function Vue(t,e,n,r,i,a,s,o){let l;if(e.side===Ua?l=r.intersectTriangle(s,a,i,!0,o):l=r.intersectTriangle(i,a,s,e.side===Yu,o),l===null)return null;Qb.copy(o),Qb.applyMatrix4(t.matrixWorld);const c=n.ray.origin.distanceTo(Qb);return c<n.near||c>n.far?null:{distance:c,point:Qb.clone(),object:t}}function Jb(t,e,n,r,i,a,s,o,l,c){t.getVertexPosition(o,Xb),t.getVertexPosition(l,Kb),t.getVertexPosition(c,Yb);const u=Vue(t,e,n,r,Xb,Kb,Yb,kF);if(u){const h=new We;Bg.getBarycoord(kF,Xb,Kb,Yb,h),i&&(u.uv=Bg.getInterpolatedAttribute(i,o,l,c,h,new sn)),a&&(u.uv1=Bg.getInterpolatedAttribute(a,o,l,c,h,new sn)),s&&(u.normal=Bg.getInterpolatedAttribute(s,o,l,c,h,new We),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));const g={a:o,b:l,c,normal:new We,materialIndex:0};Bg.getNormal(Xb,Kb,Yb,g.normal),u.face=g,u.barycoord=h}return u}let uk=class X9 extends fl{constructor(e=1,n=1,r=1,i=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:s};const o=this;i=Math.floor(i),a=Math.floor(a),s=Math.floor(s);const l=[],c=[],u=[],h=[];let g=0,m=0;b("z","y","x",-1,-1,r,n,e,s,a,0),b("z","y","x",1,-1,r,n,-e,s,a,1),b("x","z","y",1,1,e,r,n,i,s,2),b("x","z","y",1,-1,e,r,-n,i,s,3),b("x","y","z",1,-1,e,n,r,i,a,4),b("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(l),this.setAttribute("position",new yo(c,3)),this.setAttribute("normal",new yo(u,3)),this.setAttribute("uv",new yo(h,2));function b(y,v,x,M,w,C,T,R,A,j,N){const k=C/A,F=T/j,I=C/2,W=T/2,D=R/2,B=A+1,G=j+1;let V=0,Z=0;const Y=new We;for(let ee=0;ee<G;ee++){const H=ee*F-W;for(let q=0;q<B;q++){const ae=q*k-I;Y[y]=ae*M,Y[v]=H*w,Y[x]=D,c.push(Y.x,Y.y,Y.z),Y[y]=0,Y[v]=0,Y[x]=R>0?1:-1,u.push(Y.x,Y.y,Y.z),h.push(q/A),h.push(1-ee/j),V+=1}}for(let ee=0;ee<j;ee++)for(let H=0;H<A;H++){const q=g+H+B*ee,ae=g+H+B*(ee+1),ce=g+(H+1)+B*(ee+1),xe=g+(H+1)+B*ee;l.push(q,ae,xe),l.push(ae,ce,xe),Z+=6}o.addGroup(m,Z,N),m+=Z,g+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new X9(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Qp(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?(Xt("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 fa(t){const e={};for(let n=0;n<t.length;n++){const r=Qp(t[n]);for(const i in r)e[i]=r[i]}return e}function Gue(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function K9(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:En.workingColorSpace}const Wue={clone:Qp,merge:fa};var que=`void main() {
  11. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  12. }`,Xue=`void main() {
  13. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  14. }`;let vc=class extends Am{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=que,this.fragmentShader=Xue,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=Qp(e.uniforms),this.uniformsGroups=Gue(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}},Y9=class extends ms{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Xr,this.projectionMatrix=new Xr,this.projectionMatrixInverse=new Xr,this.coordinateSystem=Xo,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 uu=new We,DF=new sn,OF=new sn;let js=class extends Y9{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=A3*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(S_*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return A3*2*Math.atan(Math.tan(S_*.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){uu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(uu.x,uu.y).multiplyScalar(-e/uu.z),uu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(uu.x,uu.y).multiplyScalar(-e/uu.z)}getViewSize(e,n){return this.getViewBounds(e,DF,OF),n.subVectors(OF,DF)}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(S_*.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 l=s.fullWidth,c=s.fullHeight;a+=s.offsetX*i/l,n-=s.offsetY*r/c,i*=s.width/l,r*=s.height/c}const o=this.filmOffset;o!==0&&(a+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}};const $h=-90,Vh=1;let Kue=class extends ms{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new js($h,Vh,e,n);i.layers=this.layers,this.add(i);const a=new js($h,Vh,e,n);a.layers=this.layers,this.add(a);const s=new js($h,Vh,e,n);s.layers=this.layers,this.add(s);const o=new js($h,Vh,e,n);o.layers=this.layers,this.add(o);const l=new js($h,Vh,e,n);l.layers=this.layers,this.add(l);const c=new js($h,Vh,e,n);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,s,o,l]=n;for(const c of n)this.remove(c);if(e===Xo)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Z_)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of n)this.add(c),c.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,s,o,l,c,u]=this.children,h=e.getRenderTarget(),g=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),b=e.xr.enabled;e.xr.enabled=!1;const y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,s),e.setRenderTarget(r,2,i),e.render(n,o),e.setRenderTarget(r,3,i),e.render(n,l),e.setRenderTarget(r,4,i),e.render(n,c),r.texture.generateMipmaps=y,e.setRenderTarget(r,5,i),e.render(n,u),e.setRenderTarget(h,g,m),e.xr.enabled=b,r.texture.needsPMREMUpdate=!0}},Z9=class extends No{constructor(e=[],n=Kp,r,i,a,s,o,l,c,u){super(e,n,r,i,a,s,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Yue=class extends Rf{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];this.texture=new Z9(i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
  15. varying vec3 vWorldDirection;
  16. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  17. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  18. }
  19. void main() {
  20. vWorldDirection = transformDirection( position, modelMatrix );
  21. #include <begin_vertex>
  22. #include <project_vertex>
  23. }
  24. `,fragmentShader:`
  25. uniform sampler2D tEquirect;
  26. varying vec3 vWorldDirection;
  27. #include <common>
  28. void main() {
  29. vec3 direction = normalize( vWorldDirection );
  30. vec2 sampleUV = equirectUv( direction );
  31. gl_FragColor = texture2D( tEquirect, sampleUV );
  32. }
  33. `},i=new uk(5,5,5),a=new vc({name:"CubemapFromEquirect",uniforms:Qp(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Ua,blending:lc});a.uniforms.tEquirect.value=n;const s=new il(i,a),o=n.minFilter;return n.minFilter===Jd&&(n.minFilter=Hs),new Kue(1,10,this).update(e,s),n.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,n=!0,r=!0,i=!0){const a=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(n,r,i);e.setRenderTarget(a)}},lx=class extends ms{constructor(){super(),this.isGroup=!0,this.type="Group"}};const Zue={type:"move"};let uT=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new lx,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new lx,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new We,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new We),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new lx,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new We,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new We),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,s=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(const y of e.hand.values()){const v=n.getJointPose(y,r),x=this._getHandJoint(c,y);v!==null&&(x.matrix.fromArray(v.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.matrixWorldNeedsUpdate=!0,x.jointRadius=v.radius),x.visible=v!==null}const u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],g=u.position.distanceTo(h.position),m=.02,b=.005;c.inputState.pinching&&g>m+b?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&g<=m-b&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(l.matrix.fromArray(a.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,a.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(a.linearVelocity)):l.hasLinearVelocity=!1,a.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(a.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Zue)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=a!==null),c!==null&&(c.visible=s!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new lx;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},Que=class extends ms{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 Zu,this.environmentIntensity=1,this.environmentRotation=new Zu,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}},Jue=class extends No{constructor(e=null,n=1,r=1,i,a,s,o,l,c=ds,u=ds,h,g){super(null,s,o,l,c,u,i,a,h,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const dT=new We,ede=new We,tde=new un;let yu=class{constructor(e=new We(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=dT.subVectors(r,n).cross(ede.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(dT),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||tde.getNormalMatrix(e),i=this.coplanarPoint(dT).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 Dd=new iw,nde=new sn(.5,.5),ey=new We;let dk=class{constructor(e=new yu,n=new yu,r=new yu,i=new yu,a=new yu,s=new yu){this.planes=[e,n,r,i,a,s]}set(e,n,r,i,a,s){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(a),o[5].copy(s),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=Xo,r=!1){const i=this.planes,a=e.elements,s=a[0],o=a[1],l=a[2],c=a[3],u=a[4],h=a[5],g=a[6],m=a[7],b=a[8],y=a[9],v=a[10],x=a[11],M=a[12],w=a[13],C=a[14],T=a[15];if(i[0].setComponents(c-s,m-u,x-b,T-M).normalize(),i[1].setComponents(c+s,m+u,x+b,T+M).normalize(),i[2].setComponents(c+o,m+h,x+y,T+w).normalize(),i[3].setComponents(c-o,m-h,x-y,T-w).normalize(),r)i[4].setComponents(l,g,v,C).normalize(),i[5].setComponents(c-l,m-g,x-v,T-C).normalize();else if(i[4].setComponents(c-l,m-g,x-v,T-C).normalize(),n===Xo)i[5].setComponents(c+l,m+g,x+v,T+C).normalize();else if(n===Z_)i[5].setComponents(l,g,v,C).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(),Dd.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Dd.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Dd)}intersectsSprite(e){Dd.center.set(0,0,0);const n=nde.distanceTo(e.center);return Dd.radius=.7071067811865476+n,Dd.applyMatrix4(e.matrixWorld),this.intersectsSphere(Dd)}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(ey.x=i.normal.x>0?e.max.x:e.min.x,ey.y=i.normal.y>0?e.max.y:e.min.y,ey.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ey)<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)}},Q9=class extends Am{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new bn(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 J_=new We,e1=new We,LF=new Xr,$g=new lk,ty=new iw,fT=new We,IF=new We;let rde=class extends ms{constructor(e=new fl,n=new Q9){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++)J_.fromBufferAttribute(n,i-1),e1.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=J_.distanceTo(e1);e.setAttribute("lineDistance",new yo(r,1))}else Xt("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(),ty.copy(r.boundingSphere),ty.applyMatrix4(i),ty.radius+=a,e.ray.intersectsSphere(ty)===!1)return;LF.copy(i).invert(),$g.copy(e.ray).applyMatrix4(LF);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,u=r.index,g=r.attributes.position;if(u!==null){const m=Math.max(0,s.start),b=Math.min(u.count,s.start+s.count);for(let y=m,v=b-1;y<v;y+=c){const x=u.getX(y),M=u.getX(y+1),w=ny(this,e,$g,l,x,M,y);w&&n.push(w)}if(this.isLineLoop){const y=u.getX(b-1),v=u.getX(m),x=ny(this,e,$g,l,y,v,b-1);x&&n.push(x)}}else{const m=Math.max(0,s.start),b=Math.min(g.count,s.start+s.count);for(let y=m,v=b-1;y<v;y+=c){const x=ny(this,e,$g,l,y,y+1,y);x&&n.push(x)}if(this.isLineLoop){const y=ny(this,e,$g,l,b-1,m,b-1);y&&n.push(y)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}};function ny(t,e,n,r,i,a,s){const o=t.geometry.attributes.position;if(J_.fromBufferAttribute(o,i),e1.fromBufferAttribute(o,a),n.distanceSqToSegment(J_,e1,fT,IF)>r)return;fT.applyMatrix4(t.matrixWorld);const c=e.ray.origin.distanceTo(fT);if(!(c<e.near||c>e.far))return{distance:c,point:IF.clone().applyMatrix4(t.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:t}}const jF=new We,UF=new We;let ide=class extends rde{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)jF.fromBufferAttribute(n,i),UF.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+jF.distanceTo(UF);e.setAttribute("lineDistance",new yo(r,1))}else Xt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},J9=class extends No{constructor(e,n,r=Cf,i,a,s,o=ds,l=ds,c,u=Jx,h=1){if(u!==Jx&&u!==e0)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const g={width:e,height:n,depth:h};super(g,i,a,s,o,l,u,r,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ok(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 e7 extends No{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let fk=class t7 extends fl{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,s=n/2,o=Math.floor(r),l=Math.floor(i),c=o+1,u=l+1,h=e/o,g=n/l,m=[],b=[],y=[],v=[];for(let x=0;x<u;x++){const M=x*g-s;for(let w=0;w<c;w++){const C=w*h-a;b.push(C,-M,0),y.push(0,0,1),v.push(w/o),v.push(1-x/l)}}for(let x=0;x<l;x++)for(let M=0;M<o;M++){const w=M+c*x,C=M+c*(x+1),T=M+1+c*(x+1),R=M+1+c*x;m.push(w,C,R),m.push(C,T,R)}this.setIndex(m),this.setAttribute("position",new yo(b,3)),this.setAttribute("normal",new yo(y,3)),this.setAttribute("uv",new yo(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new t7(e.width,e.height,e.widthSegments,e.heightSegments)}};class ade extends Am{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new bn(16777215),this.specular=new bn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new bn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=O9,this.normalScale=new sn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Zu,this.combine=JP,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 sde=class extends Am{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=pue,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}},ode=class extends Am{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}},n7=class extends ms{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new bn(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 hT=new Xr,FF=new We,zF=new We;let lde=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new sn(512,512),this.mapType=rl,this.map=null,this.mapPass=null,this.matrix=new Xr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new dk,this._frameExtents=new sn(1,1),this._viewportCount=1,this._viewports=[new Vr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;FF.setFromMatrixPosition(e.matrixWorld),n.position.copy(FF),zF.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(zF),n.updateMatrixWorld(),hT.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(hT,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(hT)}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}},r7=class extends Y9{constructor(e=-1,n=1,r=1,i=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=a,this.far=s,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,a,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let a=r-e,s=r+e,o=i+n,l=i-n;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=c*this.view.offsetX,s=a+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(a,s,o,l,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 cde extends lde{constructor(){super(new r7(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class BF extends n7{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ms.DEFAULT_UP),this.updateMatrix(),this.target=new ms,this.shadow=new cde}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let ude=class extends n7{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},dde=class extends js{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},HF=class{constructor(e=1,n=0,r=0){this.radius=e,this.phi=n,this.theta=r}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=mn(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(mn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class fde extends ide{constructor(e=10,n=10,r=4473924,i=8947848){r=new bn(r),i=new bn(i);const a=n/2,s=e/n,o=e/2,l=[],c=[];for(let g=0,m=0,b=-o;g<=n;g++,b+=s){l.push(-o,0,b,o,0,b),l.push(b,0,-o,b,0,o);const y=g===a?r:i;y.toArray(c,m),m+=3,y.toArray(c,m),m+=3,y.toArray(c,m),m+=3,y.toArray(c,m),m+=3}const u=new fl;u.setAttribute("position",new yo(l,3)),u.setAttribute("color",new yo(c,3));const h=new Q9({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class hde extends qf{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){Xt("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function $F(t,e,n,r){const i=pde(r);switch(n){case P9:return t*e;case D9:return t*e/i.components*i.byteLength;case rk:return t*e/i.components*i.byteLength;case ik:return t*e*2/i.components*i.byteLength;case ak:return t*e*2/i.components*i.byteLength;case k9:return t*e*3/i.components*i.byteLength;case xo:return t*e*4/i.components*i.byteLength;case sk:return t*e*4/i.components*i.byteLength;case v_:case b_:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case y_:case __:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case JN:case t3:return Math.max(t,16)*Math.max(e,8)/4;case QN:case e3:return Math.max(t,8)*Math.max(e,8)/2;case n3:case r3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case i3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case a3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case s3:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case o3:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case l3:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case c3:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case u3:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case d3:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case f3:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case h3:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case p3:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case m3:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case g3:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case x3:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case v3:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case b3:case y3:case _3:return Math.ceil(t/4)*Math.ceil(e/4)*16;case S3:case w3:return Math.ceil(t/4)*Math.ceil(e/4)*8;case M3:case E3:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function pde(t){switch(t){case rl:case T9:return{byteLength:1,components:1};case Zx:case C9:case Em:return{byteLength:2,components:1};case tk:case nk:return{byteLength:2,components:4};case Cf:case ek:case nc:return{byteLength:4,components:1};case N9:case R9:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:QP}}));typeof window<"u"&&(window.__THREE__?Xt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=QP);function i7(){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 mde(t){const e=new WeakMap;function n(o,l){const c=o.array,u=o.usage,h=c.byteLength,g=t.createBuffer();t.bindBuffer(l,g),t.bufferData(l,c,u),o.onUploadCallback();let m;if(c instanceof Float32Array)m=t.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)m=t.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?m=t.HALF_FLOAT:m=t.UNSIGNED_SHORT;else if(c instanceof Int16Array)m=t.SHORT;else if(c instanceof Uint32Array)m=t.UNSIGNED_INT;else if(c instanceof Int32Array)m=t.INT;else if(c instanceof Int8Array)m=t.BYTE;else if(c instanceof Uint8Array)m=t.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)m=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:g,type:m,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:h}}function r(o,l,c){const u=l.array,h=l.updateRanges;if(t.bindBuffer(c,o),h.length===0)t.bufferSubData(c,0,u);else{h.sort((m,b)=>m.start-b.start);let g=0;for(let m=1;m<h.length;m++){const b=h[g],y=h[m];y.start<=b.start+b.count+1?b.count=Math.max(b.count,y.start+y.count-b.start):(++g,h[g]=y)}h.length=g+1;for(let m=0,b=h.length;m<b;m++){const y=h[m];t.bufferSubData(c,y.start*u.BYTES_PER_ELEMENT,u,y.start,y.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function a(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(t.deleteBuffer(l.buffer),e.delete(o))}function s(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const u=e.get(o);(!u||u.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,n(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");r(c.buffer,o,l),c.version=o.version}}return{get:i,remove:a,update:s}}var gde=`#ifdef USE_ALPHAHASH
  34. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  35. #endif`,xde=`#ifdef USE_ALPHAHASH
  36. const float ALPHA_HASH_SCALE = 0.05;
  37. float hash2D( vec2 value ) {
  38. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  39. }
  40. float hash3D( vec3 value ) {
  41. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  42. }
  43. float getAlphaHashThreshold( vec3 position ) {
  44. float maxDeriv = max(
  45. length( dFdx( position.xyz ) ),
  46. length( dFdy( position.xyz ) )
  47. );
  48. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  49. vec2 pixScales = vec2(
  50. exp2( floor( log2( pixScale ) ) ),
  51. exp2( ceil( log2( pixScale ) ) )
  52. );
  53. vec2 alpha = vec2(
  54. hash3D( floor( pixScales.x * position.xyz ) ),
  55. hash3D( floor( pixScales.y * position.xyz ) )
  56. );
  57. float lerpFactor = fract( log2( pixScale ) );
  58. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  59. float a = min( lerpFactor, 1.0 - lerpFactor );
  60. vec3 cases = vec3(
  61. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  62. ( x - 0.5 * a ) / ( 1.0 - a ),
  63. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  64. );
  65. float threshold = ( x < ( 1.0 - a ) )
  66. ? ( ( x < a ) ? cases.x : cases.y )
  67. : cases.z;
  68. return clamp( threshold , 1.0e-6, 1.0 );
  69. }
  70. #endif`,vde=`#ifdef USE_ALPHAMAP
  71. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  72. #endif`,bde=`#ifdef USE_ALPHAMAP
  73. uniform sampler2D alphaMap;
  74. #endif`,yde=`#ifdef USE_ALPHATEST
  75. #ifdef ALPHA_TO_COVERAGE
  76. diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
  77. if ( diffuseColor.a == 0.0 ) discard;
  78. #else
  79. if ( diffuseColor.a < alphaTest ) discard;
  80. #endif
  81. #endif`,_de=`#ifdef USE_ALPHATEST
  82. uniform float alphaTest;
  83. #endif`,Sde=`#ifdef USE_AOMAP
  84. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  85. reflectedLight.indirectDiffuse *= ambientOcclusion;
  86. #if defined( USE_CLEARCOAT )
  87. clearcoatSpecularIndirect *= ambientOcclusion;
  88. #endif
  89. #if defined( USE_SHEEN )
  90. sheenSpecularIndirect *= ambientOcclusion;
  91. #endif
  92. #if defined( USE_ENVMAP ) && defined( STANDARD )
  93. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  94. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  95. #endif
  96. #endif`,wde=`#ifdef USE_AOMAP
  97. uniform sampler2D aoMap;
  98. uniform float aoMapIntensity;
  99. #endif`,Mde=`#ifdef USE_BATCHING
  100. #if ! defined( GL_ANGLE_multi_draw )
  101. #define gl_DrawID _gl_DrawID
  102. uniform int _gl_DrawID;
  103. #endif
  104. uniform highp sampler2D batchingTexture;
  105. uniform highp usampler2D batchingIdTexture;
  106. mat4 getBatchingMatrix( const in float i ) {
  107. int size = textureSize( batchingTexture, 0 ).x;
  108. int j = int( i ) * 4;
  109. int x = j % size;
  110. int y = j / size;
  111. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  112. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  113. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  114. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  115. return mat4( v1, v2, v3, v4 );
  116. }
  117. float getIndirectIndex( const in int i ) {
  118. int size = textureSize( batchingIdTexture, 0 ).x;
  119. int x = i % size;
  120. int y = i / size;
  121. return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
  122. }
  123. #endif
  124. #ifdef USE_BATCHING_COLOR
  125. uniform sampler2D batchingColorTexture;
  126. vec3 getBatchingColor( const in float i ) {
  127. int size = textureSize( batchingColorTexture, 0 ).x;
  128. int j = int( i );
  129. int x = j % size;
  130. int y = j / size;
  131. return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
  132. }
  133. #endif`,Ede=`#ifdef USE_BATCHING
  134. mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
  135. #endif`,Ade=`vec3 transformed = vec3( position );
  136. #ifdef USE_ALPHAHASH
  137. vPosition = vec3( position );
  138. #endif`,Tde=`vec3 objectNormal = vec3( normal );
  139. #ifdef USE_TANGENT
  140. vec3 objectTangent = vec3( tangent.xyz );
  141. #endif`,Cde=`float G_BlinnPhong_Implicit( ) {
  142. return 0.25;
  143. }
  144. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  145. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  146. }
  147. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  148. vec3 halfDir = normalize( lightDir + viewDir );
  149. float dotNH = saturate( dot( normal, halfDir ) );
  150. float dotVH = saturate( dot( viewDir, halfDir ) );
  151. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  152. float G = G_BlinnPhong_Implicit( );
  153. float D = D_BlinnPhong( shininess, dotNH );
  154. return F * ( G * D );
  155. } // validated`,Nde=`#ifdef USE_IRIDESCENCE
  156. const mat3 XYZ_TO_REC709 = mat3(
  157. 3.2404542, -0.9692660, 0.0556434,
  158. -1.5371385, 1.8760108, -0.2040259,
  159. -0.4985314, 0.0415560, 1.0572252
  160. );
  161. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  162. vec3 sqrtF0 = sqrt( fresnel0 );
  163. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  164. }
  165. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  166. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  167. }
  168. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  169. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  170. }
  171. vec3 evalSensitivity( float OPD, vec3 shift ) {
  172. float phase = 2.0 * PI * OPD * 1.0e-9;
  173. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  174. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  175. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  176. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  177. xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
  178. xyz /= 1.0685e-7;
  179. vec3 rgb = XYZ_TO_REC709 * xyz;
  180. return rgb;
  181. }
  182. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  183. vec3 I;
  184. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  185. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  186. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  187. if ( cosTheta2Sq < 0.0 ) {
  188. return vec3( 1.0 );
  189. }
  190. float cosTheta2 = sqrt( cosTheta2Sq );
  191. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  192. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  193. float T121 = 1.0 - R12;
  194. float phi12 = 0.0;
  195. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  196. float phi21 = PI - phi12;
  197. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  198. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  199. vec3 phi23 = vec3( 0.0 );
  200. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  201. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  202. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  203. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  204. vec3 phi = vec3( phi21 ) + phi23;
  205. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  206. vec3 r123 = sqrt( R123 );
  207. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  208. vec3 C0 = R12 + Rs;
  209. I = C0;
  210. vec3 Cm = Rs - T121;
  211. for ( int m = 1; m <= 2; ++ m ) {
  212. Cm *= r123;
  213. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  214. I += Cm * Sm;
  215. }
  216. return max( I, vec3( 0.0 ) );
  217. }
  218. #endif`,Rde=`#ifdef USE_BUMPMAP
  219. uniform sampler2D bumpMap;
  220. uniform float bumpScale;
  221. vec2 dHdxy_fwd() {
  222. vec2 dSTdx = dFdx( vBumpMapUv );
  223. vec2 dSTdy = dFdy( vBumpMapUv );
  224. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  225. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  226. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  227. return vec2( dBx, dBy );
  228. }
  229. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  230. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  231. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  232. vec3 vN = surf_norm;
  233. vec3 R1 = cross( vSigmaY, vN );
  234. vec3 R2 = cross( vN, vSigmaX );
  235. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  236. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  237. return normalize( abs( fDet ) * surf_norm - vGrad );
  238. }
  239. #endif`,Pde=`#if NUM_CLIPPING_PLANES > 0
  240. vec4 plane;
  241. #ifdef ALPHA_TO_COVERAGE
  242. float distanceToPlane, distanceGradient;
  243. float clipOpacity = 1.0;
  244. #pragma unroll_loop_start
  245. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  246. plane = clippingPlanes[ i ];
  247. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  248. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  249. clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  250. if ( clipOpacity == 0.0 ) discard;
  251. }
  252. #pragma unroll_loop_end
  253. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  254. float unionClipOpacity = 1.0;
  255. #pragma unroll_loop_start
  256. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  257. plane = clippingPlanes[ i ];
  258. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  259. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  260. unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  261. }
  262. #pragma unroll_loop_end
  263. clipOpacity *= 1.0 - unionClipOpacity;
  264. #endif
  265. diffuseColor.a *= clipOpacity;
  266. if ( diffuseColor.a == 0.0 ) discard;
  267. #else
  268. #pragma unroll_loop_start
  269. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  270. plane = clippingPlanes[ i ];
  271. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  272. }
  273. #pragma unroll_loop_end
  274. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  275. bool clipped = true;
  276. #pragma unroll_loop_start
  277. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  278. plane = clippingPlanes[ i ];
  279. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  280. }
  281. #pragma unroll_loop_end
  282. if ( clipped ) discard;
  283. #endif
  284. #endif
  285. #endif`,kde=`#if NUM_CLIPPING_PLANES > 0
  286. varying vec3 vClipPosition;
  287. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  288. #endif`,Dde=`#if NUM_CLIPPING_PLANES > 0
  289. varying vec3 vClipPosition;
  290. #endif`,Ode=`#if NUM_CLIPPING_PLANES > 0
  291. vClipPosition = - mvPosition.xyz;
  292. #endif`,Lde=`#if defined( USE_COLOR_ALPHA )
  293. diffuseColor *= vColor;
  294. #elif defined( USE_COLOR )
  295. diffuseColor.rgb *= vColor;
  296. #endif`,Ide=`#if defined( USE_COLOR_ALPHA )
  297. varying vec4 vColor;
  298. #elif defined( USE_COLOR )
  299. varying vec3 vColor;
  300. #endif`,jde=`#if defined( USE_COLOR_ALPHA )
  301. varying vec4 vColor;
  302. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  303. varying vec3 vColor;
  304. #endif`,Ude=`#if defined( USE_COLOR_ALPHA )
  305. vColor = vec4( 1.0 );
  306. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  307. vColor = vec3( 1.0 );
  308. #endif
  309. #ifdef USE_COLOR
  310. vColor *= color;
  311. #endif
  312. #ifdef USE_INSTANCING_COLOR
  313. vColor.xyz *= instanceColor.xyz;
  314. #endif
  315. #ifdef USE_BATCHING_COLOR
  316. vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
  317. vColor.xyz *= batchingColor.xyz;
  318. #endif`,Fde=`#define PI 3.141592653589793
  319. #define PI2 6.283185307179586
  320. #define PI_HALF 1.5707963267948966
  321. #define RECIPROCAL_PI 0.3183098861837907
  322. #define RECIPROCAL_PI2 0.15915494309189535
  323. #define EPSILON 1e-6
  324. #ifndef saturate
  325. #define saturate( a ) clamp( a, 0.0, 1.0 )
  326. #endif
  327. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  328. float pow2( const in float x ) { return x*x; }
  329. vec3 pow2( const in vec3 x ) { return x*x; }
  330. float pow3( const in float x ) { return x*x*x; }
  331. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  332. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  333. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  334. highp float rand( const in vec2 uv ) {
  335. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  336. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  337. return fract( sin( sn ) * c );
  338. }
  339. #ifdef HIGH_PRECISION
  340. float precisionSafeLength( vec3 v ) { return length( v ); }
  341. #else
  342. float precisionSafeLength( vec3 v ) {
  343. float maxComponent = max3( abs( v ) );
  344. return length( v / maxComponent ) * maxComponent;
  345. }
  346. #endif
  347. struct IncidentLight {
  348. vec3 color;
  349. vec3 direction;
  350. bool visible;
  351. };
  352. struct ReflectedLight {
  353. vec3 directDiffuse;
  354. vec3 directSpecular;
  355. vec3 indirectDiffuse;
  356. vec3 indirectSpecular;
  357. };
  358. #ifdef USE_ALPHAHASH
  359. varying vec3 vPosition;
  360. #endif
  361. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  362. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  363. }
  364. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  365. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  366. }
  367. bool isPerspectiveMatrix( mat4 m ) {
  368. return m[ 2 ][ 3 ] == - 1.0;
  369. }
  370. vec2 equirectUv( in vec3 dir ) {
  371. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  372. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  373. return vec2( u, v );
  374. }
  375. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  376. return RECIPROCAL_PI * diffuseColor;
  377. }
  378. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  379. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  380. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  381. }
  382. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  383. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  384. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  385. } // validated`,zde=`#ifdef ENVMAP_TYPE_CUBE_UV
  386. #define cubeUV_minMipLevel 4.0
  387. #define cubeUV_minTileSize 16.0
  388. float getFace( vec3 direction ) {
  389. vec3 absDirection = abs( direction );
  390. float face = - 1.0;
  391. if ( absDirection.x > absDirection.z ) {
  392. if ( absDirection.x > absDirection.y )
  393. face = direction.x > 0.0 ? 0.0 : 3.0;
  394. else
  395. face = direction.y > 0.0 ? 1.0 : 4.0;
  396. } else {
  397. if ( absDirection.z > absDirection.y )
  398. face = direction.z > 0.0 ? 2.0 : 5.0;
  399. else
  400. face = direction.y > 0.0 ? 1.0 : 4.0;
  401. }
  402. return face;
  403. }
  404. vec2 getUV( vec3 direction, float face ) {
  405. vec2 uv;
  406. if ( face == 0.0 ) {
  407. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  408. } else if ( face == 1.0 ) {
  409. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  410. } else if ( face == 2.0 ) {
  411. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  412. } else if ( face == 3.0 ) {
  413. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  414. } else if ( face == 4.0 ) {
  415. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  416. } else {
  417. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  418. }
  419. return 0.5 * ( uv + 1.0 );
  420. }
  421. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  422. float face = getFace( direction );
  423. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  424. mipInt = max( mipInt, cubeUV_minMipLevel );
  425. float faceSize = exp2( mipInt );
  426. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  427. if ( face > 2.0 ) {
  428. uv.y += faceSize;
  429. face -= 3.0;
  430. }
  431. uv.x += face * faceSize;
  432. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  433. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  434. uv.x *= CUBEUV_TEXEL_WIDTH;
  435. uv.y *= CUBEUV_TEXEL_HEIGHT;
  436. #ifdef texture2DGradEXT
  437. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  438. #else
  439. return texture2D( envMap, uv ).rgb;
  440. #endif
  441. }
  442. #define cubeUV_r0 1.0
  443. #define cubeUV_m0 - 2.0
  444. #define cubeUV_r1 0.8
  445. #define cubeUV_m1 - 1.0
  446. #define cubeUV_r4 0.4
  447. #define cubeUV_m4 2.0
  448. #define cubeUV_r5 0.305
  449. #define cubeUV_m5 3.0
  450. #define cubeUV_r6 0.21
  451. #define cubeUV_m6 4.0
  452. float roughnessToMip( float roughness ) {
  453. float mip = 0.0;
  454. if ( roughness >= cubeUV_r1 ) {
  455. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  456. } else if ( roughness >= cubeUV_r4 ) {
  457. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  458. } else if ( roughness >= cubeUV_r5 ) {
  459. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  460. } else if ( roughness >= cubeUV_r6 ) {
  461. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  462. } else {
  463. mip = - 2.0 * log2( 1.16 * roughness ); }
  464. return mip;
  465. }
  466. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  467. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  468. float mipF = fract( mip );
  469. float mipInt = floor( mip );
  470. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  471. if ( mipF == 0.0 ) {
  472. return vec4( color0, 1.0 );
  473. } else {
  474. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  475. return vec4( mix( color0, color1, mipF ), 1.0 );
  476. }
  477. }
  478. #endif`,Bde=`vec3 transformedNormal = objectNormal;
  479. #ifdef USE_TANGENT
  480. vec3 transformedTangent = objectTangent;
  481. #endif
  482. #ifdef USE_BATCHING
  483. mat3 bm = mat3( batchingMatrix );
  484. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  485. transformedNormal = bm * transformedNormal;
  486. #ifdef USE_TANGENT
  487. transformedTangent = bm * transformedTangent;
  488. #endif
  489. #endif
  490. #ifdef USE_INSTANCING
  491. mat3 im = mat3( instanceMatrix );
  492. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  493. transformedNormal = im * transformedNormal;
  494. #ifdef USE_TANGENT
  495. transformedTangent = im * transformedTangent;
  496. #endif
  497. #endif
  498. transformedNormal = normalMatrix * transformedNormal;
  499. #ifdef FLIP_SIDED
  500. transformedNormal = - transformedNormal;
  501. #endif
  502. #ifdef USE_TANGENT
  503. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  504. #ifdef FLIP_SIDED
  505. transformedTangent = - transformedTangent;
  506. #endif
  507. #endif`,Hde=`#ifdef USE_DISPLACEMENTMAP
  508. uniform sampler2D displacementMap;
  509. uniform float displacementScale;
  510. uniform float displacementBias;
  511. #endif`,$de=`#ifdef USE_DISPLACEMENTMAP
  512. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  513. #endif`,Vde=`#ifdef USE_EMISSIVEMAP
  514. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  515. #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
  516. emissiveColor = sRGBTransferEOTF( emissiveColor );
  517. #endif
  518. totalEmissiveRadiance *= emissiveColor.rgb;
  519. #endif`,Gde=`#ifdef USE_EMISSIVEMAP
  520. uniform sampler2D emissiveMap;
  521. #endif`,Wde="gl_FragColor = linearToOutputTexel( gl_FragColor );",qde=`vec4 LinearTransferOETF( in vec4 value ) {
  522. return value;
  523. }
  524. vec4 sRGBTransferEOTF( in vec4 value ) {
  525. return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
  526. }
  527. vec4 sRGBTransferOETF( in vec4 value ) {
  528. return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
  529. }`,Xde=`#ifdef USE_ENVMAP
  530. #ifdef ENV_WORLDPOS
  531. vec3 cameraToFrag;
  532. if ( isOrthographic ) {
  533. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  534. } else {
  535. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  536. }
  537. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  538. #ifdef ENVMAP_MODE_REFLECTION
  539. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  540. #else
  541. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  542. #endif
  543. #else
  544. vec3 reflectVec = vReflect;
  545. #endif
  546. #ifdef ENVMAP_TYPE_CUBE
  547. vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  548. #else
  549. vec4 envColor = vec4( 0.0 );
  550. #endif
  551. #ifdef ENVMAP_BLENDING_MULTIPLY
  552. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  553. #elif defined( ENVMAP_BLENDING_MIX )
  554. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  555. #elif defined( ENVMAP_BLENDING_ADD )
  556. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  557. #endif
  558. #endif`,Kde=`#ifdef USE_ENVMAP
  559. uniform float envMapIntensity;
  560. uniform float flipEnvMap;
  561. uniform mat3 envMapRotation;
  562. #ifdef ENVMAP_TYPE_CUBE
  563. uniform samplerCube envMap;
  564. #else
  565. uniform sampler2D envMap;
  566. #endif
  567. #endif`,Yde=`#ifdef USE_ENVMAP
  568. uniform float reflectivity;
  569. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  570. #define ENV_WORLDPOS
  571. #endif
  572. #ifdef ENV_WORLDPOS
  573. varying vec3 vWorldPosition;
  574. uniform float refractionRatio;
  575. #else
  576. varying vec3 vReflect;
  577. #endif
  578. #endif`,Zde=`#ifdef USE_ENVMAP
  579. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  580. #define ENV_WORLDPOS
  581. #endif
  582. #ifdef ENV_WORLDPOS
  583. varying vec3 vWorldPosition;
  584. #else
  585. varying vec3 vReflect;
  586. uniform float refractionRatio;
  587. #endif
  588. #endif`,Qde=`#ifdef USE_ENVMAP
  589. #ifdef ENV_WORLDPOS
  590. vWorldPosition = worldPosition.xyz;
  591. #else
  592. vec3 cameraToVertex;
  593. if ( isOrthographic ) {
  594. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  595. } else {
  596. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  597. }
  598. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  599. #ifdef ENVMAP_MODE_REFLECTION
  600. vReflect = reflect( cameraToVertex, worldNormal );
  601. #else
  602. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  603. #endif
  604. #endif
  605. #endif`,Jde=`#ifdef USE_FOG
  606. vFogDepth = - mvPosition.z;
  607. #endif`,efe=`#ifdef USE_FOG
  608. varying float vFogDepth;
  609. #endif`,tfe=`#ifdef USE_FOG
  610. #ifdef FOG_EXP2
  611. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  612. #else
  613. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  614. #endif
  615. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  616. #endif`,nfe=`#ifdef USE_FOG
  617. uniform vec3 fogColor;
  618. varying float vFogDepth;
  619. #ifdef FOG_EXP2
  620. uniform float fogDensity;
  621. #else
  622. uniform float fogNear;
  623. uniform float fogFar;
  624. #endif
  625. #endif`,rfe=`#ifdef USE_GRADIENTMAP
  626. uniform sampler2D gradientMap;
  627. #endif
  628. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  629. float dotNL = dot( normal, lightDirection );
  630. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  631. #ifdef USE_GRADIENTMAP
  632. return vec3( texture2D( gradientMap, coord ).r );
  633. #else
  634. vec2 fw = fwidth( coord ) * 0.5;
  635. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  636. #endif
  637. }`,ife=`#ifdef USE_LIGHTMAP
  638. uniform sampler2D lightMap;
  639. uniform float lightMapIntensity;
  640. #endif`,afe=`LambertMaterial material;
  641. material.diffuseColor = diffuseColor.rgb;
  642. material.specularStrength = specularStrength;`,sfe=`varying vec3 vViewPosition;
  643. struct LambertMaterial {
  644. vec3 diffuseColor;
  645. float specularStrength;
  646. };
  647. void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  648. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  649. vec3 irradiance = dotNL * directLight.color;
  650. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  651. }
  652. void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  653. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  654. }
  655. #define RE_Direct RE_Direct_Lambert
  656. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,ofe=`uniform bool receiveShadow;
  657. uniform vec3 ambientLightColor;
  658. #if defined( USE_LIGHT_PROBES )
  659. uniform vec3 lightProbe[ 9 ];
  660. #endif
  661. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  662. float x = normal.x, y = normal.y, z = normal.z;
  663. vec3 result = shCoefficients[ 0 ] * 0.886227;
  664. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  665. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  666. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  667. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  668. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  669. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  670. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  671. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  672. return result;
  673. }
  674. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  675. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  676. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  677. return irradiance;
  678. }
  679. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  680. vec3 irradiance = ambientLightColor;
  681. return irradiance;
  682. }
  683. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  684. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  685. if ( cutoffDistance > 0.0 ) {
  686. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  687. }
  688. return distanceFalloff;
  689. }
  690. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  691. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  692. }
  693. #if NUM_DIR_LIGHTS > 0
  694. struct DirectionalLight {
  695. vec3 direction;
  696. vec3 color;
  697. };
  698. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  699. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  700. light.color = directionalLight.color;
  701. light.direction = directionalLight.direction;
  702. light.visible = true;
  703. }
  704. #endif
  705. #if NUM_POINT_LIGHTS > 0
  706. struct PointLight {
  707. vec3 position;
  708. vec3 color;
  709. float distance;
  710. float decay;
  711. };
  712. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  713. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  714. vec3 lVector = pointLight.position - geometryPosition;
  715. light.direction = normalize( lVector );
  716. float lightDistance = length( lVector );
  717. light.color = pointLight.color;
  718. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  719. light.visible = ( light.color != vec3( 0.0 ) );
  720. }
  721. #endif
  722. #if NUM_SPOT_LIGHTS > 0
  723. struct SpotLight {
  724. vec3 position;
  725. vec3 direction;
  726. vec3 color;
  727. float distance;
  728. float decay;
  729. float coneCos;
  730. float penumbraCos;
  731. };
  732. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  733. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  734. vec3 lVector = spotLight.position - geometryPosition;
  735. light.direction = normalize( lVector );
  736. float angleCos = dot( light.direction, spotLight.direction );
  737. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  738. if ( spotAttenuation > 0.0 ) {
  739. float lightDistance = length( lVector );
  740. light.color = spotLight.color * spotAttenuation;
  741. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  742. light.visible = ( light.color != vec3( 0.0 ) );
  743. } else {
  744. light.color = vec3( 0.0 );
  745. light.visible = false;
  746. }
  747. }
  748. #endif
  749. #if NUM_RECT_AREA_LIGHTS > 0
  750. struct RectAreaLight {
  751. vec3 color;
  752. vec3 position;
  753. vec3 halfWidth;
  754. vec3 halfHeight;
  755. };
  756. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  757. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  758. #endif
  759. #if NUM_HEMI_LIGHTS > 0
  760. struct HemisphereLight {
  761. vec3 direction;
  762. vec3 skyColor;
  763. vec3 groundColor;
  764. };
  765. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  766. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  767. float dotNL = dot( normal, hemiLight.direction );
  768. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  769. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  770. return irradiance;
  771. }
  772. #endif`,lfe=`#ifdef USE_ENVMAP
  773. vec3 getIBLIrradiance( const in vec3 normal ) {
  774. #ifdef ENVMAP_TYPE_CUBE_UV
  775. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  776. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
  777. return PI * envMapColor.rgb * envMapIntensity;
  778. #else
  779. return vec3( 0.0 );
  780. #endif
  781. }
  782. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  783. #ifdef ENVMAP_TYPE_CUBE_UV
  784. vec3 reflectVec = reflect( - viewDir, normal );
  785. reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
  786. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  787. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
  788. return envMapColor.rgb * envMapIntensity;
  789. #else
  790. return vec3( 0.0 );
  791. #endif
  792. }
  793. #ifdef USE_ANISOTROPY
  794. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  795. #ifdef ENVMAP_TYPE_CUBE_UV
  796. vec3 bentNormal = cross( bitangent, viewDir );
  797. bentNormal = normalize( cross( bentNormal, bitangent ) );
  798. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  799. return getIBLRadiance( viewDir, bentNormal, roughness );
  800. #else
  801. return vec3( 0.0 );
  802. #endif
  803. }
  804. #endif
  805. #endif`,cfe=`ToonMaterial material;
  806. material.diffuseColor = diffuseColor.rgb;`,ufe=`varying vec3 vViewPosition;
  807. struct ToonMaterial {
  808. vec3 diffuseColor;
  809. };
  810. void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  811. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  812. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  813. }
  814. void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  815. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  816. }
  817. #define RE_Direct RE_Direct_Toon
  818. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,dfe=`BlinnPhongMaterial material;
  819. material.diffuseColor = diffuseColor.rgb;
  820. material.specularColor = specular;
  821. material.specularShininess = shininess;
  822. material.specularStrength = specularStrength;`,ffe=`varying vec3 vViewPosition;
  823. struct BlinnPhongMaterial {
  824. vec3 diffuseColor;
  825. vec3 specularColor;
  826. float specularShininess;
  827. float specularStrength;
  828. };
  829. void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  830. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  831. vec3 irradiance = dotNL * directLight.color;
  832. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  833. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  834. }
  835. void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  836. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  837. }
  838. #define RE_Direct RE_Direct_BlinnPhong
  839. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,hfe=`PhysicalMaterial material;
  840. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  841. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  842. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  843. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  844. material.roughness = min( material.roughness, 1.0 );
  845. #ifdef IOR
  846. material.ior = ior;
  847. #ifdef USE_SPECULAR
  848. float specularIntensityFactor = specularIntensity;
  849. vec3 specularColorFactor = specularColor;
  850. #ifdef USE_SPECULAR_COLORMAP
  851. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  852. #endif
  853. #ifdef USE_SPECULAR_INTENSITYMAP
  854. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  855. #endif
  856. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  857. #else
  858. float specularIntensityFactor = 1.0;
  859. vec3 specularColorFactor = vec3( 1.0 );
  860. material.specularF90 = 1.0;
  861. #endif
  862. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  863. #else
  864. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  865. material.specularF90 = 1.0;
  866. #endif
  867. #ifdef USE_CLEARCOAT
  868. material.clearcoat = clearcoat;
  869. material.clearcoatRoughness = clearcoatRoughness;
  870. material.clearcoatF0 = vec3( 0.04 );
  871. material.clearcoatF90 = 1.0;
  872. #ifdef USE_CLEARCOATMAP
  873. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  874. #endif
  875. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  876. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  877. #endif
  878. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  879. material.clearcoatRoughness += geometryRoughness;
  880. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  881. #endif
  882. #ifdef USE_DISPERSION
  883. material.dispersion = dispersion;
  884. #endif
  885. #ifdef USE_IRIDESCENCE
  886. material.iridescence = iridescence;
  887. material.iridescenceIOR = iridescenceIOR;
  888. #ifdef USE_IRIDESCENCEMAP
  889. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  890. #endif
  891. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  892. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  893. #else
  894. material.iridescenceThickness = iridescenceThicknessMaximum;
  895. #endif
  896. #endif
  897. #ifdef USE_SHEEN
  898. material.sheenColor = sheenColor;
  899. #ifdef USE_SHEEN_COLORMAP
  900. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  901. #endif
  902. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  903. #ifdef USE_SHEEN_ROUGHNESSMAP
  904. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  905. #endif
  906. #endif
  907. #ifdef USE_ANISOTROPY
  908. #ifdef USE_ANISOTROPYMAP
  909. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  910. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  911. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  912. #else
  913. vec2 anisotropyV = anisotropyVector;
  914. #endif
  915. material.anisotropy = length( anisotropyV );
  916. if( material.anisotropy == 0.0 ) {
  917. anisotropyV = vec2( 1.0, 0.0 );
  918. } else {
  919. anisotropyV /= material.anisotropy;
  920. material.anisotropy = saturate( material.anisotropy );
  921. }
  922. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  923. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  924. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  925. #endif`,pfe=`uniform sampler2D dfgLUT;
  926. struct PhysicalMaterial {
  927. vec3 diffuseColor;
  928. float roughness;
  929. vec3 specularColor;
  930. float specularF90;
  931. float dispersion;
  932. #ifdef USE_CLEARCOAT
  933. float clearcoat;
  934. float clearcoatRoughness;
  935. vec3 clearcoatF0;
  936. float clearcoatF90;
  937. #endif
  938. #ifdef USE_IRIDESCENCE
  939. float iridescence;
  940. float iridescenceIOR;
  941. float iridescenceThickness;
  942. vec3 iridescenceFresnel;
  943. vec3 iridescenceF0;
  944. #endif
  945. #ifdef USE_SHEEN
  946. vec3 sheenColor;
  947. float sheenRoughness;
  948. #endif
  949. #ifdef IOR
  950. float ior;
  951. #endif
  952. #ifdef USE_TRANSMISSION
  953. float transmission;
  954. float transmissionAlpha;
  955. float thickness;
  956. float attenuationDistance;
  957. vec3 attenuationColor;
  958. #endif
  959. #ifdef USE_ANISOTROPY
  960. float anisotropy;
  961. float alphaT;
  962. vec3 anisotropyT;
  963. vec3 anisotropyB;
  964. #endif
  965. };
  966. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  967. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  968. vec3 sheenSpecularDirect = vec3( 0.0 );
  969. vec3 sheenSpecularIndirect = vec3(0.0 );
  970. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  971. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  972. float x2 = x * x;
  973. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  974. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  975. }
  976. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  977. float a2 = pow2( alpha );
  978. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  979. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  980. return 0.5 / max( gv + gl, EPSILON );
  981. }
  982. float D_GGX( const in float alpha, const in float dotNH ) {
  983. float a2 = pow2( alpha );
  984. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  985. return RECIPROCAL_PI * a2 / pow2( denom );
  986. }
  987. #ifdef USE_ANISOTROPY
  988. float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
  989. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  990. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  991. float v = 0.5 / ( gv + gl );
  992. return saturate(v);
  993. }
  994. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  995. float a2 = alphaT * alphaB;
  996. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  997. highp float v2 = dot( v, v );
  998. float w2 = a2 / v2;
  999. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  1000. }
  1001. #endif
  1002. #ifdef USE_CLEARCOAT
  1003. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  1004. vec3 f0 = material.clearcoatF0;
  1005. float f90 = material.clearcoatF90;
  1006. float roughness = material.clearcoatRoughness;
  1007. float alpha = pow2( roughness );
  1008. vec3 halfDir = normalize( lightDir + viewDir );
  1009. float dotNL = saturate( dot( normal, lightDir ) );
  1010. float dotNV = saturate( dot( normal, viewDir ) );
  1011. float dotNH = saturate( dot( normal, halfDir ) );
  1012. float dotVH = saturate( dot( viewDir, halfDir ) );
  1013. vec3 F = F_Schlick( f0, f90, dotVH );
  1014. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1015. float D = D_GGX( alpha, dotNH );
  1016. return F * ( V * D );
  1017. }
  1018. #endif
  1019. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1020. vec3 f0 = material.specularColor;
  1021. float f90 = material.specularF90;
  1022. float roughness = material.roughness;
  1023. float alpha = pow2( roughness );
  1024. vec3 halfDir = normalize( lightDir + viewDir );
  1025. float dotNL = saturate( dot( normal, lightDir ) );
  1026. float dotNV = saturate( dot( normal, viewDir ) );
  1027. float dotNH = saturate( dot( normal, halfDir ) );
  1028. float dotVH = saturate( dot( viewDir, halfDir ) );
  1029. vec3 F = F_Schlick( f0, f90, dotVH );
  1030. #ifdef USE_IRIDESCENCE
  1031. F = mix( F, material.iridescenceFresnel, material.iridescence );
  1032. #endif
  1033. #ifdef USE_ANISOTROPY
  1034. float dotTL = dot( material.anisotropyT, lightDir );
  1035. float dotTV = dot( material.anisotropyT, viewDir );
  1036. float dotTH = dot( material.anisotropyT, halfDir );
  1037. float dotBL = dot( material.anisotropyB, lightDir );
  1038. float dotBV = dot( material.anisotropyB, viewDir );
  1039. float dotBH = dot( material.anisotropyB, halfDir );
  1040. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  1041. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  1042. #else
  1043. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1044. float D = D_GGX( alpha, dotNH );
  1045. #endif
  1046. return F * ( V * D );
  1047. }
  1048. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  1049. const float LUT_SIZE = 64.0;
  1050. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  1051. const float LUT_BIAS = 0.5 / LUT_SIZE;
  1052. float dotNV = saturate( dot( N, V ) );
  1053. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  1054. uv = uv * LUT_SCALE + LUT_BIAS;
  1055. return uv;
  1056. }
  1057. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  1058. float l = length( f );
  1059. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  1060. }
  1061. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  1062. float x = dot( v1, v2 );
  1063. float y = abs( x );
  1064. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  1065. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  1066. float v = a / b;
  1067. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  1068. return cross( v1, v2 ) * theta_sintheta;
  1069. }
  1070. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  1071. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  1072. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  1073. vec3 lightNormal = cross( v1, v2 );
  1074. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  1075. vec3 T1, T2;
  1076. T1 = normalize( V - N * dot( V, N ) );
  1077. T2 = - cross( N, T1 );
  1078. mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
  1079. vec3 coords[ 4 ];
  1080. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  1081. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  1082. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  1083. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  1084. coords[ 0 ] = normalize( coords[ 0 ] );
  1085. coords[ 1 ] = normalize( coords[ 1 ] );
  1086. coords[ 2 ] = normalize( coords[ 2 ] );
  1087. coords[ 3 ] = normalize( coords[ 3 ] );
  1088. vec3 vectorFormFactor = vec3( 0.0 );
  1089. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  1090. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  1091. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  1092. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  1093. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  1094. return vec3( result );
  1095. }
  1096. #if defined( USE_SHEEN )
  1097. float D_Charlie( float roughness, float dotNH ) {
  1098. float alpha = pow2( roughness );
  1099. float invAlpha = 1.0 / alpha;
  1100. float cos2h = dotNH * dotNH;
  1101. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  1102. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  1103. }
  1104. float V_Neubelt( float dotNV, float dotNL ) {
  1105. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  1106. }
  1107. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  1108. vec3 halfDir = normalize( lightDir + viewDir );
  1109. float dotNL = saturate( dot( normal, lightDir ) );
  1110. float dotNV = saturate( dot( normal, viewDir ) );
  1111. float dotNH = saturate( dot( normal, halfDir ) );
  1112. float D = D_Charlie( sheenRoughness, dotNH );
  1113. float V = V_Neubelt( dotNV, dotNL );
  1114. return sheenColor * ( D * V );
  1115. }
  1116. #endif
  1117. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1118. float dotNV = saturate( dot( normal, viewDir ) );
  1119. float r2 = roughness * roughness;
  1120. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  1121. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  1122. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  1123. return saturate( DG * RECIPROCAL_PI );
  1124. }
  1125. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1126. float dotNV = saturate( dot( normal, viewDir ) );
  1127. vec2 uv = vec2( roughness, dotNV );
  1128. return texture2D( dfgLUT, uv ).rg;
  1129. }
  1130. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  1131. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1132. return specularColor * fab.x + specularF90 * fab.y;
  1133. }
  1134. #ifdef USE_IRIDESCENCE
  1135. void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  1136. #else
  1137. void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  1138. #endif
  1139. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1140. #ifdef USE_IRIDESCENCE
  1141. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  1142. #else
  1143. vec3 Fr = specularColor;
  1144. #endif
  1145. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  1146. float Ess = fab.x + fab.y;
  1147. float Ems = 1.0 - Ess;
  1148. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  1149. singleScatter += FssEss;
  1150. multiScatter += Fms * Ems;
  1151. }
  1152. vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1153. vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
  1154. float dotNL = saturate( dot( normal, lightDir ) );
  1155. float dotNV = saturate( dot( normal, viewDir ) );
  1156. vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
  1157. vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
  1158. vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
  1159. vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
  1160. float Ess_V = dfgV.x + dfgV.y;
  1161. float Ess_L = dfgL.x + dfgL.y;
  1162. float Ems_V = 1.0 - Ess_V;
  1163. float Ems_L = 1.0 - Ess_L;
  1164. vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
  1165. vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
  1166. float compensationFactor = Ems_V * Ems_L;
  1167. vec3 multiScatter = Fms * compensationFactor;
  1168. return singleScatter + multiScatter;
  1169. }
  1170. #if NUM_RECT_AREA_LIGHTS > 0
  1171. void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1172. vec3 normal = geometryNormal;
  1173. vec3 viewDir = geometryViewDir;
  1174. vec3 position = geometryPosition;
  1175. vec3 lightPos = rectAreaLight.position;
  1176. vec3 halfWidth = rectAreaLight.halfWidth;
  1177. vec3 halfHeight = rectAreaLight.halfHeight;
  1178. vec3 lightColor = rectAreaLight.color;
  1179. float roughness = material.roughness;
  1180. vec3 rectCoords[ 4 ];
  1181. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  1182. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  1183. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  1184. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  1185. vec4 t1 = texture2D( ltc_1, uv );
  1186. vec4 t2 = texture2D( ltc_2, uv );
  1187. mat3 mInv = mat3(
  1188. vec3( t1.x, 0, t1.y ),
  1189. vec3( 0, 1, 0 ),
  1190. vec3( t1.z, 0, t1.w )
  1191. );
  1192. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  1193. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  1194. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  1195. }
  1196. #endif
  1197. void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1198. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  1199. vec3 irradiance = dotNL * directLight.color;
  1200. #ifdef USE_CLEARCOAT
  1201. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  1202. vec3 ccIrradiance = dotNLcc * directLight.color;
  1203. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  1204. #endif
  1205. #ifdef USE_SHEEN
  1206. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  1207. #endif
  1208. reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
  1209. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1210. }
  1211. void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1212. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1213. }
  1214. void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
  1215. #ifdef USE_CLEARCOAT
  1216. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  1217. #endif
  1218. #ifdef USE_SHEEN
  1219. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1220. #endif
  1221. vec3 singleScattering = vec3( 0.0 );
  1222. vec3 multiScattering = vec3( 0.0 );
  1223. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1224. #ifdef USE_IRIDESCENCE
  1225. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  1226. #else
  1227. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  1228. #endif
  1229. vec3 totalScattering = singleScattering + multiScattering;
  1230. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  1231. reflectedLight.indirectSpecular += radiance * singleScattering;
  1232. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1233. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  1234. }
  1235. #define RE_Direct RE_Direct_Physical
  1236. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1237. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1238. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1239. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1240. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1241. }`,mfe=`
  1242. vec3 geometryPosition = - vViewPosition;
  1243. vec3 geometryNormal = normal;
  1244. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1245. vec3 geometryClearcoatNormal = vec3( 0.0 );
  1246. #ifdef USE_CLEARCOAT
  1247. geometryClearcoatNormal = clearcoatNormal;
  1248. #endif
  1249. #ifdef USE_IRIDESCENCE
  1250. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  1251. if ( material.iridescenceThickness == 0.0 ) {
  1252. material.iridescence = 0.0;
  1253. } else {
  1254. material.iridescence = saturate( material.iridescence );
  1255. }
  1256. if ( material.iridescence > 0.0 ) {
  1257. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  1258. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  1259. }
  1260. #endif
  1261. IncidentLight directLight;
  1262. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1263. PointLight pointLight;
  1264. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  1265. PointLightShadow pointLightShadow;
  1266. #endif
  1267. #pragma unroll_loop_start
  1268. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1269. pointLight = pointLights[ i ];
  1270. getPointLightInfo( pointLight, geometryPosition, directLight );
  1271. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  1272. pointLightShadow = pointLightShadows[ i ];
  1273. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  1274. #endif
  1275. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1276. }
  1277. #pragma unroll_loop_end
  1278. #endif
  1279. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1280. SpotLight spotLight;
  1281. vec4 spotColor;
  1282. vec3 spotLightCoord;
  1283. bool inSpotLightMap;
  1284. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1285. SpotLightShadow spotLightShadow;
  1286. #endif
  1287. #pragma unroll_loop_start
  1288. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1289. spotLight = spotLights[ i ];
  1290. getSpotLightInfo( spotLight, geometryPosition, directLight );
  1291. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1292. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  1293. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1294. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  1295. #else
  1296. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1297. #endif
  1298. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  1299. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  1300. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  1301. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  1302. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  1303. #endif
  1304. #undef SPOT_LIGHT_MAP_INDEX
  1305. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1306. spotLightShadow = spotLightShadows[ i ];
  1307. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1308. #endif
  1309. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1310. }
  1311. #pragma unroll_loop_end
  1312. #endif
  1313. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1314. DirectionalLight directionalLight;
  1315. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1316. DirectionalLightShadow directionalLightShadow;
  1317. #endif
  1318. #pragma unroll_loop_start
  1319. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1320. directionalLight = directionalLights[ i ];
  1321. getDirectionalLightInfo( directionalLight, directLight );
  1322. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1323. directionalLightShadow = directionalLightShadows[ i ];
  1324. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1325. #endif
  1326. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1327. }
  1328. #pragma unroll_loop_end
  1329. #endif
  1330. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1331. RectAreaLight rectAreaLight;
  1332. #pragma unroll_loop_start
  1333. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1334. rectAreaLight = rectAreaLights[ i ];
  1335. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1336. }
  1337. #pragma unroll_loop_end
  1338. #endif
  1339. #if defined( RE_IndirectDiffuse )
  1340. vec3 iblIrradiance = vec3( 0.0 );
  1341. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1342. #if defined( USE_LIGHT_PROBES )
  1343. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  1344. #endif
  1345. #if ( NUM_HEMI_LIGHTS > 0 )
  1346. #pragma unroll_loop_start
  1347. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1348. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  1349. }
  1350. #pragma unroll_loop_end
  1351. #endif
  1352. #endif
  1353. #if defined( RE_IndirectSpecular )
  1354. vec3 radiance = vec3( 0.0 );
  1355. vec3 clearcoatRadiance = vec3( 0.0 );
  1356. #endif`,gfe=`#if defined( RE_IndirectDiffuse )
  1357. #ifdef USE_LIGHTMAP
  1358. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  1359. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  1360. irradiance += lightMapIrradiance;
  1361. #endif
  1362. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1363. iblIrradiance += getIBLIrradiance( geometryNormal );
  1364. #endif
  1365. #endif
  1366. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1367. #ifdef USE_ANISOTROPY
  1368. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  1369. #else
  1370. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  1371. #endif
  1372. #ifdef USE_CLEARCOAT
  1373. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  1374. #endif
  1375. #endif`,xfe=`#if defined( RE_IndirectDiffuse )
  1376. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1377. #endif
  1378. #if defined( RE_IndirectSpecular )
  1379. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1380. #endif`,vfe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1381. gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1382. #endif`,bfe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1383. uniform float logDepthBufFC;
  1384. varying float vFragDepth;
  1385. varying float vIsPerspective;
  1386. #endif`,yfe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1387. varying float vFragDepth;
  1388. varying float vIsPerspective;
  1389. #endif`,_fe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1390. vFragDepth = 1.0 + gl_Position.w;
  1391. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1392. #endif`,Sfe=`#ifdef USE_MAP
  1393. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  1394. #ifdef DECODE_VIDEO_TEXTURE
  1395. sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
  1396. #endif
  1397. diffuseColor *= sampledDiffuseColor;
  1398. #endif`,wfe=`#ifdef USE_MAP
  1399. uniform sampler2D map;
  1400. #endif`,Mfe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1401. #if defined( USE_POINTS_UV )
  1402. vec2 uv = vUv;
  1403. #else
  1404. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1405. #endif
  1406. #endif
  1407. #ifdef USE_MAP
  1408. diffuseColor *= texture2D( map, uv );
  1409. #endif
  1410. #ifdef USE_ALPHAMAP
  1411. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1412. #endif`,Efe=`#if defined( USE_POINTS_UV )
  1413. varying vec2 vUv;
  1414. #else
  1415. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1416. uniform mat3 uvTransform;
  1417. #endif
  1418. #endif
  1419. #ifdef USE_MAP
  1420. uniform sampler2D map;
  1421. #endif
  1422. #ifdef USE_ALPHAMAP
  1423. uniform sampler2D alphaMap;
  1424. #endif`,Afe=`float metalnessFactor = metalness;
  1425. #ifdef USE_METALNESSMAP
  1426. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  1427. metalnessFactor *= texelMetalness.b;
  1428. #endif`,Tfe=`#ifdef USE_METALNESSMAP
  1429. uniform sampler2D metalnessMap;
  1430. #endif`,Cfe=`#ifdef USE_INSTANCING_MORPH
  1431. float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1432. float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
  1433. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1434. morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
  1435. }
  1436. #endif`,Nfe=`#if defined( USE_MORPHCOLORS )
  1437. vColor *= morphTargetBaseInfluence;
  1438. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1439. #if defined( USE_COLOR_ALPHA )
  1440. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  1441. #elif defined( USE_COLOR )
  1442. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  1443. #endif
  1444. }
  1445. #endif`,Rfe=`#ifdef USE_MORPHNORMALS
  1446. objectNormal *= morphTargetBaseInfluence;
  1447. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1448. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  1449. }
  1450. #endif`,Pfe=`#ifdef USE_MORPHTARGETS
  1451. #ifndef USE_INSTANCING_MORPH
  1452. uniform float morphTargetBaseInfluence;
  1453. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1454. #endif
  1455. uniform sampler2DArray morphTargetsTexture;
  1456. uniform ivec2 morphTargetsTextureSize;
  1457. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  1458. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  1459. int y = texelIndex / morphTargetsTextureSize.x;
  1460. int x = texelIndex - y * morphTargetsTextureSize.x;
  1461. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  1462. return texelFetch( morphTargetsTexture, morphUV, 0 );
  1463. }
  1464. #endif`,kfe=`#ifdef USE_MORPHTARGETS
  1465. transformed *= morphTargetBaseInfluence;
  1466. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1467. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  1468. }
  1469. #endif`,Dfe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  1470. #ifdef FLAT_SHADED
  1471. vec3 fdx = dFdx( vViewPosition );
  1472. vec3 fdy = dFdy( vViewPosition );
  1473. vec3 normal = normalize( cross( fdx, fdy ) );
  1474. #else
  1475. vec3 normal = normalize( vNormal );
  1476. #ifdef DOUBLE_SIDED
  1477. normal *= faceDirection;
  1478. #endif
  1479. #endif
  1480. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  1481. #ifdef USE_TANGENT
  1482. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1483. #else
  1484. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  1485. #if defined( USE_NORMALMAP )
  1486. vNormalMapUv
  1487. #elif defined( USE_CLEARCOAT_NORMALMAP )
  1488. vClearcoatNormalMapUv
  1489. #else
  1490. vUv
  1491. #endif
  1492. );
  1493. #endif
  1494. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1495. tbn[0] *= faceDirection;
  1496. tbn[1] *= faceDirection;
  1497. #endif
  1498. #endif
  1499. #ifdef USE_CLEARCOAT_NORMALMAP
  1500. #ifdef USE_TANGENT
  1501. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1502. #else
  1503. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  1504. #endif
  1505. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1506. tbn2[0] *= faceDirection;
  1507. tbn2[1] *= faceDirection;
  1508. #endif
  1509. #endif
  1510. vec3 nonPerturbedNormal = normal;`,Ofe=`#ifdef USE_NORMALMAP_OBJECTSPACE
  1511. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1512. #ifdef FLIP_SIDED
  1513. normal = - normal;
  1514. #endif
  1515. #ifdef DOUBLE_SIDED
  1516. normal = normal * faceDirection;
  1517. #endif
  1518. normal = normalize( normalMatrix * normal );
  1519. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  1520. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1521. mapN.xy *= normalScale;
  1522. normal = normalize( tbn * mapN );
  1523. #elif defined( USE_BUMPMAP )
  1524. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  1525. #endif`,Lfe=`#ifndef FLAT_SHADED
  1526. varying vec3 vNormal;
  1527. #ifdef USE_TANGENT
  1528. varying vec3 vTangent;
  1529. varying vec3 vBitangent;
  1530. #endif
  1531. #endif`,Ife=`#ifndef FLAT_SHADED
  1532. varying vec3 vNormal;
  1533. #ifdef USE_TANGENT
  1534. varying vec3 vTangent;
  1535. varying vec3 vBitangent;
  1536. #endif
  1537. #endif`,jfe=`#ifndef FLAT_SHADED
  1538. vNormal = normalize( transformedNormal );
  1539. #ifdef USE_TANGENT
  1540. vTangent = normalize( transformedTangent );
  1541. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  1542. #endif
  1543. #endif`,Ufe=`#ifdef USE_NORMALMAP
  1544. uniform sampler2D normalMap;
  1545. uniform vec2 normalScale;
  1546. #endif
  1547. #ifdef USE_NORMALMAP_OBJECTSPACE
  1548. uniform mat3 normalMatrix;
  1549. #endif
  1550. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  1551. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  1552. vec3 q0 = dFdx( eye_pos.xyz );
  1553. vec3 q1 = dFdy( eye_pos.xyz );
  1554. vec2 st0 = dFdx( uv.st );
  1555. vec2 st1 = dFdy( uv.st );
  1556. vec3 N = surf_norm;
  1557. vec3 q1perp = cross( q1, N );
  1558. vec3 q0perp = cross( N, q0 );
  1559. vec3 T = q1perp * st0.x + q0perp * st1.x;
  1560. vec3 B = q1perp * st0.y + q0perp * st1.y;
  1561. float det = max( dot( T, T ), dot( B, B ) );
  1562. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  1563. return mat3( T * scale, B * scale, N );
  1564. }
  1565. #endif`,Ffe=`#ifdef USE_CLEARCOAT
  1566. vec3 clearcoatNormal = nonPerturbedNormal;
  1567. #endif`,zfe=`#ifdef USE_CLEARCOAT_NORMALMAP
  1568. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  1569. clearcoatMapN.xy *= clearcoatNormalScale;
  1570. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  1571. #endif`,Bfe=`#ifdef USE_CLEARCOATMAP
  1572. uniform sampler2D clearcoatMap;
  1573. #endif
  1574. #ifdef USE_CLEARCOAT_NORMALMAP
  1575. uniform sampler2D clearcoatNormalMap;
  1576. uniform vec2 clearcoatNormalScale;
  1577. #endif
  1578. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1579. uniform sampler2D clearcoatRoughnessMap;
  1580. #endif`,Hfe=`#ifdef USE_IRIDESCENCEMAP
  1581. uniform sampler2D iridescenceMap;
  1582. #endif
  1583. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1584. uniform sampler2D iridescenceThicknessMap;
  1585. #endif`,$fe=`#ifdef OPAQUE
  1586. diffuseColor.a = 1.0;
  1587. #endif
  1588. #ifdef USE_TRANSMISSION
  1589. diffuseColor.a *= material.transmissionAlpha;
  1590. #endif
  1591. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Vfe=`vec3 packNormalToRGB( const in vec3 normal ) {
  1592. return normalize( normal ) * 0.5 + 0.5;
  1593. }
  1594. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1595. return 2.0 * rgb.xyz - 1.0;
  1596. }
  1597. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
  1598. const float Inv255 = 1. / 255.;
  1599. const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
  1600. const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
  1601. const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
  1602. const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
  1603. vec4 packDepthToRGBA( const in float v ) {
  1604. if( v <= 0.0 )
  1605. return vec4( 0., 0., 0., 0. );
  1606. if( v >= 1.0 )
  1607. return vec4( 1., 1., 1., 1. );
  1608. float vuf;
  1609. float af = modf( v * PackFactors.a, vuf );
  1610. float bf = modf( vuf * ShiftRight8, vuf );
  1611. float gf = modf( vuf * ShiftRight8, vuf );
  1612. return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
  1613. }
  1614. vec3 packDepthToRGB( const in float v ) {
  1615. if( v <= 0.0 )
  1616. return vec3( 0., 0., 0. );
  1617. if( v >= 1.0 )
  1618. return vec3( 1., 1., 1. );
  1619. float vuf;
  1620. float bf = modf( v * PackFactors.b, vuf );
  1621. float gf = modf( vuf * ShiftRight8, vuf );
  1622. return vec3( vuf * Inv255, gf * PackUpscale, bf );
  1623. }
  1624. vec2 packDepthToRG( const in float v ) {
  1625. if( v <= 0.0 )
  1626. return vec2( 0., 0. );
  1627. if( v >= 1.0 )
  1628. return vec2( 1., 1. );
  1629. float vuf;
  1630. float gf = modf( v * 256., vuf );
  1631. return vec2( vuf * Inv255, gf );
  1632. }
  1633. float unpackRGBAToDepth( const in vec4 v ) {
  1634. return dot( v, UnpackFactors4 );
  1635. }
  1636. float unpackRGBToDepth( const in vec3 v ) {
  1637. return dot( v, UnpackFactors3 );
  1638. }
  1639. float unpackRGToDepth( const in vec2 v ) {
  1640. return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
  1641. }
  1642. vec4 pack2HalfToRGBA( const in vec2 v ) {
  1643. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  1644. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  1645. }
  1646. vec2 unpackRGBATo2Half( const in vec4 v ) {
  1647. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1648. }
  1649. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1650. return ( viewZ + near ) / ( near - far );
  1651. }
  1652. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1653. return depth * ( near - far ) - near;
  1654. }
  1655. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1656. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  1657. }
  1658. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1659. return ( near * far ) / ( ( far - near ) * depth - far );
  1660. }`,Gfe=`#ifdef PREMULTIPLIED_ALPHA
  1661. gl_FragColor.rgb *= gl_FragColor.a;
  1662. #endif`,Wfe=`vec4 mvPosition = vec4( transformed, 1.0 );
  1663. #ifdef USE_BATCHING
  1664. mvPosition = batchingMatrix * mvPosition;
  1665. #endif
  1666. #ifdef USE_INSTANCING
  1667. mvPosition = instanceMatrix * mvPosition;
  1668. #endif
  1669. mvPosition = modelViewMatrix * mvPosition;
  1670. gl_Position = projectionMatrix * mvPosition;`,qfe=`#ifdef DITHERING
  1671. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1672. #endif`,Xfe=`#ifdef DITHERING
  1673. vec3 dithering( vec3 color ) {
  1674. float grid_position = rand( gl_FragCoord.xy );
  1675. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1676. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1677. return color + dither_shift_RGB;
  1678. }
  1679. #endif`,Kfe=`float roughnessFactor = roughness;
  1680. #ifdef USE_ROUGHNESSMAP
  1681. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  1682. roughnessFactor *= texelRoughness.g;
  1683. #endif`,Yfe=`#ifdef USE_ROUGHNESSMAP
  1684. uniform sampler2D roughnessMap;
  1685. #endif`,Zfe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1686. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1687. #endif
  1688. #if NUM_SPOT_LIGHT_MAPS > 0
  1689. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  1690. #endif
  1691. #ifdef USE_SHADOWMAP
  1692. #if NUM_DIR_LIGHT_SHADOWS > 0
  1693. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1694. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1695. struct DirectionalLightShadow {
  1696. float shadowIntensity;
  1697. float shadowBias;
  1698. float shadowNormalBias;
  1699. float shadowRadius;
  1700. vec2 shadowMapSize;
  1701. };
  1702. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1703. #endif
  1704. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1705. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1706. struct SpotLightShadow {
  1707. float shadowIntensity;
  1708. float shadowBias;
  1709. float shadowNormalBias;
  1710. float shadowRadius;
  1711. vec2 shadowMapSize;
  1712. };
  1713. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1714. #endif
  1715. #if NUM_POINT_LIGHT_SHADOWS > 0
  1716. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1717. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1718. struct PointLightShadow {
  1719. float shadowIntensity;
  1720. float shadowBias;
  1721. float shadowNormalBias;
  1722. float shadowRadius;
  1723. vec2 shadowMapSize;
  1724. float shadowCameraNear;
  1725. float shadowCameraFar;
  1726. };
  1727. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1728. #endif
  1729. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  1730. float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
  1731. #ifdef USE_REVERSED_DEPTH_BUFFER
  1732. return step( depth, compare );
  1733. #else
  1734. return step( compare, depth );
  1735. #endif
  1736. }
  1737. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  1738. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  1739. }
  1740. float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
  1741. float occlusion = 1.0;
  1742. vec2 distribution = texture2DDistribution( shadow, uv );
  1743. #ifdef USE_REVERSED_DEPTH_BUFFER
  1744. float hard_shadow = step( distribution.x, compare );
  1745. #else
  1746. float hard_shadow = step( compare, distribution.x );
  1747. #endif
  1748. if ( hard_shadow != 1.0 ) {
  1749. float distance = compare - distribution.x;
  1750. float variance = max( 0.00000, distribution.y * distribution.y );
  1751. float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
  1752. }
  1753. return occlusion;
  1754. }
  1755. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1756. float shadow = 1.0;
  1757. shadowCoord.xyz /= shadowCoord.w;
  1758. shadowCoord.z += shadowBias;
  1759. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1760. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1761. if ( frustumTest ) {
  1762. #if defined( SHADOWMAP_TYPE_PCF )
  1763. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1764. float dx0 = - texelSize.x * shadowRadius;
  1765. float dy0 = - texelSize.y * shadowRadius;
  1766. float dx1 = + texelSize.x * shadowRadius;
  1767. float dy1 = + texelSize.y * shadowRadius;
  1768. float dx2 = dx0 / 2.0;
  1769. float dy2 = dy0 / 2.0;
  1770. float dx3 = dx1 / 2.0;
  1771. float dy3 = dy1 / 2.0;
  1772. shadow = (
  1773. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  1774. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  1775. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  1776. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  1777. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  1778. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  1779. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  1780. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  1781. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  1782. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  1783. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  1784. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  1785. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  1786. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  1787. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  1788. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  1789. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  1790. ) * ( 1.0 / 17.0 );
  1791. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  1792. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1793. float dx = texelSize.x;
  1794. float dy = texelSize.y;
  1795. vec2 uv = shadowCoord.xy;
  1796. vec2 f = fract( uv * shadowMapSize + 0.5 );
  1797. uv -= f * texelSize;
  1798. shadow = (
  1799. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  1800. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  1801. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  1802. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  1803. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  1804. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  1805. f.x ) +
  1806. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  1807. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  1808. f.x ) +
  1809. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  1810. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  1811. f.y ) +
  1812. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  1813. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  1814. f.y ) +
  1815. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  1816. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  1817. f.x ),
  1818. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  1819. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  1820. f.x ),
  1821. f.y )
  1822. ) * ( 1.0 / 9.0 );
  1823. #elif defined( SHADOWMAP_TYPE_VSM )
  1824. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  1825. #else
  1826. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  1827. #endif
  1828. }
  1829. return mix( 1.0, shadow, shadowIntensity );
  1830. }
  1831. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  1832. vec3 absV = abs( v );
  1833. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  1834. absV *= scaleToCube;
  1835. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  1836. vec2 planar = v.xy;
  1837. float almostATexel = 1.5 * texelSizeY;
  1838. float almostOne = 1.0 - almostATexel;
  1839. if ( absV.z >= almostOne ) {
  1840. if ( v.z > 0.0 )
  1841. planar.x = 4.0 - v.x;
  1842. } else if ( absV.x >= almostOne ) {
  1843. float signX = sign( v.x );
  1844. planar.x = v.z * signX + 2.0 * signX;
  1845. } else if ( absV.y >= almostOne ) {
  1846. float signY = sign( v.y );
  1847. planar.x = v.x + 2.0 * signY + 2.0;
  1848. planar.y = v.z * signY - 2.0;
  1849. }
  1850. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  1851. }
  1852. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1853. float shadow = 1.0;
  1854. vec3 lightToPosition = shadowCoord.xyz;
  1855. float lightToPositionLength = length( lightToPosition );
  1856. if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
  1857. float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  1858. vec3 bd3D = normalize( lightToPosition );
  1859. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  1860. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  1861. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  1862. shadow = (
  1863. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  1864. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  1865. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  1866. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  1867. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  1868. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  1869. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  1870. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  1871. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  1872. ) * ( 1.0 / 9.0 );
  1873. #else
  1874. shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  1875. #endif
  1876. }
  1877. return mix( 1.0, shadow, shadowIntensity );
  1878. }
  1879. #endif`,Qfe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1880. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  1881. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1882. #endif
  1883. #ifdef USE_SHADOWMAP
  1884. #if NUM_DIR_LIGHT_SHADOWS > 0
  1885. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1886. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1887. struct DirectionalLightShadow {
  1888. float shadowIntensity;
  1889. float shadowBias;
  1890. float shadowNormalBias;
  1891. float shadowRadius;
  1892. vec2 shadowMapSize;
  1893. };
  1894. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1895. #endif
  1896. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1897. struct SpotLightShadow {
  1898. float shadowIntensity;
  1899. float shadowBias;
  1900. float shadowNormalBias;
  1901. float shadowRadius;
  1902. vec2 shadowMapSize;
  1903. };
  1904. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1905. #endif
  1906. #if NUM_POINT_LIGHT_SHADOWS > 0
  1907. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  1908. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1909. struct PointLightShadow {
  1910. float shadowIntensity;
  1911. float shadowBias;
  1912. float shadowNormalBias;
  1913. float shadowRadius;
  1914. vec2 shadowMapSize;
  1915. float shadowCameraNear;
  1916. float shadowCameraFar;
  1917. };
  1918. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1919. #endif
  1920. #endif`,Jfe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  1921. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  1922. vec4 shadowWorldPosition;
  1923. #endif
  1924. #if defined( USE_SHADOWMAP )
  1925. #if NUM_DIR_LIGHT_SHADOWS > 0
  1926. #pragma unroll_loop_start
  1927. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1928. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  1929. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  1930. }
  1931. #pragma unroll_loop_end
  1932. #endif
  1933. #if NUM_POINT_LIGHT_SHADOWS > 0
  1934. #pragma unroll_loop_start
  1935. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1936. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  1937. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  1938. }
  1939. #pragma unroll_loop_end
  1940. #endif
  1941. #endif
  1942. #if NUM_SPOT_LIGHT_COORDS > 0
  1943. #pragma unroll_loop_start
  1944. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  1945. shadowWorldPosition = worldPosition;
  1946. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1947. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  1948. #endif
  1949. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  1950. }
  1951. #pragma unroll_loop_end
  1952. #endif`,ehe=`float getShadowMask() {
  1953. float shadow = 1.0;
  1954. #ifdef USE_SHADOWMAP
  1955. #if NUM_DIR_LIGHT_SHADOWS > 0
  1956. DirectionalLightShadow directionalLight;
  1957. #pragma unroll_loop_start
  1958. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1959. directionalLight = directionalLightShadows[ i ];
  1960. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1961. }
  1962. #pragma unroll_loop_end
  1963. #endif
  1964. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1965. SpotLightShadow spotLight;
  1966. #pragma unroll_loop_start
  1967. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  1968. spotLight = spotLightShadows[ i ];
  1969. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1970. }
  1971. #pragma unroll_loop_end
  1972. #endif
  1973. #if NUM_POINT_LIGHT_SHADOWS > 0
  1974. PointLightShadow pointLight;
  1975. #pragma unroll_loop_start
  1976. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1977. pointLight = pointLightShadows[ i ];
  1978. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  1979. }
  1980. #pragma unroll_loop_end
  1981. #endif
  1982. #endif
  1983. return shadow;
  1984. }`,the=`#ifdef USE_SKINNING
  1985. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  1986. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  1987. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  1988. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  1989. #endif`,nhe=`#ifdef USE_SKINNING
  1990. uniform mat4 bindMatrix;
  1991. uniform mat4 bindMatrixInverse;
  1992. uniform highp sampler2D boneTexture;
  1993. mat4 getBoneMatrix( const in float i ) {
  1994. int size = textureSize( boneTexture, 0 ).x;
  1995. int j = int( i ) * 4;
  1996. int x = j % size;
  1997. int y = j / size;
  1998. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  1999. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  2000. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  2001. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  2002. return mat4( v1, v2, v3, v4 );
  2003. }
  2004. #endif`,rhe=`#ifdef USE_SKINNING
  2005. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  2006. vec4 skinned = vec4( 0.0 );
  2007. skinned += boneMatX * skinVertex * skinWeight.x;
  2008. skinned += boneMatY * skinVertex * skinWeight.y;
  2009. skinned += boneMatZ * skinVertex * skinWeight.z;
  2010. skinned += boneMatW * skinVertex * skinWeight.w;
  2011. transformed = ( bindMatrixInverse * skinned ).xyz;
  2012. #endif`,ihe=`#ifdef USE_SKINNING
  2013. mat4 skinMatrix = mat4( 0.0 );
  2014. skinMatrix += skinWeight.x * boneMatX;
  2015. skinMatrix += skinWeight.y * boneMatY;
  2016. skinMatrix += skinWeight.z * boneMatZ;
  2017. skinMatrix += skinWeight.w * boneMatW;
  2018. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  2019. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  2020. #ifdef USE_TANGENT
  2021. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  2022. #endif
  2023. #endif`,ahe=`float specularStrength;
  2024. #ifdef USE_SPECULARMAP
  2025. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  2026. specularStrength = texelSpecular.r;
  2027. #else
  2028. specularStrength = 1.0;
  2029. #endif`,she=`#ifdef USE_SPECULARMAP
  2030. uniform sampler2D specularMap;
  2031. #endif`,ohe=`#if defined( TONE_MAPPING )
  2032. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  2033. #endif`,lhe=`#ifndef saturate
  2034. #define saturate( a ) clamp( a, 0.0, 1.0 )
  2035. #endif
  2036. uniform float toneMappingExposure;
  2037. vec3 LinearToneMapping( vec3 color ) {
  2038. return saturate( toneMappingExposure * color );
  2039. }
  2040. vec3 ReinhardToneMapping( vec3 color ) {
  2041. color *= toneMappingExposure;
  2042. return saturate( color / ( vec3( 1.0 ) + color ) );
  2043. }
  2044. vec3 CineonToneMapping( vec3 color ) {
  2045. color *= toneMappingExposure;
  2046. color = max( vec3( 0.0 ), color - 0.004 );
  2047. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  2048. }
  2049. vec3 RRTAndODTFit( vec3 v ) {
  2050. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  2051. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  2052. return a / b;
  2053. }
  2054. vec3 ACESFilmicToneMapping( vec3 color ) {
  2055. const mat3 ACESInputMat = mat3(
  2056. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  2057. vec3( 0.04823, 0.01566, 0.83777 )
  2058. );
  2059. const mat3 ACESOutputMat = mat3(
  2060. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  2061. vec3( -0.07367, -0.00605, 1.07602 )
  2062. );
  2063. color *= toneMappingExposure / 0.6;
  2064. color = ACESInputMat * color;
  2065. color = RRTAndODTFit( color );
  2066. color = ACESOutputMat * color;
  2067. return saturate( color );
  2068. }
  2069. const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
  2070. vec3( 1.6605, - 0.1246, - 0.0182 ),
  2071. vec3( - 0.5876, 1.1329, - 0.1006 ),
  2072. vec3( - 0.0728, - 0.0083, 1.1187 )
  2073. );
  2074. const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
  2075. vec3( 0.6274, 0.0691, 0.0164 ),
  2076. vec3( 0.3293, 0.9195, 0.0880 ),
  2077. vec3( 0.0433, 0.0113, 0.8956 )
  2078. );
  2079. vec3 agxDefaultContrastApprox( vec3 x ) {
  2080. vec3 x2 = x * x;
  2081. vec3 x4 = x2 * x2;
  2082. return + 15.5 * x4 * x2
  2083. - 40.14 * x4 * x
  2084. + 31.96 * x4
  2085. - 6.868 * x2 * x
  2086. + 0.4298 * x2
  2087. + 0.1191 * x
  2088. - 0.00232;
  2089. }
  2090. vec3 AgXToneMapping( vec3 color ) {
  2091. const mat3 AgXInsetMatrix = mat3(
  2092. vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
  2093. vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
  2094. vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
  2095. );
  2096. const mat3 AgXOutsetMatrix = mat3(
  2097. vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
  2098. vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
  2099. vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
  2100. );
  2101. const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
  2102. color *= toneMappingExposure;
  2103. color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
  2104. color = AgXInsetMatrix * color;
  2105. color = max( color, 1e-10 ); color = log2( color );
  2106. color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
  2107. color = clamp( color, 0.0, 1.0 );
  2108. color = agxDefaultContrastApprox( color );
  2109. color = AgXOutsetMatrix * color;
  2110. color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
  2111. color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
  2112. color = clamp( color, 0.0, 1.0 );
  2113. return color;
  2114. }
  2115. vec3 NeutralToneMapping( vec3 color ) {
  2116. const float StartCompression = 0.8 - 0.04;
  2117. const float Desaturation = 0.15;
  2118. color *= toneMappingExposure;
  2119. float x = min( color.r, min( color.g, color.b ) );
  2120. float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
  2121. color -= offset;
  2122. float peak = max( color.r, max( color.g, color.b ) );
  2123. if ( peak < StartCompression ) return color;
  2124. float d = 1. - StartCompression;
  2125. float newPeak = 1. - d * d / ( peak + d - StartCompression );
  2126. color *= newPeak / peak;
  2127. float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
  2128. return mix( color, vec3( newPeak ), g );
  2129. }
  2130. vec3 CustomToneMapping( vec3 color ) { return color; }`,che=`#ifdef USE_TRANSMISSION
  2131. material.transmission = transmission;
  2132. material.transmissionAlpha = 1.0;
  2133. material.thickness = thickness;
  2134. material.attenuationDistance = attenuationDistance;
  2135. material.attenuationColor = attenuationColor;
  2136. #ifdef USE_TRANSMISSIONMAP
  2137. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  2138. #endif
  2139. #ifdef USE_THICKNESSMAP
  2140. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  2141. #endif
  2142. vec3 pos = vWorldPosition;
  2143. vec3 v = normalize( cameraPosition - pos );
  2144. vec3 n = inverseTransformDirection( normal, viewMatrix );
  2145. vec4 transmitted = getIBLVolumeRefraction(
  2146. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  2147. pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
  2148. material.attenuationColor, material.attenuationDistance );
  2149. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  2150. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  2151. #endif`,uhe=`#ifdef USE_TRANSMISSION
  2152. uniform float transmission;
  2153. uniform float thickness;
  2154. uniform float attenuationDistance;
  2155. uniform vec3 attenuationColor;
  2156. #ifdef USE_TRANSMISSIONMAP
  2157. uniform sampler2D transmissionMap;
  2158. #endif
  2159. #ifdef USE_THICKNESSMAP
  2160. uniform sampler2D thicknessMap;
  2161. #endif
  2162. uniform vec2 transmissionSamplerSize;
  2163. uniform sampler2D transmissionSamplerMap;
  2164. uniform mat4 modelMatrix;
  2165. uniform mat4 projectionMatrix;
  2166. varying vec3 vWorldPosition;
  2167. float w0( float a ) {
  2168. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  2169. }
  2170. float w1( float a ) {
  2171. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  2172. }
  2173. float w2( float a ){
  2174. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  2175. }
  2176. float w3( float a ) {
  2177. return ( 1.0 / 6.0 ) * ( a * a * a );
  2178. }
  2179. float g0( float a ) {
  2180. return w0( a ) + w1( a );
  2181. }
  2182. float g1( float a ) {
  2183. return w2( a ) + w3( a );
  2184. }
  2185. float h0( float a ) {
  2186. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  2187. }
  2188. float h1( float a ) {
  2189. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  2190. }
  2191. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  2192. uv = uv * texelSize.zw + 0.5;
  2193. vec2 iuv = floor( uv );
  2194. vec2 fuv = fract( uv );
  2195. float g0x = g0( fuv.x );
  2196. float g1x = g1( fuv.x );
  2197. float h0x = h0( fuv.x );
  2198. float h1x = h1( fuv.x );
  2199. float h0y = h0( fuv.y );
  2200. float h1y = h1( fuv.y );
  2201. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2202. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2203. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2204. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2205. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  2206. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  2207. }
  2208. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  2209. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  2210. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  2211. vec2 fLodSizeInv = 1.0 / fLodSize;
  2212. vec2 cLodSizeInv = 1.0 / cLodSize;
  2213. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  2214. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  2215. return mix( fSample, cSample, fract( lod ) );
  2216. }
  2217. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  2218. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  2219. vec3 modelScale;
  2220. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  2221. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  2222. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  2223. return normalize( refractionVector ) * thickness * modelScale;
  2224. }
  2225. float applyIorToRoughness( const in float roughness, const in float ior ) {
  2226. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  2227. }
  2228. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  2229. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  2230. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  2231. }
  2232. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  2233. if ( isinf( attenuationDistance ) ) {
  2234. return vec3( 1.0 );
  2235. } else {
  2236. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  2237. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  2238. }
  2239. }
  2240. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  2241. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  2242. const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
  2243. const in vec3 attenuationColor, const in float attenuationDistance ) {
  2244. vec4 transmittedLight;
  2245. vec3 transmittance;
  2246. #ifdef USE_DISPERSION
  2247. float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
  2248. vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
  2249. for ( int i = 0; i < 3; i ++ ) {
  2250. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
  2251. vec3 refractedRayExit = position + transmissionRay;
  2252. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2253. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2254. refractionCoords += 1.0;
  2255. refractionCoords /= 2.0;
  2256. vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
  2257. transmittedLight[ i ] = transmissionSample[ i ];
  2258. transmittedLight.a += transmissionSample.a;
  2259. transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
  2260. }
  2261. transmittedLight.a /= 3.0;
  2262. #else
  2263. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  2264. vec3 refractedRayExit = position + transmissionRay;
  2265. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2266. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2267. refractionCoords += 1.0;
  2268. refractionCoords /= 2.0;
  2269. transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  2270. transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  2271. #endif
  2272. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  2273. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  2274. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  2275. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  2276. }
  2277. #endif`,dhe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2278. varying vec2 vUv;
  2279. #endif
  2280. #ifdef USE_MAP
  2281. varying vec2 vMapUv;
  2282. #endif
  2283. #ifdef USE_ALPHAMAP
  2284. varying vec2 vAlphaMapUv;
  2285. #endif
  2286. #ifdef USE_LIGHTMAP
  2287. varying vec2 vLightMapUv;
  2288. #endif
  2289. #ifdef USE_AOMAP
  2290. varying vec2 vAoMapUv;
  2291. #endif
  2292. #ifdef USE_BUMPMAP
  2293. varying vec2 vBumpMapUv;
  2294. #endif
  2295. #ifdef USE_NORMALMAP
  2296. varying vec2 vNormalMapUv;
  2297. #endif
  2298. #ifdef USE_EMISSIVEMAP
  2299. varying vec2 vEmissiveMapUv;
  2300. #endif
  2301. #ifdef USE_METALNESSMAP
  2302. varying vec2 vMetalnessMapUv;
  2303. #endif
  2304. #ifdef USE_ROUGHNESSMAP
  2305. varying vec2 vRoughnessMapUv;
  2306. #endif
  2307. #ifdef USE_ANISOTROPYMAP
  2308. varying vec2 vAnisotropyMapUv;
  2309. #endif
  2310. #ifdef USE_CLEARCOATMAP
  2311. varying vec2 vClearcoatMapUv;
  2312. #endif
  2313. #ifdef USE_CLEARCOAT_NORMALMAP
  2314. varying vec2 vClearcoatNormalMapUv;
  2315. #endif
  2316. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2317. varying vec2 vClearcoatRoughnessMapUv;
  2318. #endif
  2319. #ifdef USE_IRIDESCENCEMAP
  2320. varying vec2 vIridescenceMapUv;
  2321. #endif
  2322. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2323. varying vec2 vIridescenceThicknessMapUv;
  2324. #endif
  2325. #ifdef USE_SHEEN_COLORMAP
  2326. varying vec2 vSheenColorMapUv;
  2327. #endif
  2328. #ifdef USE_SHEEN_ROUGHNESSMAP
  2329. varying vec2 vSheenRoughnessMapUv;
  2330. #endif
  2331. #ifdef USE_SPECULARMAP
  2332. varying vec2 vSpecularMapUv;
  2333. #endif
  2334. #ifdef USE_SPECULAR_COLORMAP
  2335. varying vec2 vSpecularColorMapUv;
  2336. #endif
  2337. #ifdef USE_SPECULAR_INTENSITYMAP
  2338. varying vec2 vSpecularIntensityMapUv;
  2339. #endif
  2340. #ifdef USE_TRANSMISSIONMAP
  2341. uniform mat3 transmissionMapTransform;
  2342. varying vec2 vTransmissionMapUv;
  2343. #endif
  2344. #ifdef USE_THICKNESSMAP
  2345. uniform mat3 thicknessMapTransform;
  2346. varying vec2 vThicknessMapUv;
  2347. #endif`,fhe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2348. varying vec2 vUv;
  2349. #endif
  2350. #ifdef USE_MAP
  2351. uniform mat3 mapTransform;
  2352. varying vec2 vMapUv;
  2353. #endif
  2354. #ifdef USE_ALPHAMAP
  2355. uniform mat3 alphaMapTransform;
  2356. varying vec2 vAlphaMapUv;
  2357. #endif
  2358. #ifdef USE_LIGHTMAP
  2359. uniform mat3 lightMapTransform;
  2360. varying vec2 vLightMapUv;
  2361. #endif
  2362. #ifdef USE_AOMAP
  2363. uniform mat3 aoMapTransform;
  2364. varying vec2 vAoMapUv;
  2365. #endif
  2366. #ifdef USE_BUMPMAP
  2367. uniform mat3 bumpMapTransform;
  2368. varying vec2 vBumpMapUv;
  2369. #endif
  2370. #ifdef USE_NORMALMAP
  2371. uniform mat3 normalMapTransform;
  2372. varying vec2 vNormalMapUv;
  2373. #endif
  2374. #ifdef USE_DISPLACEMENTMAP
  2375. uniform mat3 displacementMapTransform;
  2376. varying vec2 vDisplacementMapUv;
  2377. #endif
  2378. #ifdef USE_EMISSIVEMAP
  2379. uniform mat3 emissiveMapTransform;
  2380. varying vec2 vEmissiveMapUv;
  2381. #endif
  2382. #ifdef USE_METALNESSMAP
  2383. uniform mat3 metalnessMapTransform;
  2384. varying vec2 vMetalnessMapUv;
  2385. #endif
  2386. #ifdef USE_ROUGHNESSMAP
  2387. uniform mat3 roughnessMapTransform;
  2388. varying vec2 vRoughnessMapUv;
  2389. #endif
  2390. #ifdef USE_ANISOTROPYMAP
  2391. uniform mat3 anisotropyMapTransform;
  2392. varying vec2 vAnisotropyMapUv;
  2393. #endif
  2394. #ifdef USE_CLEARCOATMAP
  2395. uniform mat3 clearcoatMapTransform;
  2396. varying vec2 vClearcoatMapUv;
  2397. #endif
  2398. #ifdef USE_CLEARCOAT_NORMALMAP
  2399. uniform mat3 clearcoatNormalMapTransform;
  2400. varying vec2 vClearcoatNormalMapUv;
  2401. #endif
  2402. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2403. uniform mat3 clearcoatRoughnessMapTransform;
  2404. varying vec2 vClearcoatRoughnessMapUv;
  2405. #endif
  2406. #ifdef USE_SHEEN_COLORMAP
  2407. uniform mat3 sheenColorMapTransform;
  2408. varying vec2 vSheenColorMapUv;
  2409. #endif
  2410. #ifdef USE_SHEEN_ROUGHNESSMAP
  2411. uniform mat3 sheenRoughnessMapTransform;
  2412. varying vec2 vSheenRoughnessMapUv;
  2413. #endif
  2414. #ifdef USE_IRIDESCENCEMAP
  2415. uniform mat3 iridescenceMapTransform;
  2416. varying vec2 vIridescenceMapUv;
  2417. #endif
  2418. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2419. uniform mat3 iridescenceThicknessMapTransform;
  2420. varying vec2 vIridescenceThicknessMapUv;
  2421. #endif
  2422. #ifdef USE_SPECULARMAP
  2423. uniform mat3 specularMapTransform;
  2424. varying vec2 vSpecularMapUv;
  2425. #endif
  2426. #ifdef USE_SPECULAR_COLORMAP
  2427. uniform mat3 specularColorMapTransform;
  2428. varying vec2 vSpecularColorMapUv;
  2429. #endif
  2430. #ifdef USE_SPECULAR_INTENSITYMAP
  2431. uniform mat3 specularIntensityMapTransform;
  2432. varying vec2 vSpecularIntensityMapUv;
  2433. #endif
  2434. #ifdef USE_TRANSMISSIONMAP
  2435. uniform mat3 transmissionMapTransform;
  2436. varying vec2 vTransmissionMapUv;
  2437. #endif
  2438. #ifdef USE_THICKNESSMAP
  2439. uniform mat3 thicknessMapTransform;
  2440. varying vec2 vThicknessMapUv;
  2441. #endif`,hhe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2442. vUv = vec3( uv, 1 ).xy;
  2443. #endif
  2444. #ifdef USE_MAP
  2445. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  2446. #endif
  2447. #ifdef USE_ALPHAMAP
  2448. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  2449. #endif
  2450. #ifdef USE_LIGHTMAP
  2451. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  2452. #endif
  2453. #ifdef USE_AOMAP
  2454. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  2455. #endif
  2456. #ifdef USE_BUMPMAP
  2457. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  2458. #endif
  2459. #ifdef USE_NORMALMAP
  2460. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  2461. #endif
  2462. #ifdef USE_DISPLACEMENTMAP
  2463. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  2464. #endif
  2465. #ifdef USE_EMISSIVEMAP
  2466. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  2467. #endif
  2468. #ifdef USE_METALNESSMAP
  2469. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  2470. #endif
  2471. #ifdef USE_ROUGHNESSMAP
  2472. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  2473. #endif
  2474. #ifdef USE_ANISOTROPYMAP
  2475. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  2476. #endif
  2477. #ifdef USE_CLEARCOATMAP
  2478. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  2479. #endif
  2480. #ifdef USE_CLEARCOAT_NORMALMAP
  2481. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  2482. #endif
  2483. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2484. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  2485. #endif
  2486. #ifdef USE_IRIDESCENCEMAP
  2487. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  2488. #endif
  2489. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2490. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  2491. #endif
  2492. #ifdef USE_SHEEN_COLORMAP
  2493. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  2494. #endif
  2495. #ifdef USE_SHEEN_ROUGHNESSMAP
  2496. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  2497. #endif
  2498. #ifdef USE_SPECULARMAP
  2499. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  2500. #endif
  2501. #ifdef USE_SPECULAR_COLORMAP
  2502. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  2503. #endif
  2504. #ifdef USE_SPECULAR_INTENSITYMAP
  2505. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  2506. #endif
  2507. #ifdef USE_TRANSMISSIONMAP
  2508. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  2509. #endif
  2510. #ifdef USE_THICKNESSMAP
  2511. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  2512. #endif`,phe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  2513. vec4 worldPosition = vec4( transformed, 1.0 );
  2514. #ifdef USE_BATCHING
  2515. worldPosition = batchingMatrix * worldPosition;
  2516. #endif
  2517. #ifdef USE_INSTANCING
  2518. worldPosition = instanceMatrix * worldPosition;
  2519. #endif
  2520. worldPosition = modelMatrix * worldPosition;
  2521. #endif`;const mhe=`varying vec2 vUv;
  2522. uniform mat3 uvTransform;
  2523. void main() {
  2524. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  2525. gl_Position = vec4( position.xy, 1.0, 1.0 );
  2526. }`,ghe=`uniform sampler2D t2D;
  2527. uniform float backgroundIntensity;
  2528. varying vec2 vUv;
  2529. void main() {
  2530. vec4 texColor = texture2D( t2D, vUv );
  2531. #ifdef DECODE_VIDEO_TEXTURE
  2532. texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
  2533. #endif
  2534. texColor.rgb *= backgroundIntensity;
  2535. gl_FragColor = texColor;
  2536. #include <tonemapping_fragment>
  2537. #include <colorspace_fragment>
  2538. }`,xhe=`varying vec3 vWorldDirection;
  2539. #include <common>
  2540. void main() {
  2541. vWorldDirection = transformDirection( position, modelMatrix );
  2542. #include <begin_vertex>
  2543. #include <project_vertex>
  2544. gl_Position.z = gl_Position.w;
  2545. }`,vhe=`#ifdef ENVMAP_TYPE_CUBE
  2546. uniform samplerCube envMap;
  2547. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2548. uniform sampler2D envMap;
  2549. #endif
  2550. uniform float flipEnvMap;
  2551. uniform float backgroundBlurriness;
  2552. uniform float backgroundIntensity;
  2553. uniform mat3 backgroundRotation;
  2554. varying vec3 vWorldDirection;
  2555. #include <cube_uv_reflection_fragment>
  2556. void main() {
  2557. #ifdef ENVMAP_TYPE_CUBE
  2558. vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  2559. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2560. vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
  2561. #else
  2562. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2563. #endif
  2564. texColor.rgb *= backgroundIntensity;
  2565. gl_FragColor = texColor;
  2566. #include <tonemapping_fragment>
  2567. #include <colorspace_fragment>
  2568. }`,bhe=`varying vec3 vWorldDirection;
  2569. #include <common>
  2570. void main() {
  2571. vWorldDirection = transformDirection( position, modelMatrix );
  2572. #include <begin_vertex>
  2573. #include <project_vertex>
  2574. gl_Position.z = gl_Position.w;
  2575. }`,yhe=`uniform samplerCube tCube;
  2576. uniform float tFlip;
  2577. uniform float opacity;
  2578. varying vec3 vWorldDirection;
  2579. void main() {
  2580. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  2581. gl_FragColor = texColor;
  2582. gl_FragColor.a *= opacity;
  2583. #include <tonemapping_fragment>
  2584. #include <colorspace_fragment>
  2585. }`,_he=`#include <common>
  2586. #include <batching_pars_vertex>
  2587. #include <uv_pars_vertex>
  2588. #include <displacementmap_pars_vertex>
  2589. #include <morphtarget_pars_vertex>
  2590. #include <skinning_pars_vertex>
  2591. #include <logdepthbuf_pars_vertex>
  2592. #include <clipping_planes_pars_vertex>
  2593. varying vec2 vHighPrecisionZW;
  2594. void main() {
  2595. #include <uv_vertex>
  2596. #include <batching_vertex>
  2597. #include <skinbase_vertex>
  2598. #include <morphinstance_vertex>
  2599. #ifdef USE_DISPLACEMENTMAP
  2600. #include <beginnormal_vertex>
  2601. #include <morphnormal_vertex>
  2602. #include <skinnormal_vertex>
  2603. #endif
  2604. #include <begin_vertex>
  2605. #include <morphtarget_vertex>
  2606. #include <skinning_vertex>
  2607. #include <displacementmap_vertex>
  2608. #include <project_vertex>
  2609. #include <logdepthbuf_vertex>
  2610. #include <clipping_planes_vertex>
  2611. vHighPrecisionZW = gl_Position.zw;
  2612. }`,She=`#if DEPTH_PACKING == 3200
  2613. uniform float opacity;
  2614. #endif
  2615. #include <common>
  2616. #include <packing>
  2617. #include <uv_pars_fragment>
  2618. #include <map_pars_fragment>
  2619. #include <alphamap_pars_fragment>
  2620. #include <alphatest_pars_fragment>
  2621. #include <alphahash_pars_fragment>
  2622. #include <logdepthbuf_pars_fragment>
  2623. #include <clipping_planes_pars_fragment>
  2624. varying vec2 vHighPrecisionZW;
  2625. void main() {
  2626. vec4 diffuseColor = vec4( 1.0 );
  2627. #include <clipping_planes_fragment>
  2628. #if DEPTH_PACKING == 3200
  2629. diffuseColor.a = opacity;
  2630. #endif
  2631. #include <map_fragment>
  2632. #include <alphamap_fragment>
  2633. #include <alphatest_fragment>
  2634. #include <alphahash_fragment>
  2635. #include <logdepthbuf_fragment>
  2636. #ifdef USE_REVERSED_DEPTH_BUFFER
  2637. float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
  2638. #else
  2639. float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
  2640. #endif
  2641. #if DEPTH_PACKING == 3200
  2642. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  2643. #elif DEPTH_PACKING == 3201
  2644. gl_FragColor = packDepthToRGBA( fragCoordZ );
  2645. #elif DEPTH_PACKING == 3202
  2646. gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
  2647. #elif DEPTH_PACKING == 3203
  2648. gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
  2649. #endif
  2650. }`,whe=`#define DISTANCE
  2651. varying vec3 vWorldPosition;
  2652. #include <common>
  2653. #include <batching_pars_vertex>
  2654. #include <uv_pars_vertex>
  2655. #include <displacementmap_pars_vertex>
  2656. #include <morphtarget_pars_vertex>
  2657. #include <skinning_pars_vertex>
  2658. #include <clipping_planes_pars_vertex>
  2659. void main() {
  2660. #include <uv_vertex>
  2661. #include <batching_vertex>
  2662. #include <skinbase_vertex>
  2663. #include <morphinstance_vertex>
  2664. #ifdef USE_DISPLACEMENTMAP
  2665. #include <beginnormal_vertex>
  2666. #include <morphnormal_vertex>
  2667. #include <skinnormal_vertex>
  2668. #endif
  2669. #include <begin_vertex>
  2670. #include <morphtarget_vertex>
  2671. #include <skinning_vertex>
  2672. #include <displacementmap_vertex>
  2673. #include <project_vertex>
  2674. #include <worldpos_vertex>
  2675. #include <clipping_planes_vertex>
  2676. vWorldPosition = worldPosition.xyz;
  2677. }`,Mhe=`#define DISTANCE
  2678. uniform vec3 referencePosition;
  2679. uniform float nearDistance;
  2680. uniform float farDistance;
  2681. varying vec3 vWorldPosition;
  2682. #include <common>
  2683. #include <packing>
  2684. #include <uv_pars_fragment>
  2685. #include <map_pars_fragment>
  2686. #include <alphamap_pars_fragment>
  2687. #include <alphatest_pars_fragment>
  2688. #include <alphahash_pars_fragment>
  2689. #include <clipping_planes_pars_fragment>
  2690. void main () {
  2691. vec4 diffuseColor = vec4( 1.0 );
  2692. #include <clipping_planes_fragment>
  2693. #include <map_fragment>
  2694. #include <alphamap_fragment>
  2695. #include <alphatest_fragment>
  2696. #include <alphahash_fragment>
  2697. float dist = length( vWorldPosition - referencePosition );
  2698. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  2699. dist = saturate( dist );
  2700. gl_FragColor = packDepthToRGBA( dist );
  2701. }`,Ehe=`varying vec3 vWorldDirection;
  2702. #include <common>
  2703. void main() {
  2704. vWorldDirection = transformDirection( position, modelMatrix );
  2705. #include <begin_vertex>
  2706. #include <project_vertex>
  2707. }`,Ahe=`uniform sampler2D tEquirect;
  2708. varying vec3 vWorldDirection;
  2709. #include <common>
  2710. void main() {
  2711. vec3 direction = normalize( vWorldDirection );
  2712. vec2 sampleUV = equirectUv( direction );
  2713. gl_FragColor = texture2D( tEquirect, sampleUV );
  2714. #include <tonemapping_fragment>
  2715. #include <colorspace_fragment>
  2716. }`,The=`uniform float scale;
  2717. attribute float lineDistance;
  2718. varying float vLineDistance;
  2719. #include <common>
  2720. #include <uv_pars_vertex>
  2721. #include <color_pars_vertex>
  2722. #include <fog_pars_vertex>
  2723. #include <morphtarget_pars_vertex>
  2724. #include <logdepthbuf_pars_vertex>
  2725. #include <clipping_planes_pars_vertex>
  2726. void main() {
  2727. vLineDistance = scale * lineDistance;
  2728. #include <uv_vertex>
  2729. #include <color_vertex>
  2730. #include <morphinstance_vertex>
  2731. #include <morphcolor_vertex>
  2732. #include <begin_vertex>
  2733. #include <morphtarget_vertex>
  2734. #include <project_vertex>
  2735. #include <logdepthbuf_vertex>
  2736. #include <clipping_planes_vertex>
  2737. #include <fog_vertex>
  2738. }`,Che=`uniform vec3 diffuse;
  2739. uniform float opacity;
  2740. uniform float dashSize;
  2741. uniform float totalSize;
  2742. varying float vLineDistance;
  2743. #include <common>
  2744. #include <color_pars_fragment>
  2745. #include <uv_pars_fragment>
  2746. #include <map_pars_fragment>
  2747. #include <fog_pars_fragment>
  2748. #include <logdepthbuf_pars_fragment>
  2749. #include <clipping_planes_pars_fragment>
  2750. void main() {
  2751. vec4 diffuseColor = vec4( diffuse, opacity );
  2752. #include <clipping_planes_fragment>
  2753. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  2754. discard;
  2755. }
  2756. vec3 outgoingLight = vec3( 0.0 );
  2757. #include <logdepthbuf_fragment>
  2758. #include <map_fragment>
  2759. #include <color_fragment>
  2760. outgoingLight = diffuseColor.rgb;
  2761. #include <opaque_fragment>
  2762. #include <tonemapping_fragment>
  2763. #include <colorspace_fragment>
  2764. #include <fog_fragment>
  2765. #include <premultiplied_alpha_fragment>
  2766. }`,Nhe=`#include <common>
  2767. #include <batching_pars_vertex>
  2768. #include <uv_pars_vertex>
  2769. #include <envmap_pars_vertex>
  2770. #include <color_pars_vertex>
  2771. #include <fog_pars_vertex>
  2772. #include <morphtarget_pars_vertex>
  2773. #include <skinning_pars_vertex>
  2774. #include <logdepthbuf_pars_vertex>
  2775. #include <clipping_planes_pars_vertex>
  2776. void main() {
  2777. #include <uv_vertex>
  2778. #include <color_vertex>
  2779. #include <morphinstance_vertex>
  2780. #include <morphcolor_vertex>
  2781. #include <batching_vertex>
  2782. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  2783. #include <beginnormal_vertex>
  2784. #include <morphnormal_vertex>
  2785. #include <skinbase_vertex>
  2786. #include <skinnormal_vertex>
  2787. #include <defaultnormal_vertex>
  2788. #endif
  2789. #include <begin_vertex>
  2790. #include <morphtarget_vertex>
  2791. #include <skinning_vertex>
  2792. #include <project_vertex>
  2793. #include <logdepthbuf_vertex>
  2794. #include <clipping_planes_vertex>
  2795. #include <worldpos_vertex>
  2796. #include <envmap_vertex>
  2797. #include <fog_vertex>
  2798. }`,Rhe=`uniform vec3 diffuse;
  2799. uniform float opacity;
  2800. #ifndef FLAT_SHADED
  2801. varying vec3 vNormal;
  2802. #endif
  2803. #include <common>
  2804. #include <dithering_pars_fragment>
  2805. #include <color_pars_fragment>
  2806. #include <uv_pars_fragment>
  2807. #include <map_pars_fragment>
  2808. #include <alphamap_pars_fragment>
  2809. #include <alphatest_pars_fragment>
  2810. #include <alphahash_pars_fragment>
  2811. #include <aomap_pars_fragment>
  2812. #include <lightmap_pars_fragment>
  2813. #include <envmap_common_pars_fragment>
  2814. #include <envmap_pars_fragment>
  2815. #include <fog_pars_fragment>
  2816. #include <specularmap_pars_fragment>
  2817. #include <logdepthbuf_pars_fragment>
  2818. #include <clipping_planes_pars_fragment>
  2819. void main() {
  2820. vec4 diffuseColor = vec4( diffuse, opacity );
  2821. #include <clipping_planes_fragment>
  2822. #include <logdepthbuf_fragment>
  2823. #include <map_fragment>
  2824. #include <color_fragment>
  2825. #include <alphamap_fragment>
  2826. #include <alphatest_fragment>
  2827. #include <alphahash_fragment>
  2828. #include <specularmap_fragment>
  2829. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2830. #ifdef USE_LIGHTMAP
  2831. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  2832. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  2833. #else
  2834. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2835. #endif
  2836. #include <aomap_fragment>
  2837. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2838. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2839. #include <envmap_fragment>
  2840. #include <opaque_fragment>
  2841. #include <tonemapping_fragment>
  2842. #include <colorspace_fragment>
  2843. #include <fog_fragment>
  2844. #include <premultiplied_alpha_fragment>
  2845. #include <dithering_fragment>
  2846. }`,Phe=`#define LAMBERT
  2847. varying vec3 vViewPosition;
  2848. #include <common>
  2849. #include <batching_pars_vertex>
  2850. #include <uv_pars_vertex>
  2851. #include <displacementmap_pars_vertex>
  2852. #include <envmap_pars_vertex>
  2853. #include <color_pars_vertex>
  2854. #include <fog_pars_vertex>
  2855. #include <normal_pars_vertex>
  2856. #include <morphtarget_pars_vertex>
  2857. #include <skinning_pars_vertex>
  2858. #include <shadowmap_pars_vertex>
  2859. #include <logdepthbuf_pars_vertex>
  2860. #include <clipping_planes_pars_vertex>
  2861. void main() {
  2862. #include <uv_vertex>
  2863. #include <color_vertex>
  2864. #include <morphinstance_vertex>
  2865. #include <morphcolor_vertex>
  2866. #include <batching_vertex>
  2867. #include <beginnormal_vertex>
  2868. #include <morphnormal_vertex>
  2869. #include <skinbase_vertex>
  2870. #include <skinnormal_vertex>
  2871. #include <defaultnormal_vertex>
  2872. #include <normal_vertex>
  2873. #include <begin_vertex>
  2874. #include <morphtarget_vertex>
  2875. #include <skinning_vertex>
  2876. #include <displacementmap_vertex>
  2877. #include <project_vertex>
  2878. #include <logdepthbuf_vertex>
  2879. #include <clipping_planes_vertex>
  2880. vViewPosition = - mvPosition.xyz;
  2881. #include <worldpos_vertex>
  2882. #include <envmap_vertex>
  2883. #include <shadowmap_vertex>
  2884. #include <fog_vertex>
  2885. }`,khe=`#define LAMBERT
  2886. uniform vec3 diffuse;
  2887. uniform vec3 emissive;
  2888. uniform float opacity;
  2889. #include <common>
  2890. #include <packing>
  2891. #include <dithering_pars_fragment>
  2892. #include <color_pars_fragment>
  2893. #include <uv_pars_fragment>
  2894. #include <map_pars_fragment>
  2895. #include <alphamap_pars_fragment>
  2896. #include <alphatest_pars_fragment>
  2897. #include <alphahash_pars_fragment>
  2898. #include <aomap_pars_fragment>
  2899. #include <lightmap_pars_fragment>
  2900. #include <emissivemap_pars_fragment>
  2901. #include <envmap_common_pars_fragment>
  2902. #include <envmap_pars_fragment>
  2903. #include <fog_pars_fragment>
  2904. #include <bsdfs>
  2905. #include <lights_pars_begin>
  2906. #include <normal_pars_fragment>
  2907. #include <lights_lambert_pars_fragment>
  2908. #include <shadowmap_pars_fragment>
  2909. #include <bumpmap_pars_fragment>
  2910. #include <normalmap_pars_fragment>
  2911. #include <specularmap_pars_fragment>
  2912. #include <logdepthbuf_pars_fragment>
  2913. #include <clipping_planes_pars_fragment>
  2914. void main() {
  2915. vec4 diffuseColor = vec4( diffuse, opacity );
  2916. #include <clipping_planes_fragment>
  2917. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2918. vec3 totalEmissiveRadiance = emissive;
  2919. #include <logdepthbuf_fragment>
  2920. #include <map_fragment>
  2921. #include <color_fragment>
  2922. #include <alphamap_fragment>
  2923. #include <alphatest_fragment>
  2924. #include <alphahash_fragment>
  2925. #include <specularmap_fragment>
  2926. #include <normal_fragment_begin>
  2927. #include <normal_fragment_maps>
  2928. #include <emissivemap_fragment>
  2929. #include <lights_lambert_fragment>
  2930. #include <lights_fragment_begin>
  2931. #include <lights_fragment_maps>
  2932. #include <lights_fragment_end>
  2933. #include <aomap_fragment>
  2934. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  2935. #include <envmap_fragment>
  2936. #include <opaque_fragment>
  2937. #include <tonemapping_fragment>
  2938. #include <colorspace_fragment>
  2939. #include <fog_fragment>
  2940. #include <premultiplied_alpha_fragment>
  2941. #include <dithering_fragment>
  2942. }`,Dhe=`#define MATCAP
  2943. varying vec3 vViewPosition;
  2944. #include <common>
  2945. #include <batching_pars_vertex>
  2946. #include <uv_pars_vertex>
  2947. #include <color_pars_vertex>
  2948. #include <displacementmap_pars_vertex>
  2949. #include <fog_pars_vertex>
  2950. #include <normal_pars_vertex>
  2951. #include <morphtarget_pars_vertex>
  2952. #include <skinning_pars_vertex>
  2953. #include <logdepthbuf_pars_vertex>
  2954. #include <clipping_planes_pars_vertex>
  2955. void main() {
  2956. #include <uv_vertex>
  2957. #include <color_vertex>
  2958. #include <morphinstance_vertex>
  2959. #include <morphcolor_vertex>
  2960. #include <batching_vertex>
  2961. #include <beginnormal_vertex>
  2962. #include <morphnormal_vertex>
  2963. #include <skinbase_vertex>
  2964. #include <skinnormal_vertex>
  2965. #include <defaultnormal_vertex>
  2966. #include <normal_vertex>
  2967. #include <begin_vertex>
  2968. #include <morphtarget_vertex>
  2969. #include <skinning_vertex>
  2970. #include <displacementmap_vertex>
  2971. #include <project_vertex>
  2972. #include <logdepthbuf_vertex>
  2973. #include <clipping_planes_vertex>
  2974. #include <fog_vertex>
  2975. vViewPosition = - mvPosition.xyz;
  2976. }`,Ohe=`#define MATCAP
  2977. uniform vec3 diffuse;
  2978. uniform float opacity;
  2979. uniform sampler2D matcap;
  2980. varying vec3 vViewPosition;
  2981. #include <common>
  2982. #include <dithering_pars_fragment>
  2983. #include <color_pars_fragment>
  2984. #include <uv_pars_fragment>
  2985. #include <map_pars_fragment>
  2986. #include <alphamap_pars_fragment>
  2987. #include <alphatest_pars_fragment>
  2988. #include <alphahash_pars_fragment>
  2989. #include <fog_pars_fragment>
  2990. #include <normal_pars_fragment>
  2991. #include <bumpmap_pars_fragment>
  2992. #include <normalmap_pars_fragment>
  2993. #include <logdepthbuf_pars_fragment>
  2994. #include <clipping_planes_pars_fragment>
  2995. void main() {
  2996. vec4 diffuseColor = vec4( diffuse, opacity );
  2997. #include <clipping_planes_fragment>
  2998. #include <logdepthbuf_fragment>
  2999. #include <map_fragment>
  3000. #include <color_fragment>
  3001. #include <alphamap_fragment>
  3002. #include <alphatest_fragment>
  3003. #include <alphahash_fragment>
  3004. #include <normal_fragment_begin>
  3005. #include <normal_fragment_maps>
  3006. vec3 viewDir = normalize( vViewPosition );
  3007. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  3008. vec3 y = cross( viewDir, x );
  3009. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  3010. #ifdef USE_MATCAP
  3011. vec4 matcapColor = texture2D( matcap, uv );
  3012. #else
  3013. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  3014. #endif
  3015. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  3016. #include <opaque_fragment>
  3017. #include <tonemapping_fragment>
  3018. #include <colorspace_fragment>
  3019. #include <fog_fragment>
  3020. #include <premultiplied_alpha_fragment>
  3021. #include <dithering_fragment>
  3022. }`,Lhe=`#define NORMAL
  3023. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3024. varying vec3 vViewPosition;
  3025. #endif
  3026. #include <common>
  3027. #include <batching_pars_vertex>
  3028. #include <uv_pars_vertex>
  3029. #include <displacementmap_pars_vertex>
  3030. #include <normal_pars_vertex>
  3031. #include <morphtarget_pars_vertex>
  3032. #include <skinning_pars_vertex>
  3033. #include <logdepthbuf_pars_vertex>
  3034. #include <clipping_planes_pars_vertex>
  3035. void main() {
  3036. #include <uv_vertex>
  3037. #include <batching_vertex>
  3038. #include <beginnormal_vertex>
  3039. #include <morphinstance_vertex>
  3040. #include <morphnormal_vertex>
  3041. #include <skinbase_vertex>
  3042. #include <skinnormal_vertex>
  3043. #include <defaultnormal_vertex>
  3044. #include <normal_vertex>
  3045. #include <begin_vertex>
  3046. #include <morphtarget_vertex>
  3047. #include <skinning_vertex>
  3048. #include <displacementmap_vertex>
  3049. #include <project_vertex>
  3050. #include <logdepthbuf_vertex>
  3051. #include <clipping_planes_vertex>
  3052. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3053. vViewPosition = - mvPosition.xyz;
  3054. #endif
  3055. }`,Ihe=`#define NORMAL
  3056. uniform float opacity;
  3057. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3058. varying vec3 vViewPosition;
  3059. #endif
  3060. #include <packing>
  3061. #include <uv_pars_fragment>
  3062. #include <normal_pars_fragment>
  3063. #include <bumpmap_pars_fragment>
  3064. #include <normalmap_pars_fragment>
  3065. #include <logdepthbuf_pars_fragment>
  3066. #include <clipping_planes_pars_fragment>
  3067. void main() {
  3068. vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
  3069. #include <clipping_planes_fragment>
  3070. #include <logdepthbuf_fragment>
  3071. #include <normal_fragment_begin>
  3072. #include <normal_fragment_maps>
  3073. gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
  3074. #ifdef OPAQUE
  3075. gl_FragColor.a = 1.0;
  3076. #endif
  3077. }`,jhe=`#define PHONG
  3078. varying vec3 vViewPosition;
  3079. #include <common>
  3080. #include <batching_pars_vertex>
  3081. #include <uv_pars_vertex>
  3082. #include <displacementmap_pars_vertex>
  3083. #include <envmap_pars_vertex>
  3084. #include <color_pars_vertex>
  3085. #include <fog_pars_vertex>
  3086. #include <normal_pars_vertex>
  3087. #include <morphtarget_pars_vertex>
  3088. #include <skinning_pars_vertex>
  3089. #include <shadowmap_pars_vertex>
  3090. #include <logdepthbuf_pars_vertex>
  3091. #include <clipping_planes_pars_vertex>
  3092. void main() {
  3093. #include <uv_vertex>
  3094. #include <color_vertex>
  3095. #include <morphcolor_vertex>
  3096. #include <batching_vertex>
  3097. #include <beginnormal_vertex>
  3098. #include <morphinstance_vertex>
  3099. #include <morphnormal_vertex>
  3100. #include <skinbase_vertex>
  3101. #include <skinnormal_vertex>
  3102. #include <defaultnormal_vertex>
  3103. #include <normal_vertex>
  3104. #include <begin_vertex>
  3105. #include <morphtarget_vertex>
  3106. #include <skinning_vertex>
  3107. #include <displacementmap_vertex>
  3108. #include <project_vertex>
  3109. #include <logdepthbuf_vertex>
  3110. #include <clipping_planes_vertex>
  3111. vViewPosition = - mvPosition.xyz;
  3112. #include <worldpos_vertex>
  3113. #include <envmap_vertex>
  3114. #include <shadowmap_vertex>
  3115. #include <fog_vertex>
  3116. }`,Uhe=`#define PHONG
  3117. uniform vec3 diffuse;
  3118. uniform vec3 emissive;
  3119. uniform vec3 specular;
  3120. uniform float shininess;
  3121. uniform float opacity;
  3122. #include <common>
  3123. #include <packing>
  3124. #include <dithering_pars_fragment>
  3125. #include <color_pars_fragment>
  3126. #include <uv_pars_fragment>
  3127. #include <map_pars_fragment>
  3128. #include <alphamap_pars_fragment>
  3129. #include <alphatest_pars_fragment>
  3130. #include <alphahash_pars_fragment>
  3131. #include <aomap_pars_fragment>
  3132. #include <lightmap_pars_fragment>
  3133. #include <emissivemap_pars_fragment>
  3134. #include <envmap_common_pars_fragment>
  3135. #include <envmap_pars_fragment>
  3136. #include <fog_pars_fragment>
  3137. #include <bsdfs>
  3138. #include <lights_pars_begin>
  3139. #include <normal_pars_fragment>
  3140. #include <lights_phong_pars_fragment>
  3141. #include <shadowmap_pars_fragment>
  3142. #include <bumpmap_pars_fragment>
  3143. #include <normalmap_pars_fragment>
  3144. #include <specularmap_pars_fragment>
  3145. #include <logdepthbuf_pars_fragment>
  3146. #include <clipping_planes_pars_fragment>
  3147. void main() {
  3148. vec4 diffuseColor = vec4( diffuse, opacity );
  3149. #include <clipping_planes_fragment>
  3150. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3151. vec3 totalEmissiveRadiance = emissive;
  3152. #include <logdepthbuf_fragment>
  3153. #include <map_fragment>
  3154. #include <color_fragment>
  3155. #include <alphamap_fragment>
  3156. #include <alphatest_fragment>
  3157. #include <alphahash_fragment>
  3158. #include <specularmap_fragment>
  3159. #include <normal_fragment_begin>
  3160. #include <normal_fragment_maps>
  3161. #include <emissivemap_fragment>
  3162. #include <lights_phong_fragment>
  3163. #include <lights_fragment_begin>
  3164. #include <lights_fragment_maps>
  3165. #include <lights_fragment_end>
  3166. #include <aomap_fragment>
  3167. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  3168. #include <envmap_fragment>
  3169. #include <opaque_fragment>
  3170. #include <tonemapping_fragment>
  3171. #include <colorspace_fragment>
  3172. #include <fog_fragment>
  3173. #include <premultiplied_alpha_fragment>
  3174. #include <dithering_fragment>
  3175. }`,Fhe=`#define STANDARD
  3176. varying vec3 vViewPosition;
  3177. #ifdef USE_TRANSMISSION
  3178. varying vec3 vWorldPosition;
  3179. #endif
  3180. #include <common>
  3181. #include <batching_pars_vertex>
  3182. #include <uv_pars_vertex>
  3183. #include <displacementmap_pars_vertex>
  3184. #include <color_pars_vertex>
  3185. #include <fog_pars_vertex>
  3186. #include <normal_pars_vertex>
  3187. #include <morphtarget_pars_vertex>
  3188. #include <skinning_pars_vertex>
  3189. #include <shadowmap_pars_vertex>
  3190. #include <logdepthbuf_pars_vertex>
  3191. #include <clipping_planes_pars_vertex>
  3192. void main() {
  3193. #include <uv_vertex>
  3194. #include <color_vertex>
  3195. #include <morphinstance_vertex>
  3196. #include <morphcolor_vertex>
  3197. #include <batching_vertex>
  3198. #include <beginnormal_vertex>
  3199. #include <morphnormal_vertex>
  3200. #include <skinbase_vertex>
  3201. #include <skinnormal_vertex>
  3202. #include <defaultnormal_vertex>
  3203. #include <normal_vertex>
  3204. #include <begin_vertex>
  3205. #include <morphtarget_vertex>
  3206. #include <skinning_vertex>
  3207. #include <displacementmap_vertex>
  3208. #include <project_vertex>
  3209. #include <logdepthbuf_vertex>
  3210. #include <clipping_planes_vertex>
  3211. vViewPosition = - mvPosition.xyz;
  3212. #include <worldpos_vertex>
  3213. #include <shadowmap_vertex>
  3214. #include <fog_vertex>
  3215. #ifdef USE_TRANSMISSION
  3216. vWorldPosition = worldPosition.xyz;
  3217. #endif
  3218. }`,zhe=`#define STANDARD
  3219. #ifdef PHYSICAL
  3220. #define IOR
  3221. #define USE_SPECULAR
  3222. #endif
  3223. uniform vec3 diffuse;
  3224. uniform vec3 emissive;
  3225. uniform float roughness;
  3226. uniform float metalness;
  3227. uniform float opacity;
  3228. #ifdef IOR
  3229. uniform float ior;
  3230. #endif
  3231. #ifdef USE_SPECULAR
  3232. uniform float specularIntensity;
  3233. uniform vec3 specularColor;
  3234. #ifdef USE_SPECULAR_COLORMAP
  3235. uniform sampler2D specularColorMap;
  3236. #endif
  3237. #ifdef USE_SPECULAR_INTENSITYMAP
  3238. uniform sampler2D specularIntensityMap;
  3239. #endif
  3240. #endif
  3241. #ifdef USE_CLEARCOAT
  3242. uniform float clearcoat;
  3243. uniform float clearcoatRoughness;
  3244. #endif
  3245. #ifdef USE_DISPERSION
  3246. uniform float dispersion;
  3247. #endif
  3248. #ifdef USE_IRIDESCENCE
  3249. uniform float iridescence;
  3250. uniform float iridescenceIOR;
  3251. uniform float iridescenceThicknessMinimum;
  3252. uniform float iridescenceThicknessMaximum;
  3253. #endif
  3254. #ifdef USE_SHEEN
  3255. uniform vec3 sheenColor;
  3256. uniform float sheenRoughness;
  3257. #ifdef USE_SHEEN_COLORMAP
  3258. uniform sampler2D sheenColorMap;
  3259. #endif
  3260. #ifdef USE_SHEEN_ROUGHNESSMAP
  3261. uniform sampler2D sheenRoughnessMap;
  3262. #endif
  3263. #endif
  3264. #ifdef USE_ANISOTROPY
  3265. uniform vec2 anisotropyVector;
  3266. #ifdef USE_ANISOTROPYMAP
  3267. uniform sampler2D anisotropyMap;
  3268. #endif
  3269. #endif
  3270. varying vec3 vViewPosition;
  3271. #include <common>
  3272. #include <packing>
  3273. #include <dithering_pars_fragment>
  3274. #include <color_pars_fragment>
  3275. #include <uv_pars_fragment>
  3276. #include <map_pars_fragment>
  3277. #include <alphamap_pars_fragment>
  3278. #include <alphatest_pars_fragment>
  3279. #include <alphahash_pars_fragment>
  3280. #include <aomap_pars_fragment>
  3281. #include <lightmap_pars_fragment>
  3282. #include <emissivemap_pars_fragment>
  3283. #include <iridescence_fragment>
  3284. #include <cube_uv_reflection_fragment>
  3285. #include <envmap_common_pars_fragment>
  3286. #include <envmap_physical_pars_fragment>
  3287. #include <fog_pars_fragment>
  3288. #include <lights_pars_begin>
  3289. #include <normal_pars_fragment>
  3290. #include <lights_physical_pars_fragment>
  3291. #include <transmission_pars_fragment>
  3292. #include <shadowmap_pars_fragment>
  3293. #include <bumpmap_pars_fragment>
  3294. #include <normalmap_pars_fragment>
  3295. #include <clearcoat_pars_fragment>
  3296. #include <iridescence_pars_fragment>
  3297. #include <roughnessmap_pars_fragment>
  3298. #include <metalnessmap_pars_fragment>
  3299. #include <logdepthbuf_pars_fragment>
  3300. #include <clipping_planes_pars_fragment>
  3301. void main() {
  3302. vec4 diffuseColor = vec4( diffuse, opacity );
  3303. #include <clipping_planes_fragment>
  3304. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3305. vec3 totalEmissiveRadiance = emissive;
  3306. #include <logdepthbuf_fragment>
  3307. #include <map_fragment>
  3308. #include <color_fragment>
  3309. #include <alphamap_fragment>
  3310. #include <alphatest_fragment>
  3311. #include <alphahash_fragment>
  3312. #include <roughnessmap_fragment>
  3313. #include <metalnessmap_fragment>
  3314. #include <normal_fragment_begin>
  3315. #include <normal_fragment_maps>
  3316. #include <clearcoat_normal_fragment_begin>
  3317. #include <clearcoat_normal_fragment_maps>
  3318. #include <emissivemap_fragment>
  3319. #include <lights_physical_fragment>
  3320. #include <lights_fragment_begin>
  3321. #include <lights_fragment_maps>
  3322. #include <lights_fragment_end>
  3323. #include <aomap_fragment>
  3324. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  3325. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  3326. #include <transmission_fragment>
  3327. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  3328. #ifdef USE_SHEEN
  3329. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  3330. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  3331. #endif
  3332. #ifdef USE_CLEARCOAT
  3333. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  3334. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  3335. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  3336. #endif
  3337. #include <opaque_fragment>
  3338. #include <tonemapping_fragment>
  3339. #include <colorspace_fragment>
  3340. #include <fog_fragment>
  3341. #include <premultiplied_alpha_fragment>
  3342. #include <dithering_fragment>
  3343. }`,Bhe=`#define TOON
  3344. varying vec3 vViewPosition;
  3345. #include <common>
  3346. #include <batching_pars_vertex>
  3347. #include <uv_pars_vertex>
  3348. #include <displacementmap_pars_vertex>
  3349. #include <color_pars_vertex>
  3350. #include <fog_pars_vertex>
  3351. #include <normal_pars_vertex>
  3352. #include <morphtarget_pars_vertex>
  3353. #include <skinning_pars_vertex>
  3354. #include <shadowmap_pars_vertex>
  3355. #include <logdepthbuf_pars_vertex>
  3356. #include <clipping_planes_pars_vertex>
  3357. void main() {
  3358. #include <uv_vertex>
  3359. #include <color_vertex>
  3360. #include <morphinstance_vertex>
  3361. #include <morphcolor_vertex>
  3362. #include <batching_vertex>
  3363. #include <beginnormal_vertex>
  3364. #include <morphnormal_vertex>
  3365. #include <skinbase_vertex>
  3366. #include <skinnormal_vertex>
  3367. #include <defaultnormal_vertex>
  3368. #include <normal_vertex>
  3369. #include <begin_vertex>
  3370. #include <morphtarget_vertex>
  3371. #include <skinning_vertex>
  3372. #include <displacementmap_vertex>
  3373. #include <project_vertex>
  3374. #include <logdepthbuf_vertex>
  3375. #include <clipping_planes_vertex>
  3376. vViewPosition = - mvPosition.xyz;
  3377. #include <worldpos_vertex>
  3378. #include <shadowmap_vertex>
  3379. #include <fog_vertex>
  3380. }`,Hhe=`#define TOON
  3381. uniform vec3 diffuse;
  3382. uniform vec3 emissive;
  3383. uniform float opacity;
  3384. #include <common>
  3385. #include <packing>
  3386. #include <dithering_pars_fragment>
  3387. #include <color_pars_fragment>
  3388. #include <uv_pars_fragment>
  3389. #include <map_pars_fragment>
  3390. #include <alphamap_pars_fragment>
  3391. #include <alphatest_pars_fragment>
  3392. #include <alphahash_pars_fragment>
  3393. #include <aomap_pars_fragment>
  3394. #include <lightmap_pars_fragment>
  3395. #include <emissivemap_pars_fragment>
  3396. #include <gradientmap_pars_fragment>
  3397. #include <fog_pars_fragment>
  3398. #include <bsdfs>
  3399. #include <lights_pars_begin>
  3400. #include <normal_pars_fragment>
  3401. #include <lights_toon_pars_fragment>
  3402. #include <shadowmap_pars_fragment>
  3403. #include <bumpmap_pars_fragment>
  3404. #include <normalmap_pars_fragment>
  3405. #include <logdepthbuf_pars_fragment>
  3406. #include <clipping_planes_pars_fragment>
  3407. void main() {
  3408. vec4 diffuseColor = vec4( diffuse, opacity );
  3409. #include <clipping_planes_fragment>
  3410. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3411. vec3 totalEmissiveRadiance = emissive;
  3412. #include <logdepthbuf_fragment>
  3413. #include <map_fragment>
  3414. #include <color_fragment>
  3415. #include <alphamap_fragment>
  3416. #include <alphatest_fragment>
  3417. #include <alphahash_fragment>
  3418. #include <normal_fragment_begin>
  3419. #include <normal_fragment_maps>
  3420. #include <emissivemap_fragment>
  3421. #include <lights_toon_fragment>
  3422. #include <lights_fragment_begin>
  3423. #include <lights_fragment_maps>
  3424. #include <lights_fragment_end>
  3425. #include <aomap_fragment>
  3426. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3427. #include <opaque_fragment>
  3428. #include <tonemapping_fragment>
  3429. #include <colorspace_fragment>
  3430. #include <fog_fragment>
  3431. #include <premultiplied_alpha_fragment>
  3432. #include <dithering_fragment>
  3433. }`,$he=`uniform float size;
  3434. uniform float scale;
  3435. #include <common>
  3436. #include <color_pars_vertex>
  3437. #include <fog_pars_vertex>
  3438. #include <morphtarget_pars_vertex>
  3439. #include <logdepthbuf_pars_vertex>
  3440. #include <clipping_planes_pars_vertex>
  3441. #ifdef USE_POINTS_UV
  3442. varying vec2 vUv;
  3443. uniform mat3 uvTransform;
  3444. #endif
  3445. void main() {
  3446. #ifdef USE_POINTS_UV
  3447. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  3448. #endif
  3449. #include <color_vertex>
  3450. #include <morphinstance_vertex>
  3451. #include <morphcolor_vertex>
  3452. #include <begin_vertex>
  3453. #include <morphtarget_vertex>
  3454. #include <project_vertex>
  3455. gl_PointSize = size;
  3456. #ifdef USE_SIZEATTENUATION
  3457. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3458. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  3459. #endif
  3460. #include <logdepthbuf_vertex>
  3461. #include <clipping_planes_vertex>
  3462. #include <worldpos_vertex>
  3463. #include <fog_vertex>
  3464. }`,Vhe=`uniform vec3 diffuse;
  3465. uniform float opacity;
  3466. #include <common>
  3467. #include <color_pars_fragment>
  3468. #include <map_particle_pars_fragment>
  3469. #include <alphatest_pars_fragment>
  3470. #include <alphahash_pars_fragment>
  3471. #include <fog_pars_fragment>
  3472. #include <logdepthbuf_pars_fragment>
  3473. #include <clipping_planes_pars_fragment>
  3474. void main() {
  3475. vec4 diffuseColor = vec4( diffuse, opacity );
  3476. #include <clipping_planes_fragment>
  3477. vec3 outgoingLight = vec3( 0.0 );
  3478. #include <logdepthbuf_fragment>
  3479. #include <map_particle_fragment>
  3480. #include <color_fragment>
  3481. #include <alphatest_fragment>
  3482. #include <alphahash_fragment>
  3483. outgoingLight = diffuseColor.rgb;
  3484. #include <opaque_fragment>
  3485. #include <tonemapping_fragment>
  3486. #include <colorspace_fragment>
  3487. #include <fog_fragment>
  3488. #include <premultiplied_alpha_fragment>
  3489. }`,Ghe=`#include <common>
  3490. #include <batching_pars_vertex>
  3491. #include <fog_pars_vertex>
  3492. #include <morphtarget_pars_vertex>
  3493. #include <skinning_pars_vertex>
  3494. #include <logdepthbuf_pars_vertex>
  3495. #include <shadowmap_pars_vertex>
  3496. void main() {
  3497. #include <batching_vertex>
  3498. #include <beginnormal_vertex>
  3499. #include <morphinstance_vertex>
  3500. #include <morphnormal_vertex>
  3501. #include <skinbase_vertex>
  3502. #include <skinnormal_vertex>
  3503. #include <defaultnormal_vertex>
  3504. #include <begin_vertex>
  3505. #include <morphtarget_vertex>
  3506. #include <skinning_vertex>
  3507. #include <project_vertex>
  3508. #include <logdepthbuf_vertex>
  3509. #include <worldpos_vertex>
  3510. #include <shadowmap_vertex>
  3511. #include <fog_vertex>
  3512. }`,Whe=`uniform vec3 color;
  3513. uniform float opacity;
  3514. #include <common>
  3515. #include <packing>
  3516. #include <fog_pars_fragment>
  3517. #include <bsdfs>
  3518. #include <lights_pars_begin>
  3519. #include <logdepthbuf_pars_fragment>
  3520. #include <shadowmap_pars_fragment>
  3521. #include <shadowmask_pars_fragment>
  3522. void main() {
  3523. #include <logdepthbuf_fragment>
  3524. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  3525. #include <tonemapping_fragment>
  3526. #include <colorspace_fragment>
  3527. #include <fog_fragment>
  3528. }`,qhe=`uniform float rotation;
  3529. uniform vec2 center;
  3530. #include <common>
  3531. #include <uv_pars_vertex>
  3532. #include <fog_pars_vertex>
  3533. #include <logdepthbuf_pars_vertex>
  3534. #include <clipping_planes_pars_vertex>
  3535. void main() {
  3536. #include <uv_vertex>
  3537. vec4 mvPosition = modelViewMatrix[ 3 ];
  3538. vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
  3539. #ifndef USE_SIZEATTENUATION
  3540. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3541. if ( isPerspective ) scale *= - mvPosition.z;
  3542. #endif
  3543. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  3544. vec2 rotatedPosition;
  3545. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  3546. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  3547. mvPosition.xy += rotatedPosition;
  3548. gl_Position = projectionMatrix * mvPosition;
  3549. #include <logdepthbuf_vertex>
  3550. #include <clipping_planes_vertex>
  3551. #include <fog_vertex>
  3552. }`,Xhe=`uniform vec3 diffuse;
  3553. uniform float opacity;
  3554. #include <common>
  3555. #include <uv_pars_fragment>
  3556. #include <map_pars_fragment>
  3557. #include <alphamap_pars_fragment>
  3558. #include <alphatest_pars_fragment>
  3559. #include <alphahash_pars_fragment>
  3560. #include <fog_pars_fragment>
  3561. #include <logdepthbuf_pars_fragment>
  3562. #include <clipping_planes_pars_fragment>
  3563. void main() {
  3564. vec4 diffuseColor = vec4( diffuse, opacity );
  3565. #include <clipping_planes_fragment>
  3566. vec3 outgoingLight = vec3( 0.0 );
  3567. #include <logdepthbuf_fragment>
  3568. #include <map_fragment>
  3569. #include <alphamap_fragment>
  3570. #include <alphatest_fragment>
  3571. #include <alphahash_fragment>
  3572. outgoingLight = diffuseColor.rgb;
  3573. #include <opaque_fragment>
  3574. #include <tonemapping_fragment>
  3575. #include <colorspace_fragment>
  3576. #include <fog_fragment>
  3577. }`,rn={alphahash_fragment:gde,alphahash_pars_fragment:xde,alphamap_fragment:vde,alphamap_pars_fragment:bde,alphatest_fragment:yde,alphatest_pars_fragment:_de,aomap_fragment:Sde,aomap_pars_fragment:wde,batching_pars_vertex:Mde,batching_vertex:Ede,begin_vertex:Ade,beginnormal_vertex:Tde,bsdfs:Cde,iridescence_fragment:Nde,bumpmap_pars_fragment:Rde,clipping_planes_fragment:Pde,clipping_planes_pars_fragment:kde,clipping_planes_pars_vertex:Dde,clipping_planes_vertex:Ode,color_fragment:Lde,color_pars_fragment:Ide,color_pars_vertex:jde,color_vertex:Ude,common:Fde,cube_uv_reflection_fragment:zde,defaultnormal_vertex:Bde,displacementmap_pars_vertex:Hde,displacementmap_vertex:$de,emissivemap_fragment:Vde,emissivemap_pars_fragment:Gde,colorspace_fragment:Wde,colorspace_pars_fragment:qde,envmap_fragment:Xde,envmap_common_pars_fragment:Kde,envmap_pars_fragment:Yde,envmap_pars_vertex:Zde,envmap_physical_pars_fragment:lfe,envmap_vertex:Qde,fog_vertex:Jde,fog_pars_vertex:efe,fog_fragment:tfe,fog_pars_fragment:nfe,gradientmap_pars_fragment:rfe,lightmap_pars_fragment:ife,lights_lambert_fragment:afe,lights_lambert_pars_fragment:sfe,lights_pars_begin:ofe,lights_toon_fragment:cfe,lights_toon_pars_fragment:ufe,lights_phong_fragment:dfe,lights_phong_pars_fragment:ffe,lights_physical_fragment:hfe,lights_physical_pars_fragment:pfe,lights_fragment_begin:mfe,lights_fragment_maps:gfe,lights_fragment_end:xfe,logdepthbuf_fragment:vfe,logdepthbuf_pars_fragment:bfe,logdepthbuf_pars_vertex:yfe,logdepthbuf_vertex:_fe,map_fragment:Sfe,map_pars_fragment:wfe,map_particle_fragment:Mfe,map_particle_pars_fragment:Efe,metalnessmap_fragment:Afe,metalnessmap_pars_fragment:Tfe,morphinstance_vertex:Cfe,morphcolor_vertex:Nfe,morphnormal_vertex:Rfe,morphtarget_pars_vertex:Pfe,morphtarget_vertex:kfe,normal_fragment_begin:Dfe,normal_fragment_maps:Ofe,normal_pars_fragment:Lfe,normal_pars_vertex:Ife,normal_vertex:jfe,normalmap_pars_fragment:Ufe,clearcoat_normal_fragment_begin:Ffe,clearcoat_normal_fragment_maps:zfe,clearcoat_pars_fragment:Bfe,iridescence_pars_fragment:Hfe,opaque_fragment:$fe,packing:Vfe,premultiplied_alpha_fragment:Gfe,project_vertex:Wfe,dithering_fragment:qfe,dithering_pars_fragment:Xfe,roughnessmap_fragment:Kfe,roughnessmap_pars_fragment:Yfe,shadowmap_pars_fragment:Zfe,shadowmap_pars_vertex:Qfe,shadowmap_vertex:Jfe,shadowmask_pars_fragment:ehe,skinbase_vertex:the,skinning_pars_vertex:nhe,skinning_vertex:rhe,skinnormal_vertex:ihe,specularmap_fragment:ahe,specularmap_pars_fragment:she,tonemapping_fragment:ohe,tonemapping_pars_fragment:lhe,transmission_fragment:che,transmission_pars_fragment:uhe,uv_pars_fragment:dhe,uv_pars_vertex:fhe,uv_vertex:hhe,worldpos_vertex:phe,background_vert:mhe,background_frag:ghe,backgroundCube_vert:xhe,backgroundCube_frag:vhe,cube_vert:bhe,cube_frag:yhe,depth_vert:_he,depth_frag:She,distanceRGBA_vert:whe,distanceRGBA_frag:Mhe,equirect_vert:Ehe,equirect_frag:Ahe,linedashed_vert:The,linedashed_frag:Che,meshbasic_vert:Nhe,meshbasic_frag:Rhe,meshlambert_vert:Phe,meshlambert_frag:khe,meshmatcap_vert:Dhe,meshmatcap_frag:Ohe,meshnormal_vert:Lhe,meshnormal_frag:Ihe,meshphong_vert:jhe,meshphong_frag:Uhe,meshphysical_vert:Fhe,meshphysical_frag:zhe,meshtoon_vert:Bhe,meshtoon_frag:Hhe,points_vert:$he,points_frag:Vhe,shadow_vert:Ghe,shadow_frag:Whe,sprite_vert:qhe,sprite_frag:Xhe},St={common:{diffuse:{value:new bn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new un},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new un}},envmap:{envMap:{value:null},envMapRotation:{value:new un},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 un}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new un}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new un},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new un},normalScale:{value:new sn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new un},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new un}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new un}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new un}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new bn(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 bn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0},uvTransform:{value:new un}},sprite:{diffuse:{value:new bn(16777215)},opacity:{value:1},center:{value:new sn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new un},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0}}},$o={basic:{uniforms:fa([St.common,St.specularmap,St.envmap,St.aomap,St.lightmap,St.fog]),vertexShader:rn.meshbasic_vert,fragmentShader:rn.meshbasic_frag},lambert:{uniforms:fa([St.common,St.specularmap,St.envmap,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.fog,St.lights,{emissive:{value:new bn(0)}}]),vertexShader:rn.meshlambert_vert,fragmentShader:rn.meshlambert_frag},phong:{uniforms:fa([St.common,St.specularmap,St.envmap,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.fog,St.lights,{emissive:{value:new bn(0)},specular:{value:new bn(1118481)},shininess:{value:30}}]),vertexShader:rn.meshphong_vert,fragmentShader:rn.meshphong_frag},standard:{uniforms:fa([St.common,St.envmap,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.roughnessmap,St.metalnessmap,St.fog,St.lights,{emissive:{value:new bn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:rn.meshphysical_vert,fragmentShader:rn.meshphysical_frag},toon:{uniforms:fa([St.common,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.gradientmap,St.fog,St.lights,{emissive:{value:new bn(0)}}]),vertexShader:rn.meshtoon_vert,fragmentShader:rn.meshtoon_frag},matcap:{uniforms:fa([St.common,St.bumpmap,St.normalmap,St.displacementmap,St.fog,{matcap:{value:null}}]),vertexShader:rn.meshmatcap_vert,fragmentShader:rn.meshmatcap_frag},points:{uniforms:fa([St.points,St.fog]),vertexShader:rn.points_vert,fragmentShader:rn.points_frag},dashed:{uniforms:fa([St.common,St.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:rn.linedashed_vert,fragmentShader:rn.linedashed_frag},depth:{uniforms:fa([St.common,St.displacementmap]),vertexShader:rn.depth_vert,fragmentShader:rn.depth_frag},normal:{uniforms:fa([St.common,St.bumpmap,St.normalmap,St.displacementmap,{opacity:{value:1}}]),vertexShader:rn.meshnormal_vert,fragmentShader:rn.meshnormal_frag},sprite:{uniforms:fa([St.sprite,St.fog]),vertexShader:rn.sprite_vert,fragmentShader:rn.sprite_frag},background:{uniforms:{uvTransform:{value:new un},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:rn.background_vert,fragmentShader:rn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new un}},vertexShader:rn.backgroundCube_vert,fragmentShader:rn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:rn.cube_vert,fragmentShader:rn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:rn.equirect_vert,fragmentShader:rn.equirect_frag},distanceRGBA:{uniforms:fa([St.common,St.displacementmap,{referencePosition:{value:new We},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:rn.distanceRGBA_vert,fragmentShader:rn.distanceRGBA_frag},shadow:{uniforms:fa([St.lights,St.fog,{color:{value:new bn(0)},opacity:{value:1}}]),vertexShader:rn.shadow_vert,fragmentShader:rn.shadow_frag}};$o.physical={uniforms:fa([$o.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new un},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new un},clearcoatNormalScale:{value:new sn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new un},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new un},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new un},sheen:{value:0},sheenColor:{value:new bn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new un},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new un},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new un},transmissionSamplerSize:{value:new sn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new un},attenuationDistance:{value:0},attenuationColor:{value:new bn(0)},specularColor:{value:new bn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new un},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new un},anisotropyVector:{value:new sn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new un}}]),vertexShader:rn.meshphysical_vert,fragmentShader:rn.meshphysical_frag};const ry={r:0,b:0,g:0},Od=new Zu,Khe=new Xr;function Yhe(t,e,n,r,i,a,s){const o=new bn(0);let l=a===!0?0:1,c,u,h=null,g=0,m=null;function b(w){let C=w.isScene===!0?w.background:null;return C&&C.isTexture&&(C=(w.backgroundBlurriness>0?n:e).get(C)),C}function y(w){let C=!1;const T=b(w);T===null?x(o,l):T&&T.isColor&&(x(T,1),C=!0);const R=t.xr.getEnvironmentBlendMode();R==="additive"?r.buffers.color.setClear(0,0,0,1,s):R==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,s),(t.autoClear||C)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function v(w,C){const T=b(C);T&&(T.isCubeTexture||T.mapping===rw)?(u===void 0&&(u=new il(new uk(1,1,1),new vc({name:"BackgroundCubeMaterial",uniforms:Qp($o.backgroundCube.uniforms),vertexShader:$o.backgroundCube.vertexShader,fragmentShader:$o.backgroundCube.fragmentShader,side:Ua,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(R,A,j){this.matrixWorld.copyPosition(j.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),Od.copy(C.backgroundRotation),Od.x*=-1,Od.y*=-1,Od.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(Od.y*=-1,Od.z*=-1),u.material.uniforms.envMap.value=T,u.material.uniforms.flipEnvMap.value=T.isCubeTexture&&T.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=C.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=C.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(Khe.makeRotationFromEuler(Od)),u.material.toneMapped=En.getTransfer(T.colorSpace)!==Bn,(h!==T||g!==T.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,h=T,g=T.version,m=t.toneMapping),u.layers.enableAll(),w.unshift(u,u.geometry,u.material,0,0,null)):T&&T.isTexture&&(c===void 0&&(c=new il(new fk(2,2),new vc({name:"BackgroundMaterial",uniforms:Qp($o.background.uniforms),vertexShader:$o.background.vertexShader,fragmentShader:$o.background.fragmentShader,side:Yu,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=T,c.material.uniforms.backgroundIntensity.value=C.backgroundIntensity,c.material.toneMapped=En.getTransfer(T.colorSpace)!==Bn,T.matrixAutoUpdate===!0&&T.updateMatrix(),c.material.uniforms.uvTransform.value.copy(T.matrix),(h!==T||g!==T.version||m!==t.toneMapping)&&(c.material.needsUpdate=!0,h=T,g=T.version,m=t.toneMapping),c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null))}function x(w,C){w.getRGB(ry,K9(t)),r.buffers.color.setClear(ry.r,ry.g,ry.b,C,s)}function M(){u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(w,C=1){o.set(w),l=C,x(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(w){l=w,x(o,l)},render:y,addToRenderList:v,dispose:M}}function Zhe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=g(null);let a=i,s=!1;function o(k,F,I,W,D){let B=!1;const G=h(W,I,F);a!==G&&(a=G,c(a.object)),B=m(k,W,I,D),B&&b(k,W,I,D),D!==null&&e.update(D,t.ELEMENT_ARRAY_BUFFER),(B||s)&&(s=!1,C(k,F,I,W),D!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(D).buffer))}function l(){return t.createVertexArray()}function c(k){return t.bindVertexArray(k)}function u(k){return t.deleteVertexArray(k)}function h(k,F,I){const W=I.wireframe===!0;let D=r[k.id];D===void 0&&(D={},r[k.id]=D);let B=D[F.id];B===void 0&&(B={},D[F.id]=B);let G=B[W];return G===void 0&&(G=g(l()),B[W]=G),G}function g(k){const F=[],I=[],W=[];for(let D=0;D<n;D++)F[D]=0,I[D]=0,W[D]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:I,attributeDivisors:W,object:k,attributes:{},index:null}}function m(k,F,I,W){const D=a.attributes,B=F.attributes;let G=0;const V=I.getAttributes();for(const Z in V)if(V[Z].location>=0){const ee=D[Z];let H=B[Z];if(H===void 0&&(Z==="instanceMatrix"&&k.instanceMatrix&&(H=k.instanceMatrix),Z==="instanceColor"&&k.instanceColor&&(H=k.instanceColor)),ee===void 0||ee.attribute!==H||H&&ee.data!==H.data)return!0;G++}return a.attributesNum!==G||a.index!==W}function b(k,F,I,W){const D={},B=F.attributes;let G=0;const V=I.getAttributes();for(const Z in V)if(V[Z].location>=0){let ee=B[Z];ee===void 0&&(Z==="instanceMatrix"&&k.instanceMatrix&&(ee=k.instanceMatrix),Z==="instanceColor"&&k.instanceColor&&(ee=k.instanceColor));const H={};H.attribute=ee,ee&&ee.data&&(H.data=ee.data),D[Z]=H,G++}a.attributes=D,a.attributesNum=G,a.index=W}function y(){const k=a.newAttributes;for(let F=0,I=k.length;F<I;F++)k[F]=0}function v(k){x(k,0)}function x(k,F){const I=a.newAttributes,W=a.enabledAttributes,D=a.attributeDivisors;I[k]=1,W[k]===0&&(t.enableVertexAttribArray(k),W[k]=1),D[k]!==F&&(t.vertexAttribDivisor(k,F),D[k]=F)}function M(){const k=a.newAttributes,F=a.enabledAttributes;for(let I=0,W=F.length;I<W;I++)F[I]!==k[I]&&(t.disableVertexAttribArray(I),F[I]=0)}function w(k,F,I,W,D,B,G){G===!0?t.vertexAttribIPointer(k,F,I,D,B):t.vertexAttribPointer(k,F,I,W,D,B)}function C(k,F,I,W){y();const D=W.attributes,B=I.getAttributes(),G=F.defaultAttributeValues;for(const V in B){const Z=B[V];if(Z.location>=0){let Y=D[V];if(Y===void 0&&(V==="instanceMatrix"&&k.instanceMatrix&&(Y=k.instanceMatrix),V==="instanceColor"&&k.instanceColor&&(Y=k.instanceColor)),Y!==void 0){const ee=Y.normalized,H=Y.itemSize,q=e.get(Y);if(q===void 0)continue;const ae=q.buffer,ce=q.type,xe=q.bytesPerElement,ie=ce===t.INT||ce===t.UNSIGNED_INT||Y.gpuType===ek;if(Y.isInterleavedBufferAttribute){const ve=Y.data,Pe=ve.stride,he=Y.offset;if(ve.isInstancedInterleavedBuffer){for(let we=0;we<Z.locationSize;we++)x(Z.location+we,ve.meshPerAttribute);k.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=ve.meshPerAttribute*ve.count)}else for(let we=0;we<Z.locationSize;we++)v(Z.location+we);t.bindBuffer(t.ARRAY_BUFFER,ae);for(let we=0;we<Z.locationSize;we++)w(Z.location+we,H/Z.locationSize,ce,ee,Pe*xe,(he+H/Z.locationSize*we)*xe,ie)}else{if(Y.isInstancedBufferAttribute){for(let ve=0;ve<Z.locationSize;ve++)x(Z.location+ve,Y.meshPerAttribute);k.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=Y.meshPerAttribute*Y.count)}else for(let ve=0;ve<Z.locationSize;ve++)v(Z.location+ve);t.bindBuffer(t.ARRAY_BUFFER,ae);for(let ve=0;ve<Z.locationSize;ve++)w(Z.location+ve,H/Z.locationSize,ce,ee,H*xe,H/Z.locationSize*ve*xe,ie)}}else if(G!==void 0){const ee=G[V];if(ee!==void 0)switch(ee.length){case 2:t.vertexAttrib2fv(Z.location,ee);break;case 3:t.vertexAttrib3fv(Z.location,ee);break;case 4:t.vertexAttrib4fv(Z.location,ee);break;default:t.vertexAttrib1fv(Z.location,ee)}}}}M()}function T(){j();for(const k in r){const F=r[k];for(const I in F){const W=F[I];for(const D in W)u(W[D].object),delete W[D];delete F[I]}delete r[k]}}function R(k){if(r[k.id]===void 0)return;const F=r[k.id];for(const I in F){const W=F[I];for(const D in W)u(W[D].object),delete W[D];delete F[I]}delete r[k.id]}function A(k){for(const F in r){const I=r[F];if(I[k.id]===void 0)continue;const W=I[k.id];for(const D in W)u(W[D].object),delete W[D];delete I[k.id]}}function j(){N(),s=!0,a!==i&&(a=i,c(a.object))}function N(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:j,resetDefaultState:N,dispose:T,releaseStatesOfGeometry:R,releaseStatesOfProgram:A,initAttributes:y,enableAttribute:v,disableUnusedAttributes:M}}function Qhe(t,e,n){let r;function i(c){r=c}function a(c,u){t.drawArrays(r,c,u),n.update(u,r,1)}function s(c,u,h){h!==0&&(t.drawArraysInstanced(r,c,u,h),n.update(u,r,h))}function o(c,u,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,c,0,u,0,h);let m=0;for(let b=0;b<h;b++)m+=u[b];n.update(m,r,1)}function l(c,u,h,g){if(h===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let b=0;b<c.length;b++)s(c[b],u[b],g[b]);else{m.multiDrawArraysInstancedWEBGL(r,c,0,u,0,g,0,h);let b=0;for(let y=0;y<h;y++)b+=u[y]*g[y];n.update(b,r,1)}}this.setMode=i,this.render=a,this.renderInstances=s,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function Jhe(t,e,n,r){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const A=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function s(A){return!(A!==xo&&r.convert(A)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(A){const j=A===Em&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==rl&&r.convert(A)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==nc&&!j)}function l(A){if(A==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=n.precision!==void 0?n.precision:"highp";const u=l(c);u!==c&&(Xt("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const h=n.logarithmicDepthBuffer===!0,g=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),b=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=t.getParameter(t.MAX_TEXTURE_SIZE),v=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),x=t.getParameter(t.MAX_VERTEX_ATTRIBS),M=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),w=t.getParameter(t.MAX_VARYING_VECTORS),C=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),T=b>0,R=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:l,textureFormatReadable:s,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:h,reversedDepthBuffer:g,maxTextures:m,maxVertexTextures:b,maxTextureSize:y,maxCubemapSize:v,maxAttributes:x,maxVertexUniforms:M,maxVaryings:w,maxFragmentUniforms:C,vertexTextures:T,maxSamples:R}}function epe(t){const e=this;let n=null,r=0,i=!1,a=!1;const s=new yu,o=new un,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,g){const m=h.length!==0||g||r!==0||i;return i=g,r=h.length,m},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(h,g){n=u(h,g,0)},this.setState=function(h,g,m){const b=h.clippingPlanes,y=h.clipIntersection,v=h.clipShadows,x=t.get(h);if(!i||b===null||b.length===0||a&&!v)a?u(null):c();else{const M=a?0:r,w=M*4;let C=x.clippingState||null;l.value=C,C=u(b,g,w,m);for(let T=0;T!==w;++T)C[T]=n[T];x.clippingState=C,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=M}};function c(){l.value!==n&&(l.value=n,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function u(h,g,m,b){const y=h!==null?h.length:0;let v=null;if(y!==0){if(v=l.value,b!==!0||v===null){const x=m+y*4,M=g.matrixWorldInverse;o.getNormalMatrix(M),(v===null||v.length<x)&&(v=new Float32Array(x));for(let w=0,C=m;w!==y;++w,C+=4)s.copy(h[w]).applyMatrix4(M,o),s.normal.toArray(v,C),v[C+3]=s.constant}l.value=v,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,v}}function tpe(t){let e=new WeakMap;function n(s,o){return o===XN?s.mapping=Kp:o===KN&&(s.mapping=Yp),s}function r(s){if(s&&s.isTexture){const o=s.mapping;if(o===XN||o===KN)if(e.has(s)){const l=e.get(s).texture;return n(l,s.mapping)}else{const l=s.image;if(l&&l.height>0){const c=new Yue(l.height);return c.fromEquirectangularTexture(t,s),e.set(s,c),s.addEventListener("dispose",i),n(c.texture,s.mapping)}else return null}}return s}function i(s){const o=s.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}const ku=4,VF=[.125,.215,.35,.446,.526,.582],qd=20,npe=256,Vg=new r7,GF=new bn;let pT=null,mT=0,gT=0,xT=!1;const rpe=new We;let WF=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,n=0,r=.1,i=100,a={}){const{size:s=256,position:o=rpe}=a;pT=this._renderer.getRenderTarget(),mT=this._renderer.getActiveCubeFace(),gT=this._renderer.getActiveMipmapLevel(),xT=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,r,i,l,o),n>0&&this._blur(l,0,0,n),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=KF(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=XF(),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(pT,mT,gT),this._renderer.xr.enabled=xT,e.scissorTest=!1,Gh(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Kp||e.mapping===Yp?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),pT=this._renderer.getRenderTarget(),mT=this._renderer.getActiveCubeFace(),gT=this._renderer.getActiveMipmapLevel(),xT=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:Hs,minFilter:Hs,generateMipmaps:!1,type:Em,format:xo,colorSpace:Zp,depthBuffer:!1},i=qF(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=qF(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=ipe(a)),this._blurMaterial=spe(a,e,n),this._ggxMaterial=ape(a,e,n)}return i}_compileMaterial(e){const n=new il(new fl,e);this._renderer.compile(n,Vg)}_sceneToCubeUV(e,n,r,i,a){const l=new js(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],h=this._renderer,g=h.autoClear,m=h.toneMapping;h.getClearColor(GF),h.toneMapping=Fu,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(i),h.clearDepth(),h.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new il(new uk,new ck({name:"PMREM.Background",side:Ua,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,v=y.material;let x=!1;const M=e.background;M?M.isColor&&(v.color.copy(M),e.background=null,x=!0):(v.color.copy(GF),x=!0);for(let w=0;w<6;w++){const C=w%3;C===0?(l.up.set(0,c[w],0),l.position.set(a.x,a.y,a.z),l.lookAt(a.x+u[w],a.y,a.z)):C===1?(l.up.set(0,0,c[w]),l.position.set(a.x,a.y,a.z),l.lookAt(a.x,a.y+u[w],a.z)):(l.up.set(0,c[w],0),l.position.set(a.x,a.y,a.z),l.lookAt(a.x,a.y,a.z+u[w]));const T=this._cubeSize;Gh(i,C*T,w>2?T:0,T,T),h.setRenderTarget(i),x&&h.render(y,l),h.render(e,l)}h.toneMapping=m,h.autoClear=g,e.background=M}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Kp||e.mapping===Yp;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=KF()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=XF());const a=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=a;const o=a.uniforms;o.envMap.value=e;const l=this._cubeSize;Gh(n,0,0,3*l,2*l),r.setRenderTarget(n),r.render(s,Vg)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;const i=this._lodMeshes.length;for(let a=1;a<i;a++)this._applyGGXFilter(e,a-1,a);n.autoClear=r}_applyGGXFilter(e,n,r){const i=this._renderer,a=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[r];o.material=s;const l=s.uniforms,c=r/(this._lodMeshes.length-1),u=n/(this._lodMeshes.length-1),h=Math.sqrt(c*c-u*u),g=.05+c*.95,m=h*g,{_lodMax:b}=this,y=this._sizeLods[r],v=3*y*(r>b-ku?r-b+ku:0),x=4*(this._cubeSize-y);l.envMap.value=e.texture,l.roughness.value=m,l.mipInt.value=b-n,Gh(a,v,x,3*y,2*y),i.setRenderTarget(a),i.render(o,Vg),l.envMap.value=a.texture,l.roughness.value=0,l.mipInt.value=b-r,Gh(e,v,x,3*y,2*y),i.setRenderTarget(e),i.render(o,Vg)}_blur(e,n,r,i,a){const s=this._pingPongRenderTarget;this._halfBlur(e,s,n,r,i,"latitudinal",a),this._halfBlur(s,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,s,o){const l=this._renderer,c=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&Dr("blur direction must be either latitudinal or longitudinal!");const u=3,h=this._lodMeshes[i];h.material=c;const g=c.uniforms,m=this._sizeLods[r]-1,b=isFinite(a)?Math.PI/(2*m):2*Math.PI/(2*qd-1),y=a/b,v=isFinite(a)?1+Math.floor(u*y):qd;v>qd&&Xt(`sigmaRadians, ${a}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${qd}`);const x=[];let M=0;for(let A=0;A<qd;++A){const j=A/y,N=Math.exp(-j*j/2);x.push(N),A===0?M+=N:A<v&&(M+=2*N)}for(let A=0;A<x.length;A++)x[A]=x[A]/M;g.envMap.value=e.texture,g.samples.value=v,g.weights.value=x,g.latitudinal.value=s==="latitudinal",o&&(g.poleAxis.value=o);const{_lodMax:w}=this;g.dTheta.value=b,g.mipInt.value=w-r;const C=this._sizeLods[i],T=3*C*(i>w-ku?i-w+ku:0),R=4*(this._cubeSize-C);Gh(n,T,R,3*C,2*C),l.setRenderTarget(n),l.render(h,Vg)}};function ipe(t){const e=[],n=[],r=[];let i=t;const a=t-ku+1+VF.length;for(let s=0;s<a;s++){const o=Math.pow(2,i);e.push(o);let l=1/o;s>t-ku?l=VF[s-t+ku-1]:s===0&&(l=0),n.push(l);const c=1/(o-2),u=-c,h=1+c,g=[u,u,h,u,h,h,u,u,h,h,u,h],m=6,b=6,y=3,v=2,x=1,M=new Float32Array(y*b*m),w=new Float32Array(v*b*m),C=new Float32Array(x*b*m);for(let R=0;R<m;R++){const A=R%3*2/3-1,j=R>2?0:-1,N=[A,j,0,A+2/3,j,0,A+2/3,j+1,0,A,j,0,A+2/3,j+1,0,A,j+1,0];M.set(N,y*b*R),w.set(g,v*b*R);const k=[R,R,R,R,R,R];C.set(k,x*b*R)}const T=new fl;T.setAttribute("position",new Vs(M,y)),T.setAttribute("uv",new Vs(w,v)),T.setAttribute("faceIndex",new Vs(C,x)),r.push(new il(T,null)),i>ku&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function qF(t,e,n){const r=new Rf(t,e,n);return r.texture.mapping=rw,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Gh(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function ape(t,e,n){return new vc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:npe,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:aw(),fragmentShader:`
  3578. precision highp float;
  3579. precision highp int;
  3580. varying vec3 vOutputDirection;
  3581. uniform sampler2D envMap;
  3582. uniform float roughness;
  3583. uniform float mipInt;
  3584. #define ENVMAP_TYPE_CUBE_UV
  3585. #include <cube_uv_reflection_fragment>
  3586. #define PI 3.14159265359
  3587. // Van der Corput radical inverse
  3588. float radicalInverse_VdC(uint bits) {
  3589. bits = (bits << 16u) | (bits >> 16u);
  3590. bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
  3591. bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
  3592. bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
  3593. bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
  3594. return float(bits) * 2.3283064365386963e-10; // / 0x100000000
  3595. }
  3596. // Hammersley sequence
  3597. vec2 hammersley(uint i, uint N) {
  3598. return vec2(float(i) / float(N), radicalInverse_VdC(i));
  3599. }
  3600. // GGX VNDF importance sampling (Eric Heitz 2018)
  3601. // "Sampling the GGX Distribution of Visible Normals"
  3602. // https://jcgt.org/published/0007/04/01/
  3603. vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
  3604. float alpha = roughness * roughness;
  3605. // Section 3.2: Transform view direction to hemisphere configuration
  3606. vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
  3607. // Section 4.1: Orthonormal basis
  3608. float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
  3609. vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
  3610. vec3 T2 = cross(Vh, T1);
  3611. // Section 4.2: Parameterization of projected area
  3612. float r = sqrt(Xi.x);
  3613. float phi = 2.0 * PI * Xi.y;
  3614. float t1 = r * cos(phi);
  3615. float t2 = r * sin(phi);
  3616. float s = 0.5 * (1.0 + Vh.z);
  3617. t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
  3618. // Section 4.3: Reprojection onto hemisphere
  3619. vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
  3620. // Section 3.4: Transform back to ellipsoid configuration
  3621. return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
  3622. }
  3623. void main() {
  3624. vec3 N = normalize(vOutputDirection);
  3625. vec3 V = N; // Assume view direction equals normal for pre-filtering
  3626. vec3 prefilteredColor = vec3(0.0);
  3627. float totalWeight = 0.0;
  3628. // For very low roughness, just sample the environment directly
  3629. if (roughness < 0.001) {
  3630. gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
  3631. return;
  3632. }
  3633. // Tangent space basis for VNDF sampling
  3634. vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
  3635. vec3 tangent = normalize(cross(up, N));
  3636. vec3 bitangent = cross(N, tangent);
  3637. for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
  3638. vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
  3639. // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
  3640. vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
  3641. // Transform H back to world space
  3642. vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
  3643. vec3 L = normalize(2.0 * dot(V, H) * H - V);
  3644. float NdotL = max(dot(N, L), 0.0);
  3645. if(NdotL > 0.0) {
  3646. // Sample environment at fixed mip level
  3647. // VNDF importance sampling handles the distribution filtering
  3648. vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
  3649. // Weight by NdotL for the split-sum approximation
  3650. // VNDF PDF naturally accounts for the visible microfacet distribution
  3651. prefilteredColor += sampleColor * NdotL;
  3652. totalWeight += NdotL;
  3653. }
  3654. }
  3655. if (totalWeight > 0.0) {
  3656. prefilteredColor = prefilteredColor / totalWeight;
  3657. }
  3658. gl_FragColor = vec4(prefilteredColor, 1.0);
  3659. }
  3660. `,blending:lc,depthTest:!1,depthWrite:!1})}function spe(t,e,n){const r=new Float32Array(qd),i=new We(0,1,0);return new vc({name:"SphericalGaussianBlur",defines:{n:qd,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:aw(),fragmentShader:`
  3661. precision mediump float;
  3662. precision mediump int;
  3663. varying vec3 vOutputDirection;
  3664. uniform sampler2D envMap;
  3665. uniform int samples;
  3666. uniform float weights[ n ];
  3667. uniform bool latitudinal;
  3668. uniform float dTheta;
  3669. uniform float mipInt;
  3670. uniform vec3 poleAxis;
  3671. #define ENVMAP_TYPE_CUBE_UV
  3672. #include <cube_uv_reflection_fragment>
  3673. vec3 getSample( float theta, vec3 axis ) {
  3674. float cosTheta = cos( theta );
  3675. // Rodrigues' axis-angle rotation
  3676. vec3 sampleDirection = vOutputDirection * cosTheta
  3677. + cross( axis, vOutputDirection ) * sin( theta )
  3678. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  3679. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  3680. }
  3681. void main() {
  3682. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  3683. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  3684. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  3685. }
  3686. axis = normalize( axis );
  3687. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  3688. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  3689. for ( int i = 1; i < n; i++ ) {
  3690. if ( i >= samples ) {
  3691. break;
  3692. }
  3693. float theta = dTheta * float( i );
  3694. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  3695. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  3696. }
  3697. }
  3698. `,blending:lc,depthTest:!1,depthWrite:!1})}function XF(){return new vc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:aw(),fragmentShader:`
  3699. precision mediump float;
  3700. precision mediump int;
  3701. varying vec3 vOutputDirection;
  3702. uniform sampler2D envMap;
  3703. #include <common>
  3704. void main() {
  3705. vec3 outputDirection = normalize( vOutputDirection );
  3706. vec2 uv = equirectUv( outputDirection );
  3707. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  3708. }
  3709. `,blending:lc,depthTest:!1,depthWrite:!1})}function KF(){return new vc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:aw(),fragmentShader:`
  3710. precision mediump float;
  3711. precision mediump int;
  3712. uniform float flipEnvMap;
  3713. varying vec3 vOutputDirection;
  3714. uniform samplerCube envMap;
  3715. void main() {
  3716. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  3717. }
  3718. `,blending:lc,depthTest:!1,depthWrite:!1})}function aw(){return`
  3719. precision mediump float;
  3720. precision mediump int;
  3721. attribute float faceIndex;
  3722. varying vec3 vOutputDirection;
  3723. // RH coordinate system; PMREM face-indexing convention
  3724. vec3 getDirection( vec2 uv, float face ) {
  3725. uv = 2.0 * uv - 1.0;
  3726. vec3 direction = vec3( uv, 1.0 );
  3727. if ( face == 0.0 ) {
  3728. direction = direction.zyx; // ( 1, v, u ) pos x
  3729. } else if ( face == 1.0 ) {
  3730. direction = direction.xzy;
  3731. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  3732. } else if ( face == 2.0 ) {
  3733. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  3734. } else if ( face == 3.0 ) {
  3735. direction = direction.zyx;
  3736. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  3737. } else if ( face == 4.0 ) {
  3738. direction = direction.xzy;
  3739. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  3740. } else if ( face == 5.0 ) {
  3741. direction.z *= -1.0; // ( u, v, -1 ) neg z
  3742. }
  3743. return direction;
  3744. }
  3745. void main() {
  3746. vOutputDirection = getDirection( uv, faceIndex );
  3747. gl_Position = vec4( position, 1.0 );
  3748. }
  3749. `}function ope(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const l=o.mapping,c=l===XN||l===KN,u=l===Kp||l===Yp;if(c||u){let h=e.get(o);const g=h!==void 0?h.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==g)return n===null&&(n=new WF(t)),h=c?n.fromEquirectangular(o,h):n.fromCubemap(o,h),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),h.texture;if(h!==void 0)return h.texture;{const m=o.image;return c&&m&&m.height>0||u&&m&&i(m)?(n===null&&(n=new WF(t)),h=c?n.fromEquirectangular(o):n.fromCubemap(o),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),o.addEventListener("dispose",a),h.texture):null}}}return o}function i(o){let l=0;const c=6;for(let u=0;u<c;u++)o[u]!==void 0&&l++;return l===c}function a(o){const l=o.target;l.removeEventListener("dispose",a);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function s(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:s}}function lpe(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&&t0("WebGLRenderer: "+r+" extension not supported."),i}}}function cpe(t,e,n,r){const i={},a=new WeakMap;function s(h){const g=h.target;g.index!==null&&e.remove(g.index);for(const b in g.attributes)e.remove(g.attributes[b]);g.removeEventListener("dispose",s),delete i[g.id];const m=a.get(g);m&&(e.remove(m),a.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function o(h,g){return i[g.id]===!0||(g.addEventListener("dispose",s),i[g.id]=!0,n.memory.geometries++),g}function l(h){const g=h.attributes;for(const m in g)e.update(g[m],t.ARRAY_BUFFER)}function c(h){const g=[],m=h.index,b=h.attributes.position;let y=0;if(m!==null){const M=m.array;y=m.version;for(let w=0,C=M.length;w<C;w+=3){const T=M[w+0],R=M[w+1],A=M[w+2];g.push(T,R,R,A,A,T)}}else if(b!==void 0){const M=b.array;y=b.version;for(let w=0,C=M.length/3-1;w<C;w+=3){const T=w+0,R=w+1,A=w+2;g.push(T,R,R,A,A,T)}}else return;const v=new(I9(g)?W9:G9)(g,1);v.version=y;const x=a.get(h);x&&e.remove(x),a.set(h,v)}function u(h){const g=a.get(h);if(g){const m=h.index;m!==null&&g.version<m.version&&c(h)}else c(h);return a.get(h)}return{get:o,update:l,getWireframeAttribute:u}}function upe(t,e,n){let r;function i(g){r=g}let a,s;function o(g){a=g.type,s=g.bytesPerElement}function l(g,m){t.drawElements(r,m,a,g*s),n.update(m,r,1)}function c(g,m,b){b!==0&&(t.drawElementsInstanced(r,m,a,g*s,b),n.update(m,r,b))}function u(g,m,b){if(b===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,m,0,a,g,0,b);let v=0;for(let x=0;x<b;x++)v+=m[x];n.update(v,r,1)}function h(g,m,b,y){if(b===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let x=0;x<g.length;x++)c(g[x]/s,m[x],y[x]);else{v.multiDrawElementsInstancedWEBGL(r,m,0,a,g,0,y,0,b);let x=0;for(let M=0;M<b;M++)x+=m[M]*y[M];n.update(x,r,1)}}this.setMode=i,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function dpe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,s,o){switch(n.calls++,s){case t.TRIANGLES:n.triangles+=o*(a/3);break;case t.LINES:n.lines+=o*(a/2);break;case t.LINE_STRIP:n.lines+=o*(a-1);break;case t.LINE_LOOP:n.lines+=o*a;break;case t.POINTS:n.points+=o*a;break;default:Dr("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 fpe(t,e,n){const r=new WeakMap,i=new Vr;function a(s,o,l){const c=s.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,h=u!==void 0?u.length:0;let g=r.get(o);if(g===void 0||g.count!==h){let k=function(){j.dispose(),r.delete(o),o.removeEventListener("dispose",k)};var m=k;g!==void 0&&g.texture.dispose();const b=o.morphAttributes.position!==void 0,y=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,x=o.morphAttributes.position||[],M=o.morphAttributes.normal||[],w=o.morphAttributes.color||[];let C=0;b===!0&&(C=1),y===!0&&(C=2),v===!0&&(C=3);let T=o.attributes.position.count*C,R=1;T>e.maxTextureSize&&(R=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);const A=new Float32Array(T*R*4*h),j=new B9(A,T,R,h);j.type=nc,j.needsUpdate=!0;const N=C*4;for(let F=0;F<h;F++){const I=x[F],W=M[F],D=w[F],B=T*R*4*F;for(let G=0;G<I.count;G++){const V=G*N;b===!0&&(i.fromBufferAttribute(I,G),A[B+V+0]=i.x,A[B+V+1]=i.y,A[B+V+2]=i.z,A[B+V+3]=0),y===!0&&(i.fromBufferAttribute(W,G),A[B+V+4]=i.x,A[B+V+5]=i.y,A[B+V+6]=i.z,A[B+V+7]=0),v===!0&&(i.fromBufferAttribute(D,G),A[B+V+8]=i.x,A[B+V+9]=i.y,A[B+V+10]=i.z,A[B+V+11]=D.itemSize===4?i.w:1)}}g={count:h,texture:j,size:new sn(T,R)},r.set(o,g),o.addEventListener("dispose",k)}if(s.isInstancedMesh===!0&&s.morphTexture!==null)l.getUniforms().setValue(t,"morphTexture",s.morphTexture,n);else{let b=0;for(let v=0;v<c.length;v++)b+=c[v];const y=o.morphTargetsRelative?1:1-b;l.getUniforms().setValue(t,"morphTargetBaseInfluence",y),l.getUniforms().setValue(t,"morphTargetInfluences",c)}l.getUniforms().setValue(t,"morphTargetsTexture",g.texture,n),l.getUniforms().setValue(t,"morphTargetsTextureSize",g.size)}return{update:a}}function hpe(t,e,n,r){let i=new WeakMap;function a(l){const c=r.render.frame,u=l.geometry,h=e.get(l,u);if(i.get(h)!==c&&(e.update(h),i.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.get(l)!==c&&(n.update(l.instanceMatrix,t.ARRAY_BUFFER),l.instanceColor!==null&&n.update(l.instanceColor,t.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){const g=l.skeleton;i.get(g)!==c&&(g.update(),i.set(g,c))}return h}function s(){i=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),n.remove(c.instanceMatrix),c.instanceColor!==null&&n.remove(c.instanceColor)}return{update:a,dispose:s}}const a7=new No,YF=new J9(1,1),s7=new B9,o7=new Due,l7=new Z9,ZF=[],QF=[],JF=new Float32Array(16),ez=new Float32Array(9),tz=new Float32Array(4);function Tm(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=ZF[i];if(a===void 0&&(a=new Float32Array(i),ZF[i]=a),e!==0){r.toArray(a,0);for(let s=1,o=0;s!==e;++s)o+=n,t[s].toArray(a,o)}return a}function ai(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function si(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function sw(t,e){let n=QF[e];n===void 0&&(n=new Int32Array(e),QF[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function ppe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function mpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ai(n,e))return;t.uniform2fv(this.addr,e),si(n,e)}}function gpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(ai(n,e))return;t.uniform3fv(this.addr,e),si(n,e)}}function xpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ai(n,e))return;t.uniform4fv(this.addr,e),si(n,e)}}function vpe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ai(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),si(n,e)}else{if(ai(n,r))return;tz.set(r),t.uniformMatrix2fv(this.addr,!1,tz),si(n,r)}}function bpe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ai(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),si(n,e)}else{if(ai(n,r))return;ez.set(r),t.uniformMatrix3fv(this.addr,!1,ez),si(n,r)}}function ype(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ai(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),si(n,e)}else{if(ai(n,r))return;JF.set(r),t.uniformMatrix4fv(this.addr,!1,JF),si(n,r)}}function _pe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function Spe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ai(n,e))return;t.uniform2iv(this.addr,e),si(n,e)}}function wpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ai(n,e))return;t.uniform3iv(this.addr,e),si(n,e)}}function Mpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ai(n,e))return;t.uniform4iv(this.addr,e),si(n,e)}}function Epe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function Ape(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ai(n,e))return;t.uniform2uiv(this.addr,e),si(n,e)}}function Tpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ai(n,e))return;t.uniform3uiv(this.addr,e),si(n,e)}}function Cpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ai(n,e))return;t.uniform4uiv(this.addr,e),si(n,e)}}function Npe(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?(YF.compareFunction=L9,a=YF):a=a7,n.setTexture2D(e||a,i)}function Rpe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||o7,i)}function Ppe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||l7,i)}function kpe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||s7,i)}function Dpe(t){switch(t){case 5126:return ppe;case 35664:return mpe;case 35665:return gpe;case 35666:return xpe;case 35674:return vpe;case 35675:return bpe;case 35676:return ype;case 5124:case 35670:return _pe;case 35667:case 35671:return Spe;case 35668:case 35672:return wpe;case 35669:case 35673:return Mpe;case 5125:return Epe;case 36294:return Ape;case 36295:return Tpe;case 36296:return Cpe;case 35678:case 36198:case 36298:case 36306:case 35682:return Npe;case 35679:case 36299:case 36307:return Rpe;case 35680:case 36300:case 36308:case 36293:return Ppe;case 36289:case 36303:case 36311:case 36292:return kpe}}function Ope(t,e){t.uniform1fv(this.addr,e)}function Lpe(t,e){const n=Tm(e,this.size,2);t.uniform2fv(this.addr,n)}function Ipe(t,e){const n=Tm(e,this.size,3);t.uniform3fv(this.addr,n)}function jpe(t,e){const n=Tm(e,this.size,4);t.uniform4fv(this.addr,n)}function Upe(t,e){const n=Tm(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Fpe(t,e){const n=Tm(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function zpe(t,e){const n=Tm(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Bpe(t,e){t.uniform1iv(this.addr,e)}function Hpe(t,e){t.uniform2iv(this.addr,e)}function $pe(t,e){t.uniform3iv(this.addr,e)}function Vpe(t,e){t.uniform4iv(this.addr,e)}function Gpe(t,e){t.uniform1uiv(this.addr,e)}function Wpe(t,e){t.uniform2uiv(this.addr,e)}function qpe(t,e){t.uniform3uiv(this.addr,e)}function Xpe(t,e){t.uniform4uiv(this.addr,e)}function Kpe(t,e,n){const r=this.cache,i=e.length,a=sw(n,i);ai(r,a)||(t.uniform1iv(this.addr,a),si(r,a));for(let s=0;s!==i;++s)n.setTexture2D(e[s]||a7,a[s])}function Ype(t,e,n){const r=this.cache,i=e.length,a=sw(n,i);ai(r,a)||(t.uniform1iv(this.addr,a),si(r,a));for(let s=0;s!==i;++s)n.setTexture3D(e[s]||o7,a[s])}function Zpe(t,e,n){const r=this.cache,i=e.length,a=sw(n,i);ai(r,a)||(t.uniform1iv(this.addr,a),si(r,a));for(let s=0;s!==i;++s)n.setTextureCube(e[s]||l7,a[s])}function Qpe(t,e,n){const r=this.cache,i=e.length,a=sw(n,i);ai(r,a)||(t.uniform1iv(this.addr,a),si(r,a));for(let s=0;s!==i;++s)n.setTexture2DArray(e[s]||s7,a[s])}function Jpe(t){switch(t){case 5126:return Ope;case 35664:return Lpe;case 35665:return Ipe;case 35666:return jpe;case 35674:return Upe;case 35675:return Fpe;case 35676:return zpe;case 5124:case 35670:return Bpe;case 35667:case 35671:return Hpe;case 35668:case 35672:return $pe;case 35669:case 35673:return Vpe;case 5125:return Gpe;case 36294:return Wpe;case 36295:return qpe;case 36296:return Xpe;case 35678:case 36198:case 36298:case 36306:case 35682:return Kpe;case 35679:case 36299:case 36307:return Ype;case 35680:case 36300:case 36308:case 36293:return Zpe;case 36289:case 36303:case 36311:case 36292:return Qpe}}let eme=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=Dpe(n.type)}},tme=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=Jpe(n.type)}},nme=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,s=i.length;a!==s;++a){const o=i[a];o.setValue(e,n[o.id],r)}}};const vT=/(\w+)(\])?(\[|\.)?/g;function nz(t,e){t.seq.push(e),t.map[e.id]=e}function rme(t,e,n){const r=t.name,i=r.length;for(vT.lastIndex=0;;){const a=vT.exec(r),s=vT.lastIndex;let o=a[1];const l=a[2]==="]",c=a[3];if(l&&(o=o|0),c===void 0||c==="["&&s+2===i){nz(n,c===void 0?new eme(o,t,e):new tme(o,t,e));break}else{let h=n.map[o];h===void 0&&(h=new nme(o),nz(n,h)),n=h}}}let E_=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);rme(a,s,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,s=n.length;a!==s;++a){const o=n[a],l=r[o.id];l.needsUpdate!==!1&&o.setValue(e,l.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 rz(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const ime=37297;let ame=0;function sme(t,e){const n=t.split(`
  3750. `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let s=i;s<a;s++){const o=s+1;r.push(`${o===e?">":" "} ${o}: ${n[s]}`)}return r.join(`
  3751. `)}const iz=new un;function ome(t){En._getMatrix(iz,En.workingColorSpace,t);const e=`mat3( ${iz.elements.map(n=>n.toFixed(4))} )`;switch(En.getTransfer(t)){case Y_:return[e,"LinearTransferOETF"];case Bn:return[e,"sRGBTransferOETF"];default:return Xt("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function az(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),a=(t.getShaderInfoLog(e)||"").trim();if(r&&a==="")return"";const s=/ERROR: 0:(\d+)/.exec(a);if(s){const o=parseInt(s[1]);return n.toUpperCase()+`
  3752. `+a+`
  3753. `+sme(t.getShaderSource(e),o)}else return a}function lme(t,e){const n=ome(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
  3754. `)}function cme(t,e){let n;switch(e){case sue:n="Linear";break;case oue:n="Reinhard";break;case lue:n="Cineon";break;case cue:n="ACESFilmic";break;case due:n="AgX";break;case fue:n="Neutral";break;case uue:n="Custom";break;default:Xt("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const iy=new We;function ume(){En.getLuminanceCoefficients(iy);const t=iy.x.toFixed(4),e=iy.y.toFixed(4),n=iy.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
  3755. `)}function dme(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(cx).join(`
  3756. `)}function fme(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  3757. `)}function hme(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),s=a.name;let o=1;a.type===t.FLOAT_MAT2&&(o=2),a.type===t.FLOAT_MAT3&&(o=3),a.type===t.FLOAT_MAT4&&(o=4),n[s]={type:a.type,location:t.getAttribLocation(e,s),locationSize:o}}return n}function cx(t){return t!==""}function sz(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 oz(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const pme=/^[ \t]*#include +<([\w\d./]+)>/gm;function C3(t){return t.replace(pme,gme)}const mme=new Map;function gme(t,e){let n=rn[e];if(n===void 0){const r=mme.get(e);if(r!==void 0)n=rn[r],Xt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return C3(n)}const xme=/#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 lz(t){return t.replace(xme,vme)}function vme(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 cz(t){let e=`precision ${t.precision} float;
  3758. precision ${t.precision} int;
  3759. precision ${t.precision} sampler2D;
  3760. precision ${t.precision} samplerCube;
  3761. precision ${t.precision} sampler3D;
  3762. precision ${t.precision} sampler2DArray;
  3763. precision ${t.precision} sampler2DShadow;
  3764. precision ${t.precision} samplerCubeShadow;
  3765. precision ${t.precision} sampler2DArrayShadow;
  3766. precision ${t.precision} isampler2D;
  3767. precision ${t.precision} isampler3D;
  3768. precision ${t.precision} isamplerCube;
  3769. precision ${t.precision} isampler2DArray;
  3770. precision ${t.precision} usampler2D;
  3771. precision ${t.precision} usampler3D;
  3772. precision ${t.precision} usamplerCube;
  3773. precision ${t.precision} usampler2DArray;
  3774. `;return t.precision==="highp"?e+=`
  3775. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  3776. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  3777. #define LOW_PRECISION`),e}function bme(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===E9?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===Fce?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Gl&&(e="SHADOWMAP_TYPE_VSM"),e}function yme(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Kp:case Yp:e="ENVMAP_TYPE_CUBE";break;case rw:e="ENVMAP_TYPE_CUBE_UV";break}return e}function _me(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Yp:e="ENVMAP_MODE_REFRACTION";break}return e}function Sme(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case JP:e="ENVMAP_BLENDING_MULTIPLY";break;case iue:e="ENVMAP_BLENDING_MIX";break;case aue:e="ENVMAP_BLENDING_ADD";break}return e}function wme(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 Mme(t,e,n,r){const i=t.getContext(),a=n.defines;let s=n.vertexShader,o=n.fragmentShader;const l=bme(n),c=yme(n),u=_me(n),h=Sme(n),g=wme(n),m=dme(n),b=fme(a),y=i.createProgram();let v,x,M=n.glslVersion?"#version "+n.glslVersion+`
  3778. `:"";n.isRawShaderMaterial?(v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(cx).join(`
  3779. `),v.length>0&&(v+=`
  3780. `),x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(cx).join(`
  3781. `),x.length>0&&(x+=`
  3782. `)):(v=[cz(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",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 "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  3783. `].filter(cx).join(`
  3784. `),x=[cz(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+u:"",n.envMap?"#define "+h:"",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 "+l:"",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!==Fu?"#define TONE_MAPPING":"",n.toneMapping!==Fu?rn.tonemapping_pars_fragment:"",n.toneMapping!==Fu?cme("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",rn.colorspace_pars_fragment,lme("linearToOutputTexel",n.outputColorSpace),ume(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  3785. `].filter(cx).join(`
  3786. `)),s=C3(s),s=sz(s,n),s=oz(s,n),o=C3(o),o=sz(o,n),o=oz(o,n),s=lz(s),o=lz(o),n.isRawShaderMaterial!==!0&&(M=`#version 300 es
  3787. `,v=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
  3788. `)+`
  3789. `+v,x=["#define varying in",n.glslVersion===gF?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===gF?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
  3790. `)+`
  3791. `+x);const w=M+v+s,C=M+x+o,T=rz(i,i.VERTEX_SHADER,w),R=rz(i,i.FRAGMENT_SHADER,C);i.attachShader(y,T),i.attachShader(y,R),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function A(F){if(t.debug.checkShaderErrors){const I=i.getProgramInfoLog(y)||"",W=i.getShaderInfoLog(T)||"",D=i.getShaderInfoLog(R)||"",B=I.trim(),G=W.trim(),V=D.trim();let Z=!0,Y=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(Z=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,T,R);else{const ee=az(i,T,"vertex"),H=az(i,R,"fragment");Dr("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
  3792. Material Name: `+F.name+`
  3793. Material Type: `+F.type+`
  3794. Program Info Log: `+B+`
  3795. `+ee+`
  3796. `+H)}else B!==""?Xt("WebGLProgram: Program Info Log:",B):(G===""||V==="")&&(Y=!1);Y&&(F.diagnostics={runnable:Z,programLog:B,vertexShader:{log:G,prefix:v},fragmentShader:{log:V,prefix:x}})}i.deleteShader(T),i.deleteShader(R),j=new E_(i,y),N=hme(i,y)}let j;this.getUniforms=function(){return j===void 0&&A(this),j};let N;this.getAttributes=function(){return N===void 0&&A(this),N};let k=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return k===!1&&(k=i.getProgramParameter(y,ime)),k},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=ame++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=R,this}let Eme=0,Ame=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 Tme(e),n.set(e,r)),r}},Tme=class{constructor(e){this.id=Eme++,this.code=e,this.usedTimes=0}};function Cme(t,e,n,r,i,a,s){const o=new $9,l=new Ame,c=new Set,u=[],h=i.logarithmicDepthBuffer,g=i.vertexTextures;let m=i.precision;const b={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(N){return c.add(N),N===0?"uv":`uv${N}`}function v(N,k,F,I,W){const D=I.fog,B=W.geometry,G=N.isMeshStandardMaterial?I.environment:null,V=(N.isMeshStandardMaterial?n:e).get(N.envMap||G),Z=V&&V.mapping===rw?V.image.height:null,Y=b[N.type];N.precision!==null&&(m=i.getMaxPrecision(N.precision),m!==N.precision&&Xt("WebGLProgram.getParameters:",N.precision,"not supported, using",m,"instead."));const ee=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,H=ee!==void 0?ee.length:0;let q=0;B.morphAttributes.position!==void 0&&(q=1),B.morphAttributes.normal!==void 0&&(q=2),B.morphAttributes.color!==void 0&&(q=3);let ae,ce,xe,ie;if(Y){const Pt=$o[Y];ae=Pt.vertexShader,ce=Pt.fragmentShader}else ae=N.vertexShader,ce=N.fragmentShader,l.update(N),xe=l.getVertexShaderID(N),ie=l.getFragmentShaderID(N);const ve=t.getRenderTarget(),Pe=t.state.buffers.depth.getReversed(),he=W.isInstancedMesh===!0,we=W.isBatchedMesh===!0,Le=!!N.map,de=!!N.matcap,lt=!!V,$=!!N.aoMap,z=!!N.lightMap,ne=!!N.bumpMap,K=!!N.normalMap,Q=!!N.displacementMap,oe=!!N.emissiveMap,Ne=!!N.metalnessMap,Ee=!!N.roughnessMap,re=N.anisotropy>0,U=N.clearcoat>0,L=N.dispersion>0,J=N.iridescence>0,ge=N.sheen>0,ye=N.transmission>0,me=re&&!!N.anisotropyMap,et=U&&!!N.clearcoatMap,Ie=U&&!!N.clearcoatNormalMap,Ke=U&&!!N.clearcoatRoughnessMap,st=J&&!!N.iridescenceMap,je=J&&!!N.iridescenceThicknessMap,le=ge&&!!N.sheenColorMap,Ze=ge&&!!N.sheenRoughnessMap,Fe=!!N.specularMap,Xe=!!N.specularColorMap,ct=!!N.specularIntensityMap,ue=ye&&!!N.transmissionMap,Qe=ye&&!!N.thicknessMap,pe=!!N.gradientMap,Oe=!!N.alphaMap,Ae=N.alphaTest>0,be=!!N.alphaHash,$e=!!N.extensions;let ft=Fu;N.toneMapped&&(ve===null||ve.isXRRenderTarget===!0)&&(ft=t.toneMapping);const yt={shaderID:Y,shaderType:N.type,shaderName:N.name,vertexShader:ae,fragmentShader:ce,defines:N.defines,customVertexShaderID:xe,customFragmentShaderID:ie,isRawShaderMaterial:N.isRawShaderMaterial===!0,glslVersion:N.glslVersion,precision:m,batching:we,batchingColor:we&&W._colorsTexture!==null,instancing:he,instancingColor:he&&W.instanceColor!==null,instancingMorph:he&&W.morphTexture!==null,supportsVertexTextures:g,outputColorSpace:ve===null?t.outputColorSpace:ve.isXRRenderTarget===!0?ve.texture.colorSpace:Zp,alphaToCoverage:!!N.alphaToCoverage,map:Le,matcap:de,envMap:lt,envMapMode:lt&&V.mapping,envMapCubeUVHeight:Z,aoMap:$,lightMap:z,bumpMap:ne,normalMap:K,displacementMap:g&&Q,emissiveMap:oe,normalMapObjectSpace:K&&N.normalMapType===gue,normalMapTangentSpace:K&&N.normalMapType===O9,metalnessMap:Ne,roughnessMap:Ee,anisotropy:re,anisotropyMap:me,clearcoat:U,clearcoatMap:et,clearcoatNormalMap:Ie,clearcoatRoughnessMap:Ke,dispersion:L,iridescence:J,iridescenceMap:st,iridescenceThicknessMap:je,sheen:ge,sheenColorMap:le,sheenRoughnessMap:Ze,specularMap:Fe,specularColorMap:Xe,specularIntensityMap:ct,transmission:ye,transmissionMap:ue,thicknessMap:Qe,gradientMap:pe,opaque:N.transparent===!1&&N.blending===kp&&N.alphaToCoverage===!1,alphaMap:Oe,alphaTest:Ae,alphaHash:be,combine:N.combine,mapUv:Le&&y(N.map.channel),aoMapUv:$&&y(N.aoMap.channel),lightMapUv:z&&y(N.lightMap.channel),bumpMapUv:ne&&y(N.bumpMap.channel),normalMapUv:K&&y(N.normalMap.channel),displacementMapUv:Q&&y(N.displacementMap.channel),emissiveMapUv:oe&&y(N.emissiveMap.channel),metalnessMapUv:Ne&&y(N.metalnessMap.channel),roughnessMapUv:Ee&&y(N.roughnessMap.channel),anisotropyMapUv:me&&y(N.anisotropyMap.channel),clearcoatMapUv:et&&y(N.clearcoatMap.channel),clearcoatNormalMapUv:Ie&&y(N.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ke&&y(N.clearcoatRoughnessMap.channel),iridescenceMapUv:st&&y(N.iridescenceMap.channel),iridescenceThicknessMapUv:je&&y(N.iridescenceThicknessMap.channel),sheenColorMapUv:le&&y(N.sheenColorMap.channel),sheenRoughnessMapUv:Ze&&y(N.sheenRoughnessMap.channel),specularMapUv:Fe&&y(N.specularMap.channel),specularColorMapUv:Xe&&y(N.specularColorMap.channel),specularIntensityMapUv:ct&&y(N.specularIntensityMap.channel),transmissionMapUv:ue&&y(N.transmissionMap.channel),thicknessMapUv:Qe&&y(N.thicknessMap.channel),alphaMapUv:Oe&&y(N.alphaMap.channel),vertexTangents:!!B.attributes.tangent&&(K||re),vertexColors:N.vertexColors,vertexAlphas:N.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,pointsUvs:W.isPoints===!0&&!!B.attributes.uv&&(Le||Oe),fog:!!D,useFog:N.fog===!0,fogExp2:!!D&&D.isFogExp2,flatShading:N.flatShading===!0&&N.wireframe===!1,sizeAttenuation:N.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:Pe,skinning:W.isSkinnedMesh===!0,morphTargets:B.morphAttributes.position!==void 0,morphNormals:B.morphAttributes.normal!==void 0,morphColors:B.morphAttributes.color!==void 0,morphTargetsCount:H,morphTextureStride:q,numDirLights:k.directional.length,numPointLights:k.point.length,numSpotLights:k.spot.length,numSpotLightMaps:k.spotLightMap.length,numRectAreaLights:k.rectArea.length,numHemiLights:k.hemi.length,numDirLightShadows:k.directionalShadowMap.length,numPointLightShadows:k.pointShadowMap.length,numSpotLightShadows:k.spotShadowMap.length,numSpotLightShadowsWithMaps:k.numSpotLightShadowsWithMaps,numLightProbes:k.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:N.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:ft,decodeVideoTexture:Le&&N.map.isVideoTexture===!0&&En.getTransfer(N.map.colorSpace)===Bn,decodeVideoTextureEmissive:oe&&N.emissiveMap.isVideoTexture===!0&&En.getTransfer(N.emissiveMap.colorSpace)===Bn,premultipliedAlpha:N.premultipliedAlpha,doubleSided:N.side===Vo,flipSided:N.side===Ua,useDepthPacking:N.depthPacking>=0,depthPacking:N.depthPacking||0,index0AttributeName:N.index0AttributeName,extensionClipCullDistance:$e&&N.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:($e&&N.extensions.multiDraw===!0||we)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:N.customProgramCacheKey()};return yt.vertexUv1s=c.has(1),yt.vertexUv2s=c.has(2),yt.vertexUv3s=c.has(3),c.clear(),yt}function x(N){const k=[];if(N.shaderID?k.push(N.shaderID):(k.push(N.customVertexShaderID),k.push(N.customFragmentShaderID)),N.defines!==void 0)for(const F in N.defines)k.push(F),k.push(N.defines[F]);return N.isRawShaderMaterial===!1&&(M(k,N),w(k,N),k.push(t.outputColorSpace)),k.push(N.customProgramCacheKey),k.join()}function M(N,k){N.push(k.precision),N.push(k.outputColorSpace),N.push(k.envMapMode),N.push(k.envMapCubeUVHeight),N.push(k.mapUv),N.push(k.alphaMapUv),N.push(k.lightMapUv),N.push(k.aoMapUv),N.push(k.bumpMapUv),N.push(k.normalMapUv),N.push(k.displacementMapUv),N.push(k.emissiveMapUv),N.push(k.metalnessMapUv),N.push(k.roughnessMapUv),N.push(k.anisotropyMapUv),N.push(k.clearcoatMapUv),N.push(k.clearcoatNormalMapUv),N.push(k.clearcoatRoughnessMapUv),N.push(k.iridescenceMapUv),N.push(k.iridescenceThicknessMapUv),N.push(k.sheenColorMapUv),N.push(k.sheenRoughnessMapUv),N.push(k.specularMapUv),N.push(k.specularColorMapUv),N.push(k.specularIntensityMapUv),N.push(k.transmissionMapUv),N.push(k.thicknessMapUv),N.push(k.combine),N.push(k.fogExp2),N.push(k.sizeAttenuation),N.push(k.morphTargetsCount),N.push(k.morphAttributeCount),N.push(k.numDirLights),N.push(k.numPointLights),N.push(k.numSpotLights),N.push(k.numSpotLightMaps),N.push(k.numHemiLights),N.push(k.numRectAreaLights),N.push(k.numDirLightShadows),N.push(k.numPointLightShadows),N.push(k.numSpotLightShadows),N.push(k.numSpotLightShadowsWithMaps),N.push(k.numLightProbes),N.push(k.shadowMapType),N.push(k.toneMapping),N.push(k.numClippingPlanes),N.push(k.numClipIntersection),N.push(k.depthPacking)}function w(N,k){o.disableAll(),k.supportsVertexTextures&&o.enable(0),k.instancing&&o.enable(1),k.instancingColor&&o.enable(2),k.instancingMorph&&o.enable(3),k.matcap&&o.enable(4),k.envMap&&o.enable(5),k.normalMapObjectSpace&&o.enable(6),k.normalMapTangentSpace&&o.enable(7),k.clearcoat&&o.enable(8),k.iridescence&&o.enable(9),k.alphaTest&&o.enable(10),k.vertexColors&&o.enable(11),k.vertexAlphas&&o.enable(12),k.vertexUv1s&&o.enable(13),k.vertexUv2s&&o.enable(14),k.vertexUv3s&&o.enable(15),k.vertexTangents&&o.enable(16),k.anisotropy&&o.enable(17),k.alphaHash&&o.enable(18),k.batching&&o.enable(19),k.dispersion&&o.enable(20),k.batchingColor&&o.enable(21),k.gradientMap&&o.enable(22),N.push(o.mask),o.disableAll(),k.fog&&o.enable(0),k.useFog&&o.enable(1),k.flatShading&&o.enable(2),k.logarithmicDepthBuffer&&o.enable(3),k.reversedDepthBuffer&&o.enable(4),k.skinning&&o.enable(5),k.morphTargets&&o.enable(6),k.morphNormals&&o.enable(7),k.morphColors&&o.enable(8),k.premultipliedAlpha&&o.enable(9),k.shadowMapEnabled&&o.enable(10),k.doubleSided&&o.enable(11),k.flipSided&&o.enable(12),k.useDepthPacking&&o.enable(13),k.dithering&&o.enable(14),k.transmission&&o.enable(15),k.sheen&&o.enable(16),k.opaque&&o.enable(17),k.pointsUvs&&o.enable(18),k.decodeVideoTexture&&o.enable(19),k.decodeVideoTextureEmissive&&o.enable(20),k.alphaToCoverage&&o.enable(21),N.push(o.mask)}function C(N){const k=b[N.type];let F;if(k){const I=$o[k];F=Wue.clone(I.uniforms)}else F=N.uniforms;return F}function T(N,k){let F;for(let I=0,W=u.length;I<W;I++){const D=u[I];if(D.cacheKey===k){F=D,++F.usedTimes;break}}return F===void 0&&(F=new Mme(t,k,N,a),u.push(F)),F}function R(N){if(--N.usedTimes===0){const k=u.indexOf(N);u[k]=u[u.length-1],u.pop(),N.destroy()}}function A(N){l.remove(N)}function j(){l.dispose()}return{getParameters:v,getProgramCacheKey:x,getUniforms:C,acquireProgram:T,releaseProgram:R,releaseShaderCache:A,programs:u,dispose:j}}function Nme(){let t=new WeakMap;function e(s){return t.has(s)}function n(s){let o=t.get(s);return o===void 0&&(o={},t.set(s,o)),o}function r(s){t.delete(s)}function i(s,o,l){t.get(s)[o]=l}function a(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:a}}function Rme(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 uz(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 dz(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function s(h,g,m,b,y,v){let x=t[e];return x===void 0?(x={id:h.id,object:h,geometry:g,material:m,groupOrder:b,renderOrder:h.renderOrder,z:y,group:v},t[e]=x):(x.id=h.id,x.object=h,x.geometry=g,x.material=m,x.groupOrder=b,x.renderOrder=h.renderOrder,x.z=y,x.group=v),e++,x}function o(h,g,m,b,y,v){const x=s(h,g,m,b,y,v);m.transmission>0?r.push(x):m.transparent===!0?i.push(x):n.push(x)}function l(h,g,m,b,y,v){const x=s(h,g,m,b,y,v);m.transmission>0?r.unshift(x):m.transparent===!0?i.unshift(x):n.unshift(x)}function c(h,g){n.length>1&&n.sort(h||Rme),r.length>1&&r.sort(g||uz),i.length>1&&i.sort(g||uz)}function u(){for(let h=e,g=t.length;h<g;h++){const m=t[h];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:o,unshift:l,finish:u,sort:c}}function Pme(){let t=new WeakMap;function e(r,i){const a=t.get(r);let s;return a===void 0?(s=new dz,t.set(r,[s])):i>=a.length?(s=new dz,a.push(s)):s=a[i],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function kme(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new We,color:new bn};break;case"SpotLight":n={position:new We,direction:new We,color:new bn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new We,color:new bn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new We,skyColor:new bn,groundColor:new bn};break;case"RectAreaLight":n={color:new bn,position:new We,halfWidth:new We,halfHeight:new We};break}return t[e.id]=n,n}}}function Dme(){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 sn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new sn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new sn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let Ome=0;function Lme(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Ime(t){const e=new kme,n=Dme(),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 c=0;c<9;c++)r.probe.push(new We);const i=new We,a=new Xr,s=new Xr;function o(c){let u=0,h=0,g=0;for(let N=0;N<9;N++)r.probe[N].set(0,0,0);let m=0,b=0,y=0,v=0,x=0,M=0,w=0,C=0,T=0,R=0,A=0;c.sort(Lme);for(let N=0,k=c.length;N<k;N++){const F=c[N],I=F.color,W=F.intensity,D=F.distance,B=F.shadow&&F.shadow.map?F.shadow.map.texture:null;if(F.isAmbientLight)u+=I.r*W,h+=I.g*W,g+=I.b*W;else if(F.isLightProbe){for(let G=0;G<9;G++)r.probe[G].addScaledVector(F.sh.coefficients[G],W);A++}else if(F.isDirectionalLight){const G=e.get(F);if(G.color.copy(F.color).multiplyScalar(F.intensity),F.castShadow){const V=F.shadow,Z=n.get(F);Z.shadowIntensity=V.intensity,Z.shadowBias=V.bias,Z.shadowNormalBias=V.normalBias,Z.shadowRadius=V.radius,Z.shadowMapSize=V.mapSize,r.directionalShadow[m]=Z,r.directionalShadowMap[m]=B,r.directionalShadowMatrix[m]=F.shadow.matrix,M++}r.directional[m]=G,m++}else if(F.isSpotLight){const G=e.get(F);G.position.setFromMatrixPosition(F.matrixWorld),G.color.copy(I).multiplyScalar(W),G.distance=D,G.coneCos=Math.cos(F.angle),G.penumbraCos=Math.cos(F.angle*(1-F.penumbra)),G.decay=F.decay,r.spot[y]=G;const V=F.shadow;if(F.map&&(r.spotLightMap[T]=F.map,T++,V.updateMatrices(F),F.castShadow&&R++),r.spotLightMatrix[y]=V.matrix,F.castShadow){const Z=n.get(F);Z.shadowIntensity=V.intensity,Z.shadowBias=V.bias,Z.shadowNormalBias=V.normalBias,Z.shadowRadius=V.radius,Z.shadowMapSize=V.mapSize,r.spotShadow[y]=Z,r.spotShadowMap[y]=B,C++}y++}else if(F.isRectAreaLight){const G=e.get(F);G.color.copy(I).multiplyScalar(W),G.halfWidth.set(F.width*.5,0,0),G.halfHeight.set(0,F.height*.5,0),r.rectArea[v]=G,v++}else if(F.isPointLight){const G=e.get(F);if(G.color.copy(F.color).multiplyScalar(F.intensity),G.distance=F.distance,G.decay=F.decay,F.castShadow){const V=F.shadow,Z=n.get(F);Z.shadowIntensity=V.intensity,Z.shadowBias=V.bias,Z.shadowNormalBias=V.normalBias,Z.shadowRadius=V.radius,Z.shadowMapSize=V.mapSize,Z.shadowCameraNear=V.camera.near,Z.shadowCameraFar=V.camera.far,r.pointShadow[b]=Z,r.pointShadowMap[b]=B,r.pointShadowMatrix[b]=F.shadow.matrix,w++}r.point[b]=G,b++}else if(F.isHemisphereLight){const G=e.get(F);G.skyColor.copy(F.color).multiplyScalar(W),G.groundColor.copy(F.groundColor).multiplyScalar(W),r.hemi[x]=G,x++}}v>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=St.LTC_FLOAT_1,r.rectAreaLTC2=St.LTC_FLOAT_2):(r.rectAreaLTC1=St.LTC_HALF_1,r.rectAreaLTC2=St.LTC_HALF_2)),r.ambient[0]=u,r.ambient[1]=h,r.ambient[2]=g;const j=r.hash;(j.directionalLength!==m||j.pointLength!==b||j.spotLength!==y||j.rectAreaLength!==v||j.hemiLength!==x||j.numDirectionalShadows!==M||j.numPointShadows!==w||j.numSpotShadows!==C||j.numSpotMaps!==T||j.numLightProbes!==A)&&(r.directional.length=m,r.spot.length=y,r.rectArea.length=v,r.point.length=b,r.hemi.length=x,r.directionalShadow.length=M,r.directionalShadowMap.length=M,r.pointShadow.length=w,r.pointShadowMap.length=w,r.spotShadow.length=C,r.spotShadowMap.length=C,r.directionalShadowMatrix.length=M,r.pointShadowMatrix.length=w,r.spotLightMatrix.length=C+T-R,r.spotLightMap.length=T,r.numSpotLightShadowsWithMaps=R,r.numLightProbes=A,j.directionalLength=m,j.pointLength=b,j.spotLength=y,j.rectAreaLength=v,j.hemiLength=x,j.numDirectionalShadows=M,j.numPointShadows=w,j.numSpotShadows=C,j.numSpotMaps=T,j.numLightProbes=A,r.version=Ome++)}function l(c,u){let h=0,g=0,m=0,b=0,y=0;const v=u.matrixWorldInverse;for(let x=0,M=c.length;x<M;x++){const w=c[x];if(w.isDirectionalLight){const C=r.directional[h];C.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),C.direction.sub(i),C.direction.transformDirection(v),h++}else if(w.isSpotLight){const C=r.spot[m];C.position.setFromMatrixPosition(w.matrixWorld),C.position.applyMatrix4(v),C.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),C.direction.sub(i),C.direction.transformDirection(v),m++}else if(w.isRectAreaLight){const C=r.rectArea[b];C.position.setFromMatrixPosition(w.matrixWorld),C.position.applyMatrix4(v),s.identity(),a.copy(w.matrixWorld),a.premultiply(v),s.extractRotation(a),C.halfWidth.set(w.width*.5,0,0),C.halfHeight.set(0,w.height*.5,0),C.halfWidth.applyMatrix4(s),C.halfHeight.applyMatrix4(s),b++}else if(w.isPointLight){const C=r.point[g];C.position.setFromMatrixPosition(w.matrixWorld),C.position.applyMatrix4(v),g++}else if(w.isHemisphereLight){const C=r.hemi[y];C.direction.setFromMatrixPosition(w.matrixWorld),C.direction.transformDirection(v),y++}}}return{setup:o,setupView:l,state:r}}function fz(t){const e=new Ime(t),n=[],r=[];function i(u){c.camera=u,n.length=0,r.length=0}function a(u){n.push(u)}function s(u){r.push(u)}function o(){e.setup(n)}function l(u){e.setupView(n,u)}const c={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:c,setupLights:o,setupLightsView:l,pushLight:a,pushShadow:s}}function jme(t){let e=new WeakMap;function n(i,a=0){const s=e.get(i);let o;return s===void 0?(o=new fz(t),e.set(i,[o])):a>=s.length?(o=new fz(t),s.push(o)):o=s[a],o}function r(){e=new WeakMap}return{get:n,dispose:r}}const Ume=`void main() {
  3797. gl_Position = vec4( position, 1.0 );
  3798. }`,Fme=`uniform sampler2D shadow_pass;
  3799. uniform vec2 resolution;
  3800. uniform float radius;
  3801. #include <packing>
  3802. void main() {
  3803. const float samples = float( VSM_SAMPLES );
  3804. float mean = 0.0;
  3805. float squared_mean = 0.0;
  3806. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  3807. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  3808. for ( float i = 0.0; i < samples; i ++ ) {
  3809. float uvOffset = uvStart + i * uvStride;
  3810. #ifdef HORIZONTAL_PASS
  3811. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  3812. mean += distribution.x;
  3813. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  3814. #else
  3815. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  3816. mean += depth;
  3817. squared_mean += depth * depth;
  3818. #endif
  3819. }
  3820. mean = mean / samples;
  3821. squared_mean = squared_mean / samples;
  3822. float std_dev = sqrt( squared_mean - mean * mean );
  3823. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  3824. }`;function zme(t,e,n){let r=new dk;const i=new sn,a=new sn,s=new Vr,o=new sde({depthPacking:mue}),l=new ode,c={},u=n.maxTextureSize,h={[Yu]:Ua,[Ua]:Yu,[Vo]:Vo},g=new vc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new sn},radius:{value:4}},vertexShader:Ume,fragmentShader:Fme}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const b=new fl;b.setAttribute("position",new Vs(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new il(b,g),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=E9;let x=this.type;this.render=function(R,A,j){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||R.length===0)return;const N=t.getRenderTarget(),k=t.getActiveCubeFace(),F=t.getActiveMipmapLevel(),I=t.state;I.setBlending(lc),I.buffers.depth.getReversed()===!0?I.buffers.color.setClear(0,0,0,0):I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);const W=x!==Gl&&this.type===Gl,D=x===Gl&&this.type!==Gl;for(let B=0,G=R.length;B<G;B++){const V=R[B],Z=V.shadow;if(Z===void 0){Xt("WebGLShadowMap:",V,"has no shadow.");continue}if(Z.autoUpdate===!1&&Z.needsUpdate===!1)continue;i.copy(Z.mapSize);const Y=Z.getFrameExtents();if(i.multiply(Y),a.copy(Z.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(a.x=Math.floor(u/Y.x),i.x=a.x*Y.x,Z.mapSize.x=a.x),i.y>u&&(a.y=Math.floor(u/Y.y),i.y=a.y*Y.y,Z.mapSize.y=a.y)),Z.map===null||W===!0||D===!0){const H=this.type!==Gl?{minFilter:ds,magFilter:ds}:{};Z.map!==null&&Z.map.dispose(),Z.map=new Rf(i.x,i.y,H),Z.map.texture.name=V.name+".shadowMap",Z.camera.updateProjectionMatrix()}t.setRenderTarget(Z.map),t.clear();const ee=Z.getViewportCount();for(let H=0;H<ee;H++){const q=Z.getViewport(H);s.set(a.x*q.x,a.y*q.y,a.x*q.z,a.y*q.w),I.viewport(s),Z.updateMatrices(V,H),r=Z.getFrustum(),C(A,j,Z.camera,V,this.type)}Z.isPointLightShadow!==!0&&this.type===Gl&&M(Z,j),Z.needsUpdate=!1}x=this.type,v.needsUpdate=!1,t.setRenderTarget(N,k,F)};function M(R,A){const j=e.update(y);g.defines.VSM_SAMPLES!==R.blurSamples&&(g.defines.VSM_SAMPLES=R.blurSamples,m.defines.VSM_SAMPLES=R.blurSamples,g.needsUpdate=!0,m.needsUpdate=!0),R.mapPass===null&&(R.mapPass=new Rf(i.x,i.y)),g.uniforms.shadow_pass.value=R.map.texture,g.uniforms.resolution.value=R.mapSize,g.uniforms.radius.value=R.radius,t.setRenderTarget(R.mapPass),t.clear(),t.renderBufferDirect(A,null,j,g,y,null),m.uniforms.shadow_pass.value=R.mapPass.texture,m.uniforms.resolution.value=R.mapSize,m.uniforms.radius.value=R.radius,t.setRenderTarget(R.map),t.clear(),t.renderBufferDirect(A,null,j,m,y,null)}function w(R,A,j,N){let k=null;const F=j.isPointLight===!0?R.customDistanceMaterial:R.customDepthMaterial;if(F!==void 0)k=F;else if(k=j.isPointLight===!0?l:o,t.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){const I=k.uuid,W=A.uuid;let D=c[I];D===void 0&&(D={},c[I]=D);let B=D[W];B===void 0&&(B=k.clone(),D[W]=B,A.addEventListener("dispose",T)),k=B}if(k.visible=A.visible,k.wireframe=A.wireframe,N===Gl?k.side=A.shadowSide!==null?A.shadowSide:A.side:k.side=A.shadowSide!==null?A.shadowSide:h[A.side],k.alphaMap=A.alphaMap,k.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,k.map=A.map,k.clipShadows=A.clipShadows,k.clippingPlanes=A.clippingPlanes,k.clipIntersection=A.clipIntersection,k.displacementMap=A.displacementMap,k.displacementScale=A.displacementScale,k.displacementBias=A.displacementBias,k.wireframeLinewidth=A.wireframeLinewidth,k.linewidth=A.linewidth,j.isPointLight===!0&&k.isMeshDistanceMaterial===!0){const I=t.properties.get(k);I.light=j}return k}function C(R,A,j,N,k){if(R.visible===!1)return;if(R.layers.test(A.layers)&&(R.isMesh||R.isLine||R.isPoints)&&(R.castShadow||R.receiveShadow&&k===Gl)&&(!R.frustumCulled||r.intersectsObject(R))){R.modelViewMatrix.multiplyMatrices(j.matrixWorldInverse,R.matrixWorld);const W=e.update(R),D=R.material;if(Array.isArray(D)){const B=W.groups;for(let G=0,V=B.length;G<V;G++){const Z=B[G],Y=D[Z.materialIndex];if(Y&&Y.visible){const ee=w(R,Y,N,k);R.onBeforeShadow(t,R,A,j,W,ee,Z),t.renderBufferDirect(j,null,W,ee,R,Z),R.onAfterShadow(t,R,A,j,W,ee,Z)}}}else if(D.visible){const B=w(R,D,N,k);R.onBeforeShadow(t,R,A,j,W,B,null),t.renderBufferDirect(j,null,W,B,R,null),R.onAfterShadow(t,R,A,j,W,B,null)}}const I=R.children;for(let W=0,D=I.length;W<D;W++)C(I[W],A,j,N,k)}function T(R){R.target.removeEventListener("dispose",T);for(const j in c){const N=c[j],k=R.target.uuid;k in N&&(N[k].dispose(),delete N[k])}}}const Bme={[BN]:HN,[$N]:WN,[VN]:qN,[Xp]:GN,[HN]:BN,[WN]:$N,[qN]:VN,[GN]:Xp};function Hme(t,e){function n(){let ue=!1;const Qe=new Vr;let pe=null;const Oe=new Vr(0,0,0,0);return{setMask:function(Ae){pe!==Ae&&!ue&&(t.colorMask(Ae,Ae,Ae,Ae),pe=Ae)},setLocked:function(Ae){ue=Ae},setClear:function(Ae,be,$e,ft,yt){yt===!0&&(Ae*=ft,be*=ft,$e*=ft),Qe.set(Ae,be,$e,ft),Oe.equals(Qe)===!1&&(t.clearColor(Ae,be,$e,ft),Oe.copy(Qe))},reset:function(){ue=!1,pe=null,Oe.set(-1,0,0,0)}}}function r(){let ue=!1,Qe=!1,pe=null,Oe=null,Ae=null;return{setReversed:function(be){if(Qe!==be){const $e=e.get("EXT_clip_control");be?$e.clipControlEXT($e.LOWER_LEFT_EXT,$e.ZERO_TO_ONE_EXT):$e.clipControlEXT($e.LOWER_LEFT_EXT,$e.NEGATIVE_ONE_TO_ONE_EXT),Qe=be;const ft=Ae;Ae=null,this.setClear(ft)}},getReversed:function(){return Qe},setTest:function(be){be?ve(t.DEPTH_TEST):Pe(t.DEPTH_TEST)},setMask:function(be){pe!==be&&!ue&&(t.depthMask(be),pe=be)},setFunc:function(be){if(Qe&&(be=Bme[be]),Oe!==be){switch(be){case BN:t.depthFunc(t.NEVER);break;case HN:t.depthFunc(t.ALWAYS);break;case $N:t.depthFunc(t.LESS);break;case Xp:t.depthFunc(t.LEQUAL);break;case VN:t.depthFunc(t.EQUAL);break;case GN:t.depthFunc(t.GEQUAL);break;case WN:t.depthFunc(t.GREATER);break;case qN:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Oe=be}},setLocked:function(be){ue=be},setClear:function(be){Ae!==be&&(Qe&&(be=1-be),t.clearDepth(be),Ae=be)},reset:function(){ue=!1,pe=null,Oe=null,Ae=null,Qe=!1}}}function i(){let ue=!1,Qe=null,pe=null,Oe=null,Ae=null,be=null,$e=null,ft=null,yt=null;return{setTest:function(Pt){ue||(Pt?ve(t.STENCIL_TEST):Pe(t.STENCIL_TEST))},setMask:function(Pt){Qe!==Pt&&!ue&&(t.stencilMask(Pt),Qe=Pt)},setFunc:function(Pt,cn,Ot){(pe!==Pt||Oe!==cn||Ae!==Ot)&&(t.stencilFunc(Pt,cn,Ot),pe=Pt,Oe=cn,Ae=Ot)},setOp:function(Pt,cn,Ot){(be!==Pt||$e!==cn||ft!==Ot)&&(t.stencilOp(Pt,cn,Ot),be=Pt,$e=cn,ft=Ot)},setLocked:function(Pt){ue=Pt},setClear:function(Pt){yt!==Pt&&(t.clearStencil(Pt),yt=Pt)},reset:function(){ue=!1,Qe=null,pe=null,Oe=null,Ae=null,be=null,$e=null,ft=null,yt=null}}}const a=new n,s=new r,o=new i,l=new WeakMap,c=new WeakMap;let u={},h={},g=new WeakMap,m=[],b=null,y=!1,v=null,x=null,M=null,w=null,C=null,T=null,R=null,A=new bn(0,0,0),j=0,N=!1,k=null,F=null,I=null,W=null,D=null;const B=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let G=!1,V=0;const Z=t.getParameter(t.VERSION);Z.indexOf("WebGL")!==-1?(V=parseFloat(/^WebGL (\d)/.exec(Z)[1]),G=V>=1):Z.indexOf("OpenGL ES")!==-1&&(V=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),G=V>=2);let Y=null,ee={};const H=t.getParameter(t.SCISSOR_BOX),q=t.getParameter(t.VIEWPORT),ae=new Vr().fromArray(H),ce=new Vr().fromArray(q);function xe(ue,Qe,pe,Oe){const Ae=new Uint8Array(4),be=t.createTexture();t.bindTexture(ue,be),t.texParameteri(ue,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ue,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let $e=0;$e<pe;$e++)ue===t.TEXTURE_3D||ue===t.TEXTURE_2D_ARRAY?t.texImage3D(Qe,0,t.RGBA,1,1,Oe,0,t.RGBA,t.UNSIGNED_BYTE,Ae):t.texImage2D(Qe+$e,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ae);return be}const ie={};ie[t.TEXTURE_2D]=xe(t.TEXTURE_2D,t.TEXTURE_2D,1),ie[t.TEXTURE_CUBE_MAP]=xe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),ie[t.TEXTURE_2D_ARRAY]=xe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),ie[t.TEXTURE_3D]=xe(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),s.setClear(1),o.setClear(0),ve(t.DEPTH_TEST),s.setFunc(Xp),ne(!1),K(uF),ve(t.CULL_FACE),$(lc);function ve(ue){u[ue]!==!0&&(t.enable(ue),u[ue]=!0)}function Pe(ue){u[ue]!==!1&&(t.disable(ue),u[ue]=!1)}function he(ue,Qe){return h[ue]!==Qe?(t.bindFramebuffer(ue,Qe),h[ue]=Qe,ue===t.DRAW_FRAMEBUFFER&&(h[t.FRAMEBUFFER]=Qe),ue===t.FRAMEBUFFER&&(h[t.DRAW_FRAMEBUFFER]=Qe),!0):!1}function we(ue,Qe){let pe=m,Oe=!1;if(ue){pe=g.get(Qe),pe===void 0&&(pe=[],g.set(Qe,pe));const Ae=ue.textures;if(pe.length!==Ae.length||pe[0]!==t.COLOR_ATTACHMENT0){for(let be=0,$e=Ae.length;be<$e;be++)pe[be]=t.COLOR_ATTACHMENT0+be;pe.length=Ae.length,Oe=!0}}else pe[0]!==t.BACK&&(pe[0]=t.BACK,Oe=!0);Oe&&t.drawBuffers(pe)}function Le(ue){return b!==ue?(t.useProgram(ue),b=ue,!0):!1}const de={[Wd]:t.FUNC_ADD,[Bce]:t.FUNC_SUBTRACT,[Hce]:t.FUNC_REVERSE_SUBTRACT};de[$ce]=t.MIN,de[Vce]=t.MAX;const lt={[Gce]:t.ZERO,[Wce]:t.ONE,[qce]:t.SRC_COLOR,[FN]:t.SRC_ALPHA,[Jce]:t.SRC_ALPHA_SATURATE,[Zce]:t.DST_COLOR,[Kce]:t.DST_ALPHA,[Xce]:t.ONE_MINUS_SRC_COLOR,[zN]:t.ONE_MINUS_SRC_ALPHA,[Qce]:t.ONE_MINUS_DST_COLOR,[Yce]:t.ONE_MINUS_DST_ALPHA,[eue]:t.CONSTANT_COLOR,[tue]:t.ONE_MINUS_CONSTANT_COLOR,[nue]:t.CONSTANT_ALPHA,[rue]:t.ONE_MINUS_CONSTANT_ALPHA};function $(ue,Qe,pe,Oe,Ae,be,$e,ft,yt,Pt){if(ue===lc){y===!0&&(Pe(t.BLEND),y=!1);return}if(y===!1&&(ve(t.BLEND),y=!0),ue!==zce){if(ue!==v||Pt!==N){if((x!==Wd||C!==Wd)&&(t.blendEquation(t.FUNC_ADD),x=Wd,C=Wd),Pt)switch(ue){case kp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case dF:t.blendFunc(t.ONE,t.ONE);break;case fF:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case hF:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Dr("WebGLState: Invalid blending: ",ue);break}else switch(ue){case kp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case dF:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case fF:Dr("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case hF:Dr("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Dr("WebGLState: Invalid blending: ",ue);break}M=null,w=null,T=null,R=null,A.set(0,0,0),j=0,v=ue,N=Pt}return}Ae=Ae||Qe,be=be||pe,$e=$e||Oe,(Qe!==x||Ae!==C)&&(t.blendEquationSeparate(de[Qe],de[Ae]),x=Qe,C=Ae),(pe!==M||Oe!==w||be!==T||$e!==R)&&(t.blendFuncSeparate(lt[pe],lt[Oe],lt[be],lt[$e]),M=pe,w=Oe,T=be,R=$e),(ft.equals(A)===!1||yt!==j)&&(t.blendColor(ft.r,ft.g,ft.b,yt),A.copy(ft),j=yt),v=ue,N=!1}function z(ue,Qe){ue.side===Vo?Pe(t.CULL_FACE):ve(t.CULL_FACE);let pe=ue.side===Ua;Qe&&(pe=!pe),ne(pe),ue.blending===kp&&ue.transparent===!1?$(lc):$(ue.blending,ue.blendEquation,ue.blendSrc,ue.blendDst,ue.blendEquationAlpha,ue.blendSrcAlpha,ue.blendDstAlpha,ue.blendColor,ue.blendAlpha,ue.premultipliedAlpha),s.setFunc(ue.depthFunc),s.setTest(ue.depthTest),s.setMask(ue.depthWrite),a.setMask(ue.colorWrite);const Oe=ue.stencilWrite;o.setTest(Oe),Oe&&(o.setMask(ue.stencilWriteMask),o.setFunc(ue.stencilFunc,ue.stencilRef,ue.stencilFuncMask),o.setOp(ue.stencilFail,ue.stencilZFail,ue.stencilZPass)),oe(ue.polygonOffset,ue.polygonOffsetFactor,ue.polygonOffsetUnits),ue.alphaToCoverage===!0?ve(t.SAMPLE_ALPHA_TO_COVERAGE):Pe(t.SAMPLE_ALPHA_TO_COVERAGE)}function ne(ue){k!==ue&&(ue?t.frontFace(t.CW):t.frontFace(t.CCW),k=ue)}function K(ue){ue!==jce?(ve(t.CULL_FACE),ue!==F&&(ue===uF?t.cullFace(t.BACK):ue===Uce?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Pe(t.CULL_FACE),F=ue}function Q(ue){ue!==I&&(G&&t.lineWidth(ue),I=ue)}function oe(ue,Qe,pe){ue?(ve(t.POLYGON_OFFSET_FILL),(W!==Qe||D!==pe)&&(t.polygonOffset(Qe,pe),W=Qe,D=pe)):Pe(t.POLYGON_OFFSET_FILL)}function Ne(ue){ue?ve(t.SCISSOR_TEST):Pe(t.SCISSOR_TEST)}function Ee(ue){ue===void 0&&(ue=t.TEXTURE0+B-1),Y!==ue&&(t.activeTexture(ue),Y=ue)}function re(ue,Qe,pe){pe===void 0&&(Y===null?pe=t.TEXTURE0+B-1:pe=Y);let Oe=ee[pe];Oe===void 0&&(Oe={type:void 0,texture:void 0},ee[pe]=Oe),(Oe.type!==ue||Oe.texture!==Qe)&&(Y!==pe&&(t.activeTexture(pe),Y=pe),t.bindTexture(ue,Qe||ie[ue]),Oe.type=ue,Oe.texture=Qe)}function U(){const ue=ee[Y];ue!==void 0&&ue.type!==void 0&&(t.bindTexture(ue.type,null),ue.type=void 0,ue.texture=void 0)}function L(){try{t.compressedTexImage2D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function J(){try{t.compressedTexImage3D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function ge(){try{t.texSubImage2D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function ye(){try{t.texSubImage3D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function me(){try{t.compressedTexSubImage2D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function et(){try{t.compressedTexSubImage3D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function Ie(){try{t.texStorage2D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function Ke(){try{t.texStorage3D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function st(){try{t.texImage2D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function je(){try{t.texImage3D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function le(ue){ae.equals(ue)===!1&&(t.scissor(ue.x,ue.y,ue.z,ue.w),ae.copy(ue))}function Ze(ue){ce.equals(ue)===!1&&(t.viewport(ue.x,ue.y,ue.z,ue.w),ce.copy(ue))}function Fe(ue,Qe){let pe=c.get(Qe);pe===void 0&&(pe=new WeakMap,c.set(Qe,pe));let Oe=pe.get(ue);Oe===void 0&&(Oe=t.getUniformBlockIndex(Qe,ue.name),pe.set(ue,Oe))}function Xe(ue,Qe){const Oe=c.get(Qe).get(ue);l.get(Qe)!==Oe&&(t.uniformBlockBinding(Qe,Oe,ue.__bindingPointIndex),l.set(Qe,Oe))}function ct(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),s.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),u={},Y=null,ee={},h={},g=new WeakMap,m=[],b=null,y=!1,v=null,x=null,M=null,w=null,C=null,T=null,R=null,A=new bn(0,0,0),j=0,N=!1,k=null,F=null,I=null,W=null,D=null,ae.set(0,0,t.canvas.width,t.canvas.height),ce.set(0,0,t.canvas.width,t.canvas.height),a.reset(),s.reset(),o.reset()}return{buffers:{color:a,depth:s,stencil:o},enable:ve,disable:Pe,bindFramebuffer:he,drawBuffers:we,useProgram:Le,setBlending:$,setMaterial:z,setFlipSided:ne,setCullFace:K,setLineWidth:Q,setPolygonOffset:oe,setScissorTest:Ne,activeTexture:Ee,bindTexture:re,unbindTexture:U,compressedTexImage2D:L,compressedTexImage3D:J,texImage2D:st,texImage3D:je,updateUBOMapping:Fe,uniformBlockBinding:Xe,texStorage2D:Ie,texStorage3D:Ke,texSubImage2D:ge,texSubImage3D:ye,compressedTexSubImage2D:me,compressedTexSubImage3D:et,scissor:le,viewport:Ze,reset:ct}}function $me(t,e,n,r,i,a,s){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new sn,u=new WeakMap;let h;const g=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function b(U,L){return m?new OffscreenCanvas(U,L):Q_("canvas")}function y(U,L,J){let ge=1;const ye=re(U);if((ye.width>J||ye.height>J)&&(ge=J/Math.max(ye.width,ye.height)),ge<1)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap||typeof VideoFrame<"u"&&U instanceof VideoFrame){const me=Math.floor(ge*ye.width),et=Math.floor(ge*ye.height);h===void 0&&(h=b(me,et));const Ie=L?b(me,et):h;return Ie.width=me,Ie.height=et,Ie.getContext("2d").drawImage(U,0,0,me,et),Xt("WebGLRenderer: Texture has been resized from ("+ye.width+"x"+ye.height+") to ("+me+"x"+et+")."),Ie}else return"data"in U&&Xt("WebGLRenderer: Image in DataTexture is too big ("+ye.width+"x"+ye.height+")."),U;return U}function v(U){return U.generateMipmaps}function x(U){t.generateMipmap(U)}function M(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,L,J,ge,ye=!1){if(U!==null){if(t[U]!==void 0)return t[U];Xt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let me=L;if(L===t.RED&&(J===t.FLOAT&&(me=t.R32F),J===t.HALF_FLOAT&&(me=t.R16F),J===t.UNSIGNED_BYTE&&(me=t.R8)),L===t.RED_INTEGER&&(J===t.UNSIGNED_BYTE&&(me=t.R8UI),J===t.UNSIGNED_SHORT&&(me=t.R16UI),J===t.UNSIGNED_INT&&(me=t.R32UI),J===t.BYTE&&(me=t.R8I),J===t.SHORT&&(me=t.R16I),J===t.INT&&(me=t.R32I)),L===t.RG&&(J===t.FLOAT&&(me=t.RG32F),J===t.HALF_FLOAT&&(me=t.RG16F),J===t.UNSIGNED_BYTE&&(me=t.RG8)),L===t.RG_INTEGER&&(J===t.UNSIGNED_BYTE&&(me=t.RG8UI),J===t.UNSIGNED_SHORT&&(me=t.RG16UI),J===t.UNSIGNED_INT&&(me=t.RG32UI),J===t.BYTE&&(me=t.RG8I),J===t.SHORT&&(me=t.RG16I),J===t.INT&&(me=t.RG32I)),L===t.RGB_INTEGER&&(J===t.UNSIGNED_BYTE&&(me=t.RGB8UI),J===t.UNSIGNED_SHORT&&(me=t.RGB16UI),J===t.UNSIGNED_INT&&(me=t.RGB32UI),J===t.BYTE&&(me=t.RGB8I),J===t.SHORT&&(me=t.RGB16I),J===t.INT&&(me=t.RGB32I)),L===t.RGBA_INTEGER&&(J===t.UNSIGNED_BYTE&&(me=t.RGBA8UI),J===t.UNSIGNED_SHORT&&(me=t.RGBA16UI),J===t.UNSIGNED_INT&&(me=t.RGBA32UI),J===t.BYTE&&(me=t.RGBA8I),J===t.SHORT&&(me=t.RGBA16I),J===t.INT&&(me=t.RGBA32I)),L===t.RGB&&(J===t.UNSIGNED_INT_5_9_9_9_REV&&(me=t.RGB9_E5),J===t.UNSIGNED_INT_10F_11F_11F_REV&&(me=t.R11F_G11F_B10F)),L===t.RGBA){const et=ye?Y_:En.getTransfer(ge);J===t.FLOAT&&(me=t.RGBA32F),J===t.HALF_FLOAT&&(me=t.RGBA16F),J===t.UNSIGNED_BYTE&&(me=et===Bn?t.SRGB8_ALPHA8:t.RGBA8),J===t.UNSIGNED_SHORT_4_4_4_4&&(me=t.RGBA4),J===t.UNSIGNED_SHORT_5_5_5_1&&(me=t.RGB5_A1)}return(me===t.R16F||me===t.R32F||me===t.RG16F||me===t.RG32F||me===t.RGBA16F||me===t.RGBA32F)&&e.get("EXT_color_buffer_float"),me}function C(U,L){let J;return U?L===null||L===Cf||L===Qx?J=t.DEPTH24_STENCIL8:L===nc?J=t.DEPTH32F_STENCIL8:L===Zx&&(J=t.DEPTH24_STENCIL8,Xt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===Cf||L===Qx?J=t.DEPTH_COMPONENT24:L===nc?J=t.DEPTH_COMPONENT32F:L===Zx&&(J=t.DEPTH_COMPONENT16),J}function T(U,L){return v(U)===!0||U.isFramebufferTexture&&U.minFilter!==ds&&U.minFilter!==Hs?Math.log2(Math.max(L.width,L.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?L.mipmaps.length:1}function R(U){const L=U.target;L.removeEventListener("dispose",R),j(L),L.isVideoTexture&&u.delete(L)}function A(U){const L=U.target;L.removeEventListener("dispose",A),k(L)}function j(U){const L=r.get(U);if(L.__webglInit===void 0)return;const J=U.source,ge=g.get(J);if(ge){const ye=ge[L.__cacheKey];ye.usedTimes--,ye.usedTimes===0&&N(U),Object.keys(ge).length===0&&g.delete(J)}r.remove(U)}function N(U){const L=r.get(U);t.deleteTexture(L.__webglTexture);const J=U.source,ge=g.get(J);delete ge[L.__cacheKey],s.memory.textures--}function k(U){const L=r.get(U);if(U.depthTexture&&(U.depthTexture.dispose(),r.remove(U.depthTexture)),U.isWebGLCubeRenderTarget)for(let ge=0;ge<6;ge++){if(Array.isArray(L.__webglFramebuffer[ge]))for(let ye=0;ye<L.__webglFramebuffer[ge].length;ye++)t.deleteFramebuffer(L.__webglFramebuffer[ge][ye]);else t.deleteFramebuffer(L.__webglFramebuffer[ge]);L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer[ge])}else{if(Array.isArray(L.__webglFramebuffer))for(let ge=0;ge<L.__webglFramebuffer.length;ge++)t.deleteFramebuffer(L.__webglFramebuffer[ge]);else t.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&t.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let ge=0;ge<L.__webglColorRenderbuffer.length;ge++)L.__webglColorRenderbuffer[ge]&&t.deleteRenderbuffer(L.__webglColorRenderbuffer[ge]);L.__webglDepthRenderbuffer&&t.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const J=U.textures;for(let ge=0,ye=J.length;ge<ye;ge++){const me=r.get(J[ge]);me.__webglTexture&&(t.deleteTexture(me.__webglTexture),s.memory.textures--),r.remove(J[ge])}r.remove(U)}let F=0;function I(){F=0}function W(){const U=F;return U>=i.maxTextures&&Xt("WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+i.maxTextures),F+=1,U}function D(U){const L=[];return L.push(U.wrapS),L.push(U.wrapT),L.push(U.wrapR||0),L.push(U.magFilter),L.push(U.minFilter),L.push(U.anisotropy),L.push(U.internalFormat),L.push(U.format),L.push(U.type),L.push(U.generateMipmaps),L.push(U.premultiplyAlpha),L.push(U.flipY),L.push(U.unpackAlignment),L.push(U.colorSpace),L.join()}function B(U,L){const J=r.get(U);if(U.isVideoTexture&&Ne(U),U.isRenderTargetTexture===!1&&U.isExternalTexture!==!0&&U.version>0&&J.__version!==U.version){const ge=U.image;if(ge===null)Xt("WebGLRenderer: Texture marked for update but no image data found.");else if(ge.complete===!1)Xt("WebGLRenderer: Texture marked for update but image is incomplete");else{ie(J,U,L);return}}else U.isExternalTexture&&(J.__webglTexture=U.sourceTexture?U.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,J.__webglTexture,t.TEXTURE0+L)}function G(U,L){const J=r.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&J.__version!==U.version){ie(J,U,L);return}else U.isExternalTexture&&(J.__webglTexture=U.sourceTexture?U.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,J.__webglTexture,t.TEXTURE0+L)}function V(U,L){const J=r.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&J.__version!==U.version){ie(J,U,L);return}n.bindTexture(t.TEXTURE_3D,J.__webglTexture,t.TEXTURE0+L)}function Z(U,L){const J=r.get(U);if(U.version>0&&J.__version!==U.version){ve(J,U,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,J.__webglTexture,t.TEXTURE0+L)}const Y={[YN]:t.REPEAT,[tc]:t.CLAMP_TO_EDGE,[ZN]:t.MIRRORED_REPEAT},ee={[ds]:t.NEAREST,[hue]:t.NEAREST_MIPMAP_NEAREST,[jb]:t.NEAREST_MIPMAP_LINEAR,[Hs]:t.LINEAR,[HA]:t.LINEAR_MIPMAP_NEAREST,[Jd]:t.LINEAR_MIPMAP_LINEAR},H={[xue]:t.NEVER,[wue]:t.ALWAYS,[vue]:t.LESS,[L9]:t.LEQUAL,[bue]:t.EQUAL,[Sue]:t.GEQUAL,[yue]:t.GREATER,[_ue]:t.NOTEQUAL};function q(U,L){if(L.type===nc&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===Hs||L.magFilter===HA||L.magFilter===jb||L.magFilter===Jd||L.minFilter===Hs||L.minFilter===HA||L.minFilter===jb||L.minFilter===Jd)&&Xt("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,Y[L.wrapS]),t.texParameteri(U,t.TEXTURE_WRAP_T,Y[L.wrapT]),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,Y[L.wrapR]),t.texParameteri(U,t.TEXTURE_MAG_FILTER,ee[L.magFilter]),t.texParameteri(U,t.TEXTURE_MIN_FILTER,ee[L.minFilter]),L.compareFunction&&(t.texParameteri(U,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(U,t.TEXTURE_COMPARE_FUNC,H[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===ds||L.minFilter!==jb&&L.minFilter!==Jd||L.type===nc&&e.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||r.get(L).__currentAnisotropy){const J=e.get("EXT_texture_filter_anisotropic");t.texParameterf(U,J.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy}}}function ae(U,L){let J=!1;U.__webglInit===void 0&&(U.__webglInit=!0,L.addEventListener("dispose",R));const ge=L.source;let ye=g.get(ge);ye===void 0&&(ye={},g.set(ge,ye));const me=D(L);if(me!==U.__cacheKey){ye[me]===void 0&&(ye[me]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,J=!0),ye[me].usedTimes++;const et=ye[U.__cacheKey];et!==void 0&&(ye[U.__cacheKey].usedTimes--,et.usedTimes===0&&N(L)),U.__cacheKey=me,U.__webglTexture=ye[me].texture}return J}function ce(U,L,J){return Math.floor(Math.floor(U/J)/L)}function xe(U,L,J,ge){const me=U.updateRanges;if(me.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,L.width,L.height,J,ge,L.data);else{me.sort((je,le)=>je.start-le.start);let et=0;for(let je=1;je<me.length;je++){const le=me[et],Ze=me[je],Fe=le.start+le.count,Xe=ce(Ze.start,L.width,4),ct=ce(le.start,L.width,4);Ze.start<=Fe+1&&Xe===ct&&ce(Ze.start+Ze.count-1,L.width,4)===Xe?le.count=Math.max(le.count,Ze.start+Ze.count-le.start):(++et,me[et]=Ze)}me.length=et+1;const Ie=t.getParameter(t.UNPACK_ROW_LENGTH),Ke=t.getParameter(t.UNPACK_SKIP_PIXELS),st=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,L.width);for(let je=0,le=me.length;je<le;je++){const Ze=me[je],Fe=Math.floor(Ze.start/4),Xe=Math.ceil(Ze.count/4),ct=Fe%L.width,ue=Math.floor(Fe/L.width),Qe=Xe,pe=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,ct),t.pixelStorei(t.UNPACK_SKIP_ROWS,ue),n.texSubImage2D(t.TEXTURE_2D,0,ct,ue,Qe,pe,J,ge,L.data)}U.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Ie),t.pixelStorei(t.UNPACK_SKIP_PIXELS,Ke),t.pixelStorei(t.UNPACK_SKIP_ROWS,st)}}function ie(U,L,J){let ge=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ge=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ge=t.TEXTURE_3D);const ye=ae(U,L),me=L.source;n.bindTexture(ge,U.__webglTexture,t.TEXTURE0+J);const et=r.get(me);if(me.version!==et.__version||ye===!0){n.activeTexture(t.TEXTURE0+J);const Ie=En.getPrimaries(En.workingColorSpace),Ke=L.colorSpace===Cu?null:En.getPrimaries(L.colorSpace),st=L.colorSpace===Cu||Ie===Ke?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,st);let je=y(L.image,!1,i.maxTextureSize);je=Ee(L,je);const le=a.convert(L.format,L.colorSpace),Ze=a.convert(L.type);let Fe=w(L.internalFormat,le,Ze,L.colorSpace,L.isVideoTexture);q(ge,L);let Xe;const ct=L.mipmaps,ue=L.isVideoTexture!==!0,Qe=et.__version===void 0||ye===!0,pe=me.dataReady,Oe=T(L,je);if(L.isDepthTexture)Fe=C(L.format===e0,L.type),Qe&&(ue?n.texStorage2D(t.TEXTURE_2D,1,Fe,je.width,je.height):n.texImage2D(t.TEXTURE_2D,0,Fe,je.width,je.height,0,le,Ze,null));else if(L.isDataTexture)if(ct.length>0){ue&&Qe&&n.texStorage2D(t.TEXTURE_2D,Oe,Fe,ct[0].width,ct[0].height);for(let Ae=0,be=ct.length;Ae<be;Ae++)Xe=ct[Ae],ue?pe&&n.texSubImage2D(t.TEXTURE_2D,Ae,0,0,Xe.width,Xe.height,le,Ze,Xe.data):n.texImage2D(t.TEXTURE_2D,Ae,Fe,Xe.width,Xe.height,0,le,Ze,Xe.data);L.generateMipmaps=!1}else ue?(Qe&&n.texStorage2D(t.TEXTURE_2D,Oe,Fe,je.width,je.height),pe&&xe(L,je,le,Ze)):n.texImage2D(t.TEXTURE_2D,0,Fe,je.width,je.height,0,le,Ze,je.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){ue&&Qe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Oe,Fe,ct[0].width,ct[0].height,je.depth);for(let Ae=0,be=ct.length;Ae<be;Ae++)if(Xe=ct[Ae],L.format!==xo)if(le!==null)if(ue){if(pe)if(L.layerUpdates.size>0){const $e=$F(Xe.width,Xe.height,L.format,L.type);for(const ft of L.layerUpdates){const yt=Xe.data.subarray(ft*$e/Xe.data.BYTES_PER_ELEMENT,(ft+1)*$e/Xe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ae,0,0,ft,Xe.width,Xe.height,1,le,yt)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ae,0,0,0,Xe.width,Xe.height,je.depth,le,Xe.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Ae,Fe,Xe.width,Xe.height,je.depth,0,Xe.data,0,0);else Xt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ue?pe&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Ae,0,0,0,Xe.width,Xe.height,je.depth,le,Ze,Xe.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Ae,Fe,Xe.width,Xe.height,je.depth,0,le,Ze,Xe.data)}else{ue&&Qe&&n.texStorage2D(t.TEXTURE_2D,Oe,Fe,ct[0].width,ct[0].height);for(let Ae=0,be=ct.length;Ae<be;Ae++)Xe=ct[Ae],L.format!==xo?le!==null?ue?pe&&n.compressedTexSubImage2D(t.TEXTURE_2D,Ae,0,0,Xe.width,Xe.height,le,Xe.data):n.compressedTexImage2D(t.TEXTURE_2D,Ae,Fe,Xe.width,Xe.height,0,Xe.data):Xt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ue?pe&&n.texSubImage2D(t.TEXTURE_2D,Ae,0,0,Xe.width,Xe.height,le,Ze,Xe.data):n.texImage2D(t.TEXTURE_2D,Ae,Fe,Xe.width,Xe.height,0,le,Ze,Xe.data)}else if(L.isDataArrayTexture)if(ue){if(Qe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Oe,Fe,je.width,je.height,je.depth),pe)if(L.layerUpdates.size>0){const Ae=$F(je.width,je.height,L.format,L.type);for(const be of L.layerUpdates){const $e=je.data.subarray(be*Ae/je.data.BYTES_PER_ELEMENT,(be+1)*Ae/je.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,be,je.width,je.height,1,le,Ze,$e)}L.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,je.width,je.height,je.depth,le,Ze,je.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,Fe,je.width,je.height,je.depth,0,le,Ze,je.data);else if(L.isData3DTexture)ue?(Qe&&n.texStorage3D(t.TEXTURE_3D,Oe,Fe,je.width,je.height,je.depth),pe&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,je.width,je.height,je.depth,le,Ze,je.data)):n.texImage3D(t.TEXTURE_3D,0,Fe,je.width,je.height,je.depth,0,le,Ze,je.data);else if(L.isFramebufferTexture){if(Qe)if(ue)n.texStorage2D(t.TEXTURE_2D,Oe,Fe,je.width,je.height);else{let Ae=je.width,be=je.height;for(let $e=0;$e<Oe;$e++)n.texImage2D(t.TEXTURE_2D,$e,Fe,Ae,be,0,le,Ze,null),Ae>>=1,be>>=1}}else if(ct.length>0){if(ue&&Qe){const Ae=re(ct[0]);n.texStorage2D(t.TEXTURE_2D,Oe,Fe,Ae.width,Ae.height)}for(let Ae=0,be=ct.length;Ae<be;Ae++)Xe=ct[Ae],ue?pe&&n.texSubImage2D(t.TEXTURE_2D,Ae,0,0,le,Ze,Xe):n.texImage2D(t.TEXTURE_2D,Ae,Fe,le,Ze,Xe);L.generateMipmaps=!1}else if(ue){if(Qe){const Ae=re(je);n.texStorage2D(t.TEXTURE_2D,Oe,Fe,Ae.width,Ae.height)}pe&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,le,Ze,je)}else n.texImage2D(t.TEXTURE_2D,0,Fe,le,Ze,je);v(L)&&x(ge),et.__version=me.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function ve(U,L,J){if(L.image.length!==6)return;const ge=ae(U,L),ye=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,U.__webglTexture,t.TEXTURE0+J);const me=r.get(ye);if(ye.version!==me.__version||ge===!0){n.activeTexture(t.TEXTURE0+J);const et=En.getPrimaries(En.workingColorSpace),Ie=L.colorSpace===Cu?null:En.getPrimaries(L.colorSpace),Ke=L.colorSpace===Cu||et===Ie?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ke);const st=L.isCompressedTexture||L.image[0].isCompressedTexture,je=L.image[0]&&L.image[0].isDataTexture,le=[];for(let be=0;be<6;be++)!st&&!je?le[be]=y(L.image[be],!0,i.maxCubemapSize):le[be]=je?L.image[be].image:L.image[be],le[be]=Ee(L,le[be]);const Ze=le[0],Fe=a.convert(L.format,L.colorSpace),Xe=a.convert(L.type),ct=w(L.internalFormat,Fe,Xe,L.colorSpace),ue=L.isVideoTexture!==!0,Qe=me.__version===void 0||ge===!0,pe=ye.dataReady;let Oe=T(L,Ze);q(t.TEXTURE_CUBE_MAP,L);let Ae;if(st){ue&&Qe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Oe,ct,Ze.width,Ze.height);for(let be=0;be<6;be++){Ae=le[be].mipmaps;for(let $e=0;$e<Ae.length;$e++){const ft=Ae[$e];L.format!==xo?Fe!==null?ue?pe&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,$e,0,0,ft.width,ft.height,Fe,ft.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,$e,ct,ft.width,ft.height,0,ft.data):Xt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ue?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,$e,0,0,ft.width,ft.height,Fe,Xe,ft.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,$e,ct,ft.width,ft.height,0,Fe,Xe,ft.data)}}}else{if(Ae=L.mipmaps,ue&&Qe){Ae.length>0&&Oe++;const be=re(le[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Oe,ct,be.width,be.height)}for(let be=0;be<6;be++)if(je){ue?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,0,0,le[be].width,le[be].height,Fe,Xe,le[be].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,ct,le[be].width,le[be].height,0,Fe,Xe,le[be].data);for(let $e=0;$e<Ae.length;$e++){const yt=Ae[$e].image[be].image;ue?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,$e+1,0,0,yt.width,yt.height,Fe,Xe,yt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,$e+1,ct,yt.width,yt.height,0,Fe,Xe,yt.data)}}else{ue?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,0,0,Fe,Xe,le[be]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,ct,Fe,Xe,le[be]);for(let $e=0;$e<Ae.length;$e++){const ft=Ae[$e];ue?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,$e+1,0,0,Fe,Xe,ft.image[be]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,$e+1,ct,Fe,Xe,ft.image[be])}}}v(L)&&x(t.TEXTURE_CUBE_MAP),me.__version=ye.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function Pe(U,L,J,ge,ye,me){const et=a.convert(J.format,J.colorSpace),Ie=a.convert(J.type),Ke=w(J.internalFormat,et,Ie,J.colorSpace),st=r.get(L),je=r.get(J);if(je.__renderTarget=L,!st.__hasExternalTextures){const le=Math.max(1,L.width>>me),Ze=Math.max(1,L.height>>me);ye===t.TEXTURE_3D||ye===t.TEXTURE_2D_ARRAY?n.texImage3D(ye,me,Ke,le,Ze,L.depth,0,et,Ie,null):n.texImage2D(ye,me,Ke,le,Ze,0,et,Ie,null)}n.bindFramebuffer(t.FRAMEBUFFER,U),oe(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ge,ye,je.__webglTexture,0,Q(L)):(ye===t.TEXTURE_2D||ye>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&ye<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ge,ye,je.__webglTexture,me),n.bindFramebuffer(t.FRAMEBUFFER,null)}function he(U,L,J){if(t.bindRenderbuffer(t.RENDERBUFFER,U),L.depthBuffer){const ge=L.depthTexture,ye=ge&&ge.isDepthTexture?ge.type:null,me=C(L.stencilBuffer,ye),et=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ie=Q(L);oe(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ie,me,L.width,L.height):J?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ie,me,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,me,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,et,t.RENDERBUFFER,U)}else{const ge=L.textures;for(let ye=0;ye<ge.length;ye++){const me=ge[ye],et=a.convert(me.format,me.colorSpace),Ie=a.convert(me.type),Ke=w(me.internalFormat,et,Ie,me.colorSpace),st=Q(L);J&&oe(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,st,Ke,L.width,L.height):oe(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,st,Ke,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,Ke,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function we(U,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,U),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ge=r.get(L.depthTexture);ge.__renderTarget=L,(!ge.__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),B(L.depthTexture,0);const ye=ge.__webglTexture,me=Q(L);if(L.depthTexture.format===Jx)oe(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0,me):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0);else if(L.depthTexture.format===e0)oe(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0,me):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0);else throw new Error("Unknown depthTexture format")}function Le(U){const L=r.get(U),J=U.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==U.depthTexture){const ge=U.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),ge){const ye=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,ge.removeEventListener("dispose",ye)};ge.addEventListener("dispose",ye),L.__depthDisposeCallback=ye}L.__boundDepthTexture=ge}if(U.depthTexture&&!L.__autoAllocateDepthBuffer){if(J)throw new Error("target.depthTexture not supported in Cube render targets");const ge=U.texture.mipmaps;ge&&ge.length>0?we(L.__webglFramebuffer[0],U):we(L.__webglFramebuffer,U)}else if(J){L.__webglDepthbuffer=[];for(let ge=0;ge<6;ge++)if(n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ge]),L.__webglDepthbuffer[ge]===void 0)L.__webglDepthbuffer[ge]=t.createRenderbuffer(),he(L.__webglDepthbuffer[ge],U,!1);else{const ye=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,me=L.__webglDepthbuffer[ge];t.bindRenderbuffer(t.RENDERBUFFER,me),t.framebufferRenderbuffer(t.FRAMEBUFFER,ye,t.RENDERBUFFER,me)}}else{const ge=U.texture.mipmaps;if(ge&&ge.length>0?n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=t.createRenderbuffer(),he(L.__webglDepthbuffer,U,!1);else{const ye=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,me=L.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,me),t.framebufferRenderbuffer(t.FRAMEBUFFER,ye,t.RENDERBUFFER,me)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function de(U,L,J){const ge=r.get(U);L!==void 0&&Pe(ge.__webglFramebuffer,U,U.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),J!==void 0&&Le(U)}function lt(U){const L=U.texture,J=r.get(U),ge=r.get(L);U.addEventListener("dispose",A);const ye=U.textures,me=U.isWebGLCubeRenderTarget===!0,et=ye.length>1;if(et||(ge.__webglTexture===void 0&&(ge.__webglTexture=t.createTexture()),ge.__version=L.version,s.memory.textures++),me){J.__webglFramebuffer=[];for(let Ie=0;Ie<6;Ie++)if(L.mipmaps&&L.mipmaps.length>0){J.__webglFramebuffer[Ie]=[];for(let Ke=0;Ke<L.mipmaps.length;Ke++)J.__webglFramebuffer[Ie][Ke]=t.createFramebuffer()}else J.__webglFramebuffer[Ie]=t.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){J.__webglFramebuffer=[];for(let Ie=0;Ie<L.mipmaps.length;Ie++)J.__webglFramebuffer[Ie]=t.createFramebuffer()}else J.__webglFramebuffer=t.createFramebuffer();if(et)for(let Ie=0,Ke=ye.length;Ie<Ke;Ie++){const st=r.get(ye[Ie]);st.__webglTexture===void 0&&(st.__webglTexture=t.createTexture(),s.memory.textures++)}if(U.samples>0&&oe(U)===!1){J.__webglMultisampledFramebuffer=t.createFramebuffer(),J.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,J.__webglMultisampledFramebuffer);for(let Ie=0;Ie<ye.length;Ie++){const Ke=ye[Ie];J.__webglColorRenderbuffer[Ie]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,J.__webglColorRenderbuffer[Ie]);const st=a.convert(Ke.format,Ke.colorSpace),je=a.convert(Ke.type),le=w(Ke.internalFormat,st,je,Ke.colorSpace,U.isXRRenderTarget===!0),Ze=Q(U);t.renderbufferStorageMultisample(t.RENDERBUFFER,Ze,le,U.width,U.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ie,t.RENDERBUFFER,J.__webglColorRenderbuffer[Ie])}t.bindRenderbuffer(t.RENDERBUFFER,null),U.depthBuffer&&(J.__webglDepthRenderbuffer=t.createRenderbuffer(),he(J.__webglDepthRenderbuffer,U,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(me){n.bindTexture(t.TEXTURE_CUBE_MAP,ge.__webglTexture),q(t.TEXTURE_CUBE_MAP,L);for(let Ie=0;Ie<6;Ie++)if(L.mipmaps&&L.mipmaps.length>0)for(let Ke=0;Ke<L.mipmaps.length;Ke++)Pe(J.__webglFramebuffer[Ie][Ke],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,Ke);else Pe(J.__webglFramebuffer[Ie],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,0);v(L)&&x(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(et){for(let Ie=0,Ke=ye.length;Ie<Ke;Ie++){const st=ye[Ie],je=r.get(st);let le=t.TEXTURE_2D;(U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(le=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(le,je.__webglTexture),q(le,st),Pe(J.__webglFramebuffer,U,st,t.COLOR_ATTACHMENT0+Ie,le,0),v(st)&&x(le)}n.unbindTexture()}else{let Ie=t.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(Ie=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Ie,ge.__webglTexture),q(Ie,L),L.mipmaps&&L.mipmaps.length>0)for(let Ke=0;Ke<L.mipmaps.length;Ke++)Pe(J.__webglFramebuffer[Ke],U,L,t.COLOR_ATTACHMENT0,Ie,Ke);else Pe(J.__webglFramebuffer,U,L,t.COLOR_ATTACHMENT0,Ie,0);v(L)&&x(Ie),n.unbindTexture()}U.depthBuffer&&Le(U)}function $(U){const L=U.textures;for(let J=0,ge=L.length;J<ge;J++){const ye=L[J];if(v(ye)){const me=M(U),et=r.get(ye).__webglTexture;n.bindTexture(me,et),x(me),n.unbindTexture()}}}const z=[],ne=[];function K(U){if(U.samples>0){if(oe(U)===!1){const L=U.textures,J=U.width,ge=U.height;let ye=t.COLOR_BUFFER_BIT;const me=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,et=r.get(U),Ie=L.length>1;if(Ie)for(let st=0;st<L.length;st++)n.bindFramebuffer(t.FRAMEBUFFER,et.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,et.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,et.__webglMultisampledFramebuffer);const Ke=U.texture.mipmaps;Ke&&Ke.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,et.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,et.__webglFramebuffer);for(let st=0;st<L.length;st++){if(U.resolveDepthBuffer&&(U.depthBuffer&&(ye|=t.DEPTH_BUFFER_BIT),U.stencilBuffer&&U.resolveStencilBuffer&&(ye|=t.STENCIL_BUFFER_BIT)),Ie){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,et.__webglColorRenderbuffer[st]);const je=r.get(L[st]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,je,0)}t.blitFramebuffer(0,0,J,ge,0,0,J,ge,ye,t.NEAREST),l===!0&&(z.length=0,ne.length=0,z.push(t.COLOR_ATTACHMENT0+st),U.depthBuffer&&U.resolveDepthBuffer===!1&&(z.push(me),ne.push(me),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,ne)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,z))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ie)for(let st=0;st<L.length;st++){n.bindFramebuffer(t.FRAMEBUFFER,et.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,et.__webglColorRenderbuffer[st]);const je=r.get(L[st]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,et.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,je,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,et.__webglMultisampledFramebuffer)}else if(U.depthBuffer&&U.resolveDepthBuffer===!1&&l){const L=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[L])}}}function Q(U){return Math.min(i.maxSamples,U.samples)}function oe(U){const L=r.get(U);return U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ne(U){const L=s.render.frame;u.get(U)!==L&&(u.set(U,L),U.update())}function Ee(U,L){const J=U.colorSpace,ge=U.format,ye=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||J!==Zp&&J!==Cu&&(En.getTransfer(J)===Bn?(ge!==xo||ye!==rl)&&Xt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Dr("WebGLTextures: Unsupported texture color space:",J)),L}function re(U){return typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement?(c.width=U.naturalWidth||U.width,c.height=U.naturalHeight||U.height):typeof VideoFrame<"u"&&U instanceof VideoFrame?(c.width=U.displayWidth,c.height=U.displayHeight):(c.width=U.width,c.height=U.height),c}this.allocateTextureUnit=W,this.resetTextureUnits=I,this.setTexture2D=B,this.setTexture2DArray=G,this.setTexture3D=V,this.setTextureCube=Z,this.rebindTextures=de,this.setupRenderTarget=lt,this.updateRenderTargetMipmap=$,this.updateMultisampleRenderTarget=K,this.setupDepthRenderbuffer=Le,this.setupFrameBufferTexture=Pe,this.useMultisampledRTT=oe}function Vme(t,e){function n(r,i=Cu){let a;const s=En.getTransfer(i);if(r===rl)return t.UNSIGNED_BYTE;if(r===tk)return t.UNSIGNED_SHORT_4_4_4_4;if(r===nk)return t.UNSIGNED_SHORT_5_5_5_1;if(r===N9)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===R9)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===T9)return t.BYTE;if(r===C9)return t.SHORT;if(r===Zx)return t.UNSIGNED_SHORT;if(r===ek)return t.INT;if(r===Cf)return t.UNSIGNED_INT;if(r===nc)return t.FLOAT;if(r===Em)return t.HALF_FLOAT;if(r===P9)return t.ALPHA;if(r===k9)return t.RGB;if(r===xo)return t.RGBA;if(r===Jx)return t.DEPTH_COMPONENT;if(r===e0)return t.DEPTH_STENCIL;if(r===D9)return t.RED;if(r===rk)return t.RED_INTEGER;if(r===ik)return t.RG;if(r===ak)return t.RG_INTEGER;if(r===sk)return t.RGBA_INTEGER;if(r===v_||r===b_||r===y_||r===__)if(s===Bn)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===v_)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===b_)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===y_)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===__)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===v_)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===b_)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===y_)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===__)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===QN||r===JN||r===e3||r===t3)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===QN)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===JN)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===e3)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===t3)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===n3||r===r3||r===i3)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===n3||r===r3)return s===Bn?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===i3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===a3||r===s3||r===o3||r===l3||r===c3||r===u3||r===d3||r===f3||r===h3||r===p3||r===m3||r===g3||r===x3||r===v3)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===a3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===s3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===o3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===l3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===c3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===u3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===d3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===f3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===h3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===p3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===m3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===g3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===x3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===v3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===b3||r===y3||r===_3)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===b3)return s===Bn?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===y3)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===_3)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===S3||r===w3||r===M3||r===E3)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===S3)return a.COMPRESSED_RED_RGTC1_EXT;if(r===w3)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===M3)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===E3)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===Qx?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const Gme=`
  3825. void main() {
  3826. gl_Position = vec4( position, 1.0 );
  3827. }`,Wme=`
  3828. uniform sampler2DArray depthColor;
  3829. uniform float depthWidth;
  3830. uniform float depthHeight;
  3831. void main() {
  3832. vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
  3833. if ( coord.x >= 1.0 ) {
  3834. gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
  3835. } else {
  3836. gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
  3837. }
  3838. }`;class qme{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new e7(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 vc({vertexShader:Gme,fragmentShader:Wme,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new il(new fk(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let Xme=class extends qf{constructor(e,n){super();const r=this;let i=null,a=1,s=null,o="local-floor",l=1,c=null,u=null,h=null,g=null,m=null,b=null;const y=typeof XRWebGLBinding<"u",v=new qme,x={},M=n.getContextAttributes();let w=null,C=null;const T=[],R=[],A=new sn;let j=null;const N=new js;N.viewport=new Vr;const k=new js;k.viewport=new Vr;const F=[N,k],I=new dde;let W=null,D=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ie){let ve=T[ie];return ve===void 0&&(ve=new uT,T[ie]=ve),ve.getTargetRaySpace()},this.getControllerGrip=function(ie){let ve=T[ie];return ve===void 0&&(ve=new uT,T[ie]=ve),ve.getGripSpace()},this.getHand=function(ie){let ve=T[ie];return ve===void 0&&(ve=new uT,T[ie]=ve),ve.getHandSpace()};function B(ie){const ve=R.indexOf(ie.inputSource);if(ve===-1)return;const Pe=T[ve];Pe!==void 0&&(Pe.update(ie.inputSource,ie.frame,c||s),Pe.dispatchEvent({type:ie.type,data:ie.inputSource}))}function G(){i.removeEventListener("select",B),i.removeEventListener("selectstart",B),i.removeEventListener("selectend",B),i.removeEventListener("squeeze",B),i.removeEventListener("squeezestart",B),i.removeEventListener("squeezeend",B),i.removeEventListener("end",G),i.removeEventListener("inputsourceschange",V);for(let ie=0;ie<T.length;ie++){const ve=R[ie];ve!==null&&(R[ie]=null,T[ie].disconnect(ve))}W=null,D=null,v.reset();for(const ie in x)delete x[ie];e.setRenderTarget(w),m=null,g=null,h=null,i=null,C=null,xe.stop(),r.isPresenting=!1,e.setPixelRatio(j),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ie){a=ie,r.isPresenting===!0&&Xt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ie){o=ie,r.isPresenting===!0&&Xt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(ie){c=ie},this.getBaseLayer=function(){return g!==null?g:m},this.getBinding=function(){return h===null&&y&&(h=new XRWebGLBinding(i,n)),h},this.getFrame=function(){return b},this.getSession=function(){return i},this.setSession=async function(ie){if(i=ie,i!==null){if(w=e.getRenderTarget(),i.addEventListener("select",B),i.addEventListener("selectstart",B),i.addEventListener("selectend",B),i.addEventListener("squeeze",B),i.addEventListener("squeezestart",B),i.addEventListener("squeezeend",B),i.addEventListener("end",G),i.addEventListener("inputsourceschange",V),M.xrCompatible!==!0&&await n.makeXRCompatible(),j=e.getPixelRatio(),e.getSize(A),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let Pe=null,he=null,we=null;M.depth&&(we=M.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Pe=M.stencil?e0:Jx,he=M.stencil?Qx:Cf);const Le={colorFormat:n.RGBA8,depthFormat:we,scaleFactor:a};h=this.getBinding(),g=h.createProjectionLayer(Le),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),C=new Rf(g.textureWidth,g.textureHeight,{format:xo,type:rl,depthTexture:new J9(g.textureWidth,g.textureHeight,he,void 0,void 0,void 0,void 0,void 0,void 0,Pe),stencilBuffer:M.stencil,colorSpace:e.outputColorSpace,samples:M.antialias?4:0,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}else{const Pe={antialias:M.antialias,alpha:!0,depth:M.depth,stencil:M.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(i,n,Pe),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),C=new Rf(m.framebufferWidth,m.framebufferHeight,{format:xo,type:rl,colorSpace:e.outputColorSpace,stencilBuffer:M.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}C.isXRRenderTarget=!0,this.setFoveation(l),c=null,s=await i.requestReferenceSpace(o),xe.setContext(i),xe.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function V(ie){for(let ve=0;ve<ie.removed.length;ve++){const Pe=ie.removed[ve],he=R.indexOf(Pe);he>=0&&(R[he]=null,T[he].disconnect(Pe))}for(let ve=0;ve<ie.added.length;ve++){const Pe=ie.added[ve];let he=R.indexOf(Pe);if(he===-1){for(let Le=0;Le<T.length;Le++)if(Le>=R.length){R.push(Pe),he=Le;break}else if(R[Le]===null){R[Le]=Pe,he=Le;break}if(he===-1)break}const we=T[he];we&&we.connect(Pe)}}const Z=new We,Y=new We;function ee(ie,ve,Pe){Z.setFromMatrixPosition(ve.matrixWorld),Y.setFromMatrixPosition(Pe.matrixWorld);const he=Z.distanceTo(Y),we=ve.projectionMatrix.elements,Le=Pe.projectionMatrix.elements,de=we[14]/(we[10]-1),lt=we[14]/(we[10]+1),$=(we[9]+1)/we[5],z=(we[9]-1)/we[5],ne=(we[8]-1)/we[0],K=(Le[8]+1)/Le[0],Q=de*ne,oe=de*K,Ne=he/(-ne+K),Ee=Ne*-ne;if(ve.matrixWorld.decompose(ie.position,ie.quaternion,ie.scale),ie.translateX(Ee),ie.translateZ(Ne),ie.matrixWorld.compose(ie.position,ie.quaternion,ie.scale),ie.matrixWorldInverse.copy(ie.matrixWorld).invert(),we[10]===-1)ie.projectionMatrix.copy(ve.projectionMatrix),ie.projectionMatrixInverse.copy(ve.projectionMatrixInverse);else{const re=de+Ne,U=lt+Ne,L=Q-Ee,J=oe+(he-Ee),ge=$*lt/U*re,ye=z*lt/U*re;ie.projectionMatrix.makePerspective(L,J,ge,ye,re,U),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert()}}function H(ie,ve){ve===null?ie.matrixWorld.copy(ie.matrix):ie.matrixWorld.multiplyMatrices(ve.matrixWorld,ie.matrix),ie.matrixWorldInverse.copy(ie.matrixWorld).invert()}this.updateCamera=function(ie){if(i===null)return;let ve=ie.near,Pe=ie.far;v.texture!==null&&(v.depthNear>0&&(ve=v.depthNear),v.depthFar>0&&(Pe=v.depthFar)),I.near=k.near=N.near=ve,I.far=k.far=N.far=Pe,(W!==I.near||D!==I.far)&&(i.updateRenderState({depthNear:I.near,depthFar:I.far}),W=I.near,D=I.far),I.layers.mask=ie.layers.mask|6,N.layers.mask=I.layers.mask&3,k.layers.mask=I.layers.mask&5;const he=ie.parent,we=I.cameras;H(I,he);for(let Le=0;Le<we.length;Le++)H(we[Le],he);we.length===2?ee(I,N,k):I.projectionMatrix.copy(N.projectionMatrix),q(ie,I,he)};function q(ie,ve,Pe){Pe===null?ie.matrix.copy(ve.matrixWorld):(ie.matrix.copy(Pe.matrixWorld),ie.matrix.invert(),ie.matrix.multiply(ve.matrixWorld)),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.updateMatrixWorld(!0),ie.projectionMatrix.copy(ve.projectionMatrix),ie.projectionMatrixInverse.copy(ve.projectionMatrixInverse),ie.isPerspectiveCamera&&(ie.fov=A3*2*Math.atan(1/ie.projectionMatrix.elements[5]),ie.zoom=1)}this.getCamera=function(){return I},this.getFoveation=function(){if(!(g===null&&m===null))return l},this.setFoveation=function(ie){l=ie,g!==null&&(g.fixedFoveation=ie),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=ie)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(I)},this.getCameraTexture=function(ie){return x[ie]};let ae=null;function ce(ie,ve){if(u=ve.getViewerPose(c||s),b=ve,u!==null){const Pe=u.views;m!==null&&(e.setRenderTargetFramebuffer(C,m.framebuffer),e.setRenderTarget(C));let he=!1;Pe.length!==I.cameras.length&&(I.cameras.length=0,he=!0);for(let lt=0;lt<Pe.length;lt++){const $=Pe[lt];let z=null;if(m!==null)z=m.getViewport($);else{const K=h.getViewSubImage(g,$);z=K.viewport,lt===0&&(e.setRenderTargetTextures(C,K.colorTexture,K.depthStencilTexture),e.setRenderTarget(C))}let ne=F[lt];ne===void 0&&(ne=new js,ne.layers.enable(lt),ne.viewport=new Vr,F[lt]=ne),ne.matrix.fromArray($.transform.matrix),ne.matrix.decompose(ne.position,ne.quaternion,ne.scale),ne.projectionMatrix.fromArray($.projectionMatrix),ne.projectionMatrixInverse.copy(ne.projectionMatrix).invert(),ne.viewport.set(z.x,z.y,z.width,z.height),lt===0&&(I.matrix.copy(ne.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),he===!0&&I.cameras.push(ne)}const we=i.enabledFeatures;if(we&&we.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){h=r.getBinding();const lt=h.getDepthInformation(Pe[0]);lt&&lt.isValid&&lt.texture&&v.init(lt,i.renderState)}if(we&&we.includes("camera-access")&&y){e.state.unbindTexture(),h=r.getBinding();for(let lt=0;lt<Pe.length;lt++){const $=Pe[lt].camera;if($){let z=x[$];z||(z=new e7,x[$]=z);const ne=h.getCameraImage($);z.sourceTexture=ne}}}}for(let Pe=0;Pe<T.length;Pe++){const he=R[Pe],we=T[Pe];he!==null&&we!==void 0&&we.update(he,ve,c||s)}ae&&ae(ie,ve),ve.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ve}),b=null}const xe=new i7;xe.setAnimationLoop(ce),this.setAnimationLoop=function(ie){ae=ie},this.dispose=function(){}}};const Ld=new Zu,Kme=new Xr;function Yme(t,e){function n(v,x){v.matrixAutoUpdate===!0&&v.updateMatrix(),x.value.copy(v.matrix)}function r(v,x){x.color.getRGB(v.fogColor.value,K9(t)),x.isFog?(v.fogNear.value=x.near,v.fogFar.value=x.far):x.isFogExp2&&(v.fogDensity.value=x.density)}function i(v,x,M,w,C){x.isMeshBasicMaterial||x.isMeshLambertMaterial?a(v,x):x.isMeshToonMaterial?(a(v,x),h(v,x)):x.isMeshPhongMaterial?(a(v,x),u(v,x)):x.isMeshStandardMaterial?(a(v,x),g(v,x),x.isMeshPhysicalMaterial&&m(v,x,C)):x.isMeshMatcapMaterial?(a(v,x),b(v,x)):x.isMeshDepthMaterial?a(v,x):x.isMeshDistanceMaterial?(a(v,x),y(v,x)):x.isMeshNormalMaterial?a(v,x):x.isLineBasicMaterial?(s(v,x),x.isLineDashedMaterial&&o(v,x)):x.isPointsMaterial?l(v,x,M,w):x.isSpriteMaterial?c(v,x):x.isShadowMaterial?(v.color.value.copy(x.color),v.opacity.value=x.opacity):x.isShaderMaterial&&(x.uniformsNeedUpdate=!1)}function a(v,x){v.opacity.value=x.opacity,x.color&&v.diffuse.value.copy(x.color),x.emissive&&v.emissive.value.copy(x.emissive).multiplyScalar(x.emissiveIntensity),x.map&&(v.map.value=x.map,n(x.map,v.mapTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.bumpMap&&(v.bumpMap.value=x.bumpMap,n(x.bumpMap,v.bumpMapTransform),v.bumpScale.value=x.bumpScale,x.side===Ua&&(v.bumpScale.value*=-1)),x.normalMap&&(v.normalMap.value=x.normalMap,n(x.normalMap,v.normalMapTransform),v.normalScale.value.copy(x.normalScale),x.side===Ua&&v.normalScale.value.negate()),x.displacementMap&&(v.displacementMap.value=x.displacementMap,n(x.displacementMap,v.displacementMapTransform),v.displacementScale.value=x.displacementScale,v.displacementBias.value=x.displacementBias),x.emissiveMap&&(v.emissiveMap.value=x.emissiveMap,n(x.emissiveMap,v.emissiveMapTransform)),x.specularMap&&(v.specularMap.value=x.specularMap,n(x.specularMap,v.specularMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest);const M=e.get(x),w=M.envMap,C=M.envMapRotation;w&&(v.envMap.value=w,Ld.copy(C),Ld.x*=-1,Ld.y*=-1,Ld.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(Ld.y*=-1,Ld.z*=-1),v.envMapRotation.value.setFromMatrix4(Kme.makeRotationFromEuler(Ld)),v.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=x.reflectivity,v.ior.value=x.ior,v.refractionRatio.value=x.refractionRatio),x.lightMap&&(v.lightMap.value=x.lightMap,v.lightMapIntensity.value=x.lightMapIntensity,n(x.lightMap,v.lightMapTransform)),x.aoMap&&(v.aoMap.value=x.aoMap,v.aoMapIntensity.value=x.aoMapIntensity,n(x.aoMap,v.aoMapTransform))}function s(v,x){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,x.map&&(v.map.value=x.map,n(x.map,v.mapTransform))}function o(v,x){v.dashSize.value=x.dashSize,v.totalSize.value=x.dashSize+x.gapSize,v.scale.value=x.scale}function l(v,x,M,w){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,v.size.value=x.size*M,v.scale.value=w*.5,x.map&&(v.map.value=x.map,n(x.map,v.uvTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest)}function c(v,x){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,v.rotation.value=x.rotation,x.map&&(v.map.value=x.map,n(x.map,v.mapTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest)}function u(v,x){v.specular.value.copy(x.specular),v.shininess.value=Math.max(x.shininess,1e-4)}function h(v,x){x.gradientMap&&(v.gradientMap.value=x.gradientMap)}function g(v,x){v.metalness.value=x.metalness,x.metalnessMap&&(v.metalnessMap.value=x.metalnessMap,n(x.metalnessMap,v.metalnessMapTransform)),v.roughness.value=x.roughness,x.roughnessMap&&(v.roughnessMap.value=x.roughnessMap,n(x.roughnessMap,v.roughnessMapTransform)),x.envMap&&(v.envMapIntensity.value=x.envMapIntensity)}function m(v,x,M){v.ior.value=x.ior,x.sheen>0&&(v.sheenColor.value.copy(x.sheenColor).multiplyScalar(x.sheen),v.sheenRoughness.value=x.sheenRoughness,x.sheenColorMap&&(v.sheenColorMap.value=x.sheenColorMap,n(x.sheenColorMap,v.sheenColorMapTransform)),x.sheenRoughnessMap&&(v.sheenRoughnessMap.value=x.sheenRoughnessMap,n(x.sheenRoughnessMap,v.sheenRoughnessMapTransform))),x.clearcoat>0&&(v.clearcoat.value=x.clearcoat,v.clearcoatRoughness.value=x.clearcoatRoughness,x.clearcoatMap&&(v.clearcoatMap.value=x.clearcoatMap,n(x.clearcoatMap,v.clearcoatMapTransform)),x.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=x.clearcoatRoughnessMap,n(x.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),x.clearcoatNormalMap&&(v.clearcoatNormalMap.value=x.clearcoatNormalMap,n(x.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(x.clearcoatNormalScale),x.side===Ua&&v.clearcoatNormalScale.value.negate())),x.dispersion>0&&(v.dispersion.value=x.dispersion),x.iridescence>0&&(v.iridescence.value=x.iridescence,v.iridescenceIOR.value=x.iridescenceIOR,v.iridescenceThicknessMinimum.value=x.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=x.iridescenceThicknessRange[1],x.iridescenceMap&&(v.iridescenceMap.value=x.iridescenceMap,n(x.iridescenceMap,v.iridescenceMapTransform)),x.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=x.iridescenceThicknessMap,n(x.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),x.transmission>0&&(v.transmission.value=x.transmission,v.transmissionSamplerMap.value=M.texture,v.transmissionSamplerSize.value.set(M.width,M.height),x.transmissionMap&&(v.transmissionMap.value=x.transmissionMap,n(x.transmissionMap,v.transmissionMapTransform)),v.thickness.value=x.thickness,x.thicknessMap&&(v.thicknessMap.value=x.thicknessMap,n(x.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=x.attenuationDistance,v.attenuationColor.value.copy(x.attenuationColor)),x.anisotropy>0&&(v.anisotropyVector.value.set(x.anisotropy*Math.cos(x.anisotropyRotation),x.anisotropy*Math.sin(x.anisotropyRotation)),x.anisotropyMap&&(v.anisotropyMap.value=x.anisotropyMap,n(x.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=x.specularIntensity,v.specularColor.value.copy(x.specularColor),x.specularColorMap&&(v.specularColorMap.value=x.specularColorMap,n(x.specularColorMap,v.specularColorMapTransform)),x.specularIntensityMap&&(v.specularIntensityMap.value=x.specularIntensityMap,n(x.specularIntensityMap,v.specularIntensityMapTransform))}function b(v,x){x.matcap&&(v.matcap.value=x.matcap)}function y(v,x){const M=e.get(x).light;v.referencePosition.value.setFromMatrixPosition(M.matrixWorld),v.nearDistance.value=M.shadow.camera.near,v.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function Zme(t,e,n,r){let i={},a={},s=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(M,w){const C=w.program;r.uniformBlockBinding(M,C)}function c(M,w){let C=i[M.id];C===void 0&&(b(M),C=u(M),i[M.id]=C,M.addEventListener("dispose",v));const T=w.program;r.updateUBOMapping(M,T);const R=e.render.frame;a[M.id]!==R&&(g(M),a[M.id]=R)}function u(M){const w=h();M.__bindingPointIndex=w;const C=t.createBuffer(),T=M.__size,R=M.usage;return t.bindBuffer(t.UNIFORM_BUFFER,C),t.bufferData(t.UNIFORM_BUFFER,T,R),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,C),C}function h(){for(let M=0;M<o;M++)if(s.indexOf(M)===-1)return s.push(M),M;return Dr("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(M){const w=i[M.id],C=M.uniforms,T=M.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let R=0,A=C.length;R<A;R++){const j=Array.isArray(C[R])?C[R]:[C[R]];for(let N=0,k=j.length;N<k;N++){const F=j[N];if(m(F,R,N,T)===!0){const I=F.__offset,W=Array.isArray(F.value)?F.value:[F.value];let D=0;for(let B=0;B<W.length;B++){const G=W[B],V=y(G);typeof G=="number"||typeof G=="boolean"?(F.__data[0]=G,t.bufferSubData(t.UNIFORM_BUFFER,I+D,F.__data)):G.isMatrix3?(F.__data[0]=G.elements[0],F.__data[1]=G.elements[1],F.__data[2]=G.elements[2],F.__data[3]=0,F.__data[4]=G.elements[3],F.__data[5]=G.elements[4],F.__data[6]=G.elements[5],F.__data[7]=0,F.__data[8]=G.elements[6],F.__data[9]=G.elements[7],F.__data[10]=G.elements[8],F.__data[11]=0):(G.toArray(F.__data,D),D+=V.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,I,F.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(M,w,C,T){const R=M.value,A=w+"_"+C;if(T[A]===void 0)return typeof R=="number"||typeof R=="boolean"?T[A]=R:T[A]=R.clone(),!0;{const j=T[A];if(typeof R=="number"||typeof R=="boolean"){if(j!==R)return T[A]=R,!0}else if(j.equals(R)===!1)return j.copy(R),!0}return!1}function b(M){const w=M.uniforms;let C=0;const T=16;for(let A=0,j=w.length;A<j;A++){const N=Array.isArray(w[A])?w[A]:[w[A]];for(let k=0,F=N.length;k<F;k++){const I=N[k],W=Array.isArray(I.value)?I.value:[I.value];for(let D=0,B=W.length;D<B;D++){const G=W[D],V=y(G),Z=C%T,Y=Z%V.boundary,ee=Z+Y;C+=Y,ee!==0&&T-ee<V.storage&&(C+=T-ee),I.__data=new Float32Array(V.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=C,C+=V.storage}}}const R=C%T;return R>0&&(C+=T-R),M.__size=C,M.__cache={},this}function y(M){const w={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(w.boundary=4,w.storage=4):M.isVector2?(w.boundary=8,w.storage=8):M.isVector3||M.isColor?(w.boundary=16,w.storage=12):M.isVector4?(w.boundary=16,w.storage=16):M.isMatrix3?(w.boundary=48,w.storage=48):M.isMatrix4?(w.boundary=64,w.storage=64):M.isTexture?Xt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Xt("WebGLRenderer: Unsupported uniform value type.",M),w}function v(M){const w=M.target;w.removeEventListener("dispose",v);const C=s.indexOf(w.__bindingPointIndex);s.splice(C,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete a[w.id]}function x(){for(const M in i)t.deleteBuffer(i[M]);s=[],i={},a={}}return{bind:l,update:c,dispose:x}}const Qme=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 Il=null;function Jme(){return Il===null&&(Il=new Jue(Qme,32,32,ik,Em),Il.minFilter=Hs,Il.magFilter=Hs,Il.wrapS=tc,Il.wrapT=tc,Il.generateMipmaps=!1,Il.needsUpdate=!0),Il}let ege=class{constructor(e={}){const{canvas:n=Mue(),context:r=null,depth:i=!0,stencil:a=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:g=!1}=e;this.isWebGLRenderer=!0;let m;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=r.getContextAttributes().alpha}else m=s;const b=new Set([sk,ak,rk]),y=new Set([rl,Cf,Zx,Qx,tk,nk]),v=new Uint32Array(4),x=new Int32Array(4);let M=null,w=null;const C=[],T=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Fu,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const R=this;let A=!1;this._outputColorSpace=Os;let j=0,N=0,k=null,F=-1,I=null;const W=new Vr,D=new Vr;let B=null;const G=new bn(0);let V=0,Z=n.width,Y=n.height,ee=1,H=null,q=null;const ae=new Vr(0,0,Z,Y),ce=new Vr(0,0,Z,Y);let xe=!1;const ie=new dk;let ve=!1,Pe=!1;const he=new Xr,we=new We,Le=new Vr,de={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let lt=!1;function $(){return k===null?ee:1}let z=r;function ne(te,_e){return n.getContext(te,_e)}try{const te={alpha:!0,depth:i,stencil:a,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${QP}`),n.addEventListener("webglcontextlost",Ae,!1),n.addEventListener("webglcontextrestored",be,!1),n.addEventListener("webglcontextcreationerror",$e,!1),z===null){const _e="webgl2";if(z=ne(_e,te),z===null)throw ne(_e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(te){throw te("WebGLRenderer: "+te.message),te}let K,Q,oe,Ne,Ee,re,U,L,J,ge,ye,me,et,Ie,Ke,st,je,le,Ze,Fe,Xe,ct,ue,Qe;function pe(){K=new lpe(z),K.init(),ct=new Vme(z,K),Q=new Jhe(z,K,e,ct),oe=new Hme(z,K),Q.reversedDepthBuffer&&g&&oe.buffers.depth.setReversed(!0),Ne=new dpe(z),Ee=new Nme,re=new $me(z,K,oe,Ee,Q,ct,Ne),U=new tpe(R),L=new ope(R),J=new mde(z),ue=new Zhe(z,J),ge=new cpe(z,J,Ne,ue),ye=new hpe(z,ge,J,Ne),Ze=new fpe(z,Q,re),st=new epe(Ee),me=new Cme(R,U,L,K,Q,ue,st),et=new Yme(R,Ee),Ie=new Pme,Ke=new jme(K),le=new Yhe(R,U,L,oe,ye,m,l),je=new zme(R,ye,Q),Qe=new Zme(z,Ne,Q,oe),Fe=new Qhe(z,K,Ne),Xe=new upe(z,K,Ne),Ne.programs=me.programs,R.capabilities=Q,R.extensions=K,R.properties=Ee,R.renderLists=Ie,R.shadowMap=je,R.state=oe,R.info=Ne}pe();const Oe=new Xme(R,z);this.xr=Oe,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){const te=K.get("WEBGL_lose_context");te&&te.loseContext()},this.forceContextRestore=function(){const te=K.get("WEBGL_lose_context");te&&te.restoreContext()},this.getPixelRatio=function(){return ee},this.setPixelRatio=function(te){te!==void 0&&(ee=te,this.setSize(Z,Y,!1))},this.getSize=function(te){return te.set(Z,Y)},this.setSize=function(te,_e,ke=!0){if(Oe.isPresenting){Xt("WebGLRenderer: Can't change size while VR device is presenting.");return}Z=te,Y=_e,n.width=Math.floor(te*ee),n.height=Math.floor(_e*ee),ke===!0&&(n.style.width=te+"px",n.style.height=_e+"px"),this.setViewport(0,0,te,_e)},this.getDrawingBufferSize=function(te){return te.set(Z*ee,Y*ee).floor()},this.setDrawingBufferSize=function(te,_e,ke){Z=te,Y=_e,ee=ke,n.width=Math.floor(te*ke),n.height=Math.floor(_e*ke),this.setViewport(0,0,te,_e)},this.getCurrentViewport=function(te){return te.copy(W)},this.getViewport=function(te){return te.copy(ae)},this.setViewport=function(te,_e,ke,Re){te.isVector4?ae.set(te.x,te.y,te.z,te.w):ae.set(te,_e,ke,Re),oe.viewport(W.copy(ae).multiplyScalar(ee).round())},this.getScissor=function(te){return te.copy(ce)},this.setScissor=function(te,_e,ke,Re){te.isVector4?ce.set(te.x,te.y,te.z,te.w):ce.set(te,_e,ke,Re),oe.scissor(D.copy(ce).multiplyScalar(ee).round())},this.getScissorTest=function(){return xe},this.setScissorTest=function(te){oe.setScissorTest(xe=te)},this.setOpaqueSort=function(te){H=te},this.setTransparentSort=function(te){q=te},this.getClearColor=function(te){return te.copy(le.getClearColor())},this.setClearColor=function(){le.setClearColor(...arguments)},this.getClearAlpha=function(){return le.getClearAlpha()},this.setClearAlpha=function(){le.setClearAlpha(...arguments)},this.clear=function(te=!0,_e=!0,ke=!0){let Re=0;if(te){let Me=!1;if(k!==null){const it=k.texture.format;Me=b.has(it)}if(Me){const it=k.texture.type,ht=y.has(it),vt=le.getClearColor(),xt=le.getClearAlpha(),kt=vt.r,wt=vt.g,mt=vt.b;ht?(v[0]=kt,v[1]=wt,v[2]=mt,v[3]=xt,z.clearBufferuiv(z.COLOR,0,v)):(x[0]=kt,x[1]=wt,x[2]=mt,x[3]=xt,z.clearBufferiv(z.COLOR,0,x))}else Re|=z.COLOR_BUFFER_BIT}_e&&(Re|=z.DEPTH_BUFFER_BIT),ke&&(Re|=z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),z.clear(Re)},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",Ae,!1),n.removeEventListener("webglcontextrestored",be,!1),n.removeEventListener("webglcontextcreationerror",$e,!1),le.dispose(),Ie.dispose(),Ke.dispose(),Ee.dispose(),U.dispose(),L.dispose(),ye.dispose(),ue.dispose(),Qe.dispose(),me.dispose(),Oe.dispose(),Oe.removeEventListener("sessionstart",qn),Oe.removeEventListener("sessionend",pi),Qr.stop()};function Ae(te){te.preventDefault(),vF("WebGLRenderer: Context Lost."),A=!0}function be(){vF("WebGLRenderer: Context Restored."),A=!1;const te=Ne.autoReset,_e=je.enabled,ke=je.autoUpdate,Re=je.needsUpdate,Me=je.type;pe(),Ne.autoReset=te,je.enabled=_e,je.autoUpdate=ke,je.needsUpdate=Re,je.type=Me}function $e(te){Dr("WebGLRenderer: A WebGL context could not be created. Reason: ",te.statusMessage)}function ft(te){const _e=te.target;_e.removeEventListener("dispose",ft),yt(_e)}function yt(te){Pt(te),Ee.remove(te)}function Pt(te){const _e=Ee.get(te).programs;_e!==void 0&&(_e.forEach(function(ke){me.releaseProgram(ke)}),te.isShaderMaterial&&me.releaseShaderCache(te))}this.renderBufferDirect=function(te,_e,ke,Re,Me,it){_e===null&&(_e=de);const ht=Me.isMesh&&Me.matrixWorld.determinant()<0,vt=fe(te,_e,ke,Re,Me);oe.setMaterial(Re,ht);let xt=ke.index,kt=1;if(Re.wireframe===!0){if(xt=ge.getWireframeAttribute(ke),xt===void 0)return;kt=2}const wt=ke.drawRange,mt=ke.attributes.position;let qt=wt.start*kt,It=(wt.start+wt.count)*kt;it!==null&&(qt=Math.max(qt,it.start*kt),It=Math.min(It,(it.start+it.count)*kt)),xt!==null?(qt=Math.max(qt,0),It=Math.min(It,xt.count)):mt!=null&&(qt=Math.max(qt,0),It=Math.min(It,mt.count));const tn=It-qt;if(tn<0||tn===1/0)return;ue.setup(Me,Re,vt,ke,xt);let dn,gn=Fe;if(xt!==null&&(dn=J.get(xt),gn=Xe,gn.setIndex(dn)),Me.isMesh)Re.wireframe===!0?(oe.setLineWidth(Re.wireframeLinewidth*$()),gn.setMode(z.LINES)):gn.setMode(z.TRIANGLES);else if(Me.isLine){let Lt=Re.linewidth;Lt===void 0&&(Lt=1),oe.setLineWidth(Lt*$()),Me.isLineSegments?gn.setMode(z.LINES):Me.isLineLoop?gn.setMode(z.LINE_LOOP):gn.setMode(z.LINE_STRIP)}else Me.isPoints?gn.setMode(z.POINTS):Me.isSprite&&gn.setMode(z.TRIANGLES);if(Me.isBatchedMesh)if(Me._multiDrawInstances!==null)t0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),gn.renderMultiDrawInstances(Me._multiDrawStarts,Me._multiDrawCounts,Me._multiDrawCount,Me._multiDrawInstances);else if(K.get("WEBGL_multi_draw"))gn.renderMultiDraw(Me._multiDrawStarts,Me._multiDrawCounts,Me._multiDrawCount);else{const Lt=Me._multiDrawStarts,Yt=Me._multiDrawCounts,Qt=Me._multiDrawCount,yr=xt?J.get(xt).bytesPerElement:1,Cr=Ee.get(Re).currentProgram.getUniforms();for(let Nn=0;Nn<Qt;Nn++)Cr.setValue(z,"_gl_DrawID",Nn),gn.render(Lt[Nn]/yr,Yt[Nn])}else if(Me.isInstancedMesh)gn.renderInstances(qt,tn,Me.count);else if(ke.isInstancedBufferGeometry){const Lt=ke._maxInstanceCount!==void 0?ke._maxInstanceCount:1/0,Yt=Math.min(ke.instanceCount,Lt);gn.renderInstances(qt,tn,Yt)}else gn.render(qt,tn)};function cn(te,_e,ke){te.transparent===!0&&te.side===Vo&&te.forceSinglePass===!1?(te.side=Ua,te.needsUpdate=!0,Tr(te,_e,ke),te.side=Yu,te.needsUpdate=!0,Tr(te,_e,ke),te.side=Vo):Tr(te,_e,ke)}this.compile=function(te,_e,ke=null){ke===null&&(ke=te),w=Ke.get(ke),w.init(_e),T.push(w),ke.traverseVisible(function(Me){Me.isLight&&Me.layers.test(_e.layers)&&(w.pushLight(Me),Me.castShadow&&w.pushShadow(Me))}),te!==ke&&te.traverseVisible(function(Me){Me.isLight&&Me.layers.test(_e.layers)&&(w.pushLight(Me),Me.castShadow&&w.pushShadow(Me))}),w.setupLights();const Re=new Set;return te.traverse(function(Me){if(!(Me.isMesh||Me.isPoints||Me.isLine||Me.isSprite))return;const it=Me.material;if(it)if(Array.isArray(it))for(let ht=0;ht<it.length;ht++){const vt=it[ht];cn(vt,ke,Me),Re.add(vt)}else cn(it,ke,Me),Re.add(it)}),w=T.pop(),Re},this.compileAsync=function(te,_e,ke=null){const Re=this.compile(te,_e,ke);return new Promise(Me=>{function it(){if(Re.forEach(function(ht){Ee.get(ht).currentProgram.isReady()&&Re.delete(ht)}),Re.size===0){Me(te);return}setTimeout(it,10)}K.get("KHR_parallel_shader_compile")!==null?it():setTimeout(it,10)})};let Ot=null;function Rn(te){Ot&&Ot(te)}function qn(){Qr.stop()}function pi(){Qr.start()}const Qr=new i7;Qr.setAnimationLoop(Rn),typeof self<"u"&&Qr.setContext(self),this.setAnimationLoop=function(te){Ot=te,Oe.setAnimationLoop(te),te===null?Qr.stop():Qr.start()},Oe.addEventListener("sessionstart",qn),Oe.addEventListener("sessionend",pi),this.render=function(te,_e){if(_e!==void 0&&_e.isCamera!==!0){Dr("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;if(te.matrixWorldAutoUpdate===!0&&te.updateMatrixWorld(),_e.parent===null&&_e.matrixWorldAutoUpdate===!0&&_e.updateMatrixWorld(),Oe.enabled===!0&&Oe.isPresenting===!0&&(Oe.cameraAutoUpdate===!0&&Oe.updateCamera(_e),_e=Oe.getCamera()),te.isScene===!0&&te.onBeforeRender(R,te,_e,k),w=Ke.get(te,T.length),w.init(_e),T.push(w),he.multiplyMatrices(_e.projectionMatrix,_e.matrixWorldInverse),ie.setFromProjectionMatrix(he,Xo,_e.reversedDepth),Pe=this.localClippingEnabled,ve=st.init(this.clippingPlanes,Pe),M=Ie.get(te,C.length),M.init(),C.push(M),Oe.enabled===!0&&Oe.isPresenting===!0){const it=R.xr.getDepthSensingMesh();it!==null&&mi(it,_e,-1/0,R.sortObjects)}mi(te,_e,0,R.sortObjects),M.finish(),R.sortObjects===!0&&M.sort(H,q),lt=Oe.enabled===!1||Oe.isPresenting===!1||Oe.hasDepthSensing()===!1,lt&&le.addToRenderList(M,te),this.info.render.frame++,ve===!0&&st.beginShadows();const ke=w.state.shadowsArray;je.render(ke,te,_e),ve===!0&&st.endShadows(),this.info.autoReset===!0&&this.info.reset();const Re=M.opaque,Me=M.transmissive;if(w.setupLights(),_e.isArrayCamera){const it=_e.cameras;if(Me.length>0)for(let ht=0,vt=it.length;ht<vt;ht++){const xt=it[ht];qi(Re,Me,te,xt)}lt&&le.render(te);for(let ht=0,vt=it.length;ht<vt;ht++){const xt=it[ht];Pi(M,te,xt,xt.viewport)}}else Me.length>0&&qi(Re,Me,te,_e),lt&&le.render(te),Pi(M,te,_e);k!==null&&N===0&&(re.updateMultisampleRenderTarget(k),re.updateRenderTargetMipmap(k)),te.isScene===!0&&te.onAfterRender(R,te,_e),ue.resetDefaultState(),F=-1,I=null,T.pop(),T.length>0?(w=T[T.length-1],ve===!0&&st.setGlobalState(R.clippingPlanes,w.state.camera)):w=null,C.pop(),C.length>0?M=C[C.length-1]:M=null};function mi(te,_e,ke,Re){if(te.visible===!1)return;if(te.layers.test(_e.layers)){if(te.isGroup)ke=te.renderOrder;else if(te.isLOD)te.autoUpdate===!0&&te.update(_e);else if(te.isLight)w.pushLight(te),te.castShadow&&w.pushShadow(te);else if(te.isSprite){if(!te.frustumCulled||ie.intersectsSprite(te)){Re&&Le.setFromMatrixPosition(te.matrixWorld).applyMatrix4(he);const ht=ye.update(te),vt=te.material;vt.visible&&M.push(te,ht,vt,ke,Le.z,null)}}else if((te.isMesh||te.isLine||te.isPoints)&&(!te.frustumCulled||ie.intersectsObject(te))){const ht=ye.update(te),vt=te.material;if(Re&&(te.boundingSphere!==void 0?(te.boundingSphere===null&&te.computeBoundingSphere(),Le.copy(te.boundingSphere.center)):(ht.boundingSphere===null&&ht.computeBoundingSphere(),Le.copy(ht.boundingSphere.center)),Le.applyMatrix4(te.matrixWorld).applyMatrix4(he)),Array.isArray(vt)){const xt=ht.groups;for(let kt=0,wt=xt.length;kt<wt;kt++){const mt=xt[kt],qt=vt[mt.materialIndex];qt&&qt.visible&&M.push(te,ht,qt,ke,Le.z,mt)}}else vt.visible&&M.push(te,ht,vt,ke,Le.z,null)}}const it=te.children;for(let ht=0,vt=it.length;ht<vt;ht++)mi(it[ht],_e,ke,Re)}function Pi(te,_e,ke,Re){const{opaque:Me,transmissive:it,transparent:ht}=te;w.setupLightsView(ke),ve===!0&&st.setGlobalState(R.clippingPlanes,ke),Re&&oe.viewport(W.copy(Re)),Me.length>0&&Ir(Me,_e,ke),it.length>0&&Ir(it,_e,ke),ht.length>0&&Ir(ht,_e,ke),oe.buffers.depth.setTest(!0),oe.buffers.depth.setMask(!0),oe.buffers.color.setMask(!0),oe.setPolygonOffset(!1)}function qi(te,_e,ke,Re){if((ke.isScene===!0?ke.overrideMaterial:null)!==null)return;w.state.transmissionRenderTarget[Re.id]===void 0&&(w.state.transmissionRenderTarget[Re.id]=new Rf(1,1,{generateMipmaps:!0,type:K.has("EXT_color_buffer_half_float")||K.has("EXT_color_buffer_float")?Em:rl,minFilter:Jd,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:En.workingColorSpace}));const it=w.state.transmissionRenderTarget[Re.id],ht=Re.viewport||W;it.setSize(ht.z*R.transmissionResolutionScale,ht.w*R.transmissionResolutionScale);const vt=R.getRenderTarget(),xt=R.getActiveCubeFace(),kt=R.getActiveMipmapLevel();R.setRenderTarget(it),R.getClearColor(G),V=R.getClearAlpha(),V<1&&R.setClearColor(16777215,.5),R.clear(),lt&&le.render(ke);const wt=R.toneMapping;R.toneMapping=Fu;const mt=Re.viewport;if(Re.viewport!==void 0&&(Re.viewport=void 0),w.setupLightsView(Re),ve===!0&&st.setGlobalState(R.clippingPlanes,Re),Ir(te,ke,Re),re.updateMultisampleRenderTarget(it),re.updateRenderTargetMipmap(it),K.has("WEBGL_multisampled_render_to_texture")===!1){let qt=!1;for(let It=0,tn=_e.length;It<tn;It++){const dn=_e[It],{object:gn,geometry:Lt,material:Yt,group:Qt}=dn;if(Yt.side===Vo&&gn.layers.test(Re.layers)){const yr=Yt.side;Yt.side=Ua,Yt.needsUpdate=!0,pr(gn,ke,Re,Lt,Yt,Qt),Yt.side=yr,Yt.needsUpdate=!0,qt=!0}}qt===!0&&(re.updateMultisampleRenderTarget(it),re.updateRenderTargetMipmap(it))}R.setRenderTarget(vt,xt,kt),R.setClearColor(G,V),mt!==void 0&&(Re.viewport=mt),R.toneMapping=wt}function Ir(te,_e,ke){const Re=_e.isScene===!0?_e.overrideMaterial:null;for(let Me=0,it=te.length;Me<it;Me++){const ht=te[Me],{object:vt,geometry:xt,group:kt}=ht;let wt=ht.material;wt.allowOverride===!0&&Re!==null&&(wt=Re),vt.layers.test(ke.layers)&&pr(vt,_e,ke,xt,wt,kt)}}function pr(te,_e,ke,Re,Me,it){te.onBeforeRender(R,_e,ke,Re,Me,it),te.modelViewMatrix.multiplyMatrices(ke.matrixWorldInverse,te.matrixWorld),te.normalMatrix.getNormalMatrix(te.modelViewMatrix),Me.onBeforeRender(R,_e,ke,Re,te,it),Me.transparent===!0&&Me.side===Vo&&Me.forceSinglePass===!1?(Me.side=Ua,Me.needsUpdate=!0,R.renderBufferDirect(ke,_e,Re,Me,te,it),Me.side=Yu,Me.needsUpdate=!0,R.renderBufferDirect(ke,_e,Re,Me,te,it),Me.side=Vo):R.renderBufferDirect(ke,_e,Re,Me,te,it),te.onAfterRender(R,_e,ke,Re,Me,it)}function Tr(te,_e,ke){_e.isScene!==!0&&(_e=de);const Re=Ee.get(te),Me=w.state.lights,it=w.state.shadowsArray,ht=Me.state.version,vt=me.getParameters(te,Me.state,it,_e,ke),xt=me.getProgramCacheKey(vt);let kt=Re.programs;Re.environment=te.isMeshStandardMaterial?_e.environment:null,Re.fog=_e.fog,Re.envMap=(te.isMeshStandardMaterial?L:U).get(te.envMap||Re.environment),Re.envMapRotation=Re.environment!==null&&te.envMap===null?_e.environmentRotation:te.envMapRotation,kt===void 0&&(te.addEventListener("dispose",ft),kt=new Map,Re.programs=kt);let wt=kt.get(xt);if(wt!==void 0){if(Re.currentProgram===wt&&Re.lightsStateVersion===ht)return Lc(te,vt),wt}else vt.uniforms=me.getUniforms(te),te.onBeforeCompile(vt,R),wt=me.acquireProgram(vt,xt),kt.set(xt,wt),Re.uniforms=vt.uniforms;const mt=Re.uniforms;return(!te.isShaderMaterial&&!te.isRawShaderMaterial||te.clipping===!0)&&(mt.clippingPlanes=st.uniform),Lc(te,vt),Re.needsLights=Je(te),Re.lightsStateVersion=ht,Re.needsLights&&(mt.ambientLightColor.value=Me.state.ambient,mt.lightProbe.value=Me.state.probe,mt.directionalLights.value=Me.state.directional,mt.directionalLightShadows.value=Me.state.directionalShadow,mt.spotLights.value=Me.state.spot,mt.spotLightShadows.value=Me.state.spotShadow,mt.rectAreaLights.value=Me.state.rectArea,mt.ltc_1.value=Me.state.rectAreaLTC1,mt.ltc_2.value=Me.state.rectAreaLTC2,mt.pointLights.value=Me.state.point,mt.pointLightShadows.value=Me.state.pointShadow,mt.hemisphereLights.value=Me.state.hemi,mt.directionalShadowMap.value=Me.state.directionalShadowMap,mt.directionalShadowMatrix.value=Me.state.directionalShadowMatrix,mt.spotShadowMap.value=Me.state.spotShadowMap,mt.spotLightMatrix.value=Me.state.spotLightMatrix,mt.spotLightMap.value=Me.state.spotLightMap,mt.pointShadowMap.value=Me.state.pointShadowMap,mt.pointShadowMatrix.value=Me.state.pointShadowMatrix),Re.currentProgram=wt,Re.uniformsList=null,wt}function Js(te){if(te.uniformsList===null){const _e=te.currentProgram.getUniforms();te.uniformsList=E_.seqWithValue(_e.seq,te.uniforms)}return te.uniformsList}function Lc(te,_e){const ke=Ee.get(te);ke.outputColorSpace=_e.outputColorSpace,ke.batching=_e.batching,ke.batchingColor=_e.batchingColor,ke.instancing=_e.instancing,ke.instancingColor=_e.instancingColor,ke.instancingMorph=_e.instancingMorph,ke.skinning=_e.skinning,ke.morphTargets=_e.morphTargets,ke.morphNormals=_e.morphNormals,ke.morphColors=_e.morphColors,ke.morphTargetsCount=_e.morphTargetsCount,ke.numClippingPlanes=_e.numClippingPlanes,ke.numIntersection=_e.numClipIntersection,ke.vertexAlphas=_e.vertexAlphas,ke.vertexTangents=_e.vertexTangents,ke.toneMapping=_e.toneMapping}function fe(te,_e,ke,Re,Me){_e.isScene!==!0&&(_e=de),re.resetTextureUnits();const it=_e.fog,ht=Re.isMeshStandardMaterial?_e.environment:null,vt=k===null?R.outputColorSpace:k.isXRRenderTarget===!0?k.texture.colorSpace:Zp,xt=(Re.isMeshStandardMaterial?L:U).get(Re.envMap||ht),kt=Re.vertexColors===!0&&!!ke.attributes.color&&ke.attributes.color.itemSize===4,wt=!!ke.attributes.tangent&&(!!Re.normalMap||Re.anisotropy>0),mt=!!ke.morphAttributes.position,qt=!!ke.morphAttributes.normal,It=!!ke.morphAttributes.color;let tn=Fu;Re.toneMapped&&(k===null||k.isXRRenderTarget===!0)&&(tn=R.toneMapping);const dn=ke.morphAttributes.position||ke.morphAttributes.normal||ke.morphAttributes.color,gn=dn!==void 0?dn.length:0,Lt=Ee.get(Re),Yt=w.state.lights;if(ve===!0&&(Pe===!0||te!==I)){const xi=te===I&&Re.id===F;st.setState(Re,te,xi)}let Qt=!1;Re.version===Lt.__version?(Lt.needsLights&&Lt.lightsStateVersion!==Yt.state.version||Lt.outputColorSpace!==vt||Me.isBatchedMesh&&Lt.batching===!1||!Me.isBatchedMesh&&Lt.batching===!0||Me.isBatchedMesh&&Lt.batchingColor===!0&&Me.colorTexture===null||Me.isBatchedMesh&&Lt.batchingColor===!1&&Me.colorTexture!==null||Me.isInstancedMesh&&Lt.instancing===!1||!Me.isInstancedMesh&&Lt.instancing===!0||Me.isSkinnedMesh&&Lt.skinning===!1||!Me.isSkinnedMesh&&Lt.skinning===!0||Me.isInstancedMesh&&Lt.instancingColor===!0&&Me.instanceColor===null||Me.isInstancedMesh&&Lt.instancingColor===!1&&Me.instanceColor!==null||Me.isInstancedMesh&&Lt.instancingMorph===!0&&Me.morphTexture===null||Me.isInstancedMesh&&Lt.instancingMorph===!1&&Me.morphTexture!==null||Lt.envMap!==xt||Re.fog===!0&&Lt.fog!==it||Lt.numClippingPlanes!==void 0&&(Lt.numClippingPlanes!==st.numPlanes||Lt.numIntersection!==st.numIntersection)||Lt.vertexAlphas!==kt||Lt.vertexTangents!==wt||Lt.morphTargets!==mt||Lt.morphNormals!==qt||Lt.morphColors!==It||Lt.toneMapping!==tn||Lt.morphTargetsCount!==gn)&&(Qt=!0):(Qt=!0,Lt.__version=Re.version);let yr=Lt.currentProgram;Qt===!0&&(yr=Tr(Re,_e,Me));let Cr=!1,Nn=!1,eo=!1;const Pn=yr.getUniforms(),gi=Lt.uniforms;if(oe.useProgram(yr.program)&&(Cr=!0,Nn=!0,eo=!0),Re.id!==F&&(F=Re.id,Nn=!0),Cr||I!==te){oe.buffers.depth.getReversed()&&te.reversedDepth!==!0&&(te._reversedDepth=!0,te.updateProjectionMatrix()),Pn.setValue(z,"projectionMatrix",te.projectionMatrix),Pn.setValue(z,"viewMatrix",te.matrixWorldInverse);const ki=Pn.map.cameraPosition;ki!==void 0&&ki.setValue(z,we.setFromMatrixPosition(te.matrixWorld)),Q.logarithmicDepthBuffer&&Pn.setValue(z,"logDepthBufFC",2/(Math.log(te.far+1)/Math.LN2)),(Re.isMeshPhongMaterial||Re.isMeshToonMaterial||Re.isMeshLambertMaterial||Re.isMeshBasicMaterial||Re.isMeshStandardMaterial||Re.isShaderMaterial)&&Pn.setValue(z,"isOrthographic",te.isOrthographicCamera===!0),I!==te&&(I=te,Nn=!0,eo=!0)}if(Me.isSkinnedMesh){Pn.setOptional(z,Me,"bindMatrix"),Pn.setOptional(z,Me,"bindMatrixInverse");const xi=Me.skeleton;xi&&(xi.boneTexture===null&&xi.computeBoneTexture(),Pn.setValue(z,"boneTexture",xi.boneTexture,re))}Me.isBatchedMesh&&(Pn.setOptional(z,Me,"batchingTexture"),Pn.setValue(z,"batchingTexture",Me._matricesTexture,re),Pn.setOptional(z,Me,"batchingIdTexture"),Pn.setValue(z,"batchingIdTexture",Me._indirectTexture,re),Pn.setOptional(z,Me,"batchingColorTexture"),Me._colorsTexture!==null&&Pn.setValue(z,"batchingColorTexture",Me._colorsTexture,re));const Jr=ke.morphAttributes;if((Jr.position!==void 0||Jr.normal!==void 0||Jr.color!==void 0)&&Ze.update(Me,ke,yr),(Nn||Lt.receiveShadow!==Me.receiveShadow)&&(Lt.receiveShadow=Me.receiveShadow,Pn.setValue(z,"receiveShadow",Me.receiveShadow)),Re.isMeshGouraudMaterial&&Re.envMap!==null&&(gi.envMap.value=xt,gi.flipEnvMap.value=xt.isCubeTexture&&xt.isRenderTargetTexture===!1?-1:1),Re.isMeshStandardMaterial&&Re.envMap===null&&_e.environment!==null&&(gi.envMapIntensity.value=_e.environmentIntensity),gi.dfgLUT!==void 0&&(gi.dfgLUT.value=Jme()),Nn&&(Pn.setValue(z,"toneMappingExposure",R.toneMappingExposure),Lt.needsLights&&Ue(gi,eo),it&&Re.fog===!0&&et.refreshFogUniforms(gi,it),et.refreshMaterialUniforms(gi,Re,ee,Y,w.state.transmissionRenderTarget[te.id]),E_.upload(z,Js(Lt),gi,re)),Re.isShaderMaterial&&Re.uniformsNeedUpdate===!0&&(E_.upload(z,Js(Lt),gi,re),Re.uniformsNeedUpdate=!1),Re.isSpriteMaterial&&Pn.setValue(z,"center",Me.center),Pn.setValue(z,"modelViewMatrix",Me.modelViewMatrix),Pn.setValue(z,"normalMatrix",Me.normalMatrix),Pn.setValue(z,"modelMatrix",Me.matrixWorld),Re.isShaderMaterial||Re.isRawShaderMaterial){const xi=Re.uniformsGroups;for(let ki=0,Po=xi.length;ki<Po;ki++){const hl=xi[ki];Qe.update(hl,yr),Qe.bind(hl,yr)}}return yr}function Ue(te,_e){te.ambientLightColor.needsUpdate=_e,te.lightProbe.needsUpdate=_e,te.directionalLights.needsUpdate=_e,te.directionalLightShadows.needsUpdate=_e,te.pointLights.needsUpdate=_e,te.pointLightShadows.needsUpdate=_e,te.spotLights.needsUpdate=_e,te.spotLightShadows.needsUpdate=_e,te.rectAreaLights.needsUpdate=_e,te.hemisphereLights.needsUpdate=_e}function Je(te){return te.isMeshLambertMaterial||te.isMeshToonMaterial||te.isMeshPhongMaterial||te.isMeshStandardMaterial||te.isShadowMaterial||te.isShaderMaterial&&te.lights===!0}this.getActiveCubeFace=function(){return j},this.getActiveMipmapLevel=function(){return N},this.getRenderTarget=function(){return k},this.setRenderTargetTextures=function(te,_e,ke){const Re=Ee.get(te);Re.__autoAllocateDepthBuffer=te.resolveDepthBuffer===!1,Re.__autoAllocateDepthBuffer===!1&&(Re.__useRenderToTexture=!1),Ee.get(te.texture).__webglTexture=_e,Ee.get(te.depthTexture).__webglTexture=Re.__autoAllocateDepthBuffer?void 0:ke,Re.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(te,_e){const ke=Ee.get(te);ke.__webglFramebuffer=_e,ke.__useDefaultFramebuffer=_e===void 0};const tt=z.createFramebuffer();this.setRenderTarget=function(te,_e=0,ke=0){k=te,j=_e,N=ke;let Re=!0,Me=null,it=!1,ht=!1;if(te){const xt=Ee.get(te);if(xt.__useDefaultFramebuffer!==void 0)oe.bindFramebuffer(z.FRAMEBUFFER,null),Re=!1;else if(xt.__webglFramebuffer===void 0)re.setupRenderTarget(te);else if(xt.__hasExternalTextures)re.rebindTextures(te,Ee.get(te.texture).__webglTexture,Ee.get(te.depthTexture).__webglTexture);else if(te.depthBuffer){const mt=te.depthTexture;if(xt.__boundDepthTexture!==mt){if(mt!==null&&Ee.has(mt)&&(te.width!==mt.image.width||te.height!==mt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");re.setupDepthRenderbuffer(te)}}const kt=te.texture;(kt.isData3DTexture||kt.isDataArrayTexture||kt.isCompressedArrayTexture)&&(ht=!0);const wt=Ee.get(te).__webglFramebuffer;te.isWebGLCubeRenderTarget?(Array.isArray(wt[_e])?Me=wt[_e][ke]:Me=wt[_e],it=!0):te.samples>0&&re.useMultisampledRTT(te)===!1?Me=Ee.get(te).__webglMultisampledFramebuffer:Array.isArray(wt)?Me=wt[ke]:Me=wt,W.copy(te.viewport),D.copy(te.scissor),B=te.scissorTest}else W.copy(ae).multiplyScalar(ee).floor(),D.copy(ce).multiplyScalar(ee).floor(),B=xe;if(ke!==0&&(Me=tt),oe.bindFramebuffer(z.FRAMEBUFFER,Me)&&Re&&oe.drawBuffers(te,Me),oe.viewport(W),oe.scissor(D),oe.setScissorTest(B),it){const xt=Ee.get(te.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+_e,xt.__webglTexture,ke)}else if(ht){const xt=_e;for(let kt=0;kt<te.textures.length;kt++){const wt=Ee.get(te.textures[kt]);z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0+kt,wt.__webglTexture,ke,xt)}}else if(te!==null&&ke!==0){const xt=Ee.get(te.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,xt.__webglTexture,ke)}F=-1},this.readRenderTargetPixels=function(te,_e,ke,Re,Me,it,ht,vt=0){if(!(te&&te.isWebGLRenderTarget)){Dr("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let xt=Ee.get(te).__webglFramebuffer;if(te.isWebGLCubeRenderTarget&&ht!==void 0&&(xt=xt[ht]),xt){oe.bindFramebuffer(z.FRAMEBUFFER,xt);try{const kt=te.textures[vt],wt=kt.format,mt=kt.type;if(!Q.textureFormatReadable(wt)){Dr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Q.textureTypeReadable(mt)){Dr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}_e>=0&&_e<=te.width-Re&&ke>=0&&ke<=te.height-Me&&(te.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+vt),z.readPixels(_e,ke,Re,Me,ct.convert(wt),ct.convert(mt),it))}finally{const kt=k!==null?Ee.get(k).__webglFramebuffer:null;oe.bindFramebuffer(z.FRAMEBUFFER,kt)}}},this.readRenderTargetPixelsAsync=async function(te,_e,ke,Re,Me,it,ht,vt=0){if(!(te&&te.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let xt=Ee.get(te).__webglFramebuffer;if(te.isWebGLCubeRenderTarget&&ht!==void 0&&(xt=xt[ht]),xt)if(_e>=0&&_e<=te.width-Re&&ke>=0&&ke<=te.height-Me){oe.bindFramebuffer(z.FRAMEBUFFER,xt);const kt=te.textures[vt],wt=kt.format,mt=kt.type;if(!Q.textureFormatReadable(wt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Q.textureTypeReadable(mt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const qt=z.createBuffer();z.bindBuffer(z.PIXEL_PACK_BUFFER,qt),z.bufferData(z.PIXEL_PACK_BUFFER,it.byteLength,z.STREAM_READ),te.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+vt),z.readPixels(_e,ke,Re,Me,ct.convert(wt),ct.convert(mt),0);const It=k!==null?Ee.get(k).__webglFramebuffer:null;oe.bindFramebuffer(z.FRAMEBUFFER,It);const tn=z.fenceSync(z.SYNC_GPU_COMMANDS_COMPLETE,0);return z.flush(),await Eue(z,tn,4),z.bindBuffer(z.PIXEL_PACK_BUFFER,qt),z.getBufferSubData(z.PIXEL_PACK_BUFFER,0,it),z.deleteBuffer(qt),z.deleteSync(tn),it}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(te,_e=null,ke=0){const Re=Math.pow(2,-ke),Me=Math.floor(te.image.width*Re),it=Math.floor(te.image.height*Re),ht=_e!==null?_e.x:0,vt=_e!==null?_e.y:0;re.setTexture2D(te,0),z.copyTexSubImage2D(z.TEXTURE_2D,ke,0,0,ht,vt,Me,it),oe.unbindTexture()};const Ye=z.createFramebuffer(),_t=z.createFramebuffer();this.copyTextureToTexture=function(te,_e,ke=null,Re=null,Me=0,it=null){it===null&&(Me!==0?(t0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),it=Me,Me=0):it=0);let ht,vt,xt,kt,wt,mt,qt,It,tn;const dn=te.isCompressedTexture?te.mipmaps[it]:te.image;if(ke!==null)ht=ke.max.x-ke.min.x,vt=ke.max.y-ke.min.y,xt=ke.isBox3?ke.max.z-ke.min.z:1,kt=ke.min.x,wt=ke.min.y,mt=ke.isBox3?ke.min.z:0;else{const Jr=Math.pow(2,-Me);ht=Math.floor(dn.width*Jr),vt=Math.floor(dn.height*Jr),te.isDataArrayTexture?xt=dn.depth:te.isData3DTexture?xt=Math.floor(dn.depth*Jr):xt=1,kt=0,wt=0,mt=0}Re!==null?(qt=Re.x,It=Re.y,tn=Re.z):(qt=0,It=0,tn=0);const gn=ct.convert(_e.format),Lt=ct.convert(_e.type);let Yt;_e.isData3DTexture?(re.setTexture3D(_e,0),Yt=z.TEXTURE_3D):_e.isDataArrayTexture||_e.isCompressedArrayTexture?(re.setTexture2DArray(_e,0),Yt=z.TEXTURE_2D_ARRAY):(re.setTexture2D(_e,0),Yt=z.TEXTURE_2D),z.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,_e.flipY),z.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_e.premultiplyAlpha),z.pixelStorei(z.UNPACK_ALIGNMENT,_e.unpackAlignment);const Qt=z.getParameter(z.UNPACK_ROW_LENGTH),yr=z.getParameter(z.UNPACK_IMAGE_HEIGHT),Cr=z.getParameter(z.UNPACK_SKIP_PIXELS),Nn=z.getParameter(z.UNPACK_SKIP_ROWS),eo=z.getParameter(z.UNPACK_SKIP_IMAGES);z.pixelStorei(z.UNPACK_ROW_LENGTH,dn.width),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,dn.height),z.pixelStorei(z.UNPACK_SKIP_PIXELS,kt),z.pixelStorei(z.UNPACK_SKIP_ROWS,wt),z.pixelStorei(z.UNPACK_SKIP_IMAGES,mt);const Pn=te.isDataArrayTexture||te.isData3DTexture,gi=_e.isDataArrayTexture||_e.isData3DTexture;if(te.isDepthTexture){const Jr=Ee.get(te),xi=Ee.get(_e),ki=Ee.get(Jr.__renderTarget),Po=Ee.get(xi.__renderTarget);oe.bindFramebuffer(z.READ_FRAMEBUFFER,ki.__webglFramebuffer),oe.bindFramebuffer(z.DRAW_FRAMEBUFFER,Po.__webglFramebuffer);for(let hl=0;hl<xt;hl++)Pn&&(z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Ee.get(te).__webglTexture,Me,mt+hl),z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Ee.get(_e).__webglTexture,it,tn+hl)),z.blitFramebuffer(kt,wt,ht,vt,qt,It,ht,vt,z.DEPTH_BUFFER_BIT,z.NEAREST);oe.bindFramebuffer(z.READ_FRAMEBUFFER,null),oe.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else if(Me!==0||te.isRenderTargetTexture||Ee.has(te)){const Jr=Ee.get(te),xi=Ee.get(_e);oe.bindFramebuffer(z.READ_FRAMEBUFFER,Ye),oe.bindFramebuffer(z.DRAW_FRAMEBUFFER,_t);for(let ki=0;ki<xt;ki++)Pn?z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Jr.__webglTexture,Me,mt+ki):z.framebufferTexture2D(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,Jr.__webglTexture,Me),gi?z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,xi.__webglTexture,it,tn+ki):z.framebufferTexture2D(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,xi.__webglTexture,it),Me!==0?z.blitFramebuffer(kt,wt,ht,vt,qt,It,ht,vt,z.COLOR_BUFFER_BIT,z.NEAREST):gi?z.copyTexSubImage3D(Yt,it,qt,It,tn+ki,kt,wt,ht,vt):z.copyTexSubImage2D(Yt,it,qt,It,kt,wt,ht,vt);oe.bindFramebuffer(z.READ_FRAMEBUFFER,null),oe.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else gi?te.isDataTexture||te.isData3DTexture?z.texSubImage3D(Yt,it,qt,It,tn,ht,vt,xt,gn,Lt,dn.data):_e.isCompressedArrayTexture?z.compressedTexSubImage3D(Yt,it,qt,It,tn,ht,vt,xt,gn,dn.data):z.texSubImage3D(Yt,it,qt,It,tn,ht,vt,xt,gn,Lt,dn):te.isDataTexture?z.texSubImage2D(z.TEXTURE_2D,it,qt,It,ht,vt,gn,Lt,dn.data):te.isCompressedTexture?z.compressedTexSubImage2D(z.TEXTURE_2D,it,qt,It,dn.width,dn.height,gn,dn.data):z.texSubImage2D(z.TEXTURE_2D,it,qt,It,ht,vt,gn,Lt,dn);z.pixelStorei(z.UNPACK_ROW_LENGTH,Qt),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,yr),z.pixelStorei(z.UNPACK_SKIP_PIXELS,Cr),z.pixelStorei(z.UNPACK_SKIP_ROWS,Nn),z.pixelStorei(z.UNPACK_SKIP_IMAGES,eo),it===0&&_e.generateMipmaps&&z.generateMipmap(Yt),oe.unbindTexture()},this.initRenderTarget=function(te){Ee.get(te).__webglFramebuffer===void 0&&re.setupRenderTarget(te)},this.initTexture=function(te){te.isCubeTexture?re.setTextureCube(te,0):te.isData3DTexture?re.setTexture3D(te,0):te.isDataArrayTexture||te.isCompressedArrayTexture?re.setTexture2DArray(te,0):re.setTexture2D(te,0),oe.unbindTexture()},this.resetState=function(){j=0,N=0,k=null,oe.reset(),ue.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Xo}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=En._getDrawingBufferColorSpace(e),n.unpackColorSpace=En._getUnpackColorSpace()}};const hz={type:"change"},hk={type:"start"},c7={type:"end"},ay=new lk,pz=new yu,tge=Math.cos(70*Tue.DEG2RAD),ti=new We,ka=2*Math.PI,Vn={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},bT=1e-6;class nge extends hde{constructor(e,n=null){super(e,n),this.state=Vn.NONE,this.target=new We,this.cursor=new We,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.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:Pp.ROTATE,MIDDLE:Pp.DOLLY,RIGHT:Pp.PAN},this.touches={ONE:Mp.ROTATE,TWO:Mp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new We,this._lastQuaternion=new Nf,this._lastTargetPosition=new We,this._quat=new Nf().setFromUnitVectors(e.up,new We(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new HF,this._sphericalDelta=new HF,this._scale=1,this._panOffset=new We,this._rotateStart=new sn,this._rotateEnd=new sn,this._rotateDelta=new sn,this._panStart=new sn,this._panEnd=new sn,this._panDelta=new sn,this._dollyStart=new sn,this._dollyEnd=new sn,this._dollyDelta=new sn,this._dollyDirection=new We,this._mouse=new sn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=ige.bind(this),this._onPointerDown=rge.bind(this),this._onPointerUp=age.bind(this),this._onContextMenu=fge.bind(this),this._onMouseWheel=lge.bind(this),this._onKeyDown=cge.bind(this),this._onTouchStart=uge.bind(this),this._onTouchMove=dge.bind(this),this._onMouseDown=sge.bind(this),this._onMouseMove=oge.bind(this),this._interceptControlDown=hge.bind(this),this._interceptControlUp=pge.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(hz),this.update(),this.state=Vn.NONE}update(e=null){const n=this.object.position;ti.copy(n).sub(this.target),ti.applyQuaternion(this._quat),this._spherical.setFromVector3(ti),this.autoRotate&&this.state===Vn.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(ti.setFromSpherical(this._spherical),ti.applyQuaternion(this._quatInverse),n.copy(this.target).add(ti),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){const o=ti.length();s=this._clampDistance(o*this._scale);const l=o-s;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),a=!!l}else if(this.object.isOrthographicCamera){const o=new We(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=l!==this.object.zoom;const c=new We(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=ti.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):(ay.origin.copy(this.object.position),ay.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(ay.direction))<tge?this.object.lookAt(this.target):(pz.setFromNormalAndCoplanarPoint(this.object.up,this.target),ay.intersectPlane(pz,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)>bT||8*(1-this._lastQuaternion.dot(this.object.quaternion))>bT||this._lastTargetPosition.distanceToSquared(this.target)>bT?(this.dispatchEvent(hz),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){ti.setFromMatrixColumn(n,0),ti.multiplyScalar(-e),this._panOffset.add(ti)}_panUp(e,n){this.screenSpacePanning===!0?ti.setFromMatrixColumn(n,1):(ti.setFromMatrixColumn(n,0),ti.crossVectors(this.object.up,ti)),ti.multiplyScalar(e),this._panOffset.add(ti)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;ti.copy(i).sub(this.target);let a=ti.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*a/r.clientHeight,this.object.matrix),this._panUp(2*n*a/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),i=e-r.left,a=n-r.top,s=r.width,o=r.height;this._mouse.x=i/s*2-1,this._mouse.y=-(a/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(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,o=(e.pageY+n.y)*.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new sn,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 rge(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 ige(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function age(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(c7),this.state=Vn.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 sge(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 Pp.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Vn.DOLLY;break;case Pp.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Vn.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Vn.ROTATE}break;case Pp.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Vn.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Vn.PAN}break;default:this.state=Vn.NONE}this.state!==Vn.NONE&&this.dispatchEvent(hk)}function oge(t){switch(this.state){case Vn.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Vn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Vn.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function lge(t){this.enabled===!1||this.enableZoom===!1||this.state!==Vn.NONE||(t.preventDefault(),this.dispatchEvent(hk),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(c7))}function cge(t){this.enabled!==!1&&this._handleKeyDown(t)}function uge(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case Mp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Vn.TOUCH_ROTATE;break;case Mp.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Vn.TOUCH_PAN;break;default:this.state=Vn.NONE}break;case 2:switch(this.touches.TWO){case Mp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Vn.TOUCH_DOLLY_PAN;break;case Mp.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Vn.TOUCH_DOLLY_ROTATE;break;default:this.state=Vn.NONE}break;default:this.state=Vn.NONE}this.state!==Vn.NONE&&this.dispatchEvent(hk)}function dge(t){switch(this._trackPointer(t),this.state){case Vn.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Vn.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Vn.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Vn.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Vn.NONE}}function fge(t){this.enabled!==!1&&t.preventDefault()}function hge(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function pge(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function mge(t,e=!1){const n=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),a={},s={},o=t[0].morphTargetsRelative,l=new fl;let c=0;for(let u=0;u<t.length;++u){const h=t[u];let g=0;if(n!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const m in h.attributes){if(!r.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;a[m]===void 0&&(a[m]=[]),a[m].push(h.attributes[m]),g++}if(g!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(o!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const m in h.morphAttributes){if(!i.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;s[m]===void 0&&(s[m]=[]),s[m].push(h.morphAttributes[m])}if(e){let m;if(n)m=h.index.count;else if(h.attributes.position!==void 0)m=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,m,u),c+=m}}if(n){let u=0;const h=[];for(let g=0;g<t.length;++g){const m=t[g].index;for(let b=0;b<m.count;++b)h.push(m.getX(b)+u);u+=t[g].attributes.position.count}l.setIndex(h)}for(const u in a){const h=mz(a[u]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,h)}for(const u in s){const h=s[u][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let g=0;g<h;++g){const m=[];for(let y=0;y<s[u].length;++y)m.push(s[u][y][g]);const b=mz(m);if(!b)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(b)}}return l}function mz(t){let e,n,r,i=-1,a=0;for(let c=0;c<t.length;++c){const u=t[c];if(e===void 0&&(e=u.array.constructor),e!==u.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=u.itemSize),n!==u.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=u.normalized),r!==u.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=u.gpuType),i!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=u.count*n}const s=new e(a),o=new Vs(s,n,r);let l=0;for(let c=0;c<t.length;++c){const u=t[c];if(u.isInterleavedBufferAttribute){const h=l/n;for(let g=0,m=u.count;g<m;g++)for(let b=0;b<n;b++){const y=u.getComponent(g,b);o.setComponent(g+h,b,y)}}else s.set(u.array,l);l+=u.count*n}return i!==void 0&&(o.gpuType=i),o}function sy(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 yT={exports:{}};var gz;function gge(){return gz||(gz=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,a){function s(c,u){if(!i[c]){if(!r[c]){var h=typeof sy=="function"&&sy;if(!u&&h)return h(c,!0);if(o)return o(c,!0);var g=new Error("Cannot find module '"+c+"'");throw g.code="MODULE_NOT_FOUND",g}var m=i[c]={exports:{}};r[c][0].call(m.exports,function(b){var y=r[c][1][b];return s(y||b)},m,m.exports,n,r,i,a)}return i[c].exports}for(var o=typeof sy=="function"&&sy,l=0;l<a.length;l++)s(a[l]);return s})({1:[function(n,r,i){var a=n("./utils"),s=n("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(l){for(var c,u,h,g,m,b,y,v=[],x=0,M=l.length,w=M,C=a.getTypeOf(l)!=="string";x<l.length;)w=M-x,h=C?(c=l[x++],u=x<M?l[x++]:0,x<M?l[x++]:0):(c=l.charCodeAt(x++),u=x<M?l.charCodeAt(x++):0,x<M?l.charCodeAt(x++):0),g=c>>2,m=(3&c)<<4|u>>4,b=1<w?(15&u)<<2|h>>6:64,y=2<w?63&h:64,v.push(o.charAt(g)+o.charAt(m)+o.charAt(b)+o.charAt(y));return v.join("")},i.decode=function(l){var c,u,h,g,m,b,y=0,v=0,x="data:";if(l.substr(0,x.length)===x)throw new Error("Invalid base64 input, it looks like a data url.");var M,w=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===o.charAt(64)&&w--,l.charAt(l.length-2)===o.charAt(64)&&w--,w%1!=0)throw new Error("Invalid base64 input, bad content length.");for(M=s.uint8array?new Uint8Array(0|w):new Array(0|w);y<l.length;)c=o.indexOf(l.charAt(y++))<<2|(g=o.indexOf(l.charAt(y++)))>>4,u=(15&g)<<4|(m=o.indexOf(l.charAt(y++)))>>2,h=(3&m)<<6|(b=o.indexOf(l.charAt(y++))),M[v++]=c,m!==64&&(M[v++]=u),b!==64&&(M[v++]=h);return M}},{"./support":30,"./utils":32}],2:[function(n,r,i){var a=n("./external"),s=n("./stream/DataWorker"),o=n("./stream/Crc32Probe"),l=n("./stream/DataLengthProbe");function c(u,h,g,m,b){this.compressedSize=u,this.uncompressedSize=h,this.crc32=g,this.compression=m,this.compressedContent=b}c.prototype={getContentWorker:function(){var u=new s(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),h=this;return u.on("end",function(){if(this.streamInfo.data_length!==h.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},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)}},c.createWorkerFrom=function(u,h,g){return u.pipe(new o).pipe(new l("uncompressedSize")).pipe(h.compressWorker(g)).pipe(new l("compressedSize")).withStreamInfo("compression",h)},r.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var a=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var a=n("./utils"),s=(function(){for(var o,l=[],c=0;c<256;c++){o=c;for(var u=0;u<8;u++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l})();r.exports=function(o,l){return o!==void 0&&o.length?a.getTypeOf(o)!=="string"?(function(c,u,h,g){var m=s,b=g+h;c^=-1;for(var y=g;y<b;y++)c=c>>>8^m[255&(c^u[y])];return-1^c})(0|l,o,o.length,0):(function(c,u,h,g){var m=s,b=g+h;c^=-1;for(var y=g;y<b;y++)c=c>>>8^m[255&(c^u.charCodeAt(y))];return-1^c})(0|l,o,o.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var a=null;a=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:a}},{lie:37}],7:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=n("pako"),o=n("./utils"),l=n("./stream/GenericWorker"),c=a?"uint8array":"array";function u(h,g){l.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=g,this.meta={}}i.magic="\b\0",o.inherits(u,l),u.prototype.processChunk=function(h){this.meta=h.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(c,h.data),!1)},u.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var h=this;this._pako.onData=function(g){h.push({data:g,meta:h.meta})}},i.compressWorker=function(h){return new u("Deflate",h)},i.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function a(m,b){var y,v="";for(y=0;y<b;y++)v+=String.fromCharCode(255&m),m>>>=8;return v}function s(m,b,y,v,x,M){var w,C,T=m.file,R=m.compression,A=M!==c.utf8encode,j=o.transformTo("string",M(T.name)),N=o.transformTo("string",c.utf8encode(T.name)),k=T.comment,F=o.transformTo("string",M(k)),I=o.transformTo("string",c.utf8encode(k)),W=N.length!==T.name.length,D=I.length!==k.length,B="",G="",V="",Z=T.dir,Y=T.date,ee={crc32:0,compressedSize:0,uncompressedSize:0};b&&!y||(ee.crc32=m.crc32,ee.compressedSize=m.compressedSize,ee.uncompressedSize=m.uncompressedSize);var H=0;b&&(H|=8),A||!W&&!D||(H|=2048);var q=0,ae=0;Z&&(q|=16),x==="UNIX"?(ae=798,q|=(function(xe,ie){var ve=xe;return xe||(ve=ie?16893:33204),(65535&ve)<<16})(T.unixPermissions,Z)):(ae=20,q|=(function(xe){return 63&(xe||0)})(T.dosPermissions)),w=Y.getUTCHours(),w<<=6,w|=Y.getUTCMinutes(),w<<=5,w|=Y.getUTCSeconds()/2,C=Y.getUTCFullYear()-1980,C<<=4,C|=Y.getUTCMonth()+1,C<<=5,C|=Y.getUTCDate(),W&&(G=a(1,1)+a(u(j),4)+N,B+="up"+a(G.length,2)+G),D&&(V=a(1,1)+a(u(F),4)+I,B+="uc"+a(V.length,2)+V);var ce="";return ce+=`
  3839. \0`,ce+=a(H,2),ce+=R.magic,ce+=a(w,2),ce+=a(C,2),ce+=a(ee.crc32,4),ce+=a(ee.compressedSize,4),ce+=a(ee.uncompressedSize,4),ce+=a(j.length,2),ce+=a(B.length,2),{fileRecord:h.LOCAL_FILE_HEADER+ce+j+B,dirRecord:h.CENTRAL_FILE_HEADER+a(ae,2)+ce+a(F.length,2)+"\0\0\0\0"+a(q,4)+a(v,4)+j+B+F}}var o=n("../utils"),l=n("../stream/GenericWorker"),c=n("../utf8"),u=n("../crc32"),h=n("../signature");function g(m,b,y,v){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=y,this.encodeFileName=v,this.streamFiles=m,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(g,l),g.prototype.push=function(m){var b=m.meta.percent||0,y=this.entriesCount,v=this._sources.length;this.accumulate?this.contentBuffer.push(m):(this.bytesWritten+=m.data.length,l.prototype.push.call(this,{data:m.data,meta:{currentFile:this.currentFile,percent:y?(b+100*(y-v-1))/y:100}}))},g.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var b=this.streamFiles&&!m.file.dir;if(b){var y=s(m,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:y.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(m){this.accumulate=!1;var b=this.streamFiles&&!m.file.dir,y=s(m,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(y.dirRecord),b)this.push({data:(function(v){return h.DATA_DESCRIPTOR+a(v.crc32,4)+a(v.compressedSize,4)+a(v.uncompressedSize,4)})(m),meta:{percent:100}});else for(this.push({data:y.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var m=this.bytesWritten,b=0;b<this.dirRecords.length;b++)this.push({data:this.dirRecords[b],meta:{percent:100}});var y=this.bytesWritten-m,v=(function(x,M,w,C,T){var R=o.transformTo("string",T(C));return h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(x,2)+a(x,2)+a(M,4)+a(w,4)+a(R.length,2)+R})(this.dirRecords.length,y,m,this.zipComment,this.encodeFileName);this.push({data:v,meta:{percent:100}})},g.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},g.prototype.registerPrevious=function(m){this._sources.push(m);var b=this;return m.on("data",function(y){b.processChunk(y)}),m.on("end",function(){b.closedSource(b.previous.streamInfo),b._sources.length?b.prepareNextSource():b.end()}),m.on("error",function(y){b.error(y)}),this},g.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},g.prototype.error=function(m){var b=this._sources;if(!l.prototype.error.call(this,m))return!1;for(var y=0;y<b.length;y++)try{b[y].error(m)}catch{}return!0},g.prototype.lock=function(){l.prototype.lock.call(this);for(var m=this._sources,b=0;b<m.length;b++)m[b].lock()},r.exports=g},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var a=n("../compressions"),s=n("./ZipFileWorker");i.generateWorker=function(o,l,c){var u=new s(l.streamFiles,c,l.platform,l.encodeFileName),h=0;try{o.forEach(function(g,m){h++;var b=(function(M,w){var C=M||w,T=a[C];if(!T)throw new Error(C+" is not a valid compression method !");return T})(m.options.compression,l.compression),y=m.options.compressionOptions||l.compressionOptions||{},v=m.dir,x=m.date;m._compressWorker(b,y).withStreamInfo("file",{name:g,dir:v,date:x,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(u)}),u.entriesCount=h}catch(g){u.error(g)}return u}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){function a(){if(!(this instanceof a))return new a;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var s=new a;for(var o in this)typeof this[o]!="function"&&(s[o]=this[o]);return s}}(a.prototype=n("./object")).loadAsync=n("./load"),a.support=n("./support"),a.defaults=n("./defaults"),a.version="3.10.1",a.loadAsync=function(s,o){return new a().loadAsync(s,o)},a.external=n("./external"),r.exports=a},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var a=n("./utils"),s=n("./external"),o=n("./utf8"),l=n("./zipEntries"),c=n("./stream/Crc32Probe"),u=n("./nodejsUtils");function h(g){return new s.Promise(function(m,b){var y=g.decompressed.getContentWorker().pipe(new c);y.on("error",function(v){b(v)}).on("end",function(){y.streamInfo.crc32!==g.decompressed.crc32?b(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}r.exports=function(g,m){var b=this;return m=a.extend(m||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),u.isNode&&u.isStream(g)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",g,!0,m.optimizedBinaryString,m.base64).then(function(y){var v=new l(m);return v.load(y),v}).then(function(y){var v=[s.Promise.resolve(y)],x=y.files;if(m.checkCRC32)for(var M=0;M<x.length;M++)v.push(h(x[M]));return s.Promise.all(v)}).then(function(y){for(var v=y.shift(),x=v.files,M=0;M<x.length;M++){var w=x[M],C=w.fileNameStr,T=a.resolve(w.fileNameStr);b.file(T,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:m.createFolders}),w.dir||(b.file(T).unsafeOriginalName=C)}return v.zipComment.length&&(b.comment=v.zipComment),b})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var a=n("../utils"),s=n("../stream/GenericWorker");function o(l,c){s.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}a.inherits(o,s),o.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(u){c.push({data:u,meta:{percent:0}})}).on("error",function(u){c.isPaused?this.generatedError=u:c.error(u)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},o.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){var a=n("readable-stream").Readable;function s(o,l,c){a.call(this,l),this._helper=o;var u=this;o.on("data",function(h,g){u.push(h)||u._helper.pause(),c&&c(g)}).on("error",function(h){u.emit("error",h)}).on("end",function(){u.push(null)})}n("../utils").inherits(s,a),s.prototype._read=function(){this._helper.resume()},r.exports=s},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(a,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(a,s);if(typeof a=="number")throw new Error('The "data" argument must not be a number');return new Buffer(a,s)},allocBuffer:function(a){if(Buffer.alloc)return Buffer.alloc(a);var s=new Buffer(a);return s.fill(0),s},isBuffer:function(a){return Buffer.isBuffer(a)},isStream:function(a){return a&&typeof a.on=="function"&&typeof a.pause=="function"&&typeof a.resume=="function"}}},{}],15:[function(n,r,i){function a(T,R,A){var j,N=o.getTypeOf(R),k=o.extend(A||{},u);k.date=k.date||new Date,k.compression!==null&&(k.compression=k.compression.toUpperCase()),typeof k.unixPermissions=="string"&&(k.unixPermissions=parseInt(k.unixPermissions,8)),k.unixPermissions&&16384&k.unixPermissions&&(k.dir=!0),k.dosPermissions&&16&k.dosPermissions&&(k.dir=!0),k.dir&&(T=x(T)),k.createFolders&&(j=v(T))&&M.call(this,j,!0);var F=N==="string"&&k.binary===!1&&k.base64===!1;A&&A.binary!==void 0||(k.binary=!F),(R instanceof h&&R.uncompressedSize===0||k.dir||!R||R.length===0)&&(k.base64=!1,k.binary=!0,R="",k.compression="STORE",N="string");var I=null;I=R instanceof h||R instanceof l?R:b.isNode&&b.isStream(R)?new y(T,R):o.prepareContent(T,R,k.binary,k.optimizedBinaryString,k.base64);var W=new g(T,I,k);this.files[T]=W}var s=n("./utf8"),o=n("./utils"),l=n("./stream/GenericWorker"),c=n("./stream/StreamHelper"),u=n("./defaults"),h=n("./compressedObject"),g=n("./zipObject"),m=n("./generate"),b=n("./nodejsUtils"),y=n("./nodejs/NodejsStreamInputAdapter"),v=function(T){T.slice(-1)==="/"&&(T=T.substring(0,T.length-1));var R=T.lastIndexOf("/");return 0<R?T.substring(0,R):""},x=function(T){return T.slice(-1)!=="/"&&(T+="/"),T},M=function(T,R){return R=R!==void 0?R:u.createFolders,T=x(T),this.files[T]||a.call(this,T,null,{dir:!0,createFolders:R}),this.files[T]};function w(T){return Object.prototype.toString.call(T)==="[object RegExp]"}var C={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(T){var R,A,j;for(R in this.files)j=this.files[R],(A=R.slice(this.root.length,R.length))&&R.slice(0,this.root.length)===this.root&&T(A,j)},filter:function(T){var R=[];return this.forEach(function(A,j){T(A,j)&&R.push(j)}),R},file:function(T,R,A){if(arguments.length!==1)return T=this.root+T,a.call(this,T,R,A),this;if(w(T)){var j=T;return this.filter(function(k,F){return!F.dir&&j.test(k)})}var N=this.files[this.root+T];return N&&!N.dir?N:null},folder:function(T){if(!T)return this;if(w(T))return this.filter(function(N,k){return k.dir&&T.test(N)});var R=this.root+T,A=M.call(this,R),j=this.clone();return j.root=A.name,j},remove:function(T){T=this.root+T;var R=this.files[T];if(R||(T.slice(-1)!=="/"&&(T+="/"),R=this.files[T]),R&&!R.dir)delete this.files[T];else for(var A=this.filter(function(N,k){return k.name.slice(0,T.length)===T}),j=0;j<A.length;j++)delete this.files[A[j].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(T){var R,A={};try{if((A=o.extend(T||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=A.type.toLowerCase(),A.compression=A.compression.toUpperCase(),A.type==="binarystring"&&(A.type="string"),!A.type)throw new Error("No output type specified.");o.checkSupport(A.type),A.platform!=="darwin"&&A.platform!=="freebsd"&&A.platform!=="linux"&&A.platform!=="sunos"||(A.platform="UNIX"),A.platform==="win32"&&(A.platform="DOS");var j=A.comment||this.comment||"";R=m.generateWorker(this,A,j)}catch(N){(R=new l("error")).error(N)}return new c(R,A.type||"string",A.mimeType)},generateAsync:function(T,R){return this.generateInternalStream(T).accumulate(R)},generateNodeStream:function(T,R){return(T=T||{}).type||(T.type="nodebuffer"),this.generateInternalStream(T).toNodejsStream(R)}};r.exports=C},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var a=n("./DataReader");function s(o){a.call(this,o);for(var l=0;l<this.data.length;l++)o[l]=255&o[l]}n("../utils").inherits(s,a),s.prototype.byteAt=function(o){return this.data[this.zero+o]},s.prototype.lastIndexOfSignature=function(o){for(var l=o.charCodeAt(0),c=o.charCodeAt(1),u=o.charCodeAt(2),h=o.charCodeAt(3),g=this.length-4;0<=g;--g)if(this.data[g]===l&&this.data[g+1]===c&&this.data[g+2]===u&&this.data[g+3]===h)return g-this.zero;return-1},s.prototype.readAndCheckSignature=function(o){var l=o.charCodeAt(0),c=o.charCodeAt(1),u=o.charCodeAt(2),h=o.charCodeAt(3),g=this.readData(4);return l===g[0]&&c===g[1]&&u===g[2]&&h===g[3]},s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},r.exports=s},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){var a=n("../utils");function s(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var l,c=0;for(this.checkOffset(o),l=this.index+o-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=o,c},readString:function(o){return a.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},r.exports=s},{"../utils":32}],19:[function(n,r,i){var a=n("./Uint8ArrayReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},r.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var a=n("./DataReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},s.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},s.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},s.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},r.exports=s},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var a=n("./ArrayReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},r.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var a=n("../utils"),s=n("../support"),o=n("./ArrayReader"),l=n("./StringReader"),c=n("./NodeBufferReader"),u=n("./Uint8ArrayReader");r.exports=function(h){var g=a.getTypeOf(h);return a.checkSupport(g),g!=="string"||s.uint8array?g==="nodebuffer"?new c(h):s.uint8array?new u(a.transformTo("uint8array",h)):new o(a.transformTo("array",h)):new l(h)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var a=n("./GenericWorker"),s=n("../utils");function o(l){a.call(this,"ConvertWorker to "+l),this.destType=l}s.inherits(o,a),o.prototype.processChunk=function(l){this.push({data:s.transformTo(this.destType,l.data),meta:l.meta})},r.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var a=n("./GenericWorker"),s=n("../crc32");function o(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(o,a),o.prototype.processChunk=function(l){this.streamInfo.crc32=s(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var a=n("../utils"),s=n("./GenericWorker");function o(l){s.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}a.inherits(o,s),o.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}s.prototype.processChunk.call(this,l)},r.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var a=n("../utils"),s=n("./GenericWorker");function o(l){s.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(u){c.dataIsReady=!0,c.data=u,c.max=u&&u.length||0,c.type=a.getTypeOf(u),c.isPaused||c._tickAndRepeat()},function(u){c.error(u)})}a.inherits(o,s),o.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,a.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function a(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}a.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,o){return this._listeners[s].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,o){if(this._listeners[s])for(var l=0;l<this._listeners[s].length;l++)this._listeners[s][l].call(this,o)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var o=this;return s.on("data",function(l){o.processChunk(l)}),s.on("end",function(){o.end()}),s.on("error",function(l){o.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,o){return this.extraStreamInfo[s]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},r.exports=a},{}],29:[function(n,r,i){var a=n("../utils"),s=n("./ConvertWorker"),o=n("./GenericWorker"),l=n("../base64"),c=n("../support"),u=n("../external"),h=null;if(c.nodestream)try{h=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(b,y){return new u.Promise(function(v,x){var M=[],w=b._internalType,C=b._outputType,T=b._mimeType;b.on("data",function(R,A){M.push(R),y&&y(A)}).on("error",function(R){M=[],x(R)}).on("end",function(){try{var R=(function(A,j,N){switch(A){case"blob":return a.newBlob(a.transformTo("arraybuffer",j),N);case"base64":return l.encode(j);default:return a.transformTo(A,j)}})(C,(function(A,j){var N,k=0,F=null,I=0;for(N=0;N<j.length;N++)I+=j[N].length;switch(A){case"string":return j.join("");case"array":return Array.prototype.concat.apply([],j);case"uint8array":for(F=new Uint8Array(I),N=0;N<j.length;N++)F.set(j[N],k),k+=j[N].length;return F;case"nodebuffer":return Buffer.concat(j);default:throw new Error("concat : unsupported type '"+A+"'")}})(w,M),T);v(R)}catch(A){x(A)}M=[]}).resume()})}function m(b,y,v){var x=y;switch(y){case"blob":case"arraybuffer":x="uint8array";break;case"base64":x="string"}try{this._internalType=x,this._outputType=y,this._mimeType=v,a.checkSupport(x),this._worker=b.pipe(new s(x)),b.lock()}catch(M){this._worker=new o("error"),this._worker.error(M)}}m.prototype={accumulate:function(b){return g(this,b)},on:function(b,y){var v=this;return b==="data"?this._worker.on(b,function(x){y.call(v,x.data,x.meta)}):this._worker.on(b,function(){a.delay(y,arguments,v)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(b){if(a.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new h(this,{objectMode:this._outputType!=="nodebuffer"},b)}},r.exports=m},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var a=new ArrayBuffer(0);try{i.blob=new Blob([a],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(a),i.blob=s.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!n("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,i){for(var a=n("./utils"),s=n("./support"),o=n("./nodejsUtils"),l=n("./stream/GenericWorker"),c=new Array(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;c[254]=c[254]=1;function h(){l.call(this,"utf-8 decode"),this.leftOver=null}function g(){l.call(this,"utf-8 encode")}i.utf8encode=function(m){return s.nodebuffer?o.newBufferFrom(m,"utf-8"):(function(b){var y,v,x,M,w,C=b.length,T=0;for(M=0;M<C;M++)(64512&(v=b.charCodeAt(M)))==55296&&M+1<C&&(64512&(x=b.charCodeAt(M+1)))==56320&&(v=65536+(v-55296<<10)+(x-56320),M++),T+=v<128?1:v<2048?2:v<65536?3:4;for(y=s.uint8array?new Uint8Array(T):new Array(T),M=w=0;w<T;M++)(64512&(v=b.charCodeAt(M)))==55296&&M+1<C&&(64512&(x=b.charCodeAt(M+1)))==56320&&(v=65536+(v-55296<<10)+(x-56320),M++),v<128?y[w++]=v:(v<2048?y[w++]=192|v>>>6:(v<65536?y[w++]=224|v>>>12:(y[w++]=240|v>>>18,y[w++]=128|v>>>12&63),y[w++]=128|v>>>6&63),y[w++]=128|63&v);return y})(m)},i.utf8decode=function(m){return s.nodebuffer?a.transformTo("nodebuffer",m).toString("utf-8"):(function(b){var y,v,x,M,w=b.length,C=new Array(2*w);for(y=v=0;y<w;)if((x=b[y++])<128)C[v++]=x;else if(4<(M=c[x]))C[v++]=65533,y+=M-1;else{for(x&=M===2?31:M===3?15:7;1<M&&y<w;)x=x<<6|63&b[y++],M--;1<M?C[v++]=65533:x<65536?C[v++]=x:(x-=65536,C[v++]=55296|x>>10&1023,C[v++]=56320|1023&x)}return C.length!==v&&(C.subarray?C=C.subarray(0,v):C.length=v),a.applyFromCharCode(C)})(m=a.transformTo(s.uint8array?"uint8array":"array",m))},a.inherits(h,l),h.prototype.processChunk=function(m){var b=a.transformTo(s.uint8array?"uint8array":"array",m.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var y=b;(b=new Uint8Array(y.length+this.leftOver.length)).set(this.leftOver,0),b.set(y,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var v=(function(M,w){var C;for((w=w||M.length)>M.length&&(w=M.length),C=w-1;0<=C&&(192&M[C])==128;)C--;return C<0||C===0?w:C+c[M[C]]>w?C:w})(b),x=b;v!==b.length&&(s.uint8array?(x=b.subarray(0,v),this.leftOver=b.subarray(v,b.length)):(x=b.slice(0,v),this.leftOver=b.slice(v,b.length))),this.push({data:i.utf8decode(x),meta:m.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=h,a.inherits(g,l),g.prototype.processChunk=function(m){this.push({data:i.utf8encode(m.data),meta:m.meta})},i.Utf8EncodeWorker=g},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){var a=n("./support"),s=n("./base64"),o=n("./nodejsUtils"),l=n("./external");function c(y){return y}function u(y,v){for(var x=0;x<y.length;++x)v[x]=255&y.charCodeAt(x);return v}n("setimmediate"),i.newBlob=function(y,v){i.checkSupport("blob");try{return new Blob([y],{type:v})}catch{try{var x=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return x.append(y),x.getBlob(v)}catch{throw new Error("Bug : can't construct the Blob.")}}};var h={stringifyByChunk:function(y,v,x){var M=[],w=0,C=y.length;if(C<=x)return String.fromCharCode.apply(null,y);for(;w<C;)v==="array"||v==="nodebuffer"?M.push(String.fromCharCode.apply(null,y.slice(w,Math.min(w+x,C)))):M.push(String.fromCharCode.apply(null,y.subarray(w,Math.min(w+x,C)))),w+=x;return M.join("")},stringifyByChar:function(y){for(var v="",x=0;x<y.length;x++)v+=String.fromCharCode(y[x]);return v},applyCanBeUsed:{uint8array:(function(){try{return a.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return a.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}})()}};function g(y){var v=65536,x=i.getTypeOf(y),M=!0;if(x==="uint8array"?M=h.applyCanBeUsed.uint8array:x==="nodebuffer"&&(M=h.applyCanBeUsed.nodebuffer),M)for(;1<v;)try{return h.stringifyByChunk(y,x,v)}catch{v=Math.floor(v/2)}return h.stringifyByChar(y)}function m(y,v){for(var x=0;x<y.length;x++)v[x]=y[x];return v}i.applyFromCharCode=g;var b={};b.string={string:c,array:function(y){return u(y,new Array(y.length))},arraybuffer:function(y){return b.string.uint8array(y).buffer},uint8array:function(y){return u(y,new Uint8Array(y.length))},nodebuffer:function(y){return u(y,o.allocBuffer(y.length))}},b.array={string:g,array:c,arraybuffer:function(y){return new Uint8Array(y).buffer},uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return o.newBufferFrom(y)}},b.arraybuffer={string:function(y){return g(new Uint8Array(y))},array:function(y){return m(new Uint8Array(y),new Array(y.byteLength))},arraybuffer:c,uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return o.newBufferFrom(new Uint8Array(y))}},b.uint8array={string:g,array:function(y){return m(y,new Array(y.length))},arraybuffer:function(y){return y.buffer},uint8array:c,nodebuffer:function(y){return o.newBufferFrom(y)}},b.nodebuffer={string:g,array:function(y){return m(y,new Array(y.length))},arraybuffer:function(y){return b.nodebuffer.uint8array(y).buffer},uint8array:function(y){return m(y,new Uint8Array(y.length))},nodebuffer:c},i.transformTo=function(y,v){if(v=v||"",!y)return v;i.checkSupport(y);var x=i.getTypeOf(v);return b[x][y](v)},i.resolve=function(y){for(var v=y.split("/"),x=[],M=0;M<v.length;M++){var w=v[M];w==="."||w===""&&M!==0&&M!==v.length-1||(w===".."?x.pop():x.push(w))}return x.join("/")},i.getTypeOf=function(y){return typeof y=="string"?"string":Object.prototype.toString.call(y)==="[object Array]"?"array":a.nodebuffer&&o.isBuffer(y)?"nodebuffer":a.uint8array&&y instanceof Uint8Array?"uint8array":a.arraybuffer&&y instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(y){if(!a[y.toLowerCase()])throw new Error(y+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(y){var v,x,M="";for(x=0;x<(y||"").length;x++)M+="\\x"+((v=y.charCodeAt(x))<16?"0":"")+v.toString(16).toUpperCase();return M},i.delay=function(y,v,x){setImmediate(function(){y.apply(x||null,v||[])})},i.inherits=function(y,v){function x(){}x.prototype=v.prototype,y.prototype=new x},i.extend=function(){var y,v,x={};for(y=0;y<arguments.length;y++)for(v in arguments[y])Object.prototype.hasOwnProperty.call(arguments[y],v)&&x[v]===void 0&&(x[v]=arguments[y][v]);return x},i.prepareContent=function(y,v,x,M,w){return l.Promise.resolve(v).then(function(C){return a.blob&&(C instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(C))!==-1)&&typeof FileReader<"u"?new l.Promise(function(T,R){var A=new FileReader;A.onload=function(j){T(j.target.result)},A.onerror=function(j){R(j.target.error)},A.readAsArrayBuffer(C)}):C}).then(function(C){var T=i.getTypeOf(C);return T?(T==="arraybuffer"?C=i.transformTo("uint8array",C):T==="string"&&(w?C=s.decode(C):x&&M!==!0&&(C=(function(R){return u(R,a.uint8array?new Uint8Array(R.length):new Array(R.length))})(C))),C):l.Promise.reject(new Error("Can't read the data of '"+y+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var a=n("./reader/readerFor"),s=n("./utils"),o=n("./signature"),l=n("./zipEntry"),c=n("./support");function u(h){this.files=[],this.loadOptions=h}u.prototype={checkSignature:function(h){if(!this.reader.readAndCheckSignature(h)){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(h)+")")}},isSignature:function(h,g){var m=this.reader.index;this.reader.setIndex(h);var b=this.reader.readString(4)===g;return this.reader.setIndex(m),b},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var h=this.reader.readData(this.zipCommentLength),g=c.uint8array?"uint8array":"array",m=s.transformTo(g,h);this.zipComment=this.loadOptions.decodeFileName(m)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var h,g,m,b=this.zip64EndOfCentralSize-44;0<b;)h=this.reader.readInt(2),g=this.reader.readInt(4),m=this.reader.readData(g),this.zip64ExtensibleData[h]={id:h,length:g,value:m}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var h,g;for(h=0;h<this.files.length;h++)g=this.files[h],this.reader.setIndex(g.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),g.readLocalPart(this.reader),g.handleUTF8(),g.processAttributes()},readCentralDir:function(){var h;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(h=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(h);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var h=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(h<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(h);var g=h;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(h=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(h),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var m=this.centralDirOffset+this.centralDirSize;this.zip64&&(m+=20,m+=12+this.zip64EndOfCentralSize);var b=g-m;if(0<b)this.isSignature(g,o.CENTRAL_FILE_HEADER)||(this.reader.zero=b);else if(b<0)throw new Error("Corrupted zip: missing "+Math.abs(b)+" bytes.")},prepareReader:function(h){this.reader=a(h)},load:function(h){this.prepareReader(h),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=u},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var a=n("./reader/readerFor"),s=n("./utils"),o=n("./compressedObject"),l=n("./crc32"),c=n("./utf8"),u=n("./compressions"),h=n("./support");function g(m,b){this.options=m,this.loadOptions=b}g.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(m){var b,y;if(m.skip(22),this.fileNameLength=m.readInt(2),y=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.skip(y),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((b=(function(v){for(var x in u)if(Object.prototype.hasOwnProperty.call(u,x)&&u[x].magic===v)return u[x];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,b,m.readData(this.compressedSize))},readCentralPart:function(m){this.versionMadeBy=m.readInt(2),m.skip(2),this.bitFlag=m.readInt(2),this.compressionMethod=m.readString(2),this.date=m.readDate(),this.crc32=m.readInt(4),this.compressedSize=m.readInt(4),this.uncompressedSize=m.readInt(4);var b=m.readInt(2);if(this.extraFieldsLength=m.readInt(2),this.fileCommentLength=m.readInt(2),this.diskNumberStart=m.readInt(2),this.internalFileAttributes=m.readInt(2),this.externalFileAttributes=m.readInt(4),this.localHeaderOffset=m.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");m.skip(b),this.readExtraFields(m),this.parseZIP64ExtraField(m),this.fileComment=m.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var m=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),m==0&&(this.dosPermissions=63&this.externalFileAttributes),m==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var m=a(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=m.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=m.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=m.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=m.readInt(4))}},readExtraFields:function(m){var b,y,v,x=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<x;)b=m.readInt(2),y=m.readInt(2),v=m.readData(y),this.extraFields[b]={id:b,length:y,value:v};m.setIndex(x)},handleUTF8:function(){var m=h.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var b=this.findExtraFieldUnicodePath();if(b!==null)this.fileNameStr=b;else{var y=s.transformTo(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(y)}var v=this.findExtraFieldUnicodeComment();if(v!==null)this.fileCommentStr=v;else{var x=s.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(x)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var b=a(m.value);return b.readInt(1)!==1||l(this.fileName)!==b.readInt(4)?null:c.utf8decode(b.readData(m.length-5))}return null},findExtraFieldUnicodeComment:function(){var m=this.extraFields[25461];if(m){var b=a(m.value);return b.readInt(1)!==1||l(this.fileComment)!==b.readInt(4)?null:c.utf8decode(b.readData(m.length-5))}return null}},r.exports=g},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function a(b,y,v){this.name=b,this.dir=v.dir,this.date=v.date,this.comment=v.comment,this.unixPermissions=v.unixPermissions,this.dosPermissions=v.dosPermissions,this._data=y,this._dataBinary=v.binary,this.options={compression:v.compression,compressionOptions:v.compressionOptions}}var s=n("./stream/StreamHelper"),o=n("./stream/DataWorker"),l=n("./utf8"),c=n("./compressedObject"),u=n("./stream/GenericWorker");a.prototype={internalStream:function(b){var y=null,v="string";try{if(!b)throw new Error("No output type specified.");var x=(v=b.toLowerCase())==="string"||v==="text";v!=="binarystring"&&v!=="text"||(v="string"),y=this._decompressWorker();var M=!this._dataBinary;M&&!x&&(y=y.pipe(new l.Utf8EncodeWorker)),!M&&x&&(y=y.pipe(new l.Utf8DecodeWorker))}catch(w){(y=new u("error")).error(w)}return new s(y,v,"")},async:function(b,y){return this.internalStream(b).accumulate(y)},nodeStream:function(b,y){return this.internalStream(b||"nodebuffer").toNodejsStream(y)},_compressWorker:function(b,y){if(this._data instanceof c&&this._data.compression.magic===b.magic)return this._data.getCompressedWorker();var v=this._decompressWorker();return this._dataBinary||(v=v.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(v,b,y)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof u?this._data:new o(this._data)}};for(var h=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],g=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},m=0;m<h.length;m++)a.prototype[h[m]]=g;r.exports=a},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(a){var s,o,l=a.MutationObserver||a.WebKitMutationObserver;if(l){var c=0,u=new l(b),h=a.document.createTextNode("");u.observe(h,{characterData:!0}),s=function(){h.data=c=++c%2}}else if(a.setImmediate||a.MessageChannel===void 0)s="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var y=a.document.createElement("script");y.onreadystatechange=function(){b(),y.onreadystatechange=null,y.parentNode.removeChild(y),y=null},a.document.documentElement.appendChild(y)}:function(){setTimeout(b,0)};else{var g=new a.MessageChannel;g.port1.onmessage=b,s=function(){g.port2.postMessage(0)}}var m=[];function b(){var y,v;o=!0;for(var x=m.length;x;){for(v=m,m=[],y=-1;++y<x;)v[y]();x=m.length}o=!1}r.exports=function(y){m.push(y)!==1||o||s()}}).call(this,typeof Db<"u"?Db:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var a=n("immediate");function s(){}var o={},l=["REJECTED"],c=["FULFILLED"],u=["PENDING"];function h(x){if(typeof x!="function")throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,x!==s&&y(this,x)}function g(x,M,w){this.promise=x,typeof M=="function"&&(this.onFulfilled=M,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected)}function m(x,M,w){a(function(){var C;try{C=M(w)}catch(T){return o.reject(x,T)}C===x?o.reject(x,new TypeError("Cannot resolve promise with itself")):o.resolve(x,C)})}function b(x){var M=x&&x.then;if(x&&(typeof x=="object"||typeof x=="function")&&typeof M=="function")return function(){M.apply(x,arguments)}}function y(x,M){var w=!1;function C(A){w||(w=!0,o.reject(x,A))}function T(A){w||(w=!0,o.resolve(x,A))}var R=v(function(){M(T,C)});R.status==="error"&&C(R.value)}function v(x,M){var w={};try{w.value=x(M),w.status="success"}catch(C){w.status="error",w.value=C}return w}(r.exports=h).prototype.finally=function(x){if(typeof x!="function")return this;var M=this.constructor;return this.then(function(w){return M.resolve(x()).then(function(){return w})},function(w){return M.resolve(x()).then(function(){throw w})})},h.prototype.catch=function(x){return this.then(null,x)},h.prototype.then=function(x,M){if(typeof x!="function"&&this.state===c||typeof M!="function"&&this.state===l)return this;var w=new this.constructor(s);return this.state!==u?m(w,this.state===c?x:M,this.outcome):this.queue.push(new g(w,x,M)),w},g.prototype.callFulfilled=function(x){o.resolve(this.promise,x)},g.prototype.otherCallFulfilled=function(x){m(this.promise,this.onFulfilled,x)},g.prototype.callRejected=function(x){o.reject(this.promise,x)},g.prototype.otherCallRejected=function(x){m(this.promise,this.onRejected,x)},o.resolve=function(x,M){var w=v(b,M);if(w.status==="error")return o.reject(x,w.value);var C=w.value;if(C)y(x,C);else{x.state=c,x.outcome=M;for(var T=-1,R=x.queue.length;++T<R;)x.queue[T].callFulfilled(M)}return x},o.reject=function(x,M){x.state=l,x.outcome=M;for(var w=-1,C=x.queue.length;++w<C;)x.queue[w].callRejected(M);return x},h.resolve=function(x){return x instanceof this?x:o.resolve(new this(s),x)},h.reject=function(x){var M=new this(s);return o.reject(M,x)},h.all=function(x){var M=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=x.length,C=!1;if(!w)return this.resolve([]);for(var T=new Array(w),R=0,A=-1,j=new this(s);++A<w;)N(x[A],A);return j;function N(k,F){M.resolve(k).then(function(I){T[F]=I,++R!==w||C||(C=!0,o.resolve(j,T))},function(I){C||(C=!0,o.reject(j,I))})}},h.race=function(x){var M=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=x.length,C=!1;if(!w)return this.resolve([]);for(var T=-1,R=new this(s);++T<w;)A=x[T],M.resolve(A).then(function(j){C||(C=!0,o.resolve(R,j))},function(j){C||(C=!0,o.reject(R,j))});var A;return R}},{immediate:36}],38:[function(n,r,i){var a={};(0,n("./lib/utils/common").assign)(a,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=a},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var a=n("./zlib/deflate"),s=n("./utils/common"),o=n("./utils/strings"),l=n("./zlib/messages"),c=n("./zlib/zstream"),u=Object.prototype.toString,h=0,g=-1,m=0,b=8;function y(x){if(!(this instanceof y))return new y(x);this.options=s.assign({level:g,method:b,chunkSize:16384,windowBits:15,memLevel:8,strategy:m,to:""},x||{});var M=this.options;M.raw&&0<M.windowBits?M.windowBits=-M.windowBits:M.gzip&&0<M.windowBits&&M.windowBits<16&&(M.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var w=a.deflateInit2(this.strm,M.level,M.method,M.windowBits,M.memLevel,M.strategy);if(w!==h)throw new Error(l[w]);if(M.header&&a.deflateSetHeader(this.strm,M.header),M.dictionary){var C;if(C=typeof M.dictionary=="string"?o.string2buf(M.dictionary):u.call(M.dictionary)==="[object ArrayBuffer]"?new Uint8Array(M.dictionary):M.dictionary,(w=a.deflateSetDictionary(this.strm,C))!==h)throw new Error(l[w]);this._dict_set=!0}}function v(x,M){var w=new y(M);if(w.push(x,!0),w.err)throw w.msg||l[w.err];return w.result}y.prototype.push=function(x,M){var w,C,T=this.strm,R=this.options.chunkSize;if(this.ended)return!1;C=M===~~M?M:M===!0?4:0,typeof x=="string"?T.input=o.string2buf(x):u.call(x)==="[object ArrayBuffer]"?T.input=new Uint8Array(x):T.input=x,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new s.Buf8(R),T.next_out=0,T.avail_out=R),(w=a.deflate(T,C))!==1&&w!==h)return this.onEnd(w),!(this.ended=!0);T.avail_out!==0&&(T.avail_in!==0||C!==4&&C!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(s.shrinkBuf(T.output,T.next_out))):this.onData(s.shrinkBuf(T.output,T.next_out)))}while((0<T.avail_in||T.avail_out===0)&&w!==1);return C===4?(w=a.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===h):C!==2||(this.onEnd(h),!(T.avail_out=0))},y.prototype.onData=function(x){this.chunks.push(x)},y.prototype.onEnd=function(x){x===h&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=x,this.msg=this.strm.msg},i.Deflate=y,i.deflate=v,i.deflateRaw=function(x,M){return(M=M||{}).raw=!0,v(x,M)},i.gzip=function(x,M){return(M=M||{}).gzip=!0,v(x,M)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){var a=n("./zlib/inflate"),s=n("./utils/common"),o=n("./utils/strings"),l=n("./zlib/constants"),c=n("./zlib/messages"),u=n("./zlib/zstream"),h=n("./zlib/gzheader"),g=Object.prototype.toString;function m(y){if(!(this instanceof m))return new m(y);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},y||{});var v=this.options;v.raw&&0<=v.windowBits&&v.windowBits<16&&(v.windowBits=-v.windowBits,v.windowBits===0&&(v.windowBits=-15)),!(0<=v.windowBits&&v.windowBits<16)||y&&y.windowBits||(v.windowBits+=32),15<v.windowBits&&v.windowBits<48&&(15&v.windowBits)==0&&(v.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var x=a.inflateInit2(this.strm,v.windowBits);if(x!==l.Z_OK)throw new Error(c[x]);this.header=new h,a.inflateGetHeader(this.strm,this.header)}function b(y,v){var x=new m(v);if(x.push(y,!0),x.err)throw x.msg||c[x.err];return x.result}m.prototype.push=function(y,v){var x,M,w,C,T,R,A=this.strm,j=this.options.chunkSize,N=this.options.dictionary,k=!1;if(this.ended)return!1;M=v===~~v?v:v===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof y=="string"?A.input=o.binstring2buf(y):g.call(y)==="[object ArrayBuffer]"?A.input=new Uint8Array(y):A.input=y,A.next_in=0,A.avail_in=A.input.length;do{if(A.avail_out===0&&(A.output=new s.Buf8(j),A.next_out=0,A.avail_out=j),(x=a.inflate(A,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&N&&(R=typeof N=="string"?o.string2buf(N):g.call(N)==="[object ArrayBuffer]"?new Uint8Array(N):N,x=a.inflateSetDictionary(this.strm,R)),x===l.Z_BUF_ERROR&&k===!0&&(x=l.Z_OK,k=!1),x!==l.Z_STREAM_END&&x!==l.Z_OK)return this.onEnd(x),!(this.ended=!0);A.next_out&&(A.avail_out!==0&&x!==l.Z_STREAM_END&&(A.avail_in!==0||M!==l.Z_FINISH&&M!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(w=o.utf8border(A.output,A.next_out),C=A.next_out-w,T=o.buf2string(A.output,w),A.next_out=C,A.avail_out=j-C,C&&s.arraySet(A.output,A.output,w,C,0),this.onData(T)):this.onData(s.shrinkBuf(A.output,A.next_out)))),A.avail_in===0&&A.avail_out===0&&(k=!0)}while((0<A.avail_in||A.avail_out===0)&&x!==l.Z_STREAM_END);return x===l.Z_STREAM_END&&(M=l.Z_FINISH),M===l.Z_FINISH?(x=a.inflateEnd(this.strm),this.onEnd(x),this.ended=!0,x===l.Z_OK):M!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(A.avail_out=0))},m.prototype.onData=function(y){this.chunks.push(y)},m.prototype.onEnd=function(y){y===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Inflate=m,i.inflate=b,i.inflateRaw=function(y,v){return(v=v||{}).raw=!0,b(y,v)},i.ungzip=b},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(l){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var u=c.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var h in u)u.hasOwnProperty(h)&&(l[h]=u[h])}}return l},i.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var s={arraySet:function(l,c,u,h,g){if(c.subarray&&l.subarray)l.set(c.subarray(u,u+h),g);else for(var m=0;m<h;m++)l[g+m]=c[u+m]},flattenChunks:function(l){var c,u,h,g,m,b;for(c=h=0,u=l.length;c<u;c++)h+=l[c].length;for(b=new Uint8Array(h),c=g=0,u=l.length;c<u;c++)m=l[c],b.set(m,g),g+=m.length;return b}},o={arraySet:function(l,c,u,h,g){for(var m=0;m<h;m++)l[g+m]=c[u+m]},flattenChunks:function(l){return[].concat.apply([],l)}};i.setTyped=function(l){l?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,s)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,o))},i.setTyped(a)},{}],42:[function(n,r,i){var a=n("./common"),s=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var l=new a.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function u(h,g){if(g<65537&&(h.subarray&&o||!h.subarray&&s))return String.fromCharCode.apply(null,a.shrinkBuf(h,g));for(var m="",b=0;b<g;b++)m+=String.fromCharCode(h[b]);return m}l[254]=l[254]=1,i.string2buf=function(h){var g,m,b,y,v,x=h.length,M=0;for(y=0;y<x;y++)(64512&(m=h.charCodeAt(y)))==55296&&y+1<x&&(64512&(b=h.charCodeAt(y+1)))==56320&&(m=65536+(m-55296<<10)+(b-56320),y++),M+=m<128?1:m<2048?2:m<65536?3:4;for(g=new a.Buf8(M),y=v=0;v<M;y++)(64512&(m=h.charCodeAt(y)))==55296&&y+1<x&&(64512&(b=h.charCodeAt(y+1)))==56320&&(m=65536+(m-55296<<10)+(b-56320),y++),m<128?g[v++]=m:(m<2048?g[v++]=192|m>>>6:(m<65536?g[v++]=224|m>>>12:(g[v++]=240|m>>>18,g[v++]=128|m>>>12&63),g[v++]=128|m>>>6&63),g[v++]=128|63&m);return g},i.buf2binstring=function(h){return u(h,h.length)},i.binstring2buf=function(h){for(var g=new a.Buf8(h.length),m=0,b=g.length;m<b;m++)g[m]=h.charCodeAt(m);return g},i.buf2string=function(h,g){var m,b,y,v,x=g||h.length,M=new Array(2*x);for(m=b=0;m<x;)if((y=h[m++])<128)M[b++]=y;else if(4<(v=l[y]))M[b++]=65533,m+=v-1;else{for(y&=v===2?31:v===3?15:7;1<v&&m<x;)y=y<<6|63&h[m++],v--;1<v?M[b++]=65533:y<65536?M[b++]=y:(y-=65536,M[b++]=55296|y>>10&1023,M[b++]=56320|1023&y)}return u(M,b)},i.utf8border=function(h,g){var m;for((g=g||h.length)>h.length&&(g=h.length),m=g-1;0<=m&&(192&h[m])==128;)m--;return m<0||m===0?g:m+l[h[m]]>g?m:g}},{"./common":41}],43:[function(n,r,i){r.exports=function(a,s,o,l){for(var c=65535&a|0,u=a>>>16&65535|0,h=0;o!==0;){for(o-=h=2e3<o?2e3:o;u=u+(c=c+s[l++]|0)|0,--h;);c%=65521,u%=65521}return c|u<<16|0}},{}],44:[function(n,r,i){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){var a=(function(){for(var s,o=[],l=0;l<256;l++){s=l;for(var c=0;c<8;c++)s=1&s?3988292384^s>>>1:s>>>1;o[l]=s}return o})();r.exports=function(s,o,l,c){var u=a,h=c+l;s^=-1;for(var g=c;g<h;g++)s=s>>>8^u[255&(s^o[g])];return-1^s}},{}],46:[function(n,r,i){var a,s=n("../utils/common"),o=n("./trees"),l=n("./adler32"),c=n("./crc32"),u=n("./messages"),h=0,g=4,m=0,b=-2,y=-1,v=4,x=2,M=8,w=9,C=286,T=30,R=19,A=2*C+1,j=15,N=3,k=258,F=k+N+1,I=42,W=113,D=1,B=2,G=3,V=4;function Z($,z){return $.msg=u[z],z}function Y($){return($<<1)-(4<$?9:0)}function ee($){for(var z=$.length;0<=--z;)$[z]=0}function H($){var z=$.state,ne=z.pending;ne>$.avail_out&&(ne=$.avail_out),ne!==0&&(s.arraySet($.output,z.pending_buf,z.pending_out,ne,$.next_out),$.next_out+=ne,z.pending_out+=ne,$.total_out+=ne,$.avail_out-=ne,z.pending-=ne,z.pending===0&&(z.pending_out=0))}function q($,z){o._tr_flush_block($,0<=$.block_start?$.block_start:-1,$.strstart-$.block_start,z),$.block_start=$.strstart,H($.strm)}function ae($,z){$.pending_buf[$.pending++]=z}function ce($,z){$.pending_buf[$.pending++]=z>>>8&255,$.pending_buf[$.pending++]=255&z}function xe($,z){var ne,K,Q=$.max_chain_length,oe=$.strstart,Ne=$.prev_length,Ee=$.nice_match,re=$.strstart>$.w_size-F?$.strstart-($.w_size-F):0,U=$.window,L=$.w_mask,J=$.prev,ge=$.strstart+k,ye=U[oe+Ne-1],me=U[oe+Ne];$.prev_length>=$.good_match&&(Q>>=2),Ee>$.lookahead&&(Ee=$.lookahead);do if(U[(ne=z)+Ne]===me&&U[ne+Ne-1]===ye&&U[ne]===U[oe]&&U[++ne]===U[oe+1]){oe+=2,ne++;do;while(U[++oe]===U[++ne]&&U[++oe]===U[++ne]&&U[++oe]===U[++ne]&&U[++oe]===U[++ne]&&U[++oe]===U[++ne]&&U[++oe]===U[++ne]&&U[++oe]===U[++ne]&&U[++oe]===U[++ne]&&oe<ge);if(K=k-(ge-oe),oe=ge-k,Ne<K){if($.match_start=z,Ee<=(Ne=K))break;ye=U[oe+Ne-1],me=U[oe+Ne]}}while((z=J[z&L])>re&&--Q!=0);return Ne<=$.lookahead?Ne:$.lookahead}function ie($){var z,ne,K,Q,oe,Ne,Ee,re,U,L,J=$.w_size;do{if(Q=$.window_size-$.lookahead-$.strstart,$.strstart>=J+(J-F)){for(s.arraySet($.window,$.window,J,J,0),$.match_start-=J,$.strstart-=J,$.block_start-=J,z=ne=$.hash_size;K=$.head[--z],$.head[z]=J<=K?K-J:0,--ne;);for(z=ne=J;K=$.prev[--z],$.prev[z]=J<=K?K-J:0,--ne;);Q+=J}if($.strm.avail_in===0)break;if(Ne=$.strm,Ee=$.window,re=$.strstart+$.lookahead,U=Q,L=void 0,L=Ne.avail_in,U<L&&(L=U),ne=L===0?0:(Ne.avail_in-=L,s.arraySet(Ee,Ne.input,Ne.next_in,L,re),Ne.state.wrap===1?Ne.adler=l(Ne.adler,Ee,L,re):Ne.state.wrap===2&&(Ne.adler=c(Ne.adler,Ee,L,re)),Ne.next_in+=L,Ne.total_in+=L,L),$.lookahead+=ne,$.lookahead+$.insert>=N)for(oe=$.strstart-$.insert,$.ins_h=$.window[oe],$.ins_h=($.ins_h<<$.hash_shift^$.window[oe+1])&$.hash_mask;$.insert&&($.ins_h=($.ins_h<<$.hash_shift^$.window[oe+N-1])&$.hash_mask,$.prev[oe&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=oe,oe++,$.insert--,!($.lookahead+$.insert<N)););}while($.lookahead<F&&$.strm.avail_in!==0)}function ve($,z){for(var ne,K;;){if($.lookahead<F){if(ie($),$.lookahead<F&&z===h)return D;if($.lookahead===0)break}if(ne=0,$.lookahead>=N&&($.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+N-1])&$.hash_mask,ne=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart),ne!==0&&$.strstart-ne<=$.w_size-F&&($.match_length=xe($,ne)),$.match_length>=N)if(K=o._tr_tally($,$.strstart-$.match_start,$.match_length-N),$.lookahead-=$.match_length,$.match_length<=$.max_lazy_match&&$.lookahead>=N){for($.match_length--;$.strstart++,$.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+N-1])&$.hash_mask,ne=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart,--$.match_length!=0;);$.strstart++}else $.strstart+=$.match_length,$.match_length=0,$.ins_h=$.window[$.strstart],$.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+1])&$.hash_mask;else K=o._tr_tally($,0,$.window[$.strstart]),$.lookahead--,$.strstart++;if(K&&(q($,!1),$.strm.avail_out===0))return D}return $.insert=$.strstart<N-1?$.strstart:N-1,z===g?(q($,!0),$.strm.avail_out===0?G:V):$.last_lit&&(q($,!1),$.strm.avail_out===0)?D:B}function Pe($,z){for(var ne,K,Q;;){if($.lookahead<F){if(ie($),$.lookahead<F&&z===h)return D;if($.lookahead===0)break}if(ne=0,$.lookahead>=N&&($.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+N-1])&$.hash_mask,ne=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart),$.prev_length=$.match_length,$.prev_match=$.match_start,$.match_length=N-1,ne!==0&&$.prev_length<$.max_lazy_match&&$.strstart-ne<=$.w_size-F&&($.match_length=xe($,ne),$.match_length<=5&&($.strategy===1||$.match_length===N&&4096<$.strstart-$.match_start)&&($.match_length=N-1)),$.prev_length>=N&&$.match_length<=$.prev_length){for(Q=$.strstart+$.lookahead-N,K=o._tr_tally($,$.strstart-1-$.prev_match,$.prev_length-N),$.lookahead-=$.prev_length-1,$.prev_length-=2;++$.strstart<=Q&&($.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+N-1])&$.hash_mask,ne=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart),--$.prev_length!=0;);if($.match_available=0,$.match_length=N-1,$.strstart++,K&&(q($,!1),$.strm.avail_out===0))return D}else if($.match_available){if((K=o._tr_tally($,0,$.window[$.strstart-1]))&&q($,!1),$.strstart++,$.lookahead--,$.strm.avail_out===0)return D}else $.match_available=1,$.strstart++,$.lookahead--}return $.match_available&&(K=o._tr_tally($,0,$.window[$.strstart-1]),$.match_available=0),$.insert=$.strstart<N-1?$.strstart:N-1,z===g?(q($,!0),$.strm.avail_out===0?G:V):$.last_lit&&(q($,!1),$.strm.avail_out===0)?D:B}function he($,z,ne,K,Q){this.good_length=$,this.max_lazy=z,this.nice_length=ne,this.max_chain=K,this.func=Q}function we(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=M,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new s.Buf16(2*A),this.dyn_dtree=new s.Buf16(2*(2*T+1)),this.bl_tree=new s.Buf16(2*(2*R+1)),ee(this.dyn_ltree),ee(this.dyn_dtree),ee(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(j+1),this.heap=new s.Buf16(2*C+1),ee(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*C+1),ee(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 Le($){var z;return $&&$.state?($.total_in=$.total_out=0,$.data_type=x,(z=$.state).pending=0,z.pending_out=0,z.wrap<0&&(z.wrap=-z.wrap),z.status=z.wrap?I:W,$.adler=z.wrap===2?0:1,z.last_flush=h,o._tr_init(z),m):Z($,b)}function de($){var z=Le($);return z===m&&(function(ne){ne.window_size=2*ne.w_size,ee(ne.head),ne.max_lazy_match=a[ne.level].max_lazy,ne.good_match=a[ne.level].good_length,ne.nice_match=a[ne.level].nice_length,ne.max_chain_length=a[ne.level].max_chain,ne.strstart=0,ne.block_start=0,ne.lookahead=0,ne.insert=0,ne.match_length=ne.prev_length=N-1,ne.match_available=0,ne.ins_h=0})($.state),z}function lt($,z,ne,K,Q,oe){if(!$)return b;var Ne=1;if(z===y&&(z=6),K<0?(Ne=0,K=-K):15<K&&(Ne=2,K-=16),Q<1||w<Q||ne!==M||K<8||15<K||z<0||9<z||oe<0||v<oe)return Z($,b);K===8&&(K=9);var Ee=new we;return($.state=Ee).strm=$,Ee.wrap=Ne,Ee.gzhead=null,Ee.w_bits=K,Ee.w_size=1<<Ee.w_bits,Ee.w_mask=Ee.w_size-1,Ee.hash_bits=Q+7,Ee.hash_size=1<<Ee.hash_bits,Ee.hash_mask=Ee.hash_size-1,Ee.hash_shift=~~((Ee.hash_bits+N-1)/N),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<<Q+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=z,Ee.strategy=oe,Ee.method=ne,de($)}a=[new he(0,0,0,0,function($,z){var ne=65535;for(ne>$.pending_buf_size-5&&(ne=$.pending_buf_size-5);;){if($.lookahead<=1){if(ie($),$.lookahead===0&&z===h)return D;if($.lookahead===0)break}$.strstart+=$.lookahead,$.lookahead=0;var K=$.block_start+ne;if(($.strstart===0||$.strstart>=K)&&($.lookahead=$.strstart-K,$.strstart=K,q($,!1),$.strm.avail_out===0)||$.strstart-$.block_start>=$.w_size-F&&(q($,!1),$.strm.avail_out===0))return D}return $.insert=0,z===g?(q($,!0),$.strm.avail_out===0?G:V):($.strstart>$.block_start&&(q($,!1),$.strm.avail_out),D)}),new he(4,4,8,4,ve),new he(4,5,16,8,ve),new he(4,6,32,32,ve),new he(4,4,16,16,Pe),new he(8,16,32,32,Pe),new he(8,16,128,128,Pe),new he(8,32,128,256,Pe),new he(32,128,258,1024,Pe),new he(32,258,258,4096,Pe)],i.deflateInit=function($,z){return lt($,z,M,15,8,0)},i.deflateInit2=lt,i.deflateReset=de,i.deflateResetKeep=Le,i.deflateSetHeader=function($,z){return $&&$.state?$.state.wrap!==2?b:($.state.gzhead=z,m):b},i.deflate=function($,z){var ne,K,Q,oe;if(!$||!$.state||5<z||z<0)return $?Z($,b):b;if(K=$.state,!$.output||!$.input&&$.avail_in!==0||K.status===666&&z!==g)return Z($,$.avail_out===0?-5:b);if(K.strm=$,ne=K.last_flush,K.last_flush=z,K.status===I)if(K.wrap===2)$.adler=0,ae(K,31),ae(K,139),ae(K,8),K.gzhead?(ae(K,(K.gzhead.text?1:0)+(K.gzhead.hcrc?2:0)+(K.gzhead.extra?4:0)+(K.gzhead.name?8:0)+(K.gzhead.comment?16:0)),ae(K,255&K.gzhead.time),ae(K,K.gzhead.time>>8&255),ae(K,K.gzhead.time>>16&255),ae(K,K.gzhead.time>>24&255),ae(K,K.level===9?2:2<=K.strategy||K.level<2?4:0),ae(K,255&K.gzhead.os),K.gzhead.extra&&K.gzhead.extra.length&&(ae(K,255&K.gzhead.extra.length),ae(K,K.gzhead.extra.length>>8&255)),K.gzhead.hcrc&&($.adler=c($.adler,K.pending_buf,K.pending,0)),K.gzindex=0,K.status=69):(ae(K,0),ae(K,0),ae(K,0),ae(K,0),ae(K,0),ae(K,K.level===9?2:2<=K.strategy||K.level<2?4:0),ae(K,3),K.status=W);else{var Ne=M+(K.w_bits-8<<4)<<8;Ne|=(2<=K.strategy||K.level<2?0:K.level<6?1:K.level===6?2:3)<<6,K.strstart!==0&&(Ne|=32),Ne+=31-Ne%31,K.status=W,ce(K,Ne),K.strstart!==0&&(ce(K,$.adler>>>16),ce(K,65535&$.adler)),$.adler=1}if(K.status===69)if(K.gzhead.extra){for(Q=K.pending;K.gzindex<(65535&K.gzhead.extra.length)&&(K.pending!==K.pending_buf_size||(K.gzhead.hcrc&&K.pending>Q&&($.adler=c($.adler,K.pending_buf,K.pending-Q,Q)),H($),Q=K.pending,K.pending!==K.pending_buf_size));)ae(K,255&K.gzhead.extra[K.gzindex]),K.gzindex++;K.gzhead.hcrc&&K.pending>Q&&($.adler=c($.adler,K.pending_buf,K.pending-Q,Q)),K.gzindex===K.gzhead.extra.length&&(K.gzindex=0,K.status=73)}else K.status=73;if(K.status===73)if(K.gzhead.name){Q=K.pending;do{if(K.pending===K.pending_buf_size&&(K.gzhead.hcrc&&K.pending>Q&&($.adler=c($.adler,K.pending_buf,K.pending-Q,Q)),H($),Q=K.pending,K.pending===K.pending_buf_size)){oe=1;break}oe=K.gzindex<K.gzhead.name.length?255&K.gzhead.name.charCodeAt(K.gzindex++):0,ae(K,oe)}while(oe!==0);K.gzhead.hcrc&&K.pending>Q&&($.adler=c($.adler,K.pending_buf,K.pending-Q,Q)),oe===0&&(K.gzindex=0,K.status=91)}else K.status=91;if(K.status===91)if(K.gzhead.comment){Q=K.pending;do{if(K.pending===K.pending_buf_size&&(K.gzhead.hcrc&&K.pending>Q&&($.adler=c($.adler,K.pending_buf,K.pending-Q,Q)),H($),Q=K.pending,K.pending===K.pending_buf_size)){oe=1;break}oe=K.gzindex<K.gzhead.comment.length?255&K.gzhead.comment.charCodeAt(K.gzindex++):0,ae(K,oe)}while(oe!==0);K.gzhead.hcrc&&K.pending>Q&&($.adler=c($.adler,K.pending_buf,K.pending-Q,Q)),oe===0&&(K.status=103)}else K.status=103;if(K.status===103&&(K.gzhead.hcrc?(K.pending+2>K.pending_buf_size&&H($),K.pending+2<=K.pending_buf_size&&(ae(K,255&$.adler),ae(K,$.adler>>8&255),$.adler=0,K.status=W)):K.status=W),K.pending!==0){if(H($),$.avail_out===0)return K.last_flush=-1,m}else if($.avail_in===0&&Y(z)<=Y(ne)&&z!==g)return Z($,-5);if(K.status===666&&$.avail_in!==0)return Z($,-5);if($.avail_in!==0||K.lookahead!==0||z!==h&&K.status!==666){var Ee=K.strategy===2?(function(re,U){for(var L;;){if(re.lookahead===0&&(ie(re),re.lookahead===0)){if(U===h)return D;break}if(re.match_length=0,L=o._tr_tally(re,0,re.window[re.strstart]),re.lookahead--,re.strstart++,L&&(q(re,!1),re.strm.avail_out===0))return D}return re.insert=0,U===g?(q(re,!0),re.strm.avail_out===0?G:V):re.last_lit&&(q(re,!1),re.strm.avail_out===0)?D:B})(K,z):K.strategy===3?(function(re,U){for(var L,J,ge,ye,me=re.window;;){if(re.lookahead<=k){if(ie(re),re.lookahead<=k&&U===h)return D;if(re.lookahead===0)break}if(re.match_length=0,re.lookahead>=N&&0<re.strstart&&(J=me[ge=re.strstart-1])===me[++ge]&&J===me[++ge]&&J===me[++ge]){ye=re.strstart+k;do;while(J===me[++ge]&&J===me[++ge]&&J===me[++ge]&&J===me[++ge]&&J===me[++ge]&&J===me[++ge]&&J===me[++ge]&&J===me[++ge]&&ge<ye);re.match_length=k-(ye-ge),re.match_length>re.lookahead&&(re.match_length=re.lookahead)}if(re.match_length>=N?(L=o._tr_tally(re,1,re.match_length-N),re.lookahead-=re.match_length,re.strstart+=re.match_length,re.match_length=0):(L=o._tr_tally(re,0,re.window[re.strstart]),re.lookahead--,re.strstart++),L&&(q(re,!1),re.strm.avail_out===0))return D}return re.insert=0,U===g?(q(re,!0),re.strm.avail_out===0?G:V):re.last_lit&&(q(re,!1),re.strm.avail_out===0)?D:B})(K,z):a[K.level].func(K,z);if(Ee!==G&&Ee!==V||(K.status=666),Ee===D||Ee===G)return $.avail_out===0&&(K.last_flush=-1),m;if(Ee===B&&(z===1?o._tr_align(K):z!==5&&(o._tr_stored_block(K,0,0,!1),z===3&&(ee(K.head),K.lookahead===0&&(K.strstart=0,K.block_start=0,K.insert=0))),H($),$.avail_out===0))return K.last_flush=-1,m}return z!==g?m:K.wrap<=0?1:(K.wrap===2?(ae(K,255&$.adler),ae(K,$.adler>>8&255),ae(K,$.adler>>16&255),ae(K,$.adler>>24&255),ae(K,255&$.total_in),ae(K,$.total_in>>8&255),ae(K,$.total_in>>16&255),ae(K,$.total_in>>24&255)):(ce(K,$.adler>>>16),ce(K,65535&$.adler)),H($),0<K.wrap&&(K.wrap=-K.wrap),K.pending!==0?m:1)},i.deflateEnd=function($){var z;return $&&$.state?(z=$.state.status)!==I&&z!==69&&z!==73&&z!==91&&z!==103&&z!==W&&z!==666?Z($,b):($.state=null,z===W?Z($,-3):m):b},i.deflateSetDictionary=function($,z){var ne,K,Q,oe,Ne,Ee,re,U,L=z.length;if(!$||!$.state||(oe=(ne=$.state).wrap)===2||oe===1&&ne.status!==I||ne.lookahead)return b;for(oe===1&&($.adler=l($.adler,z,L,0)),ne.wrap=0,L>=ne.w_size&&(oe===0&&(ee(ne.head),ne.strstart=0,ne.block_start=0,ne.insert=0),U=new s.Buf8(ne.w_size),s.arraySet(U,z,L-ne.w_size,ne.w_size,0),z=U,L=ne.w_size),Ne=$.avail_in,Ee=$.next_in,re=$.input,$.avail_in=L,$.next_in=0,$.input=z,ie(ne);ne.lookahead>=N;){for(K=ne.strstart,Q=ne.lookahead-(N-1);ne.ins_h=(ne.ins_h<<ne.hash_shift^ne.window[K+N-1])&ne.hash_mask,ne.prev[K&ne.w_mask]=ne.head[ne.ins_h],ne.head[ne.ins_h]=K,K++,--Q;);ne.strstart=K,ne.lookahead=N-1,ie(ne)}return ne.strstart+=ne.lookahead,ne.block_start=ne.strstart,ne.insert=ne.lookahead,ne.lookahead=0,ne.match_length=ne.prev_length=N-1,ne.match_available=0,$.next_in=Ee,$.input=re,$.avail_in=Ne,ne.wrap=oe,m},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(a,s){var o,l,c,u,h,g,m,b,y,v,x,M,w,C,T,R,A,j,N,k,F,I,W,D,B;o=a.state,l=a.next_in,D=a.input,c=l+(a.avail_in-5),u=a.next_out,B=a.output,h=u-(s-a.avail_out),g=u+(a.avail_out-257),m=o.dmax,b=o.wsize,y=o.whave,v=o.wnext,x=o.window,M=o.hold,w=o.bits,C=o.lencode,T=o.distcode,R=(1<<o.lenbits)-1,A=(1<<o.distbits)-1;e:do{w<15&&(M+=D[l++]<<w,w+=8,M+=D[l++]<<w,w+=8),j=C[M&R];t:for(;;){if(M>>>=N=j>>>24,w-=N,(N=j>>>16&255)===0)B[u++]=65535&j;else{if(!(16&N)){if((64&N)==0){j=C[(65535&j)+(M&(1<<N)-1)];continue t}if(32&N){o.mode=12;break e}a.msg="invalid literal/length code",o.mode=30;break e}k=65535&j,(N&=15)&&(w<N&&(M+=D[l++]<<w,w+=8),k+=M&(1<<N)-1,M>>>=N,w-=N),w<15&&(M+=D[l++]<<w,w+=8,M+=D[l++]<<w,w+=8),j=T[M&A];n:for(;;){if(M>>>=N=j>>>24,w-=N,!(16&(N=j>>>16&255))){if((64&N)==0){j=T[(65535&j)+(M&(1<<N)-1)];continue n}a.msg="invalid distance code",o.mode=30;break e}if(F=65535&j,w<(N&=15)&&(M+=D[l++]<<w,(w+=8)<N&&(M+=D[l++]<<w,w+=8)),m<(F+=M&(1<<N)-1)){a.msg="invalid distance too far back",o.mode=30;break e}if(M>>>=N,w-=N,(N=u-h)<F){if(y<(N=F-N)&&o.sane){a.msg="invalid distance too far back",o.mode=30;break e}if(W=x,(I=0)===v){if(I+=b-N,N<k){for(k-=N;B[u++]=x[I++],--N;);I=u-F,W=B}}else if(v<N){if(I+=b+v-N,(N-=v)<k){for(k-=N;B[u++]=x[I++],--N;);if(I=0,v<k){for(k-=N=v;B[u++]=x[I++],--N;);I=u-F,W=B}}}else if(I+=v-N,N<k){for(k-=N;B[u++]=x[I++],--N;);I=u-F,W=B}for(;2<k;)B[u++]=W[I++],B[u++]=W[I++],B[u++]=W[I++],k-=3;k&&(B[u++]=W[I++],1<k&&(B[u++]=W[I++]))}else{for(I=u-F;B[u++]=B[I++],B[u++]=B[I++],B[u++]=B[I++],2<(k-=3););k&&(B[u++]=B[I++],1<k&&(B[u++]=B[I++]))}break}}break}}while(l<c&&u<g);l-=k=w>>3,M&=(1<<(w-=k<<3))-1,a.next_in=l,a.next_out=u,a.avail_in=l<c?c-l+5:5-(l-c),a.avail_out=u<g?g-u+257:257-(u-g),o.hold=M,o.bits=w}},{}],49:[function(n,r,i){var a=n("../utils/common"),s=n("./adler32"),o=n("./crc32"),l=n("./inffast"),c=n("./inftrees"),u=1,h=2,g=0,m=-2,b=1,y=852,v=592;function x(I){return(I>>>24&255)+(I>>>8&65280)+((65280&I)<<8)+((255&I)<<24)}function M(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(I){var W;return I&&I.state?(W=I.state,I.total_in=I.total_out=W.total=0,I.msg="",W.wrap&&(I.adler=1&W.wrap),W.mode=b,W.last=0,W.havedict=0,W.dmax=32768,W.head=null,W.hold=0,W.bits=0,W.lencode=W.lendyn=new a.Buf32(y),W.distcode=W.distdyn=new a.Buf32(v),W.sane=1,W.back=-1,g):m}function C(I){var W;return I&&I.state?((W=I.state).wsize=0,W.whave=0,W.wnext=0,w(I)):m}function T(I,W){var D,B;return I&&I.state?(B=I.state,W<0?(D=0,W=-W):(D=1+(W>>4),W<48&&(W&=15)),W&&(W<8||15<W)?m:(B.window!==null&&B.wbits!==W&&(B.window=null),B.wrap=D,B.wbits=W,C(I))):m}function R(I,W){var D,B;return I?(B=new M,(I.state=B).window=null,(D=T(I,W))!==g&&(I.state=null),D):m}var A,j,N=!0;function k(I){if(N){var W;for(A=new a.Buf32(512),j=new a.Buf32(32),W=0;W<144;)I.lens[W++]=8;for(;W<256;)I.lens[W++]=9;for(;W<280;)I.lens[W++]=7;for(;W<288;)I.lens[W++]=8;for(c(u,I.lens,0,288,A,0,I.work,{bits:9}),W=0;W<32;)I.lens[W++]=5;c(h,I.lens,0,32,j,0,I.work,{bits:5}),N=!1}I.lencode=A,I.lenbits=9,I.distcode=j,I.distbits=5}function F(I,W,D,B){var G,V=I.state;return V.window===null&&(V.wsize=1<<V.wbits,V.wnext=0,V.whave=0,V.window=new a.Buf8(V.wsize)),B>=V.wsize?(a.arraySet(V.window,W,D-V.wsize,V.wsize,0),V.wnext=0,V.whave=V.wsize):(B<(G=V.wsize-V.wnext)&&(G=B),a.arraySet(V.window,W,D-B,G,V.wnext),(B-=G)?(a.arraySet(V.window,W,D-B,B,0),V.wnext=B,V.whave=V.wsize):(V.wnext+=G,V.wnext===V.wsize&&(V.wnext=0),V.whave<V.wsize&&(V.whave+=G))),0}i.inflateReset=C,i.inflateReset2=T,i.inflateResetKeep=w,i.inflateInit=function(I){return R(I,15)},i.inflateInit2=R,i.inflate=function(I,W){var D,B,G,V,Z,Y,ee,H,q,ae,ce,xe,ie,ve,Pe,he,we,Le,de,lt,$,z,ne,K,Q=0,oe=new a.Buf8(4),Ne=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!I||!I.state||!I.output||!I.input&&I.avail_in!==0)return m;(D=I.state).mode===12&&(D.mode=13),Z=I.next_out,G=I.output,ee=I.avail_out,V=I.next_in,B=I.input,Y=I.avail_in,H=D.hold,q=D.bits,ae=Y,ce=ee,z=g;e:for(;;)switch(D.mode){case b:if(D.wrap===0){D.mode=13;break}for(;q<16;){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}if(2&D.wrap&&H===35615){oe[D.check=0]=255&H,oe[1]=H>>>8&255,D.check=o(D.check,oe,2,0),q=H=0,D.mode=2;break}if(D.flags=0,D.head&&(D.head.done=!1),!(1&D.wrap)||(((255&H)<<8)+(H>>8))%31){I.msg="incorrect header check",D.mode=30;break}if((15&H)!=8){I.msg="unknown compression method",D.mode=30;break}if(q-=4,$=8+(15&(H>>>=4)),D.wbits===0)D.wbits=$;else if($>D.wbits){I.msg="invalid window size",D.mode=30;break}D.dmax=1<<$,I.adler=D.check=1,D.mode=512&H?10:12,q=H=0;break;case 2:for(;q<16;){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}if(D.flags=H,(255&D.flags)!=8){I.msg="unknown compression method",D.mode=30;break}if(57344&D.flags){I.msg="unknown header flags set",D.mode=30;break}D.head&&(D.head.text=H>>8&1),512&D.flags&&(oe[0]=255&H,oe[1]=H>>>8&255,D.check=o(D.check,oe,2,0)),q=H=0,D.mode=3;case 3:for(;q<32;){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}D.head&&(D.head.time=H),512&D.flags&&(oe[0]=255&H,oe[1]=H>>>8&255,oe[2]=H>>>16&255,oe[3]=H>>>24&255,D.check=o(D.check,oe,4,0)),q=H=0,D.mode=4;case 4:for(;q<16;){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}D.head&&(D.head.xflags=255&H,D.head.os=H>>8),512&D.flags&&(oe[0]=255&H,oe[1]=H>>>8&255,D.check=o(D.check,oe,2,0)),q=H=0,D.mode=5;case 5:if(1024&D.flags){for(;q<16;){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}D.length=H,D.head&&(D.head.extra_len=H),512&D.flags&&(oe[0]=255&H,oe[1]=H>>>8&255,D.check=o(D.check,oe,2,0)),q=H=0}else D.head&&(D.head.extra=null);D.mode=6;case 6:if(1024&D.flags&&(Y<(xe=D.length)&&(xe=Y),xe&&(D.head&&($=D.head.extra_len-D.length,D.head.extra||(D.head.extra=new Array(D.head.extra_len)),a.arraySet(D.head.extra,B,V,xe,$)),512&D.flags&&(D.check=o(D.check,B,xe,V)),Y-=xe,V+=xe,D.length-=xe),D.length))break e;D.length=0,D.mode=7;case 7:if(2048&D.flags){if(Y===0)break e;for(xe=0;$=B[V+xe++],D.head&&$&&D.length<65536&&(D.head.name+=String.fromCharCode($)),$&&xe<Y;);if(512&D.flags&&(D.check=o(D.check,B,xe,V)),Y-=xe,V+=xe,$)break e}else D.head&&(D.head.name=null);D.length=0,D.mode=8;case 8:if(4096&D.flags){if(Y===0)break e;for(xe=0;$=B[V+xe++],D.head&&$&&D.length<65536&&(D.head.comment+=String.fromCharCode($)),$&&xe<Y;);if(512&D.flags&&(D.check=o(D.check,B,xe,V)),Y-=xe,V+=xe,$)break e}else D.head&&(D.head.comment=null);D.mode=9;case 9:if(512&D.flags){for(;q<16;){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}if(H!==(65535&D.check)){I.msg="header crc mismatch",D.mode=30;break}q=H=0}D.head&&(D.head.hcrc=D.flags>>9&1,D.head.done=!0),I.adler=D.check=0,D.mode=12;break;case 10:for(;q<32;){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}I.adler=D.check=x(H),q=H=0,D.mode=11;case 11:if(D.havedict===0)return I.next_out=Z,I.avail_out=ee,I.next_in=V,I.avail_in=Y,D.hold=H,D.bits=q,2;I.adler=D.check=1,D.mode=12;case 12:if(W===5||W===6)break e;case 13:if(D.last){H>>>=7&q,q-=7&q,D.mode=27;break}for(;q<3;){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}switch(D.last=1&H,q-=1,3&(H>>>=1)){case 0:D.mode=14;break;case 1:if(k(D),D.mode=20,W!==6)break;H>>>=2,q-=2;break e;case 2:D.mode=17;break;case 3:I.msg="invalid block type",D.mode=30}H>>>=2,q-=2;break;case 14:for(H>>>=7&q,q-=7&q;q<32;){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}if((65535&H)!=(H>>>16^65535)){I.msg="invalid stored block lengths",D.mode=30;break}if(D.length=65535&H,q=H=0,D.mode=15,W===6)break e;case 15:D.mode=16;case 16:if(xe=D.length){if(Y<xe&&(xe=Y),ee<xe&&(xe=ee),xe===0)break e;a.arraySet(G,B,V,xe,Z),Y-=xe,V+=xe,ee-=xe,Z+=xe,D.length-=xe;break}D.mode=12;break;case 17:for(;q<14;){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}if(D.nlen=257+(31&H),H>>>=5,q-=5,D.ndist=1+(31&H),H>>>=5,q-=5,D.ncode=4+(15&H),H>>>=4,q-=4,286<D.nlen||30<D.ndist){I.msg="too many length or distance symbols",D.mode=30;break}D.have=0,D.mode=18;case 18:for(;D.have<D.ncode;){for(;q<3;){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}D.lens[Ne[D.have++]]=7&H,H>>>=3,q-=3}for(;D.have<19;)D.lens[Ne[D.have++]]=0;if(D.lencode=D.lendyn,D.lenbits=7,ne={bits:D.lenbits},z=c(0,D.lens,0,19,D.lencode,0,D.work,ne),D.lenbits=ne.bits,z){I.msg="invalid code lengths set",D.mode=30;break}D.have=0,D.mode=19;case 19:for(;D.have<D.nlen+D.ndist;){for(;he=(Q=D.lencode[H&(1<<D.lenbits)-1])>>>16&255,we=65535&Q,!((Pe=Q>>>24)<=q);){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}if(we<16)H>>>=Pe,q-=Pe,D.lens[D.have++]=we;else{if(we===16){for(K=Pe+2;q<K;){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}if(H>>>=Pe,q-=Pe,D.have===0){I.msg="invalid bit length repeat",D.mode=30;break}$=D.lens[D.have-1],xe=3+(3&H),H>>>=2,q-=2}else if(we===17){for(K=Pe+3;q<K;){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}q-=Pe,$=0,xe=3+(7&(H>>>=Pe)),H>>>=3,q-=3}else{for(K=Pe+7;q<K;){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}q-=Pe,$=0,xe=11+(127&(H>>>=Pe)),H>>>=7,q-=7}if(D.have+xe>D.nlen+D.ndist){I.msg="invalid bit length repeat",D.mode=30;break}for(;xe--;)D.lens[D.have++]=$}}if(D.mode===30)break;if(D.lens[256]===0){I.msg="invalid code -- missing end-of-block",D.mode=30;break}if(D.lenbits=9,ne={bits:D.lenbits},z=c(u,D.lens,0,D.nlen,D.lencode,0,D.work,ne),D.lenbits=ne.bits,z){I.msg="invalid literal/lengths set",D.mode=30;break}if(D.distbits=6,D.distcode=D.distdyn,ne={bits:D.distbits},z=c(h,D.lens,D.nlen,D.ndist,D.distcode,0,D.work,ne),D.distbits=ne.bits,z){I.msg="invalid distances set",D.mode=30;break}if(D.mode=20,W===6)break e;case 20:D.mode=21;case 21:if(6<=Y&&258<=ee){I.next_out=Z,I.avail_out=ee,I.next_in=V,I.avail_in=Y,D.hold=H,D.bits=q,l(I,ce),Z=I.next_out,G=I.output,ee=I.avail_out,V=I.next_in,B=I.input,Y=I.avail_in,H=D.hold,q=D.bits,D.mode===12&&(D.back=-1);break}for(D.back=0;he=(Q=D.lencode[H&(1<<D.lenbits)-1])>>>16&255,we=65535&Q,!((Pe=Q>>>24)<=q);){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}if(he&&(240&he)==0){for(Le=Pe,de=he,lt=we;he=(Q=D.lencode[lt+((H&(1<<Le+de)-1)>>Le)])>>>16&255,we=65535&Q,!(Le+(Pe=Q>>>24)<=q);){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}H>>>=Le,q-=Le,D.back+=Le}if(H>>>=Pe,q-=Pe,D.back+=Pe,D.length=we,he===0){D.mode=26;break}if(32&he){D.back=-1,D.mode=12;break}if(64&he){I.msg="invalid literal/length code",D.mode=30;break}D.extra=15&he,D.mode=22;case 22:if(D.extra){for(K=D.extra;q<K;){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}D.length+=H&(1<<D.extra)-1,H>>>=D.extra,q-=D.extra,D.back+=D.extra}D.was=D.length,D.mode=23;case 23:for(;he=(Q=D.distcode[H&(1<<D.distbits)-1])>>>16&255,we=65535&Q,!((Pe=Q>>>24)<=q);){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}if((240&he)==0){for(Le=Pe,de=he,lt=we;he=(Q=D.distcode[lt+((H&(1<<Le+de)-1)>>Le)])>>>16&255,we=65535&Q,!(Le+(Pe=Q>>>24)<=q);){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}H>>>=Le,q-=Le,D.back+=Le}if(H>>>=Pe,q-=Pe,D.back+=Pe,64&he){I.msg="invalid distance code",D.mode=30;break}D.offset=we,D.extra=15&he,D.mode=24;case 24:if(D.extra){for(K=D.extra;q<K;){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}D.offset+=H&(1<<D.extra)-1,H>>>=D.extra,q-=D.extra,D.back+=D.extra}if(D.offset>D.dmax){I.msg="invalid distance too far back",D.mode=30;break}D.mode=25;case 25:if(ee===0)break e;if(xe=ce-ee,D.offset>xe){if((xe=D.offset-xe)>D.whave&&D.sane){I.msg="invalid distance too far back",D.mode=30;break}ie=xe>D.wnext?(xe-=D.wnext,D.wsize-xe):D.wnext-xe,xe>D.length&&(xe=D.length),ve=D.window}else ve=G,ie=Z-D.offset,xe=D.length;for(ee<xe&&(xe=ee),ee-=xe,D.length-=xe;G[Z++]=ve[ie++],--xe;);D.length===0&&(D.mode=21);break;case 26:if(ee===0)break e;G[Z++]=D.length,ee--,D.mode=21;break;case 27:if(D.wrap){for(;q<32;){if(Y===0)break e;Y--,H|=B[V++]<<q,q+=8}if(ce-=ee,I.total_out+=ce,D.total+=ce,ce&&(I.adler=D.check=D.flags?o(D.check,G,ce,Z-ce):s(D.check,G,ce,Z-ce)),ce=ee,(D.flags?H:x(H))!==D.check){I.msg="incorrect data check",D.mode=30;break}q=H=0}D.mode=28;case 28:if(D.wrap&&D.flags){for(;q<32;){if(Y===0)break e;Y--,H+=B[V++]<<q,q+=8}if(H!==(4294967295&D.total)){I.msg="incorrect length check",D.mode=30;break}q=H=0}D.mode=29;case 29:z=1;break e;case 30:z=-3;break e;case 31:return-4;case 32:default:return m}return I.next_out=Z,I.avail_out=ee,I.next_in=V,I.avail_in=Y,D.hold=H,D.bits=q,(D.wsize||ce!==I.avail_out&&D.mode<30&&(D.mode<27||W!==4))&&F(I,I.output,I.next_out,ce-I.avail_out)?(D.mode=31,-4):(ae-=I.avail_in,ce-=I.avail_out,I.total_in+=ae,I.total_out+=ce,D.total+=ce,D.wrap&&ce&&(I.adler=D.check=D.flags?o(D.check,G,ce,I.next_out-ce):s(D.check,G,ce,I.next_out-ce)),I.data_type=D.bits+(D.last?64:0)+(D.mode===12?128:0)+(D.mode===20||D.mode===15?256:0),(ae==0&&ce===0||W===4)&&z===g&&(z=-5),z)},i.inflateEnd=function(I){if(!I||!I.state)return m;var W=I.state;return W.window&&(W.window=null),I.state=null,g},i.inflateGetHeader=function(I,W){var D;return I&&I.state?(2&(D=I.state).wrap)==0?m:((D.head=W).done=!1,g):m},i.inflateSetDictionary=function(I,W){var D,B=W.length;return I&&I.state?(D=I.state).wrap!==0&&D.mode!==11?m:D.mode===11&&s(1,W,B,0)!==D.check?-3:F(I,W,B,B)?(D.mode=31,-4):(D.havedict=1,g):m},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var a=n("../utils/common"),s=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[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],c=[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(u,h,g,m,b,y,v,x){var M,w,C,T,R,A,j,N,k,F=x.bits,I=0,W=0,D=0,B=0,G=0,V=0,Z=0,Y=0,ee=0,H=0,q=null,ae=0,ce=new a.Buf16(16),xe=new a.Buf16(16),ie=null,ve=0;for(I=0;I<=15;I++)ce[I]=0;for(W=0;W<m;W++)ce[h[g+W]]++;for(G=F,B=15;1<=B&&ce[B]===0;B--);if(B<G&&(G=B),B===0)return b[y++]=20971520,b[y++]=20971520,x.bits=1,0;for(D=1;D<B&&ce[D]===0;D++);for(G<D&&(G=D),I=Y=1;I<=15;I++)if(Y<<=1,(Y-=ce[I])<0)return-1;if(0<Y&&(u===0||B!==1))return-1;for(xe[1]=0,I=1;I<15;I++)xe[I+1]=xe[I]+ce[I];for(W=0;W<m;W++)h[g+W]!==0&&(v[xe[h[g+W]]++]=W);if(A=u===0?(q=ie=v,19):u===1?(q=s,ae-=257,ie=o,ve-=257,256):(q=l,ie=c,-1),I=D,R=y,Z=W=H=0,C=-1,T=(ee=1<<(V=G))-1,u===1&&852<ee||u===2&&592<ee)return 1;for(;;){for(j=I-Z,k=v[W]<A?(N=0,v[W]):v[W]>A?(N=ie[ve+v[W]],q[ae+v[W]]):(N=96,0),M=1<<I-Z,D=w=1<<V;b[R+(H>>Z)+(w-=M)]=j<<24|N<<16|k|0,w!==0;);for(M=1<<I-1;H&M;)M>>=1;if(M!==0?(H&=M-1,H+=M):H=0,W++,--ce[I]==0){if(I===B)break;I=h[g+v[W]]}if(G<I&&(H&T)!==C){for(Z===0&&(Z=G),R+=D,Y=1<<(V=I-Z);V+Z<B&&!((Y-=ce[V+Z])<=0);)V++,Y<<=1;if(ee+=1<<V,u===1&&852<ee||u===2&&592<ee)return 1;b[C=H&T]=G<<24|V<<16|R-y|0}}return H!==0&&(b[R+H]=I-Z<<24|64<<16|0),x.bits=G,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var a=n("../utils/common"),s=0,o=1;function l(Q){for(var oe=Q.length;0<=--oe;)Q[oe]=0}var c=0,u=29,h=256,g=h+1+u,m=30,b=19,y=2*g+1,v=15,x=16,M=7,w=256,C=16,T=17,R=18,A=[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],j=[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],N=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],k=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],F=new Array(2*(g+2));l(F);var I=new Array(2*m);l(I);var W=new Array(512);l(W);var D=new Array(256);l(D);var B=new Array(u);l(B);var G,V,Z,Y=new Array(m);function ee(Q,oe,Ne,Ee,re){this.static_tree=Q,this.extra_bits=oe,this.extra_base=Ne,this.elems=Ee,this.max_length=re,this.has_stree=Q&&Q.length}function H(Q,oe){this.dyn_tree=Q,this.max_code=0,this.stat_desc=oe}function q(Q){return Q<256?W[Q]:W[256+(Q>>>7)]}function ae(Q,oe){Q.pending_buf[Q.pending++]=255&oe,Q.pending_buf[Q.pending++]=oe>>>8&255}function ce(Q,oe,Ne){Q.bi_valid>x-Ne?(Q.bi_buf|=oe<<Q.bi_valid&65535,ae(Q,Q.bi_buf),Q.bi_buf=oe>>x-Q.bi_valid,Q.bi_valid+=Ne-x):(Q.bi_buf|=oe<<Q.bi_valid&65535,Q.bi_valid+=Ne)}function xe(Q,oe,Ne){ce(Q,Ne[2*oe],Ne[2*oe+1])}function ie(Q,oe){for(var Ne=0;Ne|=1&Q,Q>>>=1,Ne<<=1,0<--oe;);return Ne>>>1}function ve(Q,oe,Ne){var Ee,re,U=new Array(v+1),L=0;for(Ee=1;Ee<=v;Ee++)U[Ee]=L=L+Ne[Ee-1]<<1;for(re=0;re<=oe;re++){var J=Q[2*re+1];J!==0&&(Q[2*re]=ie(U[J]++,J))}}function Pe(Q){var oe;for(oe=0;oe<g;oe++)Q.dyn_ltree[2*oe]=0;for(oe=0;oe<m;oe++)Q.dyn_dtree[2*oe]=0;for(oe=0;oe<b;oe++)Q.bl_tree[2*oe]=0;Q.dyn_ltree[2*w]=1,Q.opt_len=Q.static_len=0,Q.last_lit=Q.matches=0}function he(Q){8<Q.bi_valid?ae(Q,Q.bi_buf):0<Q.bi_valid&&(Q.pending_buf[Q.pending++]=Q.bi_buf),Q.bi_buf=0,Q.bi_valid=0}function we(Q,oe,Ne,Ee){var re=2*oe,U=2*Ne;return Q[re]<Q[U]||Q[re]===Q[U]&&Ee[oe]<=Ee[Ne]}function Le(Q,oe,Ne){for(var Ee=Q.heap[Ne],re=Ne<<1;re<=Q.heap_len&&(re<Q.heap_len&&we(oe,Q.heap[re+1],Q.heap[re],Q.depth)&&re++,!we(oe,Ee,Q.heap[re],Q.depth));)Q.heap[Ne]=Q.heap[re],Ne=re,re<<=1;Q.heap[Ne]=Ee}function de(Q,oe,Ne){var Ee,re,U,L,J=0;if(Q.last_lit!==0)for(;Ee=Q.pending_buf[Q.d_buf+2*J]<<8|Q.pending_buf[Q.d_buf+2*J+1],re=Q.pending_buf[Q.l_buf+J],J++,Ee===0?xe(Q,re,oe):(xe(Q,(U=D[re])+h+1,oe),(L=A[U])!==0&&ce(Q,re-=B[U],L),xe(Q,U=q(--Ee),Ne),(L=j[U])!==0&&ce(Q,Ee-=Y[U],L)),J<Q.last_lit;);xe(Q,w,oe)}function lt(Q,oe){var Ne,Ee,re,U=oe.dyn_tree,L=oe.stat_desc.static_tree,J=oe.stat_desc.has_stree,ge=oe.stat_desc.elems,ye=-1;for(Q.heap_len=0,Q.heap_max=y,Ne=0;Ne<ge;Ne++)U[2*Ne]!==0?(Q.heap[++Q.heap_len]=ye=Ne,Q.depth[Ne]=0):U[2*Ne+1]=0;for(;Q.heap_len<2;)U[2*(re=Q.heap[++Q.heap_len]=ye<2?++ye:0)]=1,Q.depth[re]=0,Q.opt_len--,J&&(Q.static_len-=L[2*re+1]);for(oe.max_code=ye,Ne=Q.heap_len>>1;1<=Ne;Ne--)Le(Q,U,Ne);for(re=ge;Ne=Q.heap[1],Q.heap[1]=Q.heap[Q.heap_len--],Le(Q,U,1),Ee=Q.heap[1],Q.heap[--Q.heap_max]=Ne,Q.heap[--Q.heap_max]=Ee,U[2*re]=U[2*Ne]+U[2*Ee],Q.depth[re]=(Q.depth[Ne]>=Q.depth[Ee]?Q.depth[Ne]:Q.depth[Ee])+1,U[2*Ne+1]=U[2*Ee+1]=re,Q.heap[1]=re++,Le(Q,U,1),2<=Q.heap_len;);Q.heap[--Q.heap_max]=Q.heap[1],(function(me,et){var Ie,Ke,st,je,le,Ze,Fe=et.dyn_tree,Xe=et.max_code,ct=et.stat_desc.static_tree,ue=et.stat_desc.has_stree,Qe=et.stat_desc.extra_bits,pe=et.stat_desc.extra_base,Oe=et.stat_desc.max_length,Ae=0;for(je=0;je<=v;je++)me.bl_count[je]=0;for(Fe[2*me.heap[me.heap_max]+1]=0,Ie=me.heap_max+1;Ie<y;Ie++)Oe<(je=Fe[2*Fe[2*(Ke=me.heap[Ie])+1]+1]+1)&&(je=Oe,Ae++),Fe[2*Ke+1]=je,Xe<Ke||(me.bl_count[je]++,le=0,pe<=Ke&&(le=Qe[Ke-pe]),Ze=Fe[2*Ke],me.opt_len+=Ze*(je+le),ue&&(me.static_len+=Ze*(ct[2*Ke+1]+le)));if(Ae!==0){do{for(je=Oe-1;me.bl_count[je]===0;)je--;me.bl_count[je]--,me.bl_count[je+1]+=2,me.bl_count[Oe]--,Ae-=2}while(0<Ae);for(je=Oe;je!==0;je--)for(Ke=me.bl_count[je];Ke!==0;)Xe<(st=me.heap[--Ie])||(Fe[2*st+1]!==je&&(me.opt_len+=(je-Fe[2*st+1])*Fe[2*st],Fe[2*st+1]=je),Ke--)}})(Q,oe),ve(U,ye,Q.bl_count)}function $(Q,oe,Ne){var Ee,re,U=-1,L=oe[1],J=0,ge=7,ye=4;for(L===0&&(ge=138,ye=3),oe[2*(Ne+1)+1]=65535,Ee=0;Ee<=Ne;Ee++)re=L,L=oe[2*(Ee+1)+1],++J<ge&&re===L||(J<ye?Q.bl_tree[2*re]+=J:re!==0?(re!==U&&Q.bl_tree[2*re]++,Q.bl_tree[2*C]++):J<=10?Q.bl_tree[2*T]++:Q.bl_tree[2*R]++,U=re,ye=(J=0)===L?(ge=138,3):re===L?(ge=6,3):(ge=7,4))}function z(Q,oe,Ne){var Ee,re,U=-1,L=oe[1],J=0,ge=7,ye=4;for(L===0&&(ge=138,ye=3),Ee=0;Ee<=Ne;Ee++)if(re=L,L=oe[2*(Ee+1)+1],!(++J<ge&&re===L)){if(J<ye)for(;xe(Q,re,Q.bl_tree),--J!=0;);else re!==0?(re!==U&&(xe(Q,re,Q.bl_tree),J--),xe(Q,C,Q.bl_tree),ce(Q,J-3,2)):J<=10?(xe(Q,T,Q.bl_tree),ce(Q,J-3,3)):(xe(Q,R,Q.bl_tree),ce(Q,J-11,7));U=re,ye=(J=0)===L?(ge=138,3):re===L?(ge=6,3):(ge=7,4)}}l(Y);var ne=!1;function K(Q,oe,Ne,Ee){ce(Q,(c<<1)+(Ee?1:0),3),(function(re,U,L,J){he(re),ae(re,L),ae(re,~L),a.arraySet(re.pending_buf,re.window,U,L,re.pending),re.pending+=L})(Q,oe,Ne)}i._tr_init=function(Q){ne||((function(){var oe,Ne,Ee,re,U,L=new Array(v+1);for(re=Ee=0;re<u-1;re++)for(B[re]=Ee,oe=0;oe<1<<A[re];oe++)D[Ee++]=re;for(D[Ee-1]=re,re=U=0;re<16;re++)for(Y[re]=U,oe=0;oe<1<<j[re];oe++)W[U++]=re;for(U>>=7;re<m;re++)for(Y[re]=U<<7,oe=0;oe<1<<j[re]-7;oe++)W[256+U++]=re;for(Ne=0;Ne<=v;Ne++)L[Ne]=0;for(oe=0;oe<=143;)F[2*oe+1]=8,oe++,L[8]++;for(;oe<=255;)F[2*oe+1]=9,oe++,L[9]++;for(;oe<=279;)F[2*oe+1]=7,oe++,L[7]++;for(;oe<=287;)F[2*oe+1]=8,oe++,L[8]++;for(ve(F,g+1,L),oe=0;oe<m;oe++)I[2*oe+1]=5,I[2*oe]=ie(oe,5);G=new ee(F,A,h+1,g,v),V=new ee(I,j,0,m,v),Z=new ee(new Array(0),N,0,b,M)})(),ne=!0),Q.l_desc=new H(Q.dyn_ltree,G),Q.d_desc=new H(Q.dyn_dtree,V),Q.bl_desc=new H(Q.bl_tree,Z),Q.bi_buf=0,Q.bi_valid=0,Pe(Q)},i._tr_stored_block=K,i._tr_flush_block=function(Q,oe,Ne,Ee){var re,U,L=0;0<Q.level?(Q.strm.data_type===2&&(Q.strm.data_type=(function(J){var ge,ye=4093624447;for(ge=0;ge<=31;ge++,ye>>>=1)if(1&ye&&J.dyn_ltree[2*ge]!==0)return s;if(J.dyn_ltree[18]!==0||J.dyn_ltree[20]!==0||J.dyn_ltree[26]!==0)return o;for(ge=32;ge<h;ge++)if(J.dyn_ltree[2*ge]!==0)return o;return s})(Q)),lt(Q,Q.l_desc),lt(Q,Q.d_desc),L=(function(J){var ge;for($(J,J.dyn_ltree,J.l_desc.max_code),$(J,J.dyn_dtree,J.d_desc.max_code),lt(J,J.bl_desc),ge=b-1;3<=ge&&J.bl_tree[2*k[ge]+1]===0;ge--);return J.opt_len+=3*(ge+1)+5+5+4,ge})(Q),re=Q.opt_len+3+7>>>3,(U=Q.static_len+3+7>>>3)<=re&&(re=U)):re=U=Ne+5,Ne+4<=re&&oe!==-1?K(Q,oe,Ne,Ee):Q.strategy===4||U===re?(ce(Q,2+(Ee?1:0),3),de(Q,F,I)):(ce(Q,4+(Ee?1:0),3),(function(J,ge,ye,me){var et;for(ce(J,ge-257,5),ce(J,ye-1,5),ce(J,me-4,4),et=0;et<me;et++)ce(J,J.bl_tree[2*k[et]+1],3);z(J,J.dyn_ltree,ge-1),z(J,J.dyn_dtree,ye-1)})(Q,Q.l_desc.max_code+1,Q.d_desc.max_code+1,L+1),de(Q,Q.dyn_ltree,Q.dyn_dtree)),Pe(Q),Ee&&he(Q)},i._tr_tally=function(Q,oe,Ne){return Q.pending_buf[Q.d_buf+2*Q.last_lit]=oe>>>8&255,Q.pending_buf[Q.d_buf+2*Q.last_lit+1]=255&oe,Q.pending_buf[Q.l_buf+Q.last_lit]=255&Ne,Q.last_lit++,oe===0?Q.dyn_ltree[2*Ne]++:(Q.matches++,oe--,Q.dyn_ltree[2*(D[Ne]+h+1)]++,Q.dyn_dtree[2*q(oe)]++),Q.last_lit===Q.lit_bufsize-1},i._tr_align=function(Q){ce(Q,2,3),xe(Q,w,F),(function(oe){oe.bi_valid===16?(ae(oe,oe.bi_buf),oe.bi_buf=0,oe.bi_valid=0):8<=oe.bi_valid&&(oe.pending_buf[oe.pending++]=255&oe.bi_buf,oe.bi_buf>>=8,oe.bi_valid-=8)})(Q)}},{"../utils/common":41}],53:[function(n,r,i){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(a){(function(s,o){if(!s.setImmediate){var l,c,u,h,g=1,m={},b=!1,y=s.document,v=Object.getPrototypeOf&&Object.getPrototypeOf(s);v=v&&v.setTimeout?v:s,l={}.toString.call(s.process)==="[object process]"?function(C){process.nextTick(function(){M(C)})}:(function(){if(s.postMessage&&!s.importScripts){var C=!0,T=s.onmessage;return s.onmessage=function(){C=!1},s.postMessage("","*"),s.onmessage=T,C}})()?(h="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",w,!1):s.attachEvent("onmessage",w),function(C){s.postMessage(h+C,"*")}):s.MessageChannel?((u=new MessageChannel).port1.onmessage=function(C){M(C.data)},function(C){u.port2.postMessage(C)}):y&&"onreadystatechange"in y.createElement("script")?(c=y.documentElement,function(C){var T=y.createElement("script");T.onreadystatechange=function(){M(C),T.onreadystatechange=null,c.removeChild(T),T=null},c.appendChild(T)}):function(C){setTimeout(M,0,C)},v.setImmediate=function(C){typeof C!="function"&&(C=new Function(""+C));for(var T=new Array(arguments.length-1),R=0;R<T.length;R++)T[R]=arguments[R+1];var A={callback:C,args:T};return m[g]=A,l(g),g++},v.clearImmediate=x}function x(C){delete m[C]}function M(C){if(b)setTimeout(M,0,C);else{var T=m[C];if(T){b=!0;try{(function(R){var A=R.callback,j=R.args;switch(j.length){case 0:A();break;case 1:A(j[0]);break;case 2:A(j[0],j[1]);break;case 3:A(j[0],j[1],j[2]);break;default:A.apply(o,j)}})(T)}finally{x(C),b=!1}}}}function w(C){C.source===s&&typeof C.data=="string"&&C.data.indexOf(h)===0&&M(+C.data.slice(h.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof Db<"u"?Db:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(yT)),yT.exports}var xge=gge();const vge=Zs(xge);function bge(t){const e=new Xr;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 xz=bge;async function vz(t){const e=[],n=t.getElementsByTagName("mesh");for(let r=0;r<n.length;r++){const i=n[r],a=[],s=[],o=i.getElementsByTagName("vertex");for(let c=0;c<o.length;c++){const u=o[c];a.push(parseFloat(u.getAttribute("x")||"0"),parseFloat(u.getAttribute("y")||"0"),parseFloat(u.getAttribute("z")||"0"))}const l=i.getElementsByTagName("triangle");for(let c=0;c<l.length;c++){const u=l[c];s.push(parseInt(u.getAttribute("v1")||"0"),parseInt(u.getAttribute("v2")||"0"),parseInt(u.getAttribute("v3")||"0"))}a.length>0&&s.length>0&&e.push({vertices:a,triangles:s})}return e}async function yge(t){const e=await vge.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function a(u){const h=u.startsWith("/")?u.slice(1):u,g=e.files[h];if(!g)return null;const m=await g.async("string");return i.parseFromString(m,"application/xml")}const s=Object.keys(e.files).find(u=>u==="3D/3dmodel.model"||u.endsWith("/3dmodel.model"));if(!s){const u=Object.keys(e.files).find(h=>h.endsWith(".model"));if(u){const h=await a(u);if(h){const g=await vz(h);g.length>0&&n.set("1",{id:"1",meshes:g})}}return{objects:n,buildItems:r}}const o=await a(s);if(!o)return{objects:n,buildItems:r};const l=o.getElementsByTagName("object");for(let u=0;u<l.length;u++){const h=l[u],g=h.getAttribute("id");if(!g)continue;const m=[],b=h.getElementsByTagName("mesh");for(let v=0;v<b.length;v++){const x=b[v],M=[],w=[],C=x.getElementsByTagName("vertex");for(let R=0;R<C.length;R++){const A=C[R];M.push(parseFloat(A.getAttribute("x")||"0"),parseFloat(A.getAttribute("y")||"0"),parseFloat(A.getAttribute("z")||"0"))}const T=x.getElementsByTagName("triangle");for(let R=0;R<T.length;R++){const A=T[R];w.push(parseInt(A.getAttribute("v1")||"0"),parseInt(A.getAttribute("v2")||"0"),parseInt(A.getAttribute("v3")||"0"))}M.length>0&&w.length>0&&m.push({vertices:M,triangles:w})}const y=h.getElementsByTagName("component");for(let v=0;v<y.length;v++){const x=y[v],M=x.getAttribute("p:path")||x.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path");if(M){const w=await a(M);if(w){const C=await vz(w),T=x.getAttribute("transform"),R=xz(T);for(const A of C)if(T){const j=[];for(let N=0;N<A.vertices.length;N+=3){const k=new We(A.vertices[N],A.vertices[N+1],A.vertices[N+2]);k.applyMatrix4(R),j.push(k.x,k.y,k.z)}m.push({vertices:j,triangles:A.triangles})}else m.push(A)}}}m.length>0&&n.set(g,{id:g,meshes:m})}const c=o.getElementsByTagName("build");if(c.length>0){const u=c[0].getElementsByTagName("item");for(let h=0;h<u.length;h++){const g=u[h],m=g.getAttribute("objectid");if(!m)continue;const b=xz(g.getAttribute("transform"));r.push({objectId:m,transform:b})}}return{objects:n,buildItems:r}}function bz(t){const e=new fl,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 Vs(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function _ge({url:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const r=E.useRef(null),i=E.useRef(null),a=E.useRef(null),s=E.useRef(null),o=E.useRef(null),[l,c]=E.useState(!0),[u,h]=E.useState(null);E.useEffect(()=>{if(!r.current)return;const b=r.current,y=b.clientWidth,v=b.clientHeight,x=new Que;x.background=new bn(1710618),a.current=x;const M=new js(45,y/v,.1,1e4);M.position.set(150,150,150),s.current=M;const w=new ege({antialias:!0});w.setSize(y,v),w.setPixelRatio(window.devicePixelRatio),b.appendChild(w.domElement),i.current=w;const C=new nge(M,w.domElement);C.enableDamping=!0,C.dampingFactor=.05,o.current=C;const T=new ude(16777215,.6);x.add(T);const R=new BF(16777215,.8);R.position.set(100,100,100),x.add(R);const A=new BF(16777215,.4);A.position.set(-100,50,-100),x.add(A);const j=Math.max(e.x,e.y),N=Math.ceil(j/16),k=new fde(j,N,4473924,3355443);x.add(k);const F=new fk(e.x,e.y),I=new ck({color:44610,transparent:!0,opacity:.15,side:Vo}),W=new il(F,I);W.rotation.x=-Math.PI/2,W.position.y=-.5,x.add(W);let D;const B=()=>{D=requestAnimationFrame(B),C.update(),w.render(x,M)};B(),fetch(t).then(V=>{if(!V.ok)throw new Error("Failed to load file");return V.arrayBuffer()}).then(yge).then(({objects:V,buildItems:Z})=>{if(V.size===0)throw new Error("No meshes found in 3MF file");const Y=new ade({color:44610,shininess:30,flatShading:!1}),ee=new lx,H=[];if(Z.length>0)for(const he of Z){const we=V.get(he.objectId);if(we)for(const Le of we.meshes){const de=[];for(let $=0;$<Le.vertices.length;$+=3){const z=new We(Le.vertices[$],Le.vertices[$+1],Le.vertices[$+2]);z.applyMatrix4(he.transform),de.push(z.x,z.y,z.z)}const lt=bz({vertices:de,triangles:Le.triangles});H.push(lt)}}else for(const he of V.values())for(const we of he.meshes){const Le=bz(we);H.push(Le)}if(H.length>0){const he=H.length===1?H[0]:mge(H,!1);if(he){const we=new il(he,Y);ee.add(we)}if(H.length>1)for(const we of H)we.dispose()}const q=new Pf().setFromObject(ee),ae=q.getCenter(new We);ee.position.y=-q.min.y,Z.length===0&&(ee.position.x=-ae.x,ee.position.z=-ae.z),x.add(ee);const ce=new Pf().setFromObject(ee),xe=ce.getCenter(new We),ie=ce.getSize(new We),Pe=Math.max(ie.x,ie.y,ie.z)*1.8;M.position.set(xe.x+Pe*.7,xe.y+Pe*.5,xe.z+Pe*.7),C.target.copy(xe),C.update(),c(!1)}).catch(V=>{h(V.message),c(!1)});const G=()=>{if(!b)return;const V=b.clientWidth,Z=b.clientHeight;M.aspect=V/Z,M.updateProjectionMatrix(),w.setSize(V,Z)};return window.addEventListener("resize",G),()=>{window.removeEventListener("resize",G),cancelAnimationFrame(D),C.dispose(),w.dispose(),b.removeChild(w.domElement)}},[t,e]);const g=()=>{s.current&&o.current&&(s.current.position.set(150,150,150),o.current.target.set(0,50,0),o.current.update())},m=b=>{s.current&&s.current.position.multiplyScalar(b)};return f.jsxs("div",{className:`relative ${n}`,children:[f.jsx("div",{ref:r,className:"w-full h-full min-h-[400px]"}),l&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:f.jsx($t,{className:"w-8 h-8 text-bambu-green animate-spin"})}),u&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:f.jsx("p",{className:"text-red-400",children:u})}),!l&&!u&&f.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[f.jsx(qe,{variant:"secondary",size:"sm",onClick:()=>m(.8),children:f.jsx(qle,{className:"w-4 h-4"})}),f.jsx(qe,{variant:"secondary",size:"sm",onClick:()=>m(1.25),children:f.jsx(Yle,{className:"w-4 h-4"})}),f.jsx(qe,{variant:"secondary",size:"sm",onClick:g,children:f.jsx(tw,{className:"w-4 h-4"})})]})]})}const ow="159",Wh={ROTATE:0,DOLLY:1,PAN:2},qh={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Sge=0,yz=1,wge=2,u7=1,Mge=2,Wl=3,Qu=0,Fa=1,Zl=2,zu=0,Op=1,_z=2,Sz=3,wz=4,Ege=5,Xd=100,Age=101,Tge=102,Mz=103,Ez=104,Cge=200,Nge=201,Rge=202,Pge=203,N3=204,R3=205,kge=206,Dge=207,Oge=208,Lge=209,Ige=210,jge=211,Uge=212,Fge=213,zge=214,Bge=0,Hge=1,$ge=2,t1=3,Vge=4,Gge=5,Wge=6,qge=7,pk=0,Xge=1,Kge=2,Bu=0,Yge=1,Zge=2,Qge=3,Jge=4,exe=5,d7=300,Jp=301,em=302,P3=303,k3=304,lw=306,D3=1e3,fo=1001,O3=1002,Hi=1003,Az=1004,_T=1005,Us=1006,txe=1007,n0=1008,Hu=1009,nxe=1010,rxe=1011,mk=1012,f7=1013,Du=1014,rc=1015,r0=1016,h7=1017,p7=1018,lf=1020,ixe=1021,Fs=1023,axe=1024,sxe=1025,cf=1026,tm=1027,oxe=1028,m7=1029,lxe=1030,g7=1031,x7=1033,ST=33776,wT=33777,MT=33778,ET=33779,Tz=35840,Cz=35841,Nz=35842,Rz=35843,v7=36196,Pz=37492,kz=37496,Dz=37808,Oz=37809,Lz=37810,Iz=37811,jz=37812,Uz=37813,Fz=37814,zz=37815,Bz=37816,Hz=37817,$z=37818,Vz=37819,Gz=37820,Wz=37821,AT=36492,qz=36494,Xz=36495,cxe=36283,Kz=36284,Yz=36285,Zz=36286,b7=3e3,uf=3001,uxe=3200,dxe=3201,y7=0,fxe=1,zs="",$i="srgb",bc="srgb-linear",gk="display-p3",cw="display-p3-linear",n1="linear",rr="srgb",r1="rec709",i1="p3",Xh=7680,Qz=519,hxe=512,pxe=513,mxe=514,_7=515,gxe=516,xxe=517,vxe=518,bxe=519,L3=35044,Jz="300 es",I3=1035,Ko=2e3,i0=2001;class Xf{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){if(this._listeners===void 0)return!1;const r=this._listeners;return r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const r=this._listeners[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,s=i.length;a<s;a++)i[a].call(this,e);e.target=null}}}const Zi=["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 e5=1234567;const Sx=Math.PI/180,a0=180/Math.PI;function uc(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Zi[t&255]+Zi[t>>8&255]+Zi[t>>16&255]+Zi[t>>24&255]+"-"+Zi[e&255]+Zi[e>>8&255]+"-"+Zi[e>>16&15|64]+Zi[e>>24&255]+"-"+Zi[n&63|128]+Zi[n>>8&255]+"-"+Zi[n>>16&255]+Zi[n>>24&255]+Zi[r&255]+Zi[r>>8&255]+Zi[r>>16&255]+Zi[r>>24&255]).toLowerCase()}function Vi(t,e,n){return Math.max(e,Math.min(n,t))}function xk(t,e){return(t%e+e)%e}function yxe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function _xe(t,e,n){return t!==e?(n-t)/(e-t):0}function wx(t,e,n){return(1-n)*t+n*e}function Sxe(t,e,n,r){return wx(t,e,1-Math.exp(-n*r))}function wxe(t,e=1){return e-Math.abs(xk(t,e*2)-e)}function Mxe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function Exe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function Axe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function Txe(t,e){return t+Math.random()*(e-t)}function Cxe(t){return t*(.5-Math.random())}function Nxe(t){t!==void 0&&(e5=t);let e=e5+=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 Rxe(t){return t*Sx}function Pxe(t){return t*a0}function j3(t){return(t&t-1)===0&&t!==0}function kxe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function a1(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function Dxe(t,e,n,r,i){const a=Math.cos,s=Math.sin,o=a(n/2),l=s(n/2),c=a((e+r)/2),u=s((e+r)/2),h=a((e-r)/2),g=s((e-r)/2),m=a((r-e)/2),b=s((r-e)/2);switch(i){case"XYX":t.set(o*u,l*h,l*g,o*c);break;case"YZY":t.set(l*g,o*u,l*h,o*c);break;case"ZXZ":t.set(l*h,l*g,o*u,o*c);break;case"XZX":t.set(o*u,l*b,l*m,o*c);break;case"YXY":t.set(l*m,o*u,l*b,o*c);break;case"ZYZ":t.set(l*b,l*m,o*u,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Go(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 Hn(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 S7={DEG2RAD:Sx,RAD2DEG:a0,generateUUID:uc,clamp:Vi,euclideanModulo:xk,mapLinear:yxe,inverseLerp:_xe,lerp:wx,damp:Sxe,pingpong:wxe,smoothstep:Mxe,smootherstep:Exe,randInt:Axe,randFloat:Txe,randFloatSpread:Cxe,seededRandom:Nxe,degToRad:Rxe,radToDeg:Pxe,isPowerOfTwo:j3,ceilPowerOfTwo:kxe,floorPowerOfTwo:a1,setQuaternionFromProperEuler:Dxe,normalize:Hn,denormalize:Go};class Kt{constructor(e=0,n=0){Kt.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(Vi(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,s=this.y-e.y;return this.x=a*r-s*i+e.x,this.y=a*i+s*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class fn{constructor(e,n,r,i,a,s,o,l,c){fn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,l,c)}set(e,n,r,i,a,s,o,l,c){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=n,u[4]=a,u[5]=l,u[6]=r,u[7]=s,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],o=r[3],l=r[6],c=r[1],u=r[4],h=r[7],g=r[2],m=r[5],b=r[8],y=i[0],v=i[3],x=i[6],M=i[1],w=i[4],C=i[7],T=i[2],R=i[5],A=i[8];return a[0]=s*y+o*M+l*T,a[3]=s*v+o*w+l*R,a[6]=s*x+o*C+l*A,a[1]=c*y+u*M+h*T,a[4]=c*v+u*w+h*R,a[7]=c*x+u*C+h*A,a[2]=g*y+m*M+b*T,a[5]=g*v+m*w+b*R,a[8]=g*x+m*C+b*A,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return n*s*u-n*o*c-r*a*u+r*o*l+i*a*c-i*s*l}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=u*s-o*c,g=o*l-u*a,m=c*a-s*l,b=n*h+r*g+i*m;if(b===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/b;return e[0]=h*y,e[1]=(i*c-u*r)*y,e[2]=(o*r-i*s)*y,e[3]=g*y,e[4]=(u*n-i*l)*y,e[5]=(i*a-o*n)*y,e[6]=m*y,e[7]=(r*l-c*n)*y,e[8]=(s*n-r*a)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,s,o){const l=Math.cos(a),c=Math.sin(a);return this.set(r*l,r*c,-r*(l*s+c*o)+s+e,-i*c,i*l,-i*(-c*s+l*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(TT.makeScale(e,n)),this}rotate(e){return this.premultiply(TT.makeRotation(-e)),this}translate(e,n){return this.premultiply(TT.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 TT=new fn;function w7(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function s1(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Oxe(){const t=s1("canvas");return t.style.display="block",t}const t5={};function Mx(t){t in t5||(t5[t]=!0,console.warn(t))}const n5=new fn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),r5=new fn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),oy={[bc]:{transfer:n1,primaries:r1,toReference:t=>t,fromReference:t=>t},[$i]:{transfer:rr,primaries:r1,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[cw]:{transfer:n1,primaries:i1,toReference:t=>t.applyMatrix3(r5),fromReference:t=>t.applyMatrix3(n5)},[gk]:{transfer:rr,primaries:i1,toReference:t=>t.convertSRGBToLinear().applyMatrix3(r5),fromReference:t=>t.applyMatrix3(n5).convertLinearToSRGB()}},Lxe=new Set([bc,cw]),$n={enabled:!0,_workingColorSpace:bc,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(!Lxe.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=oy[e].toReference,i=oy[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 oy[t].primaries},getTransfer:function(t){return t===zs?n1:oy[t].transfer}};function Lp(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function CT(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Kh;class M7{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Kh===void 0&&(Kh=s1("canvas")),Kh.width=e.width,Kh.height=e.height;const r=Kh.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Kh}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=s1("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]=Lp(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(Lp(n[r]/255)*255):n[r]=Lp(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 Ixe=0;class E7{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Ixe++}),this.uuid=uc(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let s=0,o=i.length;s<o;s++)i[s].isDataTexture?a.push(NT(i[s].image)):a.push(NT(i[s]))}else a=NT(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function NT(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?M7.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 jxe=0;class za extends Xf{constructor(e=za.DEFAULT_IMAGE,n=za.DEFAULT_MAPPING,r=fo,i=fo,a=Us,s=n0,o=Fs,l=Hu,c=za.DEFAULT_ANISOTROPY,u=zs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:jxe++}),this.uuid=uc(),this.name="",this.source=new E7(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Kt(0,0),this.repeat=new Kt(1,1),this.center=new Kt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new fn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof u=="string"?this.colorSpace=u:(Mx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=u===uf?$i:zs),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!==d7)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case D3:e.x=e.x-Math.floor(e.x);break;case fo:e.x=e.x<0?0:1;break;case O3: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 D3:e.y=e.y-Math.floor(e.y);break;case fo:e.y=e.y<0?0:1;break;case O3: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 Mx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===$i?uf:b7}set encoding(e){Mx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===uf?$i:zs}}za.DEFAULT_IMAGE=null;za.DEFAULT_MAPPING=d7;za.DEFAULT_ANISOTROPY=1;class Gn{constructor(e=0,n=0,r=0,i=1){Gn.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 l=e.elements,c=l[0],u=l[4],h=l[8],g=l[1],m=l[5],b=l[9],y=l[2],v=l[6],x=l[10];if(Math.abs(u-g)<.01&&Math.abs(h-y)<.01&&Math.abs(b-v)<.01){if(Math.abs(u+g)<.1&&Math.abs(h+y)<.1&&Math.abs(b+v)<.1&&Math.abs(c+m+x-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(c+1)/2,C=(m+1)/2,T=(x+1)/2,R=(u+g)/4,A=(h+y)/4,j=(b+v)/4;return w>C&&w>T?w<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(w),i=R/r,a=A/r):C>T?C<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(C),r=R/i,a=j/i):T<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(T),r=A/a,i=j/a),this.set(r,i,a,n),this}let M=Math.sqrt((v-b)*(v-b)+(h-y)*(h-y)+(g-u)*(g-u));return Math.abs(M)<.001&&(M=1),this.x=(v-b)/M,this.y=(h-y)/M,this.z=(g-u)/M,this.w=Math.acos((c+m+x-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Uxe extends Xf{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Gn(0,0,e,n),this.scissorTest=!1,this.viewport=new Gn(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(Mx("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===uf?$i:zs),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Us,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new za(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 E7(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 kf extends Uxe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class A7 extends za{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=Hi,this.minFilter=Hi,this.wrapR=fo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Fxe extends za{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=Hi,this.minFilter=Hi,this.wrapR=fo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Df{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,s,o){let l=r[i+0],c=r[i+1],u=r[i+2],h=r[i+3];const g=a[s+0],m=a[s+1],b=a[s+2],y=a[s+3];if(o===0){e[n+0]=l,e[n+1]=c,e[n+2]=u,e[n+3]=h;return}if(o===1){e[n+0]=g,e[n+1]=m,e[n+2]=b,e[n+3]=y;return}if(h!==y||l!==g||c!==m||u!==b){let v=1-o;const x=l*g+c*m+u*b+h*y,M=x>=0?1:-1,w=1-x*x;if(w>Number.EPSILON){const T=Math.sqrt(w),R=Math.atan2(T,x*M);v=Math.sin(v*R)/T,o=Math.sin(o*R)/T}const C=o*M;if(l=l*v+g*C,c=c*v+m*C,u=u*v+b*C,h=h*v+y*C,v===1-o){const T=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=T,c*=T,u*=T,h*=T}}e[n]=l,e[n+1]=c,e[n+2]=u,e[n+3]=h}static multiplyQuaternionsFlat(e,n,r,i,a,s){const o=r[i],l=r[i+1],c=r[i+2],u=r[i+3],h=a[s],g=a[s+1],m=a[s+2],b=a[s+3];return e[n]=o*b+u*h+l*m-c*g,e[n+1]=l*b+u*g+c*h-o*m,e[n+2]=c*b+u*m+o*g-l*h,e[n+3]=u*b-o*h-l*g-c*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){const r=e._x,i=e._y,a=e._z,s=e._order,o=Math.cos,l=Math.sin,c=o(r/2),u=o(i/2),h=o(a/2),g=l(r/2),m=l(i/2),b=l(a/2);switch(s){case"XYZ":this._x=g*u*h+c*m*b,this._y=c*m*h-g*u*b,this._z=c*u*b+g*m*h,this._w=c*u*h-g*m*b;break;case"YXZ":this._x=g*u*h+c*m*b,this._y=c*m*h-g*u*b,this._z=c*u*b-g*m*h,this._w=c*u*h+g*m*b;break;case"ZXY":this._x=g*u*h-c*m*b,this._y=c*m*h+g*u*b,this._z=c*u*b+g*m*h,this._w=c*u*h-g*m*b;break;case"ZYX":this._x=g*u*h-c*m*b,this._y=c*m*h+g*u*b,this._z=c*u*b-g*m*h,this._w=c*u*h+g*m*b;break;case"YZX":this._x=g*u*h+c*m*b,this._y=c*m*h+g*u*b,this._z=c*u*b-g*m*h,this._w=c*u*h-g*m*b;break;case"XZY":this._x=g*u*h-c*m*b,this._y=c*m*h-g*u*b,this._z=c*u*b+g*m*h,this._w=c*u*h+g*m*b;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return n!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],a=n[8],s=n[1],o=n[5],l=n[9],c=n[2],u=n[6],h=n[10],g=r+o+h;if(g>0){const m=.5/Math.sqrt(g+1);this._w=.25/m,this._x=(u-l)*m,this._y=(a-c)*m,this._z=(s-i)*m}else if(r>o&&r>h){const m=2*Math.sqrt(1+r-o-h);this._w=(u-l)/m,this._x=.25*m,this._y=(i+s)/m,this._z=(a+c)/m}else if(o>h){const m=2*Math.sqrt(1+o-r-h);this._w=(a-c)/m,this._x=(i+s)/m,this._y=.25*m,this._z=(l+u)/m}else{const m=2*Math.sqrt(1+h-r-o);this._w=(s-i)/m,this._x=(a+c)/m,this._y=(l+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Vi(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,s=e._w,o=n._x,l=n._y,c=n._z,u=n._w;return this._x=r*u+s*o+i*c-a*l,this._y=i*u+s*l+a*o-r*c,this._z=a*u+s*c+r*l-i*o,this._w=s*u-r*o-i*l-a*c,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,a=this._z,s=this._w;let o=s*e._w+r*e._x+i*e._y+a*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=s,this._x=r,this._y=i,this._z=a,this;const l=1-o*o;if(l<=Number.EPSILON){const m=1-n;return this._w=m*s+n*this._w,this._x=m*r+n*this._x,this._y=m*i+n*this._y,this._z=m*a+n*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(l),u=Math.atan2(c,o),h=Math.sin((1-n)*u)/c,g=Math.sin(n*u)/c;return this._w=s*h+this._w*g,this._x=r*h+this._x*g,this._y=i*h+this._y*g,this._z=a*h+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 Ce{constructor(e=0,n=0,r=0){Ce.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(i5.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(i5.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,s=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*s,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*s,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*s,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,s=e.y,o=e.z,l=e.w,c=2*(s*i-o*r),u=2*(o*n-a*i),h=2*(a*r-s*n);return this.x=n+l*c+s*h-o*u,this.y=r+l*u+o*c-a*h,this.z=i+l*h+a*u-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,s=n.x,o=n.y,l=n.z;return this.x=i*l-a*o,this.y=a*s-r*l,this.z=r*o-i*s,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return RT.copy(this).projectOnVector(e),this.sub(RT)}reflect(e){return this.sub(RT.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(Vi(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 RT=new Ce,i5=new Df;class Gs{constructor(e=new Ce(1/0,1/0,1/0),n=new Ce(-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(oo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(oo.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=oo.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=a.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,oo):oo.fromBufferAttribute(a,s),oo.applyMatrix4(e.matrixWorld),this.expandByPoint(oo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),ly.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),ly.copy(r.boundingBox)),ly.applyMatrix4(e.matrixWorld),this.union(ly)}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,oo),oo.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(Gg),cy.subVectors(this.max,Gg),Yh.subVectors(e.a,Gg),Zh.subVectors(e.b,Gg),Qh.subVectors(e.c,Gg),du.subVectors(Zh,Yh),fu.subVectors(Qh,Zh),Id.subVectors(Yh,Qh);let n=[0,-du.z,du.y,0,-fu.z,fu.y,0,-Id.z,Id.y,du.z,0,-du.x,fu.z,0,-fu.x,Id.z,0,-Id.x,-du.y,du.x,0,-fu.y,fu.x,0,-Id.y,Id.x,0];return!PT(n,Yh,Zh,Qh,cy)||(n=[1,0,0,0,1,0,0,0,1],!PT(n,Yh,Zh,Qh,cy))?!1:(uy.crossVectors(du,fu),n=[uy.x,uy.y,uy.z],PT(n,Yh,Zh,Qh,cy))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,oo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(oo).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)}}const jl=[new Ce,new Ce,new Ce,new Ce,new Ce,new Ce,new Ce,new Ce],oo=new Ce,ly=new Gs,Yh=new Ce,Zh=new Ce,Qh=new Ce,du=new Ce,fu=new Ce,Id=new Ce,Gg=new Ce,cy=new Ce,uy=new Ce,jd=new Ce;function PT(t,e,n,r,i){for(let a=0,s=t.length-3;a<=s;a+=3){jd.fromArray(t,a);const o=i.x*Math.abs(jd.x)+i.y*Math.abs(jd.y)+i.z*Math.abs(jd.z),l=e.dot(jd),c=n.dot(jd),u=r.dot(jd);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const zxe=new Gs,Wg=new Ce,kT=new Ce;class Zo{constructor(e=new Ce,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):zxe.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;Wg.subVectors(e,this.center);const n=Wg.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Wg,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):(kT.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Wg.copy(e.center).add(kT)),this.expandByPoint(Wg.copy(e.center).sub(kT))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Ul=new Ce,DT=new Ce,dy=new Ce,hu=new Ce,OT=new Ce,fy=new Ce,LT=new Ce;class vk{constructor(e=new Ce,n=new Ce(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,Ul)),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=Ul.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Ul.copy(this.origin).addScaledVector(this.direction,n),Ul.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){DT.copy(e).add(n).multiplyScalar(.5),dy.copy(n).sub(e).normalize(),hu.copy(this.origin).sub(DT);const a=e.distanceTo(n)*.5,s=-this.direction.dot(dy),o=hu.dot(this.direction),l=-hu.dot(dy),c=hu.lengthSq(),u=Math.abs(1-s*s);let h,g,m,b;if(u>0)if(h=s*l-o,g=s*o-l,b=a*u,h>=0)if(g>=-b)if(g<=b){const y=1/u;h*=y,g*=y,m=h*(h+s*g+2*o)+g*(s*h+g+2*l)+c}else g=a,h=Math.max(0,-(s*g+o)),m=-h*h+g*(g+2*l)+c;else g=-a,h=Math.max(0,-(s*g+o)),m=-h*h+g*(g+2*l)+c;else g<=-b?(h=Math.max(0,-(-s*a+o)),g=h>0?-a:Math.min(Math.max(-a,-l),a),m=-h*h+g*(g+2*l)+c):g<=b?(h=0,g=Math.min(Math.max(-a,-l),a),m=g*(g+2*l)+c):(h=Math.max(0,-(s*a+o)),g=h>0?a:Math.min(Math.max(-a,-l),a),m=-h*h+g*(g+2*l)+c);else g=s>0?-a:a,h=Math.max(0,-(s*g+o)),m=-h*h+g*(g+2*l)+c;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(DT).addScaledVector(dy,g),m}intersectSphere(e,n){Ul.subVectors(e.center,this.origin);const r=Ul.dot(this.direction),i=Ul.dot(Ul)-r*r,a=e.radius*e.radius;if(i>a)return null;const s=Math.sqrt(a-i),o=r-s,l=r+s;return l<0?null:o<0?this.at(l,n):this.at(o,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,s,o,l;const c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,g=this.origin;return c>=0?(r=(e.min.x-g.x)*c,i=(e.max.x-g.x)*c):(r=(e.max.x-g.x)*c,i=(e.min.x-g.x)*c),u>=0?(a=(e.min.y-g.y)*u,s=(e.max.y-g.y)*u):(a=(e.max.y-g.y)*u,s=(e.min.y-g.y)*u),r>s||a>i||((a>r||isNaN(r))&&(r=a),(s<i||isNaN(i))&&(i=s),h>=0?(o=(e.min.z-g.z)*h,l=(e.max.z-g.z)*h):(o=(e.max.z-g.z)*h,l=(e.min.z-g.z)*h),r>l||o>i)||((o>r||r!==r)&&(r=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Ul)!==null}intersectTriangle(e,n,r,i,a){OT.subVectors(n,e),fy.subVectors(r,e),LT.crossVectors(OT,fy);let s=this.direction.dot(LT),o;if(s>0){if(i)return null;o=1}else if(s<0)o=-1,s=-s;else return null;hu.subVectors(this.origin,e);const l=o*this.direction.dot(fy.crossVectors(hu,fy));if(l<0)return null;const c=o*this.direction.dot(OT.cross(hu));if(c<0||l+c>s)return null;const u=-o*hu.dot(LT);return u<0?null:this.at(u/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 Jn{constructor(e,n,r,i,a,s,o,l,c,u,h,g,m,b,y,v){Jn.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,l,c,u,h,g,m,b,y,v)}set(e,n,r,i,a,s,o,l,c,u,h,g,m,b,y,v){const x=this.elements;return x[0]=e,x[4]=n,x[8]=r,x[12]=i,x[1]=a,x[5]=s,x[9]=o,x[13]=l,x[2]=c,x[6]=u,x[10]=h,x[14]=g,x[3]=m,x[7]=b,x[11]=y,x[15]=v,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Jn().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/Jh.setFromMatrixColumn(e,0).length(),a=1/Jh.setFromMatrixColumn(e,1).length(),s=1/Jh.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*s,n[9]=r[9]*s,n[10]=r[10]*s,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,a=e.z,s=Math.cos(r),o=Math.sin(r),l=Math.cos(i),c=Math.sin(i),u=Math.cos(a),h=Math.sin(a);if(e.order==="XYZ"){const g=s*u,m=s*h,b=o*u,y=o*h;n[0]=l*u,n[4]=-l*h,n[8]=c,n[1]=m+b*c,n[5]=g-y*c,n[9]=-o*l,n[2]=y-g*c,n[6]=b+m*c,n[10]=s*l}else if(e.order==="YXZ"){const g=l*u,m=l*h,b=c*u,y=c*h;n[0]=g+y*o,n[4]=b*o-m,n[8]=s*c,n[1]=s*h,n[5]=s*u,n[9]=-o,n[2]=m*o-b,n[6]=y+g*o,n[10]=s*l}else if(e.order==="ZXY"){const g=l*u,m=l*h,b=c*u,y=c*h;n[0]=g-y*o,n[4]=-s*h,n[8]=b+m*o,n[1]=m+b*o,n[5]=s*u,n[9]=y-g*o,n[2]=-s*c,n[6]=o,n[10]=s*l}else if(e.order==="ZYX"){const g=s*u,m=s*h,b=o*u,y=o*h;n[0]=l*u,n[4]=b*c-m,n[8]=g*c+y,n[1]=l*h,n[5]=y*c+g,n[9]=m*c-b,n[2]=-c,n[6]=o*l,n[10]=s*l}else if(e.order==="YZX"){const g=s*l,m=s*c,b=o*l,y=o*c;n[0]=l*u,n[4]=y-g*h,n[8]=b*h+m,n[1]=h,n[5]=s*u,n[9]=-o*u,n[2]=-c*u,n[6]=m*h+b,n[10]=g-y*h}else if(e.order==="XZY"){const g=s*l,m=s*c,b=o*l,y=o*c;n[0]=l*u,n[4]=-h,n[8]=c*u,n[1]=g*h+y,n[5]=s*u,n[9]=m*h-b,n[2]=b*h-m,n[6]=o*u,n[10]=y*h+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(Bxe,e,Hxe)}lookAt(e,n,r){const i=this.elements;return ns.subVectors(e,n),ns.lengthSq()===0&&(ns.z=1),ns.normalize(),pu.crossVectors(r,ns),pu.lengthSq()===0&&(Math.abs(r.z)===1?ns.x+=1e-4:ns.z+=1e-4,ns.normalize(),pu.crossVectors(r,ns)),pu.normalize(),hy.crossVectors(ns,pu),i[0]=pu.x,i[4]=hy.x,i[8]=ns.x,i[1]=pu.y,i[5]=hy.y,i[9]=ns.y,i[2]=pu.z,i[6]=hy.z,i[10]=ns.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],o=r[4],l=r[8],c=r[12],u=r[1],h=r[5],g=r[9],m=r[13],b=r[2],y=r[6],v=r[10],x=r[14],M=r[3],w=r[7],C=r[11],T=r[15],R=i[0],A=i[4],j=i[8],N=i[12],k=i[1],F=i[5],I=i[9],W=i[13],D=i[2],B=i[6],G=i[10],V=i[14],Z=i[3],Y=i[7],ee=i[11],H=i[15];return a[0]=s*R+o*k+l*D+c*Z,a[4]=s*A+o*F+l*B+c*Y,a[8]=s*j+o*I+l*G+c*ee,a[12]=s*N+o*W+l*V+c*H,a[1]=u*R+h*k+g*D+m*Z,a[5]=u*A+h*F+g*B+m*Y,a[9]=u*j+h*I+g*G+m*ee,a[13]=u*N+h*W+g*V+m*H,a[2]=b*R+y*k+v*D+x*Z,a[6]=b*A+y*F+v*B+x*Y,a[10]=b*j+y*I+v*G+x*ee,a[14]=b*N+y*W+v*V+x*H,a[3]=M*R+w*k+C*D+T*Z,a[7]=M*A+w*F+C*B+T*Y,a[11]=M*j+w*I+C*G+T*ee,a[15]=M*N+w*W+C*V+T*H,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],s=e[1],o=e[5],l=e[9],c=e[13],u=e[2],h=e[6],g=e[10],m=e[14],b=e[3],y=e[7],v=e[11],x=e[15];return b*(+a*l*h-i*c*h-a*o*g+r*c*g+i*o*m-r*l*m)+y*(+n*l*m-n*c*g+a*s*g-i*s*m+i*c*u-a*l*u)+v*(+n*c*h-n*o*m-a*s*h+r*s*m+a*o*u-r*c*u)+x*(-i*o*u-n*l*h+n*o*g+i*s*h-r*s*g+r*l*u)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=e[9],g=e[10],m=e[11],b=e[12],y=e[13],v=e[14],x=e[15],M=h*v*c-y*g*c+y*l*m-o*v*m-h*l*x+o*g*x,w=b*g*c-u*v*c-b*l*m+s*v*m+u*l*x-s*g*x,C=u*y*c-b*h*c+b*o*m-s*y*m-u*o*x+s*h*x,T=b*h*l-u*y*l-b*o*g+s*y*g+u*o*v-s*h*v,R=n*M+r*w+i*C+a*T;if(R===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/R;return e[0]=M*A,e[1]=(y*g*a-h*v*a-y*i*m+r*v*m+h*i*x-r*g*x)*A,e[2]=(o*v*a-y*l*a+y*i*c-r*v*c-o*i*x+r*l*x)*A,e[3]=(h*l*a-o*g*a-h*i*c+r*g*c+o*i*m-r*l*m)*A,e[4]=w*A,e[5]=(u*v*a-b*g*a+b*i*m-n*v*m-u*i*x+n*g*x)*A,e[6]=(b*l*a-s*v*a-b*i*c+n*v*c+s*i*x-n*l*x)*A,e[7]=(s*g*a-u*l*a+u*i*c-n*g*c-s*i*m+n*l*m)*A,e[8]=C*A,e[9]=(b*h*a-u*y*a-b*r*m+n*y*m+u*r*x-n*h*x)*A,e[10]=(s*y*a-b*o*a+b*r*c-n*y*c-s*r*x+n*o*x)*A,e[11]=(u*o*a-s*h*a-u*r*c+n*h*c+s*r*m-n*o*m)*A,e[12]=T*A,e[13]=(u*y*i-b*h*i+b*r*g-n*y*g-u*r*v+n*h*v)*A,e[14]=(b*o*i-s*y*i-b*r*l+n*y*l+s*r*v-n*o*v)*A,e[15]=(s*h*i-u*o*i+u*r*l-n*h*l-s*r*g+n*o*g)*A,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,s=e.x,o=e.y,l=e.z,c=a*s,u=a*o;return this.set(c*s+r,c*o-i*l,c*l+i*o,0,c*o+i*l,u*o+r,u*l-i*s,0,c*l-i*o,u*l+i*s,a*l*l+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,s){return this.set(1,r,a,0,e,1,s,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,s=n._y,o=n._z,l=n._w,c=a+a,u=s+s,h=o+o,g=a*c,m=a*u,b=a*h,y=s*u,v=s*h,x=o*h,M=l*c,w=l*u,C=l*h,T=r.x,R=r.y,A=r.z;return i[0]=(1-(y+x))*T,i[1]=(m+C)*T,i[2]=(b-w)*T,i[3]=0,i[4]=(m-C)*R,i[5]=(1-(g+x))*R,i[6]=(v+M)*R,i[7]=0,i[8]=(b+w)*A,i[9]=(v-M)*A,i[10]=(1-(g+y))*A,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=Jh.set(i[0],i[1],i[2]).length();const s=Jh.set(i[4],i[5],i[6]).length(),o=Jh.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],lo.copy(this);const c=1/a,u=1/s,h=1/o;return lo.elements[0]*=c,lo.elements[1]*=c,lo.elements[2]*=c,lo.elements[4]*=u,lo.elements[5]*=u,lo.elements[6]*=u,lo.elements[8]*=h,lo.elements[9]*=h,lo.elements[10]*=h,n.setFromRotationMatrix(lo),r.x=a,r.y=s,r.z=o,this}makePerspective(e,n,r,i,a,s,o=Ko){const l=this.elements,c=2*a/(n-e),u=2*a/(r-i),h=(n+e)/(n-e),g=(r+i)/(r-i);let m,b;if(o===Ko)m=-(s+a)/(s-a),b=-2*s*a/(s-a);else if(o===i0)m=-s/(s-a),b=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=u,l[9]=g,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=b,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,n,r,i,a,s,o=Ko){const l=this.elements,c=1/(n-e),u=1/(r-i),h=1/(s-a),g=(n+e)*c,m=(r+i)*u;let b,y;if(o===Ko)b=(s+a)*h,y=-2*h;else if(o===i0)b=a*h,y=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-g,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=y,l[14]=-b,l[3]=0,l[7]=0,l[11]=0,l[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 Jh=new Ce,lo=new Jn,Bxe=new Ce(0,0,0),Hxe=new Ce(1,1,1),pu=new Ce,hy=new Ce,ns=new Ce,a5=new Jn,s5=new Df;class H0{constructor(e=0,n=0,r=0,i=H0.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],s=i[4],o=i[8],l=i[1],c=i[5],u=i[9],h=i[2],g=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(Vi(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(g,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Vi(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,a),this._z=0);break;case"ZXY":this._x=Math.asin(Vi(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-h,m),this._z=Math.atan2(-s,c)):(this._y=0,this._z=Math.atan2(l,a));break;case"ZYX":this._y=Math.asin(-Vi(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(g,m),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-s,c));break;case"YZX":this._z=Math.asin(Vi(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,a)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Vi(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(g,c),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return a5.makeRotationFromQuaternion(e),this.setFromRotationMatrix(a5,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return s5.setFromEuler(this),this.setFromQuaternion(s5,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}}H0.DEFAULT_ORDER="XYZ";class T7{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 $xe=0;const o5=new Ce,ep=new Df,Fl=new Jn,py=new Ce,qg=new Ce,Vxe=new Ce,Gxe=new Df,l5=new Ce(1,0,0),c5=new Ce(0,1,0),u5=new Ce(0,0,1),Wxe={type:"added"},qxe={type:"removed"};class va extends Xf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:$xe++}),this.uuid=uc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=va.DEFAULT_UP.clone();const e=new Ce,n=new H0,r=new Df,i=new Ce(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 Jn},normalMatrix:{value:new fn}}),this.matrix=new Jn,this.matrixWorld=new Jn,this.matrixAutoUpdate=va.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=va.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new T7,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 ep.setFromAxisAngle(e,n),this.quaternion.multiply(ep),this}rotateOnWorldAxis(e,n){return ep.setFromAxisAngle(e,n),this.quaternion.premultiply(ep),this}rotateX(e){return this.rotateOnAxis(l5,e)}rotateY(e){return this.rotateOnAxis(c5,e)}rotateZ(e){return this.rotateOnAxis(u5,e)}translateOnAxis(e,n){return o5.copy(e).applyQuaternion(this.quaternion),this.position.add(o5.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(l5,e)}translateY(e){return this.translateOnAxis(c5,e)}translateZ(e){return this.translateOnAxis(u5,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Fl.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?py.copy(e):py.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),qg.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Fl.lookAt(qg,py,this.up):Fl.lookAt(py,qg,this.up),this.quaternion.setFromRotationMatrix(Fl),i&&(Fl.extractRotation(i.matrixWorld),ep.setFromRotationMatrix(Fl),this.quaternion.premultiply(ep.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(Wxe)):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(qxe)),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),Fl.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Fl.multiply(e.parent.matrixWorld)),e.applyMatrix4(Fl),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(qg,e,Vxe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(qg,Gxe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++){const a=n[r];(a.matrixWorldAutoUpdate===!0||e===!0)&&a.updateMatrixWorld(e)}}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.matrixWorldAutoUpdate===!0&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),n===!0){const i=this.children;for(let a=0,s=i.length;a<s;a++){const o=i[a];o.matrixWorldAutoUpdate===!0&&o.updateWorldMatrix(!1,!0)}}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function a(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const h=l[c];a(e.shapes,h)}else a(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(a(e.materials,this.material[l]));i.material=o}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(a(e.animations,l))}}if(n){const o=s(e.geometries),l=s(e.materials),c=s(e.textures),u=s(e.images),h=s(e.shapes),g=s(e.skeletons),m=s(e.animations),b=s(e.nodes);o.length>0&&(r.geometries=o),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),u.length>0&&(r.images=u),h.length>0&&(r.shapes=h),g.length>0&&(r.skeletons=g),m.length>0&&(r.animations=m),b.length>0&&(r.nodes=b)}return r.object=i,r;function s(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}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}}va.DEFAULT_UP=new Ce(0,1,0);va.DEFAULT_MATRIX_AUTO_UPDATE=!0;va.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const co=new Ce,zl=new Ce,IT=new Ce,Bl=new Ce,tp=new Ce,np=new Ce,d5=new Ce,jT=new Ce,UT=new Ce,FT=new Ce;let my=!1;class uo{constructor(e=new Ce,n=new Ce,r=new Ce){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),zl.subVectors(r,n),IT.subVectors(e,n);const s=co.dot(co),o=co.dot(zl),l=co.dot(IT),c=zl.dot(zl),u=zl.dot(IT),h=s*c-o*o;if(h===0)return a.set(-2,-1,-1);const g=1/h,m=(c*l-o*u)*g,b=(s*u-o*l)*g;return a.set(1-m-b,b,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Bl),Bl.x>=0&&Bl.y>=0&&Bl.x+Bl.y<=1}static getUV(e,n,r,i,a,s,o,l){return my===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),my=!0),this.getInterpolation(e,n,r,i,a,s,o,l)}static getInterpolation(e,n,r,i,a,s,o,l){return this.getBarycoord(e,n,r,i,Bl),l.setScalar(0),l.addScaledVector(a,Bl.x),l.addScaledVector(s,Bl.y),l.addScaledVector(o,Bl.z),l}static isFrontFacing(e,n,r,i){return co.subVectors(r,n),zl.subVectors(e,n),co.cross(zl).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),zl.subVectors(this.a,this.b),co.cross(zl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return uo.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return uo.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return my===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),my=!0),uo.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return uo.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return uo.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return uo.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,a=this.c;let s,o;tp.subVectors(i,r),np.subVectors(a,r),jT.subVectors(e,r);const l=tp.dot(jT),c=np.dot(jT);if(l<=0&&c<=0)return n.copy(r);UT.subVectors(e,i);const u=tp.dot(UT),h=np.dot(UT);if(u>=0&&h<=u)return n.copy(i);const g=l*h-u*c;if(g<=0&&l>=0&&u<=0)return s=l/(l-u),n.copy(r).addScaledVector(tp,s);FT.subVectors(e,a);const m=tp.dot(FT),b=np.dot(FT);if(b>=0&&m<=b)return n.copy(a);const y=m*c-l*b;if(y<=0&&c>=0&&b<=0)return o=c/(c-b),n.copy(r).addScaledVector(np,o);const v=u*b-m*h;if(v<=0&&h-u>=0&&m-b>=0)return d5.subVectors(a,i),o=(h-u)/(h-u+(m-b)),n.copy(i).addScaledVector(d5,o);const x=1/(v+y+g);return s=y*x,o=g*x,n.copy(r).addScaledVector(tp,s).addScaledVector(np,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const C7={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},mu={h:0,s:0,l:0},gy={h:0,s:0,l:0};function zT(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 zt=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=$i){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,$n.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=$n.workingColorSpace){return this.r=e,this.g=n,this.b=r,$n.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=$n.workingColorSpace){if(e=xk(e,1),n=Vi(n,0,1),r=Vi(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=zT(s,a,e+1/3),this.g=zT(s,a,e),this.b=zT(s,a,e-1/3)}return $n.toWorkingColorSpace(this,i),this}setStyle(e,n=$i){function r(a){a!==void 0&&parseFloat(a)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(s===6)return this.setHex(parseInt(a,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=$i){const r=C7[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=Lp(e.r),this.g=Lp(e.g),this.b=Lp(e.b),this}copyLinearToSRGB(e){return this.r=CT(e.r),this.g=CT(e.g),this.b=CT(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=$i){return $n.fromWorkingColorSpace(Qi.copy(this),e),Math.round(Vi(Qi.r*255,0,255))*65536+Math.round(Vi(Qi.g*255,0,255))*256+Math.round(Vi(Qi.b*255,0,255))}getHexString(e=$i){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=$n.workingColorSpace){$n.fromWorkingColorSpace(Qi.copy(this),n);const r=Qi.r,i=Qi.g,a=Qi.b,s=Math.max(r,i,a),o=Math.min(r,i,a);let l,c;const u=(o+s)/2;if(o===s)l=0,c=0;else{const h=s-o;switch(c=u<=.5?h/(s+o):h/(2-s-o),s){case r:l=(i-a)/h+(i<a?6:0);break;case i:l=(a-r)/h+2;break;case a:l=(r-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,n=$n.workingColorSpace){return $n.fromWorkingColorSpace(Qi.copy(this),n),e.r=Qi.r,e.g=Qi.g,e.b=Qi.b,e}getStyle(e=$i){$n.fromWorkingColorSpace(Qi.copy(this),e);const n=Qi.r,r=Qi.g,i=Qi.b;return e!==$i?`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(mu),this.setHSL(mu.h+e,mu.s+n,mu.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(mu),e.getHSL(gy);const r=wx(mu.h,gy.h,n),i=wx(mu.s,gy.s,n),a=wx(mu.l,gy.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 Qi=new zt;zt.NAMES=C7;let Xxe=0;class Cm extends Xf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Xxe++}),this.uuid=uc(),this.name="",this.type="Material",this.blending=Op,this.side=Qu,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=N3,this.blendDst=R3,this.blendEquation=Xd,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new zt(0,0,0),this.blendAlpha=0,this.depthFunc=t1,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Qz,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Xh,this.stencilZFail=Xh,this.stencilZPass=Xh,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!==Op&&(r.blending=this.blending),this.side!==Qu&&(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!==N3&&(r.blendSrc=this.blendSrc),this.blendDst!==R3&&(r.blendDst=this.blendDst),this.blendEquation!==Xd&&(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!==t1&&(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!==Qz&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Xh&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Xh&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Xh&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(a){const s=[];for(const o in a){const l=a[o];delete l.metadata,s.push(l)}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 N7 extends Cm{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new zt(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=pk,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 Hr=new Ce,xy=new Kt;class fs{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=L3,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=rc,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)xy.fromBufferAttribute(this,n),xy.applyMatrix3(e),this.setXY(n,xy.x,xy.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Hr.fromBufferAttribute(this,n),Hr.applyMatrix3(e),this.setXYZ(n,Hr.x,Hr.y,Hr.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Hr.fromBufferAttribute(this,n),Hr.applyMatrix4(e),this.setXYZ(n,Hr.x,Hr.y,Hr.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Hr.fromBufferAttribute(this,n),Hr.applyNormalMatrix(e),this.setXYZ(n,Hr.x,Hr.y,Hr.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Hr.fromBufferAttribute(this,n),Hr.transformDirection(e),this.setXYZ(n,Hr.x,Hr.y,Hr.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=Go(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Hn(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Go(n,this.array)),n}setX(e,n){return this.normalized&&(n=Hn(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Go(n,this.array)),n}setY(e,n){return this.normalized&&(n=Hn(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=Go(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Hn(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=Go(n,this.array)),n}setW(e,n){return this.normalized&&(n=Hn(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Hn(n,this.array),r=Hn(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=Hn(n,this.array),r=Hn(r,this.array),i=Hn(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=Hn(n,this.array),r=Hn(r,this.array),i=Hn(i,this.array),a=Hn(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!==L3&&(e.usage=this.usage),e}}class R7 extends fs{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class P7 extends fs{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Or extends fs{constructor(e,n,r){super(new Float32Array(e),n,r)}}let Kxe=0;const As=new Jn,BT=new va,rp=new Ce,rs=new Gs,Xg=new Gs,yi=new Ce;class oa extends Xf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Kxe++}),this.uuid=uc(),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(w7(e)?P7:R7)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new fn().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return As.makeRotationFromQuaternion(e),this.applyMatrix4(As),this}rotateX(e){return As.makeRotationX(e),this.applyMatrix4(As),this}rotateY(e){return As.makeRotationY(e),this.applyMatrix4(As),this}rotateZ(e){return As.makeRotationZ(e),this.applyMatrix4(As),this}translate(e,n,r){return As.makeTranslation(e,n,r),this.applyMatrix4(As),this}scale(e,n,r){return As.makeScale(e,n,r),this.applyMatrix4(As),this}lookAt(e){return BT.lookAt(e),BT.updateMatrix(),this.applyMatrix4(BT.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(rp).negate(),this.translate(rp.x,rp.y,rp.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 Or(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Gs);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 Ce(-1/0,-1/0,-1/0),new Ce(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];rs.setFromBufferAttribute(a),this.morphTargetsRelative?(yi.addVectors(this.boundingBox.min,rs.min),this.boundingBox.expandByPoint(yi),yi.addVectors(this.boundingBox.max,rs.max),this.boundingBox.expandByPoint(yi)):(this.boundingBox.expandByPoint(rs.min),this.boundingBox.expandByPoint(rs.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 Zo);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 Ce,1/0);return}if(e){const r=this.boundingSphere.center;if(rs.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const o=n[a];Xg.setFromBufferAttribute(o),this.morphTargetsRelative?(yi.addVectors(rs.min,Xg.min),rs.expandByPoint(yi),yi.addVectors(rs.max,Xg.max),rs.expandByPoint(yi)):(rs.expandByPoint(Xg.min),rs.expandByPoint(Xg.max))}rs.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)yi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(yi));if(n)for(let a=0,s=n.length;a<s;a++){const o=n[a],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)yi.fromBufferAttribute(o,c),l&&(rp.fromBufferAttribute(e,c),yi.add(rp)),i=Math.max(i,r.distanceToSquared(yi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.array,i=n.position.array,a=n.normal.array,s=n.uv.array,o=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new fs(new Float32Array(4*o),4));const l=this.getAttribute("tangent").array,c=[],u=[];for(let k=0;k<o;k++)c[k]=new Ce,u[k]=new Ce;const h=new Ce,g=new Ce,m=new Ce,b=new Kt,y=new Kt,v=new Kt,x=new Ce,M=new Ce;function w(k,F,I){h.fromArray(i,k*3),g.fromArray(i,F*3),m.fromArray(i,I*3),b.fromArray(s,k*2),y.fromArray(s,F*2),v.fromArray(s,I*2),g.sub(h),m.sub(h),y.sub(b),v.sub(b);const W=1/(y.x*v.y-v.x*y.y);isFinite(W)&&(x.copy(g).multiplyScalar(v.y).addScaledVector(m,-y.y).multiplyScalar(W),M.copy(m).multiplyScalar(y.x).addScaledVector(g,-v.x).multiplyScalar(W),c[k].add(x),c[F].add(x),c[I].add(x),u[k].add(M),u[F].add(M),u[I].add(M))}let C=this.groups;C.length===0&&(C=[{start:0,count:r.length}]);for(let k=0,F=C.length;k<F;++k){const I=C[k],W=I.start,D=I.count;for(let B=W,G=W+D;B<G;B+=3)w(r[B+0],r[B+1],r[B+2])}const T=new Ce,R=new Ce,A=new Ce,j=new Ce;function N(k){A.fromArray(a,k*3),j.copy(A);const F=c[k];T.copy(F),T.sub(A.multiplyScalar(A.dot(F))).normalize(),R.crossVectors(j,F);const W=R.dot(u[k])<0?-1:1;l[k*4]=T.x,l[k*4+1]=T.y,l[k*4+2]=T.z,l[k*4+3]=W}for(let k=0,F=C.length;k<F;++k){const I=C[k],W=I.start,D=I.count;for(let B=W,G=W+D;B<G;B+=3)N(r[B+0]),N(r[B+1]),N(r[B+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 fs(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,m=r.count;g<m;g++)r.setXYZ(g,0,0,0);const i=new Ce,a=new Ce,s=new Ce,o=new Ce,l=new Ce,c=new Ce,u=new Ce,h=new Ce;if(e)for(let g=0,m=e.count;g<m;g+=3){const b=e.getX(g+0),y=e.getX(g+1),v=e.getX(g+2);i.fromBufferAttribute(n,b),a.fromBufferAttribute(n,y),s.fromBufferAttribute(n,v),u.subVectors(s,a),h.subVectors(i,a),u.cross(h),o.fromBufferAttribute(r,b),l.fromBufferAttribute(r,y),c.fromBufferAttribute(r,v),o.add(u),l.add(u),c.add(u),r.setXYZ(b,o.x,o.y,o.z),r.setXYZ(y,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z)}else for(let g=0,m=n.count;g<m;g+=3)i.fromBufferAttribute(n,g+0),a.fromBufferAttribute(n,g+1),s.fromBufferAttribute(n,g+2),u.subVectors(s,a),h.subVectors(i,a),u.cross(h),r.setXYZ(g+0,u.x,u.y,u.z),r.setXYZ(g+1,u.x,u.y,u.z),r.setXYZ(g+2,u.x,u.y,u.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)yi.fromBufferAttribute(e,n),yi.normalize(),e.setXYZ(n,yi.x,yi.y,yi.z)}toNonIndexed(){function e(o,l){const c=o.array,u=o.itemSize,h=o.normalized,g=new c.constructor(l.length*u);let m=0,b=0;for(let y=0,v=l.length;y<v;y++){o.isInterleavedBufferAttribute?m=l[y]*o.data.stride+o.offset:m=l[y]*u;for(let x=0;x<u;x++)g[b++]=c[m++]}return new fs(g,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new oa,r=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,r);n.setAttribute(o,c)}const a=this.morphAttributes;for(const o in a){const l=[],c=a[o];for(let u=0,h=c.length;u<h;u++){const g=c[u],m=e(g,r);l.push(m)}n.morphAttributes[o]=l}n.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let o=0,l=s.length;o<l;o++){const c=s[o];n.addGroup(c.start,c.count,c.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 l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);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 l in r){const c=r[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let a=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let h=0,g=c.length;h<g;h++){const m=c[h];u.push(m.toJSON(e.data))}u.length>0&&(i[l]=u,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(n));const i=e.attributes;for(const c in i){const u=i[c];this.setAttribute(c,u.clone(n))}const a=e.morphAttributes;for(const c in a){const u=[],h=a[c];for(let g=0,m=h.length;g<m;g++)u.push(h[g].clone(n));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let c=0,u=s.length;c<u;c++){const h=s[c];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const f5=new Jn,Ud=new vk,vy=new Zo,h5=new Ce,ip=new Ce,ap=new Ce,sp=new Ce,HT=new Ce,by=new Ce,yy=new Kt,_y=new Kt,Sy=new Kt,p5=new Ce,m5=new Ce,g5=new Ce,wy=new Ce,My=new Ce;class vo extends va{constructor(e=new oa,n=new N7){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,s=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(a&&o){by.set(0,0,0);for(let l=0,c=a.length;l<c;l++){const u=o[l],h=a[l];u!==0&&(HT.fromBufferAttribute(h,e),s?by.addScaledVector(HT,u):by.addScaledVector(HT.sub(n),u))}n.add(by)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),vy.copy(r.boundingSphere),vy.applyMatrix4(a),Ud.copy(e.ray).recast(e.near),!(vy.containsPoint(Ud.origin)===!1&&(Ud.intersectSphere(vy,h5)===null||Ud.origin.distanceToSquared(h5)>(e.far-e.near)**2))&&(f5.copy(a).invert(),Ud.copy(e.ray).applyMatrix4(f5),!(r.boundingBox!==null&&Ud.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Ud)))}_computeIntersections(e,n,r){let i;const a=this.geometry,s=this.material,o=a.index,l=a.attributes.position,c=a.attributes.uv,u=a.attributes.uv1,h=a.attributes.normal,g=a.groups,m=a.drawRange;if(o!==null)if(Array.isArray(s))for(let b=0,y=g.length;b<y;b++){const v=g[b],x=s[v.materialIndex],M=Math.max(v.start,m.start),w=Math.min(o.count,Math.min(v.start+v.count,m.start+m.count));for(let C=M,T=w;C<T;C+=3){const R=o.getX(C),A=o.getX(C+1),j=o.getX(C+2);i=Ey(this,x,e,r,c,u,h,R,A,j),i&&(i.faceIndex=Math.floor(C/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const b=Math.max(0,m.start),y=Math.min(o.count,m.start+m.count);for(let v=b,x=y;v<x;v+=3){const M=o.getX(v),w=o.getX(v+1),C=o.getX(v+2);i=Ey(this,s,e,r,c,u,h,M,w,C),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}else if(l!==void 0)if(Array.isArray(s))for(let b=0,y=g.length;b<y;b++){const v=g[b],x=s[v.materialIndex],M=Math.max(v.start,m.start),w=Math.min(l.count,Math.min(v.start+v.count,m.start+m.count));for(let C=M,T=w;C<T;C+=3){const R=C,A=C+1,j=C+2;i=Ey(this,x,e,r,c,u,h,R,A,j),i&&(i.faceIndex=Math.floor(C/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const b=Math.max(0,m.start),y=Math.min(l.count,m.start+m.count);for(let v=b,x=y;v<x;v+=3){const M=v,w=v+1,C=v+2;i=Ey(this,s,e,r,c,u,h,M,w,C),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}}}function Yxe(t,e,n,r,i,a,s,o){let l;if(e.side===Fa?l=r.intersectTriangle(s,a,i,!0,o):l=r.intersectTriangle(i,a,s,e.side===Qu,o),l===null)return null;My.copy(o),My.applyMatrix4(t.matrixWorld);const c=n.ray.origin.distanceTo(My);return c<n.near||c>n.far?null:{distance:c,point:My.clone(),object:t}}function Ey(t,e,n,r,i,a,s,o,l,c){t.getVertexPosition(o,ip),t.getVertexPosition(l,ap),t.getVertexPosition(c,sp);const u=Yxe(t,e,n,r,ip,ap,sp,wy);if(u){i&&(yy.fromBufferAttribute(i,o),_y.fromBufferAttribute(i,l),Sy.fromBufferAttribute(i,c),u.uv=uo.getInterpolation(wy,ip,ap,sp,yy,_y,Sy,new Kt)),a&&(yy.fromBufferAttribute(a,o),_y.fromBufferAttribute(a,l),Sy.fromBufferAttribute(a,c),u.uv1=uo.getInterpolation(wy,ip,ap,sp,yy,_y,Sy,new Kt),u.uv2=u.uv1),s&&(p5.fromBufferAttribute(s,o),m5.fromBufferAttribute(s,l),g5.fromBufferAttribute(s,c),u.normal=uo.getInterpolation(wy,ip,ap,sp,p5,m5,g5,new Ce),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));const h={a:o,b:l,c,normal:new Ce,materialIndex:0};uo.getNormal(ip,ap,sp,h.normal),u.face=h}return u}class $0 extends oa{constructor(e=1,n=1,r=1,i=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:s};const o=this;i=Math.floor(i),a=Math.floor(a),s=Math.floor(s);const l=[],c=[],u=[],h=[];let g=0,m=0;b("z","y","x",-1,-1,r,n,e,s,a,0),b("z","y","x",1,-1,r,n,-e,s,a,1),b("x","z","y",1,1,e,r,n,i,s,2),b("x","z","y",1,-1,e,r,-n,i,s,3),b("x","y","z",1,-1,e,n,r,i,a,4),b("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(l),this.setAttribute("position",new Or(c,3)),this.setAttribute("normal",new Or(u,3)),this.setAttribute("uv",new Or(h,2));function b(y,v,x,M,w,C,T,R,A,j,N){const k=C/A,F=T/j,I=C/2,W=T/2,D=R/2,B=A+1,G=j+1;let V=0,Z=0;const Y=new Ce;for(let ee=0;ee<G;ee++){const H=ee*F-W;for(let q=0;q<B;q++){const ae=q*k-I;Y[y]=ae*M,Y[v]=H*w,Y[x]=D,c.push(Y.x,Y.y,Y.z),Y[y]=0,Y[v]=0,Y[x]=R>0?1:-1,u.push(Y.x,Y.y,Y.z),h.push(q/A),h.push(1-ee/j),V+=1}}for(let ee=0;ee<j;ee++)for(let H=0;H<A;H++){const q=g+H+B*ee,ae=g+H+B*(ee+1),ce=g+(H+1)+B*(ee+1),xe=g+(H+1)+B*ee;l.push(q,ae,xe),l.push(ae,ce,xe),Z+=6}o.addGroup(m,Z,N),m+=Z,g+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $0(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function nm(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 ha(t){const e={};for(let n=0;n<t.length;n++){const r=nm(t[n]);for(const i in r)e[i]=r[i]}return e}function Zxe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function k7(t){return t.getRenderTarget()===null?t.outputColorSpace:$n.workingColorSpace}const bk={clone:nm,merge:ha};var Qxe=`void main() {
  3840. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  3841. }`,Jxe=`void main() {
  3842. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  3843. }`;class Ju extends Cm{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Qxe,this.fragmentShader=Jxe,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=nm(e.uniforms),this.uniformsGroups=Zxe(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 D7 extends va{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Jn,this.projectionMatrix=new Jn,this.projectionMatrixInverse=new Jn,this.coordinateSystem=Ko}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 ss extends D7{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=a0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Sx*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return a0*2*Math.atan(Math.tan(Sx*.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(Sx*.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 l=s.fullWidth,c=s.fullHeight;a+=s.offsetX*i/l,n-=s.offsetY*r/c,i*=s.width/l,r*=s.height/c}const o=this.filmOffset;o!==0&&(a+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}const op=-90,lp=1;class e0e extends va{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ss(op,lp,e,n);i.layers=this.layers,this.add(i);const a=new ss(op,lp,e,n);a.layers=this.layers,this.add(a);const s=new ss(op,lp,e,n);s.layers=this.layers,this.add(s);const o=new ss(op,lp,e,n);o.layers=this.layers,this.add(o);const l=new ss(op,lp,e,n);l.layers=this.layers,this.add(l);const c=new ss(op,lp,e,n);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,s,o,l]=n;for(const c of n)this.remove(c);if(e===Ko)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===i0)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of n)this.add(c),c.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,s,o,l,c,u]=this.children,h=e.getRenderTarget(),g=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),b=e.xr.enabled;e.xr.enabled=!1;const y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,s),e.setRenderTarget(r,2,i),e.render(n,o),e.setRenderTarget(r,3,i),e.render(n,l),e.setRenderTarget(r,4,i),e.render(n,c),r.texture.generateMipmaps=y,e.setRenderTarget(r,5,i),e.render(n,u),e.setRenderTarget(h,g,m),e.xr.enabled=b,r.texture.needsPMREMUpdate=!0}}class O7 extends za{constructor(e,n,r,i,a,s,o,l,c,u){e=e!==void 0?e:[],n=n!==void 0?n:Jp,super(e,n,r,i,a,s,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class t0e extends kf{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&&(Mx("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===uf?$i:zs),this.texture=new O7(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:Us}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
  3844. varying vec3 vWorldDirection;
  3845. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  3846. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  3847. }
  3848. void main() {
  3849. vWorldDirection = transformDirection( position, modelMatrix );
  3850. #include <begin_vertex>
  3851. #include <project_vertex>
  3852. }
  3853. `,fragmentShader:`
  3854. uniform sampler2D tEquirect;
  3855. varying vec3 vWorldDirection;
  3856. #include <common>
  3857. void main() {
  3858. vec3 direction = normalize( vWorldDirection );
  3859. vec2 sampleUV = equirectUv( direction );
  3860. gl_FragColor = texture2D( tEquirect, sampleUV );
  3861. }
  3862. `},i=new $0(5,5,5),a=new Ju({name:"CubemapFromEquirect",uniforms:nm(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Fa,blending:zu});a.uniforms.tEquirect.value=n;const s=new vo(i,a),o=n.minFilter;return n.minFilter===n0&&(n.minFilter=Us),new e0e(1,10,this).update(e,s),n.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,n,r,i){const a=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(n,r,i);e.setRenderTarget(a)}}const $T=new Ce,n0e=new Ce,r0e=new fn;class _u{constructor(e=new Ce(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=$T.subVectors(r,n).cross(n0e.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($T),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||r0e.getNormalMatrix(e),i=this.coplanarPoint($T).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 Fd=new Zo,Ay=new Ce;class uw{constructor(e=new _u,n=new _u,r=new _u,i=new _u,a=new _u,s=new _u){this.planes=[e,n,r,i,a,s]}set(e,n,r,i,a,s){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(a),o[5].copy(s),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=Ko){const r=this.planes,i=e.elements,a=i[0],s=i[1],o=i[2],l=i[3],c=i[4],u=i[5],h=i[6],g=i[7],m=i[8],b=i[9],y=i[10],v=i[11],x=i[12],M=i[13],w=i[14],C=i[15];if(r[0].setComponents(l-a,g-c,v-m,C-x).normalize(),r[1].setComponents(l+a,g+c,v+m,C+x).normalize(),r[2].setComponents(l+s,g+u,v+b,C+M).normalize(),r[3].setComponents(l-s,g-u,v-b,C-M).normalize(),r[4].setComponents(l-o,g-h,v-y,C-w).normalize(),n===Ko)r[5].setComponents(l+o,g+h,v+y,C+w).normalize();else if(n===i0)r[5].setComponents(o,h,y,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Fd.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Fd.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Fd)}intersectsSprite(e){return Fd.center.set(0,0,0),Fd.radius=.7071067811865476,Fd.applyMatrix4(e.matrixWorld),this.intersectsSphere(Fd)}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(Ay.x=i.normal.x>0?e.max.x:e.min.x,Ay.y=i.normal.y>0?e.max.y:e.min.y,Ay.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Ay)<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 L7(){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 i0e(t,e){const n=e.isWebGL2,r=new WeakMap;function i(c,u){const h=c.array,g=c.usage,m=h.byteLength,b=t.createBuffer();t.bindBuffer(u,b),t.bufferData(u,h,g),c.onUploadCallback();let y;if(h instanceof Float32Array)y=t.FLOAT;else if(h instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(n)y=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else y=t.UNSIGNED_SHORT;else if(h instanceof Int16Array)y=t.SHORT;else if(h instanceof Uint32Array)y=t.UNSIGNED_INT;else if(h instanceof Int32Array)y=t.INT;else if(h instanceof Int8Array)y=t.BYTE;else if(h instanceof Uint8Array)y=t.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)y=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:b,type:y,bytesPerElement:h.BYTES_PER_ELEMENT,version:c.version,size:m}}function a(c,u,h){const g=u.array,m=u._updateRange,b=u.updateRanges;if(t.bindBuffer(h,c),m.count===-1&&b.length===0&&t.bufferSubData(h,0,g),b.length!==0){for(let y=0,v=b.length;y<v;y++){const x=b[y];n?t.bufferSubData(h,x.start*g.BYTES_PER_ELEMENT,g,x.start,x.count):t.bufferSubData(h,x.start*g.BYTES_PER_ELEMENT,g.subarray(x.start,x.start+x.count))}u.clearUpdateRanges()}m.count!==-1&&(n?t.bufferSubData(h,m.offset*g.BYTES_PER_ELEMENT,g,m.offset,m.count):t.bufferSubData(h,m.offset*g.BYTES_PER_ELEMENT,g.subarray(m.offset,m.offset+m.count)),m.count=-1),u.onUploadCallback()}function s(c){return c.isInterleavedBufferAttribute&&(c=c.data),r.get(c)}function o(c){c.isInterleavedBufferAttribute&&(c=c.data);const u=r.get(c);u&&(t.deleteBuffer(u.buffer),r.delete(c))}function l(c,u){if(c.isGLBufferAttribute){const g=r.get(c);(!g||g.version<c.version)&&r.set(c,{buffer:c.buffer,type:c.type,bytesPerElement:c.elementSize,version:c.version});return}c.isInterleavedBufferAttribute&&(c=c.data);const h=r.get(c);if(h===void 0)r.set(c,i(c,u));else if(h.version<c.version){if(h.size!==c.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(h.buffer,c,u),h.version=c.version}}return{get:s,remove:o,update:l}}class yk extends oa{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,s=n/2,o=Math.floor(r),l=Math.floor(i),c=o+1,u=l+1,h=e/o,g=n/l,m=[],b=[],y=[],v=[];for(let x=0;x<u;x++){const M=x*g-s;for(let w=0;w<c;w++){const C=w*h-a;b.push(C,-M,0),y.push(0,0,1),v.push(w/o),v.push(1-x/l)}}for(let x=0;x<l;x++)for(let M=0;M<o;M++){const w=M+c*x,C=M+c*(x+1),T=M+1+c*(x+1),R=M+1+c*x;m.push(w,C,R),m.push(C,T,R)}this.setIndex(m),this.setAttribute("position",new Or(b,3)),this.setAttribute("normal",new Or(y,3)),this.setAttribute("uv",new Or(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new yk(e.width,e.height,e.widthSegments,e.heightSegments)}}var a0e=`#ifdef USE_ALPHAHASH
  3863. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  3864. #endif`,s0e=`#ifdef USE_ALPHAHASH
  3865. const float ALPHA_HASH_SCALE = 0.05;
  3866. float hash2D( vec2 value ) {
  3867. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  3868. }
  3869. float hash3D( vec3 value ) {
  3870. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  3871. }
  3872. float getAlphaHashThreshold( vec3 position ) {
  3873. float maxDeriv = max(
  3874. length( dFdx( position.xyz ) ),
  3875. length( dFdy( position.xyz ) )
  3876. );
  3877. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  3878. vec2 pixScales = vec2(
  3879. exp2( floor( log2( pixScale ) ) ),
  3880. exp2( ceil( log2( pixScale ) ) )
  3881. );
  3882. vec2 alpha = vec2(
  3883. hash3D( floor( pixScales.x * position.xyz ) ),
  3884. hash3D( floor( pixScales.y * position.xyz ) )
  3885. );
  3886. float lerpFactor = fract( log2( pixScale ) );
  3887. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  3888. float a = min( lerpFactor, 1.0 - lerpFactor );
  3889. vec3 cases = vec3(
  3890. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  3891. ( x - 0.5 * a ) / ( 1.0 - a ),
  3892. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  3893. );
  3894. float threshold = ( x < ( 1.0 - a ) )
  3895. ? ( ( x < a ) ? cases.x : cases.y )
  3896. : cases.z;
  3897. return clamp( threshold , 1.0e-6, 1.0 );
  3898. }
  3899. #endif`,o0e=`#ifdef USE_ALPHAMAP
  3900. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  3901. #endif`,l0e=`#ifdef USE_ALPHAMAP
  3902. uniform sampler2D alphaMap;
  3903. #endif`,c0e=`#ifdef USE_ALPHATEST
  3904. if ( diffuseColor.a < alphaTest ) discard;
  3905. #endif`,u0e=`#ifdef USE_ALPHATEST
  3906. uniform float alphaTest;
  3907. #endif`,d0e=`#ifdef USE_AOMAP
  3908. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  3909. reflectedLight.indirectDiffuse *= ambientOcclusion;
  3910. #if defined( USE_CLEARCOAT )
  3911. clearcoatSpecularIndirect *= ambientOcclusion;
  3912. #endif
  3913. #if defined( USE_SHEEN )
  3914. sheenSpecularIndirect *= ambientOcclusion;
  3915. #endif
  3916. #if defined( USE_ENVMAP ) && defined( STANDARD )
  3917. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  3918. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  3919. #endif
  3920. #endif`,f0e=`#ifdef USE_AOMAP
  3921. uniform sampler2D aoMap;
  3922. uniform float aoMapIntensity;
  3923. #endif`,h0e=`#ifdef USE_BATCHING
  3924. attribute float batchId;
  3925. uniform highp sampler2D batchingTexture;
  3926. mat4 getBatchingMatrix( const in float i ) {
  3927. int size = textureSize( batchingTexture, 0 ).x;
  3928. int j = int( i ) * 4;
  3929. int x = j % size;
  3930. int y = j / size;
  3931. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  3932. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  3933. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  3934. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  3935. return mat4( v1, v2, v3, v4 );
  3936. }
  3937. #endif`,p0e=`#ifdef USE_BATCHING
  3938. mat4 batchingMatrix = getBatchingMatrix( batchId );
  3939. #endif`,m0e=`vec3 transformed = vec3( position );
  3940. #ifdef USE_ALPHAHASH
  3941. vPosition = vec3( position );
  3942. #endif`,g0e=`vec3 objectNormal = vec3( normal );
  3943. #ifdef USE_TANGENT
  3944. vec3 objectTangent = vec3( tangent.xyz );
  3945. #endif`,x0e=`float G_BlinnPhong_Implicit( ) {
  3946. return 0.25;
  3947. }
  3948. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  3949. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  3950. }
  3951. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  3952. vec3 halfDir = normalize( lightDir + viewDir );
  3953. float dotNH = saturate( dot( normal, halfDir ) );
  3954. float dotVH = saturate( dot( viewDir, halfDir ) );
  3955. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  3956. float G = G_BlinnPhong_Implicit( );
  3957. float D = D_BlinnPhong( shininess, dotNH );
  3958. return F * ( G * D );
  3959. } // validated`,v0e=`#ifdef USE_IRIDESCENCE
  3960. const mat3 XYZ_TO_REC709 = mat3(
  3961. 3.2404542, -0.9692660, 0.0556434,
  3962. -1.5371385, 1.8760108, -0.2040259,
  3963. -0.4985314, 0.0415560, 1.0572252
  3964. );
  3965. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  3966. vec3 sqrtF0 = sqrt( fresnel0 );
  3967. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  3968. }
  3969. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  3970. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  3971. }
  3972. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  3973. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  3974. }
  3975. vec3 evalSensitivity( float OPD, vec3 shift ) {
  3976. float phase = 2.0 * PI * OPD * 1.0e-9;
  3977. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  3978. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  3979. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  3980. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  3981. xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
  3982. xyz /= 1.0685e-7;
  3983. vec3 rgb = XYZ_TO_REC709 * xyz;
  3984. return rgb;
  3985. }
  3986. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  3987. vec3 I;
  3988. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  3989. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  3990. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  3991. if ( cosTheta2Sq < 0.0 ) {
  3992. return vec3( 1.0 );
  3993. }
  3994. float cosTheta2 = sqrt( cosTheta2Sq );
  3995. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  3996. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  3997. float T121 = 1.0 - R12;
  3998. float phi12 = 0.0;
  3999. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  4000. float phi21 = PI - phi12;
  4001. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  4002. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  4003. vec3 phi23 = vec3( 0.0 );
  4004. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  4005. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  4006. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  4007. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  4008. vec3 phi = vec3( phi21 ) + phi23;
  4009. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  4010. vec3 r123 = sqrt( R123 );
  4011. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  4012. vec3 C0 = R12 + Rs;
  4013. I = C0;
  4014. vec3 Cm = Rs - T121;
  4015. for ( int m = 1; m <= 2; ++ m ) {
  4016. Cm *= r123;
  4017. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  4018. I += Cm * Sm;
  4019. }
  4020. return max( I, vec3( 0.0 ) );
  4021. }
  4022. #endif`,b0e=`#ifdef USE_BUMPMAP
  4023. uniform sampler2D bumpMap;
  4024. uniform float bumpScale;
  4025. vec2 dHdxy_fwd() {
  4026. vec2 dSTdx = dFdx( vBumpMapUv );
  4027. vec2 dSTdy = dFdy( vBumpMapUv );
  4028. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  4029. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  4030. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  4031. return vec2( dBx, dBy );
  4032. }
  4033. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  4034. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  4035. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  4036. vec3 vN = surf_norm;
  4037. vec3 R1 = cross( vSigmaY, vN );
  4038. vec3 R2 = cross( vN, vSigmaX );
  4039. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  4040. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  4041. return normalize( abs( fDet ) * surf_norm - vGrad );
  4042. }
  4043. #endif`,y0e=`#if NUM_CLIPPING_PLANES > 0
  4044. vec4 plane;
  4045. #pragma unroll_loop_start
  4046. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  4047. plane = clippingPlanes[ i ];
  4048. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  4049. }
  4050. #pragma unroll_loop_end
  4051. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  4052. bool clipped = true;
  4053. #pragma unroll_loop_start
  4054. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  4055. plane = clippingPlanes[ i ];
  4056. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  4057. }
  4058. #pragma unroll_loop_end
  4059. if ( clipped ) discard;
  4060. #endif
  4061. #endif`,_0e=`#if NUM_CLIPPING_PLANES > 0
  4062. varying vec3 vClipPosition;
  4063. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  4064. #endif`,S0e=`#if NUM_CLIPPING_PLANES > 0
  4065. varying vec3 vClipPosition;
  4066. #endif`,w0e=`#if NUM_CLIPPING_PLANES > 0
  4067. vClipPosition = - mvPosition.xyz;
  4068. #endif`,M0e=`#if defined( USE_COLOR_ALPHA )
  4069. diffuseColor *= vColor;
  4070. #elif defined( USE_COLOR )
  4071. diffuseColor.rgb *= vColor;
  4072. #endif`,E0e=`#if defined( USE_COLOR_ALPHA )
  4073. varying vec4 vColor;
  4074. #elif defined( USE_COLOR )
  4075. varying vec3 vColor;
  4076. #endif`,A0e=`#if defined( USE_COLOR_ALPHA )
  4077. varying vec4 vColor;
  4078. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4079. varying vec3 vColor;
  4080. #endif`,T0e=`#if defined( USE_COLOR_ALPHA )
  4081. vColor = vec4( 1.0 );
  4082. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4083. vColor = vec3( 1.0 );
  4084. #endif
  4085. #ifdef USE_COLOR
  4086. vColor *= color;
  4087. #endif
  4088. #ifdef USE_INSTANCING_COLOR
  4089. vColor.xyz *= instanceColor.xyz;
  4090. #endif`,C0e=`#define PI 3.141592653589793
  4091. #define PI2 6.283185307179586
  4092. #define PI_HALF 1.5707963267948966
  4093. #define RECIPROCAL_PI 0.3183098861837907
  4094. #define RECIPROCAL_PI2 0.15915494309189535
  4095. #define EPSILON 1e-6
  4096. #ifndef saturate
  4097. #define saturate( a ) clamp( a, 0.0, 1.0 )
  4098. #endif
  4099. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  4100. float pow2( const in float x ) { return x*x; }
  4101. vec3 pow2( const in vec3 x ) { return x*x; }
  4102. float pow3( const in float x ) { return x*x*x; }
  4103. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  4104. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  4105. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  4106. highp float rand( const in vec2 uv ) {
  4107. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  4108. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  4109. return fract( sin( sn ) * c );
  4110. }
  4111. #ifdef HIGH_PRECISION
  4112. float precisionSafeLength( vec3 v ) { return length( v ); }
  4113. #else
  4114. float precisionSafeLength( vec3 v ) {
  4115. float maxComponent = max3( abs( v ) );
  4116. return length( v / maxComponent ) * maxComponent;
  4117. }
  4118. #endif
  4119. struct IncidentLight {
  4120. vec3 color;
  4121. vec3 direction;
  4122. bool visible;
  4123. };
  4124. struct ReflectedLight {
  4125. vec3 directDiffuse;
  4126. vec3 directSpecular;
  4127. vec3 indirectDiffuse;
  4128. vec3 indirectSpecular;
  4129. };
  4130. #ifdef USE_ALPHAHASH
  4131. varying vec3 vPosition;
  4132. #endif
  4133. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  4134. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  4135. }
  4136. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  4137. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  4138. }
  4139. mat3 transposeMat3( const in mat3 m ) {
  4140. mat3 tmp;
  4141. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  4142. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  4143. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  4144. return tmp;
  4145. }
  4146. float luminance( const in vec3 rgb ) {
  4147. const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
  4148. return dot( weights, rgb );
  4149. }
  4150. bool isPerspectiveMatrix( mat4 m ) {
  4151. return m[ 2 ][ 3 ] == - 1.0;
  4152. }
  4153. vec2 equirectUv( in vec3 dir ) {
  4154. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  4155. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  4156. return vec2( u, v );
  4157. }
  4158. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  4159. return RECIPROCAL_PI * diffuseColor;
  4160. }
  4161. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  4162. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4163. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4164. }
  4165. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  4166. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4167. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4168. } // validated`,N0e=`#ifdef ENVMAP_TYPE_CUBE_UV
  4169. #define cubeUV_minMipLevel 4.0
  4170. #define cubeUV_minTileSize 16.0
  4171. float getFace( vec3 direction ) {
  4172. vec3 absDirection = abs( direction );
  4173. float face = - 1.0;
  4174. if ( absDirection.x > absDirection.z ) {
  4175. if ( absDirection.x > absDirection.y )
  4176. face = direction.x > 0.0 ? 0.0 : 3.0;
  4177. else
  4178. face = direction.y > 0.0 ? 1.0 : 4.0;
  4179. } else {
  4180. if ( absDirection.z > absDirection.y )
  4181. face = direction.z > 0.0 ? 2.0 : 5.0;
  4182. else
  4183. face = direction.y > 0.0 ? 1.0 : 4.0;
  4184. }
  4185. return face;
  4186. }
  4187. vec2 getUV( vec3 direction, float face ) {
  4188. vec2 uv;
  4189. if ( face == 0.0 ) {
  4190. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  4191. } else if ( face == 1.0 ) {
  4192. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  4193. } else if ( face == 2.0 ) {
  4194. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  4195. } else if ( face == 3.0 ) {
  4196. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  4197. } else if ( face == 4.0 ) {
  4198. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  4199. } else {
  4200. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  4201. }
  4202. return 0.5 * ( uv + 1.0 );
  4203. }
  4204. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  4205. float face = getFace( direction );
  4206. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  4207. mipInt = max( mipInt, cubeUV_minMipLevel );
  4208. float faceSize = exp2( mipInt );
  4209. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  4210. if ( face > 2.0 ) {
  4211. uv.y += faceSize;
  4212. face -= 3.0;
  4213. }
  4214. uv.x += face * faceSize;
  4215. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  4216. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  4217. uv.x *= CUBEUV_TEXEL_WIDTH;
  4218. uv.y *= CUBEUV_TEXEL_HEIGHT;
  4219. #ifdef texture2DGradEXT
  4220. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  4221. #else
  4222. return texture2D( envMap, uv ).rgb;
  4223. #endif
  4224. }
  4225. #define cubeUV_r0 1.0
  4226. #define cubeUV_v0 0.339
  4227. #define cubeUV_m0 - 2.0
  4228. #define cubeUV_r1 0.8
  4229. #define cubeUV_v1 0.276
  4230. #define cubeUV_m1 - 1.0
  4231. #define cubeUV_r4 0.4
  4232. #define cubeUV_v4 0.046
  4233. #define cubeUV_m4 2.0
  4234. #define cubeUV_r5 0.305
  4235. #define cubeUV_v5 0.016
  4236. #define cubeUV_m5 3.0
  4237. #define cubeUV_r6 0.21
  4238. #define cubeUV_v6 0.0038
  4239. #define cubeUV_m6 4.0
  4240. float roughnessToMip( float roughness ) {
  4241. float mip = 0.0;
  4242. if ( roughness >= cubeUV_r1 ) {
  4243. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  4244. } else if ( roughness >= cubeUV_r4 ) {
  4245. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  4246. } else if ( roughness >= cubeUV_r5 ) {
  4247. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  4248. } else if ( roughness >= cubeUV_r6 ) {
  4249. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  4250. } else {
  4251. mip = - 2.0 * log2( 1.16 * roughness ); }
  4252. return mip;
  4253. }
  4254. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  4255. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  4256. float mipF = fract( mip );
  4257. float mipInt = floor( mip );
  4258. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  4259. if ( mipF == 0.0 ) {
  4260. return vec4( color0, 1.0 );
  4261. } else {
  4262. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  4263. return vec4( mix( color0, color1, mipF ), 1.0 );
  4264. }
  4265. }
  4266. #endif`,R0e=`vec3 transformedNormal = objectNormal;
  4267. #ifdef USE_TANGENT
  4268. vec3 transformedTangent = objectTangent;
  4269. #endif
  4270. #ifdef USE_BATCHING
  4271. mat3 bm = mat3( batchingMatrix );
  4272. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  4273. transformedNormal = bm * transformedNormal;
  4274. #ifdef USE_TANGENT
  4275. transformedTangent = bm * transformedTangent;
  4276. #endif
  4277. #endif
  4278. #ifdef USE_INSTANCING
  4279. mat3 im = mat3( instanceMatrix );
  4280. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  4281. transformedNormal = im * transformedNormal;
  4282. #ifdef USE_TANGENT
  4283. transformedTangent = im * transformedTangent;
  4284. #endif
  4285. #endif
  4286. transformedNormal = normalMatrix * transformedNormal;
  4287. #ifdef FLIP_SIDED
  4288. transformedNormal = - transformedNormal;
  4289. #endif
  4290. #ifdef USE_TANGENT
  4291. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  4292. #ifdef FLIP_SIDED
  4293. transformedTangent = - transformedTangent;
  4294. #endif
  4295. #endif`,P0e=`#ifdef USE_DISPLACEMENTMAP
  4296. uniform sampler2D displacementMap;
  4297. uniform float displacementScale;
  4298. uniform float displacementBias;
  4299. #endif`,k0e=`#ifdef USE_DISPLACEMENTMAP
  4300. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  4301. #endif`,D0e=`#ifdef USE_EMISSIVEMAP
  4302. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  4303. totalEmissiveRadiance *= emissiveColor.rgb;
  4304. #endif`,O0e=`#ifdef USE_EMISSIVEMAP
  4305. uniform sampler2D emissiveMap;
  4306. #endif`,L0e="gl_FragColor = linearToOutputTexel( gl_FragColor );",I0e=`
  4307. const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
  4308. vec3( 0.8224621, 0.177538, 0.0 ),
  4309. vec3( 0.0331941, 0.9668058, 0.0 ),
  4310. vec3( 0.0170827, 0.0723974, 0.9105199 )
  4311. );
  4312. const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
  4313. vec3( 1.2249401, - 0.2249404, 0.0 ),
  4314. vec3( - 0.0420569, 1.0420571, 0.0 ),
  4315. vec3( - 0.0196376, - 0.0786361, 1.0982735 )
  4316. );
  4317. vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
  4318. return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
  4319. }
  4320. vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
  4321. return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
  4322. }
  4323. vec4 LinearTransferOETF( in vec4 value ) {
  4324. return value;
  4325. }
  4326. vec4 sRGBTransferOETF( in vec4 value ) {
  4327. return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
  4328. }
  4329. vec4 LinearToLinear( in vec4 value ) {
  4330. return value;
  4331. }
  4332. vec4 LinearTosRGB( in vec4 value ) {
  4333. return sRGBTransferOETF( value );
  4334. }`,j0e=`#ifdef USE_ENVMAP
  4335. #ifdef ENV_WORLDPOS
  4336. vec3 cameraToFrag;
  4337. if ( isOrthographic ) {
  4338. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4339. } else {
  4340. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  4341. }
  4342. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4343. #ifdef ENVMAP_MODE_REFLECTION
  4344. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  4345. #else
  4346. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  4347. #endif
  4348. #else
  4349. vec3 reflectVec = vReflect;
  4350. #endif
  4351. #ifdef ENVMAP_TYPE_CUBE
  4352. vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  4353. #else
  4354. vec4 envColor = vec4( 0.0 );
  4355. #endif
  4356. #ifdef ENVMAP_BLENDING_MULTIPLY
  4357. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  4358. #elif defined( ENVMAP_BLENDING_MIX )
  4359. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  4360. #elif defined( ENVMAP_BLENDING_ADD )
  4361. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  4362. #endif
  4363. #endif`,U0e=`#ifdef USE_ENVMAP
  4364. uniform float envMapIntensity;
  4365. uniform float flipEnvMap;
  4366. #ifdef ENVMAP_TYPE_CUBE
  4367. uniform samplerCube envMap;
  4368. #else
  4369. uniform sampler2D envMap;
  4370. #endif
  4371. #endif`,F0e=`#ifdef USE_ENVMAP
  4372. uniform float reflectivity;
  4373. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4374. #define ENV_WORLDPOS
  4375. #endif
  4376. #ifdef ENV_WORLDPOS
  4377. varying vec3 vWorldPosition;
  4378. uniform float refractionRatio;
  4379. #else
  4380. varying vec3 vReflect;
  4381. #endif
  4382. #endif`,z0e=`#ifdef USE_ENVMAP
  4383. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4384. #define ENV_WORLDPOS
  4385. #endif
  4386. #ifdef ENV_WORLDPOS
  4387. varying vec3 vWorldPosition;
  4388. #else
  4389. varying vec3 vReflect;
  4390. uniform float refractionRatio;
  4391. #endif
  4392. #endif`,B0e=`#ifdef USE_ENVMAP
  4393. #ifdef ENV_WORLDPOS
  4394. vWorldPosition = worldPosition.xyz;
  4395. #else
  4396. vec3 cameraToVertex;
  4397. if ( isOrthographic ) {
  4398. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4399. } else {
  4400. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  4401. }
  4402. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  4403. #ifdef ENVMAP_MODE_REFLECTION
  4404. vReflect = reflect( cameraToVertex, worldNormal );
  4405. #else
  4406. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  4407. #endif
  4408. #endif
  4409. #endif`,H0e=`#ifdef USE_FOG
  4410. vFogDepth = - mvPosition.z;
  4411. #endif`,$0e=`#ifdef USE_FOG
  4412. varying float vFogDepth;
  4413. #endif`,V0e=`#ifdef USE_FOG
  4414. #ifdef FOG_EXP2
  4415. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  4416. #else
  4417. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  4418. #endif
  4419. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  4420. #endif`,G0e=`#ifdef USE_FOG
  4421. uniform vec3 fogColor;
  4422. varying float vFogDepth;
  4423. #ifdef FOG_EXP2
  4424. uniform float fogDensity;
  4425. #else
  4426. uniform float fogNear;
  4427. uniform float fogFar;
  4428. #endif
  4429. #endif`,W0e=`#ifdef USE_GRADIENTMAP
  4430. uniform sampler2D gradientMap;
  4431. #endif
  4432. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  4433. float dotNL = dot( normal, lightDirection );
  4434. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  4435. #ifdef USE_GRADIENTMAP
  4436. return vec3( texture2D( gradientMap, coord ).r );
  4437. #else
  4438. vec2 fw = fwidth( coord ) * 0.5;
  4439. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  4440. #endif
  4441. }`,q0e=`#ifdef USE_LIGHTMAP
  4442. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  4443. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  4444. reflectedLight.indirectDiffuse += lightMapIrradiance;
  4445. #endif`,X0e=`#ifdef USE_LIGHTMAP
  4446. uniform sampler2D lightMap;
  4447. uniform float lightMapIntensity;
  4448. #endif`,K0e=`LambertMaterial material;
  4449. material.diffuseColor = diffuseColor.rgb;
  4450. material.specularStrength = specularStrength;`,Y0e=`varying vec3 vViewPosition;
  4451. struct LambertMaterial {
  4452. vec3 diffuseColor;
  4453. float specularStrength;
  4454. };
  4455. void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  4456. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4457. vec3 irradiance = dotNL * directLight.color;
  4458. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4459. }
  4460. void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  4461. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4462. }
  4463. #define RE_Direct RE_Direct_Lambert
  4464. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Z0e=`uniform bool receiveShadow;
  4465. uniform vec3 ambientLightColor;
  4466. #if defined( USE_LIGHT_PROBES )
  4467. uniform vec3 lightProbe[ 9 ];
  4468. #endif
  4469. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  4470. float x = normal.x, y = normal.y, z = normal.z;
  4471. vec3 result = shCoefficients[ 0 ] * 0.886227;
  4472. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  4473. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  4474. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  4475. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  4476. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  4477. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  4478. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  4479. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  4480. return result;
  4481. }
  4482. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  4483. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4484. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  4485. return irradiance;
  4486. }
  4487. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  4488. vec3 irradiance = ambientLightColor;
  4489. return irradiance;
  4490. }
  4491. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  4492. #if defined ( LEGACY_LIGHTS )
  4493. if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
  4494. return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
  4495. }
  4496. return 1.0;
  4497. #else
  4498. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  4499. if ( cutoffDistance > 0.0 ) {
  4500. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  4501. }
  4502. return distanceFalloff;
  4503. #endif
  4504. }
  4505. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  4506. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  4507. }
  4508. #if NUM_DIR_LIGHTS > 0
  4509. struct DirectionalLight {
  4510. vec3 direction;
  4511. vec3 color;
  4512. };
  4513. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  4514. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  4515. light.color = directionalLight.color;
  4516. light.direction = directionalLight.direction;
  4517. light.visible = true;
  4518. }
  4519. #endif
  4520. #if NUM_POINT_LIGHTS > 0
  4521. struct PointLight {
  4522. vec3 position;
  4523. vec3 color;
  4524. float distance;
  4525. float decay;
  4526. };
  4527. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  4528. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4529. vec3 lVector = pointLight.position - geometryPosition;
  4530. light.direction = normalize( lVector );
  4531. float lightDistance = length( lVector );
  4532. light.color = pointLight.color;
  4533. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  4534. light.visible = ( light.color != vec3( 0.0 ) );
  4535. }
  4536. #endif
  4537. #if NUM_SPOT_LIGHTS > 0
  4538. struct SpotLight {
  4539. vec3 position;
  4540. vec3 direction;
  4541. vec3 color;
  4542. float distance;
  4543. float decay;
  4544. float coneCos;
  4545. float penumbraCos;
  4546. };
  4547. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  4548. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4549. vec3 lVector = spotLight.position - geometryPosition;
  4550. light.direction = normalize( lVector );
  4551. float angleCos = dot( light.direction, spotLight.direction );
  4552. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  4553. if ( spotAttenuation > 0.0 ) {
  4554. float lightDistance = length( lVector );
  4555. light.color = spotLight.color * spotAttenuation;
  4556. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  4557. light.visible = ( light.color != vec3( 0.0 ) );
  4558. } else {
  4559. light.color = vec3( 0.0 );
  4560. light.visible = false;
  4561. }
  4562. }
  4563. #endif
  4564. #if NUM_RECT_AREA_LIGHTS > 0
  4565. struct RectAreaLight {
  4566. vec3 color;
  4567. vec3 position;
  4568. vec3 halfWidth;
  4569. vec3 halfHeight;
  4570. };
  4571. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  4572. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  4573. #endif
  4574. #if NUM_HEMI_LIGHTS > 0
  4575. struct HemisphereLight {
  4576. vec3 direction;
  4577. vec3 skyColor;
  4578. vec3 groundColor;
  4579. };
  4580. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  4581. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  4582. float dotNL = dot( normal, hemiLight.direction );
  4583. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  4584. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  4585. return irradiance;
  4586. }
  4587. #endif`,Q0e=`#ifdef USE_ENVMAP
  4588. vec3 getIBLIrradiance( const in vec3 normal ) {
  4589. #ifdef ENVMAP_TYPE_CUBE_UV
  4590. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4591. vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
  4592. return PI * envMapColor.rgb * envMapIntensity;
  4593. #else
  4594. return vec3( 0.0 );
  4595. #endif
  4596. }
  4597. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  4598. #ifdef ENVMAP_TYPE_CUBE_UV
  4599. vec3 reflectVec = reflect( - viewDir, normal );
  4600. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  4601. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  4602. vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
  4603. return envMapColor.rgb * envMapIntensity;
  4604. #else
  4605. return vec3( 0.0 );
  4606. #endif
  4607. }
  4608. #ifdef USE_ANISOTROPY
  4609. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  4610. #ifdef ENVMAP_TYPE_CUBE_UV
  4611. vec3 bentNormal = cross( bitangent, viewDir );
  4612. bentNormal = normalize( cross( bentNormal, bitangent ) );
  4613. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  4614. return getIBLRadiance( viewDir, bentNormal, roughness );
  4615. #else
  4616. return vec3( 0.0 );
  4617. #endif
  4618. }
  4619. #endif
  4620. #endif`,J0e=`ToonMaterial material;
  4621. material.diffuseColor = diffuseColor.rgb;`,eve=`varying vec3 vViewPosition;
  4622. struct ToonMaterial {
  4623. vec3 diffuseColor;
  4624. };
  4625. void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  4626. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  4627. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4628. }
  4629. void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  4630. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4631. }
  4632. #define RE_Direct RE_Direct_Toon
  4633. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,tve=`BlinnPhongMaterial material;
  4634. material.diffuseColor = diffuseColor.rgb;
  4635. material.specularColor = specular;
  4636. material.specularShininess = shininess;
  4637. material.specularStrength = specularStrength;`,nve=`varying vec3 vViewPosition;
  4638. struct BlinnPhongMaterial {
  4639. vec3 diffuseColor;
  4640. vec3 specularColor;
  4641. float specularShininess;
  4642. float specularStrength;
  4643. };
  4644. void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  4645. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4646. vec3 irradiance = dotNL * directLight.color;
  4647. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4648. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  4649. }
  4650. void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  4651. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4652. }
  4653. #define RE_Direct RE_Direct_BlinnPhong
  4654. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,rve=`PhysicalMaterial material;
  4655. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  4656. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  4657. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  4658. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  4659. material.roughness = min( material.roughness, 1.0 );
  4660. #ifdef IOR
  4661. material.ior = ior;
  4662. #ifdef USE_SPECULAR
  4663. float specularIntensityFactor = specularIntensity;
  4664. vec3 specularColorFactor = specularColor;
  4665. #ifdef USE_SPECULAR_COLORMAP
  4666. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  4667. #endif
  4668. #ifdef USE_SPECULAR_INTENSITYMAP
  4669. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  4670. #endif
  4671. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  4672. #else
  4673. float specularIntensityFactor = 1.0;
  4674. vec3 specularColorFactor = vec3( 1.0 );
  4675. material.specularF90 = 1.0;
  4676. #endif
  4677. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  4678. #else
  4679. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  4680. material.specularF90 = 1.0;
  4681. #endif
  4682. #ifdef USE_CLEARCOAT
  4683. material.clearcoat = clearcoat;
  4684. material.clearcoatRoughness = clearcoatRoughness;
  4685. material.clearcoatF0 = vec3( 0.04 );
  4686. material.clearcoatF90 = 1.0;
  4687. #ifdef USE_CLEARCOATMAP
  4688. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  4689. #endif
  4690. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  4691. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  4692. #endif
  4693. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  4694. material.clearcoatRoughness += geometryRoughness;
  4695. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  4696. #endif
  4697. #ifdef USE_IRIDESCENCE
  4698. material.iridescence = iridescence;
  4699. material.iridescenceIOR = iridescenceIOR;
  4700. #ifdef USE_IRIDESCENCEMAP
  4701. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  4702. #endif
  4703. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  4704. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  4705. #else
  4706. material.iridescenceThickness = iridescenceThicknessMaximum;
  4707. #endif
  4708. #endif
  4709. #ifdef USE_SHEEN
  4710. material.sheenColor = sheenColor;
  4711. #ifdef USE_SHEEN_COLORMAP
  4712. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  4713. #endif
  4714. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  4715. #ifdef USE_SHEEN_ROUGHNESSMAP
  4716. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  4717. #endif
  4718. #endif
  4719. #ifdef USE_ANISOTROPY
  4720. #ifdef USE_ANISOTROPYMAP
  4721. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  4722. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  4723. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  4724. #else
  4725. vec2 anisotropyV = anisotropyVector;
  4726. #endif
  4727. material.anisotropy = length( anisotropyV );
  4728. if( material.anisotropy == 0.0 ) {
  4729. anisotropyV = vec2( 1.0, 0.0 );
  4730. } else {
  4731. anisotropyV /= material.anisotropy;
  4732. material.anisotropy = saturate( material.anisotropy );
  4733. }
  4734. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  4735. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  4736. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  4737. #endif`,ive=`struct PhysicalMaterial {
  4738. vec3 diffuseColor;
  4739. float roughness;
  4740. vec3 specularColor;
  4741. float specularF90;
  4742. #ifdef USE_CLEARCOAT
  4743. float clearcoat;
  4744. float clearcoatRoughness;
  4745. vec3 clearcoatF0;
  4746. float clearcoatF90;
  4747. #endif
  4748. #ifdef USE_IRIDESCENCE
  4749. float iridescence;
  4750. float iridescenceIOR;
  4751. float iridescenceThickness;
  4752. vec3 iridescenceFresnel;
  4753. vec3 iridescenceF0;
  4754. #endif
  4755. #ifdef USE_SHEEN
  4756. vec3 sheenColor;
  4757. float sheenRoughness;
  4758. #endif
  4759. #ifdef IOR
  4760. float ior;
  4761. #endif
  4762. #ifdef USE_TRANSMISSION
  4763. float transmission;
  4764. float transmissionAlpha;
  4765. float thickness;
  4766. float attenuationDistance;
  4767. vec3 attenuationColor;
  4768. #endif
  4769. #ifdef USE_ANISOTROPY
  4770. float anisotropy;
  4771. float alphaT;
  4772. vec3 anisotropyT;
  4773. vec3 anisotropyB;
  4774. #endif
  4775. };
  4776. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  4777. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  4778. vec3 sheenSpecularDirect = vec3( 0.0 );
  4779. vec3 sheenSpecularIndirect = vec3(0.0 );
  4780. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  4781. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  4782. float x2 = x * x;
  4783. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  4784. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  4785. }
  4786. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  4787. float a2 = pow2( alpha );
  4788. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  4789. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  4790. return 0.5 / max( gv + gl, EPSILON );
  4791. }
  4792. float D_GGX( const in float alpha, const in float dotNH ) {
  4793. float a2 = pow2( alpha );
  4794. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  4795. return RECIPROCAL_PI * a2 / pow2( denom );
  4796. }
  4797. #ifdef USE_ANISOTROPY
  4798. float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
  4799. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  4800. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  4801. float v = 0.5 / ( gv + gl );
  4802. return saturate(v);
  4803. }
  4804. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  4805. float a2 = alphaT * alphaB;
  4806. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  4807. highp float v2 = dot( v, v );
  4808. float w2 = a2 / v2;
  4809. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  4810. }
  4811. #endif
  4812. #ifdef USE_CLEARCOAT
  4813. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  4814. vec3 f0 = material.clearcoatF0;
  4815. float f90 = material.clearcoatF90;
  4816. float roughness = material.clearcoatRoughness;
  4817. float alpha = pow2( roughness );
  4818. vec3 halfDir = normalize( lightDir + viewDir );
  4819. float dotNL = saturate( dot( normal, lightDir ) );
  4820. float dotNV = saturate( dot( normal, viewDir ) );
  4821. float dotNH = saturate( dot( normal, halfDir ) );
  4822. float dotVH = saturate( dot( viewDir, halfDir ) );
  4823. vec3 F = F_Schlick( f0, f90, dotVH );
  4824. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4825. float D = D_GGX( alpha, dotNH );
  4826. return F * ( V * D );
  4827. }
  4828. #endif
  4829. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  4830. vec3 f0 = material.specularColor;
  4831. float f90 = material.specularF90;
  4832. float roughness = material.roughness;
  4833. float alpha = pow2( roughness );
  4834. vec3 halfDir = normalize( lightDir + viewDir );
  4835. float dotNL = saturate( dot( normal, lightDir ) );
  4836. float dotNV = saturate( dot( normal, viewDir ) );
  4837. float dotNH = saturate( dot( normal, halfDir ) );
  4838. float dotVH = saturate( dot( viewDir, halfDir ) );
  4839. vec3 F = F_Schlick( f0, f90, dotVH );
  4840. #ifdef USE_IRIDESCENCE
  4841. F = mix( F, material.iridescenceFresnel, material.iridescence );
  4842. #endif
  4843. #ifdef USE_ANISOTROPY
  4844. float dotTL = dot( material.anisotropyT, lightDir );
  4845. float dotTV = dot( material.anisotropyT, viewDir );
  4846. float dotTH = dot( material.anisotropyT, halfDir );
  4847. float dotBL = dot( material.anisotropyB, lightDir );
  4848. float dotBV = dot( material.anisotropyB, viewDir );
  4849. float dotBH = dot( material.anisotropyB, halfDir );
  4850. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  4851. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  4852. #else
  4853. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4854. float D = D_GGX( alpha, dotNH );
  4855. #endif
  4856. return F * ( V * D );
  4857. }
  4858. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  4859. const float LUT_SIZE = 64.0;
  4860. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  4861. const float LUT_BIAS = 0.5 / LUT_SIZE;
  4862. float dotNV = saturate( dot( N, V ) );
  4863. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  4864. uv = uv * LUT_SCALE + LUT_BIAS;
  4865. return uv;
  4866. }
  4867. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  4868. float l = length( f );
  4869. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  4870. }
  4871. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  4872. float x = dot( v1, v2 );
  4873. float y = abs( x );
  4874. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  4875. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  4876. float v = a / b;
  4877. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  4878. return cross( v1, v2 ) * theta_sintheta;
  4879. }
  4880. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  4881. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  4882. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  4883. vec3 lightNormal = cross( v1, v2 );
  4884. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  4885. vec3 T1, T2;
  4886. T1 = normalize( V - N * dot( V, N ) );
  4887. T2 = - cross( N, T1 );
  4888. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  4889. vec3 coords[ 4 ];
  4890. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  4891. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  4892. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  4893. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  4894. coords[ 0 ] = normalize( coords[ 0 ] );
  4895. coords[ 1 ] = normalize( coords[ 1 ] );
  4896. coords[ 2 ] = normalize( coords[ 2 ] );
  4897. coords[ 3 ] = normalize( coords[ 3 ] );
  4898. vec3 vectorFormFactor = vec3( 0.0 );
  4899. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  4900. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  4901. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  4902. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  4903. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  4904. return vec3( result );
  4905. }
  4906. #if defined( USE_SHEEN )
  4907. float D_Charlie( float roughness, float dotNH ) {
  4908. float alpha = pow2( roughness );
  4909. float invAlpha = 1.0 / alpha;
  4910. float cos2h = dotNH * dotNH;
  4911. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  4912. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  4913. }
  4914. float V_Neubelt( float dotNV, float dotNL ) {
  4915. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  4916. }
  4917. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  4918. vec3 halfDir = normalize( lightDir + viewDir );
  4919. float dotNL = saturate( dot( normal, lightDir ) );
  4920. float dotNV = saturate( dot( normal, viewDir ) );
  4921. float dotNH = saturate( dot( normal, halfDir ) );
  4922. float D = D_Charlie( sheenRoughness, dotNH );
  4923. float V = V_Neubelt( dotNV, dotNL );
  4924. return sheenColor * ( D * V );
  4925. }
  4926. #endif
  4927. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  4928. float dotNV = saturate( dot( normal, viewDir ) );
  4929. float r2 = roughness * roughness;
  4930. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  4931. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  4932. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  4933. return saturate( DG * RECIPROCAL_PI );
  4934. }
  4935. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  4936. float dotNV = saturate( dot( normal, viewDir ) );
  4937. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  4938. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  4939. vec4 r = roughness * c0 + c1;
  4940. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  4941. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  4942. return fab;
  4943. }
  4944. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  4945. vec2 fab = DFGApprox( normal, viewDir, roughness );
  4946. return specularColor * fab.x + specularF90 * fab.y;
  4947. }
  4948. #ifdef USE_IRIDESCENCE
  4949. void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  4950. #else
  4951. void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  4952. #endif
  4953. vec2 fab = DFGApprox( normal, viewDir, roughness );
  4954. #ifdef USE_IRIDESCENCE
  4955. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  4956. #else
  4957. vec3 Fr = specularColor;
  4958. #endif
  4959. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  4960. float Ess = fab.x + fab.y;
  4961. float Ems = 1.0 - Ess;
  4962. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  4963. singleScatter += FssEss;
  4964. multiScatter += Fms * Ems;
  4965. }
  4966. #if NUM_RECT_AREA_LIGHTS > 0
  4967. void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  4968. vec3 normal = geometryNormal;
  4969. vec3 viewDir = geometryViewDir;
  4970. vec3 position = geometryPosition;
  4971. vec3 lightPos = rectAreaLight.position;
  4972. vec3 halfWidth = rectAreaLight.halfWidth;
  4973. vec3 halfHeight = rectAreaLight.halfHeight;
  4974. vec3 lightColor = rectAreaLight.color;
  4975. float roughness = material.roughness;
  4976. vec3 rectCoords[ 4 ];
  4977. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  4978. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  4979. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  4980. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  4981. vec4 t1 = texture2D( ltc_1, uv );
  4982. vec4 t2 = texture2D( ltc_2, uv );
  4983. mat3 mInv = mat3(
  4984. vec3( t1.x, 0, t1.y ),
  4985. vec3( 0, 1, 0 ),
  4986. vec3( t1.z, 0, t1.w )
  4987. );
  4988. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  4989. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  4990. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  4991. }
  4992. #endif
  4993. void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  4994. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4995. vec3 irradiance = dotNL * directLight.color;
  4996. #ifdef USE_CLEARCOAT
  4997. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  4998. vec3 ccIrradiance = dotNLcc * directLight.color;
  4999. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  5000. #endif
  5001. #ifdef USE_SHEEN
  5002. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  5003. #endif
  5004. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
  5005. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5006. }
  5007. void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  5008. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5009. }
  5010. void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
  5011. #ifdef USE_CLEARCOAT
  5012. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  5013. #endif
  5014. #ifdef USE_SHEEN
  5015. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  5016. #endif
  5017. vec3 singleScattering = vec3( 0.0 );
  5018. vec3 multiScattering = vec3( 0.0 );
  5019. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  5020. #ifdef USE_IRIDESCENCE
  5021. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  5022. #else
  5023. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  5024. #endif
  5025. vec3 totalScattering = singleScattering + multiScattering;
  5026. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  5027. reflectedLight.indirectSpecular += radiance * singleScattering;
  5028. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  5029. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  5030. }
  5031. #define RE_Direct RE_Direct_Physical
  5032. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  5033. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  5034. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  5035. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  5036. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  5037. }`,ave=`
  5038. vec3 geometryPosition = - vViewPosition;
  5039. vec3 geometryNormal = normal;
  5040. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  5041. vec3 geometryClearcoatNormal = vec3( 0.0 );
  5042. #ifdef USE_CLEARCOAT
  5043. geometryClearcoatNormal = clearcoatNormal;
  5044. #endif
  5045. #ifdef USE_IRIDESCENCE
  5046. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  5047. if ( material.iridescenceThickness == 0.0 ) {
  5048. material.iridescence = 0.0;
  5049. } else {
  5050. material.iridescence = saturate( material.iridescence );
  5051. }
  5052. if ( material.iridescence > 0.0 ) {
  5053. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  5054. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  5055. }
  5056. #endif
  5057. IncidentLight directLight;
  5058. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  5059. PointLight pointLight;
  5060. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  5061. PointLightShadow pointLightShadow;
  5062. #endif
  5063. #pragma unroll_loop_start
  5064. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  5065. pointLight = pointLights[ i ];
  5066. getPointLightInfo( pointLight, geometryPosition, directLight );
  5067. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  5068. pointLightShadow = pointLightShadows[ i ];
  5069. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  5070. #endif
  5071. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5072. }
  5073. #pragma unroll_loop_end
  5074. #endif
  5075. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  5076. SpotLight spotLight;
  5077. vec4 spotColor;
  5078. vec3 spotLightCoord;
  5079. bool inSpotLightMap;
  5080. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  5081. SpotLightShadow spotLightShadow;
  5082. #endif
  5083. #pragma unroll_loop_start
  5084. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  5085. spotLight = spotLights[ i ];
  5086. getSpotLightInfo( spotLight, geometryPosition, directLight );
  5087. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5088. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  5089. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5090. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  5091. #else
  5092. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5093. #endif
  5094. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  5095. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  5096. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  5097. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  5098. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  5099. #endif
  5100. #undef SPOT_LIGHT_MAP_INDEX
  5101. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5102. spotLightShadow = spotLightShadows[ i ];
  5103. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5104. #endif
  5105. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5106. }
  5107. #pragma unroll_loop_end
  5108. #endif
  5109. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  5110. DirectionalLight directionalLight;
  5111. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  5112. DirectionalLightShadow directionalLightShadow;
  5113. #endif
  5114. #pragma unroll_loop_start
  5115. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  5116. directionalLight = directionalLights[ i ];
  5117. getDirectionalLightInfo( directionalLight, directLight );
  5118. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  5119. directionalLightShadow = directionalLightShadows[ i ];
  5120. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5121. #endif
  5122. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5123. }
  5124. #pragma unroll_loop_end
  5125. #endif
  5126. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  5127. RectAreaLight rectAreaLight;
  5128. #pragma unroll_loop_start
  5129. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  5130. rectAreaLight = rectAreaLights[ i ];
  5131. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5132. }
  5133. #pragma unroll_loop_end
  5134. #endif
  5135. #if defined( RE_IndirectDiffuse )
  5136. vec3 iblIrradiance = vec3( 0.0 );
  5137. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  5138. #if defined( USE_LIGHT_PROBES )
  5139. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  5140. #endif
  5141. #if ( NUM_HEMI_LIGHTS > 0 )
  5142. #pragma unroll_loop_start
  5143. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  5144. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  5145. }
  5146. #pragma unroll_loop_end
  5147. #endif
  5148. #endif
  5149. #if defined( RE_IndirectSpecular )
  5150. vec3 radiance = vec3( 0.0 );
  5151. vec3 clearcoatRadiance = vec3( 0.0 );
  5152. #endif`,sve=`#if defined( RE_IndirectDiffuse )
  5153. #ifdef USE_LIGHTMAP
  5154. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  5155. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  5156. irradiance += lightMapIrradiance;
  5157. #endif
  5158. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  5159. iblIrradiance += getIBLIrradiance( geometryNormal );
  5160. #endif
  5161. #endif
  5162. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  5163. #ifdef USE_ANISOTROPY
  5164. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  5165. #else
  5166. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  5167. #endif
  5168. #ifdef USE_CLEARCOAT
  5169. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  5170. #endif
  5171. #endif`,ove=`#if defined( RE_IndirectDiffuse )
  5172. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5173. #endif
  5174. #if defined( RE_IndirectSpecular )
  5175. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5176. #endif`,lve=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5177. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  5178. #endif`,cve=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5179. uniform float logDepthBufFC;
  5180. varying float vFragDepth;
  5181. varying float vIsPerspective;
  5182. #endif`,uve=`#ifdef USE_LOGDEPTHBUF
  5183. #ifdef USE_LOGDEPTHBUF_EXT
  5184. varying float vFragDepth;
  5185. varying float vIsPerspective;
  5186. #else
  5187. uniform float logDepthBufFC;
  5188. #endif
  5189. #endif`,dve=`#ifdef USE_LOGDEPTHBUF
  5190. #ifdef USE_LOGDEPTHBUF_EXT
  5191. vFragDepth = 1.0 + gl_Position.w;
  5192. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  5193. #else
  5194. if ( isPerspectiveMatrix( projectionMatrix ) ) {
  5195. gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
  5196. gl_Position.z *= gl_Position.w;
  5197. }
  5198. #endif
  5199. #endif`,fve=`#ifdef USE_MAP
  5200. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  5201. #ifdef DECODE_VIDEO_TEXTURE
  5202. sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
  5203. #endif
  5204. diffuseColor *= sampledDiffuseColor;
  5205. #endif`,hve=`#ifdef USE_MAP
  5206. uniform sampler2D map;
  5207. #endif`,pve=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5208. #if defined( USE_POINTS_UV )
  5209. vec2 uv = vUv;
  5210. #else
  5211. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  5212. #endif
  5213. #endif
  5214. #ifdef USE_MAP
  5215. diffuseColor *= texture2D( map, uv );
  5216. #endif
  5217. #ifdef USE_ALPHAMAP
  5218. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  5219. #endif`,mve=`#if defined( USE_POINTS_UV )
  5220. varying vec2 vUv;
  5221. #else
  5222. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5223. uniform mat3 uvTransform;
  5224. #endif
  5225. #endif
  5226. #ifdef USE_MAP
  5227. uniform sampler2D map;
  5228. #endif
  5229. #ifdef USE_ALPHAMAP
  5230. uniform sampler2D alphaMap;
  5231. #endif`,gve=`float metalnessFactor = metalness;
  5232. #ifdef USE_METALNESSMAP
  5233. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  5234. metalnessFactor *= texelMetalness.b;
  5235. #endif`,xve=`#ifdef USE_METALNESSMAP
  5236. uniform sampler2D metalnessMap;
  5237. #endif`,vve=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
  5238. vColor *= morphTargetBaseInfluence;
  5239. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5240. #if defined( USE_COLOR_ALPHA )
  5241. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  5242. #elif defined( USE_COLOR )
  5243. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  5244. #endif
  5245. }
  5246. #endif`,bve=`#ifdef USE_MORPHNORMALS
  5247. objectNormal *= morphTargetBaseInfluence;
  5248. #ifdef MORPHTARGETS_TEXTURE
  5249. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5250. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  5251. }
  5252. #else
  5253. objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
  5254. objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
  5255. objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
  5256. objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
  5257. #endif
  5258. #endif`,yve=`#ifdef USE_MORPHTARGETS
  5259. uniform float morphTargetBaseInfluence;
  5260. #ifdef MORPHTARGETS_TEXTURE
  5261. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  5262. uniform sampler2DArray morphTargetsTexture;
  5263. uniform ivec2 morphTargetsTextureSize;
  5264. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  5265. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  5266. int y = texelIndex / morphTargetsTextureSize.x;
  5267. int x = texelIndex - y * morphTargetsTextureSize.x;
  5268. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  5269. return texelFetch( morphTargetsTexture, morphUV, 0 );
  5270. }
  5271. #else
  5272. #ifndef USE_MORPHNORMALS
  5273. uniform float morphTargetInfluences[ 8 ];
  5274. #else
  5275. uniform float morphTargetInfluences[ 4 ];
  5276. #endif
  5277. #endif
  5278. #endif`,_ve=`#ifdef USE_MORPHTARGETS
  5279. transformed *= morphTargetBaseInfluence;
  5280. #ifdef MORPHTARGETS_TEXTURE
  5281. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5282. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  5283. }
  5284. #else
  5285. transformed += morphTarget0 * morphTargetInfluences[ 0 ];
  5286. transformed += morphTarget1 * morphTargetInfluences[ 1 ];
  5287. transformed += morphTarget2 * morphTargetInfluences[ 2 ];
  5288. transformed += morphTarget3 * morphTargetInfluences[ 3 ];
  5289. #ifndef USE_MORPHNORMALS
  5290. transformed += morphTarget4 * morphTargetInfluences[ 4 ];
  5291. transformed += morphTarget5 * morphTargetInfluences[ 5 ];
  5292. transformed += morphTarget6 * morphTargetInfluences[ 6 ];
  5293. transformed += morphTarget7 * morphTargetInfluences[ 7 ];
  5294. #endif
  5295. #endif
  5296. #endif`,Sve=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  5297. #ifdef FLAT_SHADED
  5298. vec3 fdx = dFdx( vViewPosition );
  5299. vec3 fdy = dFdy( vViewPosition );
  5300. vec3 normal = normalize( cross( fdx, fdy ) );
  5301. #else
  5302. vec3 normal = normalize( vNormal );
  5303. #ifdef DOUBLE_SIDED
  5304. normal *= faceDirection;
  5305. #endif
  5306. #endif
  5307. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  5308. #ifdef USE_TANGENT
  5309. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5310. #else
  5311. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  5312. #if defined( USE_NORMALMAP )
  5313. vNormalMapUv
  5314. #elif defined( USE_CLEARCOAT_NORMALMAP )
  5315. vClearcoatNormalMapUv
  5316. #else
  5317. vUv
  5318. #endif
  5319. );
  5320. #endif
  5321. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5322. tbn[0] *= faceDirection;
  5323. tbn[1] *= faceDirection;
  5324. #endif
  5325. #endif
  5326. #ifdef USE_CLEARCOAT_NORMALMAP
  5327. #ifdef USE_TANGENT
  5328. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5329. #else
  5330. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  5331. #endif
  5332. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5333. tbn2[0] *= faceDirection;
  5334. tbn2[1] *= faceDirection;
  5335. #endif
  5336. #endif
  5337. vec3 nonPerturbedNormal = normal;`,wve=`#ifdef USE_NORMALMAP_OBJECTSPACE
  5338. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5339. #ifdef FLIP_SIDED
  5340. normal = - normal;
  5341. #endif
  5342. #ifdef DOUBLE_SIDED
  5343. normal = normal * faceDirection;
  5344. #endif
  5345. normal = normalize( normalMatrix * normal );
  5346. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  5347. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5348. mapN.xy *= normalScale;
  5349. normal = normalize( tbn * mapN );
  5350. #elif defined( USE_BUMPMAP )
  5351. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  5352. #endif`,Mve=`#ifndef FLAT_SHADED
  5353. varying vec3 vNormal;
  5354. #ifdef USE_TANGENT
  5355. varying vec3 vTangent;
  5356. varying vec3 vBitangent;
  5357. #endif
  5358. #endif`,Eve=`#ifndef FLAT_SHADED
  5359. varying vec3 vNormal;
  5360. #ifdef USE_TANGENT
  5361. varying vec3 vTangent;
  5362. varying vec3 vBitangent;
  5363. #endif
  5364. #endif`,Ave=`#ifndef FLAT_SHADED
  5365. vNormal = normalize( transformedNormal );
  5366. #ifdef USE_TANGENT
  5367. vTangent = normalize( transformedTangent );
  5368. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  5369. #endif
  5370. #endif`,Tve=`#ifdef USE_NORMALMAP
  5371. uniform sampler2D normalMap;
  5372. uniform vec2 normalScale;
  5373. #endif
  5374. #ifdef USE_NORMALMAP_OBJECTSPACE
  5375. uniform mat3 normalMatrix;
  5376. #endif
  5377. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  5378. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  5379. vec3 q0 = dFdx( eye_pos.xyz );
  5380. vec3 q1 = dFdy( eye_pos.xyz );
  5381. vec2 st0 = dFdx( uv.st );
  5382. vec2 st1 = dFdy( uv.st );
  5383. vec3 N = surf_norm;
  5384. vec3 q1perp = cross( q1, N );
  5385. vec3 q0perp = cross( N, q0 );
  5386. vec3 T = q1perp * st0.x + q0perp * st1.x;
  5387. vec3 B = q1perp * st0.y + q0perp * st1.y;
  5388. float det = max( dot( T, T ), dot( B, B ) );
  5389. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  5390. return mat3( T * scale, B * scale, N );
  5391. }
  5392. #endif`,Cve=`#ifdef USE_CLEARCOAT
  5393. vec3 clearcoatNormal = nonPerturbedNormal;
  5394. #endif`,Nve=`#ifdef USE_CLEARCOAT_NORMALMAP
  5395. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  5396. clearcoatMapN.xy *= clearcoatNormalScale;
  5397. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  5398. #endif`,Rve=`#ifdef USE_CLEARCOATMAP
  5399. uniform sampler2D clearcoatMap;
  5400. #endif
  5401. #ifdef USE_CLEARCOAT_NORMALMAP
  5402. uniform sampler2D clearcoatNormalMap;
  5403. uniform vec2 clearcoatNormalScale;
  5404. #endif
  5405. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  5406. uniform sampler2D clearcoatRoughnessMap;
  5407. #endif`,Pve=`#ifdef USE_IRIDESCENCEMAP
  5408. uniform sampler2D iridescenceMap;
  5409. #endif
  5410. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  5411. uniform sampler2D iridescenceThicknessMap;
  5412. #endif`,kve=`#ifdef OPAQUE
  5413. diffuseColor.a = 1.0;
  5414. #endif
  5415. #ifdef USE_TRANSMISSION
  5416. diffuseColor.a *= material.transmissionAlpha;
  5417. #endif
  5418. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Dve=`vec3 packNormalToRGB( const in vec3 normal ) {
  5419. return normalize( normal ) * 0.5 + 0.5;
  5420. }
  5421. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  5422. return 2.0 * rgb.xyz - 1.0;
  5423. }
  5424. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  5425. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  5426. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  5427. const float ShiftRight8 = 1. / 256.;
  5428. vec4 packDepthToRGBA( const in float v ) {
  5429. vec4 r = vec4( fract( v * PackFactors ), v );
  5430. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  5431. }
  5432. float unpackRGBAToDepth( const in vec4 v ) {
  5433. return dot( v, UnpackFactors );
  5434. }
  5435. vec2 packDepthToRG( in highp float v ) {
  5436. return packDepthToRGBA( v ).yx;
  5437. }
  5438. float unpackRGToDepth( const in highp vec2 v ) {
  5439. return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
  5440. }
  5441. vec4 pack2HalfToRGBA( vec2 v ) {
  5442. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  5443. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  5444. }
  5445. vec2 unpackRGBATo2Half( vec4 v ) {
  5446. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  5447. }
  5448. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  5449. return ( viewZ + near ) / ( near - far );
  5450. }
  5451. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5452. return depth * ( near - far ) - near;
  5453. }
  5454. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  5455. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  5456. }
  5457. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5458. return ( near * far ) / ( ( far - near ) * depth - far );
  5459. }`,Ove=`#ifdef PREMULTIPLIED_ALPHA
  5460. gl_FragColor.rgb *= gl_FragColor.a;
  5461. #endif`,Lve=`vec4 mvPosition = vec4( transformed, 1.0 );
  5462. #ifdef USE_BATCHING
  5463. mvPosition = batchingMatrix * mvPosition;
  5464. #endif
  5465. #ifdef USE_INSTANCING
  5466. mvPosition = instanceMatrix * mvPosition;
  5467. #endif
  5468. mvPosition = modelViewMatrix * mvPosition;
  5469. gl_Position = projectionMatrix * mvPosition;`,Ive=`#ifdef DITHERING
  5470. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  5471. #endif`,jve=`#ifdef DITHERING
  5472. vec3 dithering( vec3 color ) {
  5473. float grid_position = rand( gl_FragCoord.xy );
  5474. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  5475. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  5476. return color + dither_shift_RGB;
  5477. }
  5478. #endif`,Uve=`float roughnessFactor = roughness;
  5479. #ifdef USE_ROUGHNESSMAP
  5480. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  5481. roughnessFactor *= texelRoughness.g;
  5482. #endif`,Fve=`#ifdef USE_ROUGHNESSMAP
  5483. uniform sampler2D roughnessMap;
  5484. #endif`,zve=`#if NUM_SPOT_LIGHT_COORDS > 0
  5485. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5486. #endif
  5487. #if NUM_SPOT_LIGHT_MAPS > 0
  5488. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  5489. #endif
  5490. #ifdef USE_SHADOWMAP
  5491. #if NUM_DIR_LIGHT_SHADOWS > 0
  5492. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  5493. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5494. struct DirectionalLightShadow {
  5495. float shadowBias;
  5496. float shadowNormalBias;
  5497. float shadowRadius;
  5498. vec2 shadowMapSize;
  5499. };
  5500. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5501. #endif
  5502. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5503. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  5504. struct SpotLightShadow {
  5505. float shadowBias;
  5506. float shadowNormalBias;
  5507. float shadowRadius;
  5508. vec2 shadowMapSize;
  5509. };
  5510. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5511. #endif
  5512. #if NUM_POINT_LIGHT_SHADOWS > 0
  5513. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  5514. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5515. struct PointLightShadow {
  5516. float shadowBias;
  5517. float shadowNormalBias;
  5518. float shadowRadius;
  5519. vec2 shadowMapSize;
  5520. float shadowCameraNear;
  5521. float shadowCameraFar;
  5522. };
  5523. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5524. #endif
  5525. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  5526. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  5527. }
  5528. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  5529. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  5530. }
  5531. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  5532. float occlusion = 1.0;
  5533. vec2 distribution = texture2DDistribution( shadow, uv );
  5534. float hard_shadow = step( compare , distribution.x );
  5535. if (hard_shadow != 1.0 ) {
  5536. float distance = compare - distribution.x ;
  5537. float variance = max( 0.00000, distribution.y * distribution.y );
  5538. float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
  5539. }
  5540. return occlusion;
  5541. }
  5542. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  5543. float shadow = 1.0;
  5544. shadowCoord.xyz /= shadowCoord.w;
  5545. shadowCoord.z += shadowBias;
  5546. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  5547. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  5548. if ( frustumTest ) {
  5549. #if defined( SHADOWMAP_TYPE_PCF )
  5550. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5551. float dx0 = - texelSize.x * shadowRadius;
  5552. float dy0 = - texelSize.y * shadowRadius;
  5553. float dx1 = + texelSize.x * shadowRadius;
  5554. float dy1 = + texelSize.y * shadowRadius;
  5555. float dx2 = dx0 / 2.0;
  5556. float dy2 = dy0 / 2.0;
  5557. float dx3 = dx1 / 2.0;
  5558. float dy3 = dy1 / 2.0;
  5559. shadow = (
  5560. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  5561. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  5562. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  5563. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  5564. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  5565. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  5566. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  5567. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  5568. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  5569. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  5570. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  5571. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  5572. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  5573. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  5574. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  5575. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  5576. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  5577. ) * ( 1.0 / 17.0 );
  5578. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  5579. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5580. float dx = texelSize.x;
  5581. float dy = texelSize.y;
  5582. vec2 uv = shadowCoord.xy;
  5583. vec2 f = fract( uv * shadowMapSize + 0.5 );
  5584. uv -= f * texelSize;
  5585. shadow = (
  5586. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  5587. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  5588. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  5589. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  5590. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  5591. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  5592. f.x ) +
  5593. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  5594. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  5595. f.x ) +
  5596. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  5597. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  5598. f.y ) +
  5599. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  5600. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  5601. f.y ) +
  5602. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  5603. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  5604. f.x ),
  5605. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  5606. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  5607. f.x ),
  5608. f.y )
  5609. ) * ( 1.0 / 9.0 );
  5610. #elif defined( SHADOWMAP_TYPE_VSM )
  5611. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  5612. #else
  5613. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  5614. #endif
  5615. }
  5616. return shadow;
  5617. }
  5618. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  5619. vec3 absV = abs( v );
  5620. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  5621. absV *= scaleToCube;
  5622. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  5623. vec2 planar = v.xy;
  5624. float almostATexel = 1.5 * texelSizeY;
  5625. float almostOne = 1.0 - almostATexel;
  5626. if ( absV.z >= almostOne ) {
  5627. if ( v.z > 0.0 )
  5628. planar.x = 4.0 - v.x;
  5629. } else if ( absV.x >= almostOne ) {
  5630. float signX = sign( v.x );
  5631. planar.x = v.z * signX + 2.0 * signX;
  5632. } else if ( absV.y >= almostOne ) {
  5633. float signY = sign( v.y );
  5634. planar.x = v.x + 2.0 * signY + 2.0;
  5635. planar.y = v.z * signY - 2.0;
  5636. }
  5637. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  5638. }
  5639. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  5640. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  5641. vec3 lightToPosition = shadowCoord.xyz;
  5642. float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  5643. vec3 bd3D = normalize( lightToPosition );
  5644. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  5645. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  5646. return (
  5647. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  5648. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  5649. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  5650. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  5651. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  5652. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  5653. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  5654. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  5655. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  5656. ) * ( 1.0 / 9.0 );
  5657. #else
  5658. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  5659. #endif
  5660. }
  5661. #endif`,Bve=`#if NUM_SPOT_LIGHT_COORDS > 0
  5662. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  5663. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5664. #endif
  5665. #ifdef USE_SHADOWMAP
  5666. #if NUM_DIR_LIGHT_SHADOWS > 0
  5667. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  5668. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5669. struct DirectionalLightShadow {
  5670. float shadowBias;
  5671. float shadowNormalBias;
  5672. float shadowRadius;
  5673. vec2 shadowMapSize;
  5674. };
  5675. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5676. #endif
  5677. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5678. struct SpotLightShadow {
  5679. float shadowBias;
  5680. float shadowNormalBias;
  5681. float shadowRadius;
  5682. vec2 shadowMapSize;
  5683. };
  5684. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5685. #endif
  5686. #if NUM_POINT_LIGHT_SHADOWS > 0
  5687. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  5688. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5689. struct PointLightShadow {
  5690. float shadowBias;
  5691. float shadowNormalBias;
  5692. float shadowRadius;
  5693. vec2 shadowMapSize;
  5694. float shadowCameraNear;
  5695. float shadowCameraFar;
  5696. };
  5697. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5698. #endif
  5699. #endif`,Hve=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  5700. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  5701. vec4 shadowWorldPosition;
  5702. #endif
  5703. #if defined( USE_SHADOWMAP )
  5704. #if NUM_DIR_LIGHT_SHADOWS > 0
  5705. #pragma unroll_loop_start
  5706. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5707. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  5708. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  5709. }
  5710. #pragma unroll_loop_end
  5711. #endif
  5712. #if NUM_POINT_LIGHT_SHADOWS > 0
  5713. #pragma unroll_loop_start
  5714. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5715. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  5716. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  5717. }
  5718. #pragma unroll_loop_end
  5719. #endif
  5720. #endif
  5721. #if NUM_SPOT_LIGHT_COORDS > 0
  5722. #pragma unroll_loop_start
  5723. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  5724. shadowWorldPosition = worldPosition;
  5725. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5726. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  5727. #endif
  5728. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  5729. }
  5730. #pragma unroll_loop_end
  5731. #endif`,$ve=`float getShadowMask() {
  5732. float shadow = 1.0;
  5733. #ifdef USE_SHADOWMAP
  5734. #if NUM_DIR_LIGHT_SHADOWS > 0
  5735. DirectionalLightShadow directionalLight;
  5736. #pragma unroll_loop_start
  5737. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5738. directionalLight = directionalLightShadows[ i ];
  5739. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5740. }
  5741. #pragma unroll_loop_end
  5742. #endif
  5743. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5744. SpotLightShadow spotLight;
  5745. #pragma unroll_loop_start
  5746. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  5747. spotLight = spotLightShadows[ i ];
  5748. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5749. }
  5750. #pragma unroll_loop_end
  5751. #endif
  5752. #if NUM_POINT_LIGHT_SHADOWS > 0
  5753. PointLightShadow pointLight;
  5754. #pragma unroll_loop_start
  5755. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5756. pointLight = pointLightShadows[ i ];
  5757. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  5758. }
  5759. #pragma unroll_loop_end
  5760. #endif
  5761. #endif
  5762. return shadow;
  5763. }`,Vve=`#ifdef USE_SKINNING
  5764. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  5765. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  5766. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  5767. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  5768. #endif`,Gve=`#ifdef USE_SKINNING
  5769. uniform mat4 bindMatrix;
  5770. uniform mat4 bindMatrixInverse;
  5771. uniform highp sampler2D boneTexture;
  5772. mat4 getBoneMatrix( const in float i ) {
  5773. int size = textureSize( boneTexture, 0 ).x;
  5774. int j = int( i ) * 4;
  5775. int x = j % size;
  5776. int y = j / size;
  5777. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  5778. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  5779. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  5780. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  5781. return mat4( v1, v2, v3, v4 );
  5782. }
  5783. #endif`,Wve=`#ifdef USE_SKINNING
  5784. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  5785. vec4 skinned = vec4( 0.0 );
  5786. skinned += boneMatX * skinVertex * skinWeight.x;
  5787. skinned += boneMatY * skinVertex * skinWeight.y;
  5788. skinned += boneMatZ * skinVertex * skinWeight.z;
  5789. skinned += boneMatW * skinVertex * skinWeight.w;
  5790. transformed = ( bindMatrixInverse * skinned ).xyz;
  5791. #endif`,qve=`#ifdef USE_SKINNING
  5792. mat4 skinMatrix = mat4( 0.0 );
  5793. skinMatrix += skinWeight.x * boneMatX;
  5794. skinMatrix += skinWeight.y * boneMatY;
  5795. skinMatrix += skinWeight.z * boneMatZ;
  5796. skinMatrix += skinWeight.w * boneMatW;
  5797. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  5798. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  5799. #ifdef USE_TANGENT
  5800. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  5801. #endif
  5802. #endif`,Xve=`float specularStrength;
  5803. #ifdef USE_SPECULARMAP
  5804. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  5805. specularStrength = texelSpecular.r;
  5806. #else
  5807. specularStrength = 1.0;
  5808. #endif`,Kve=`#ifdef USE_SPECULARMAP
  5809. uniform sampler2D specularMap;
  5810. #endif`,Yve=`#if defined( TONE_MAPPING )
  5811. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  5812. #endif`,Zve=`#ifndef saturate
  5813. #define saturate( a ) clamp( a, 0.0, 1.0 )
  5814. #endif
  5815. uniform float toneMappingExposure;
  5816. vec3 LinearToneMapping( vec3 color ) {
  5817. return saturate( toneMappingExposure * color );
  5818. }
  5819. vec3 ReinhardToneMapping( vec3 color ) {
  5820. color *= toneMappingExposure;
  5821. return saturate( color / ( vec3( 1.0 ) + color ) );
  5822. }
  5823. vec3 OptimizedCineonToneMapping( vec3 color ) {
  5824. color *= toneMappingExposure;
  5825. color = max( vec3( 0.0 ), color - 0.004 );
  5826. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  5827. }
  5828. vec3 RRTAndODTFit( vec3 v ) {
  5829. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  5830. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  5831. return a / b;
  5832. }
  5833. vec3 ACESFilmicToneMapping( vec3 color ) {
  5834. const mat3 ACESInputMat = mat3(
  5835. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  5836. vec3( 0.04823, 0.01566, 0.83777 )
  5837. );
  5838. const mat3 ACESOutputMat = mat3(
  5839. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  5840. vec3( -0.07367, -0.00605, 1.07602 )
  5841. );
  5842. color *= toneMappingExposure / 0.6;
  5843. color = ACESInputMat * color;
  5844. color = RRTAndODTFit( color );
  5845. color = ACESOutputMat * color;
  5846. return saturate( color );
  5847. }
  5848. vec3 CustomToneMapping( vec3 color ) { return color; }`,Qve=`#ifdef USE_TRANSMISSION
  5849. material.transmission = transmission;
  5850. material.transmissionAlpha = 1.0;
  5851. material.thickness = thickness;
  5852. material.attenuationDistance = attenuationDistance;
  5853. material.attenuationColor = attenuationColor;
  5854. #ifdef USE_TRANSMISSIONMAP
  5855. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  5856. #endif
  5857. #ifdef USE_THICKNESSMAP
  5858. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  5859. #endif
  5860. vec3 pos = vWorldPosition;
  5861. vec3 v = normalize( cameraPosition - pos );
  5862. vec3 n = inverseTransformDirection( normal, viewMatrix );
  5863. vec4 transmitted = getIBLVolumeRefraction(
  5864. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  5865. pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
  5866. material.attenuationColor, material.attenuationDistance );
  5867. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  5868. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  5869. #endif`,Jve=`#ifdef USE_TRANSMISSION
  5870. uniform float transmission;
  5871. uniform float thickness;
  5872. uniform float attenuationDistance;
  5873. uniform vec3 attenuationColor;
  5874. #ifdef USE_TRANSMISSIONMAP
  5875. uniform sampler2D transmissionMap;
  5876. #endif
  5877. #ifdef USE_THICKNESSMAP
  5878. uniform sampler2D thicknessMap;
  5879. #endif
  5880. uniform vec2 transmissionSamplerSize;
  5881. uniform sampler2D transmissionSamplerMap;
  5882. uniform mat4 modelMatrix;
  5883. uniform mat4 projectionMatrix;
  5884. varying vec3 vWorldPosition;
  5885. float w0( float a ) {
  5886. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  5887. }
  5888. float w1( float a ) {
  5889. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  5890. }
  5891. float w2( float a ){
  5892. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  5893. }
  5894. float w3( float a ) {
  5895. return ( 1.0 / 6.0 ) * ( a * a * a );
  5896. }
  5897. float g0( float a ) {
  5898. return w0( a ) + w1( a );
  5899. }
  5900. float g1( float a ) {
  5901. return w2( a ) + w3( a );
  5902. }
  5903. float h0( float a ) {
  5904. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  5905. }
  5906. float h1( float a ) {
  5907. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  5908. }
  5909. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  5910. uv = uv * texelSize.zw + 0.5;
  5911. vec2 iuv = floor( uv );
  5912. vec2 fuv = fract( uv );
  5913. float g0x = g0( fuv.x );
  5914. float g1x = g1( fuv.x );
  5915. float h0x = h0( fuv.x );
  5916. float h1x = h1( fuv.x );
  5917. float h0y = h0( fuv.y );
  5918. float h1y = h1( fuv.y );
  5919. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  5920. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  5921. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  5922. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  5923. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  5924. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  5925. }
  5926. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  5927. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  5928. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  5929. vec2 fLodSizeInv = 1.0 / fLodSize;
  5930. vec2 cLodSizeInv = 1.0 / cLodSize;
  5931. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  5932. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  5933. return mix( fSample, cSample, fract( lod ) );
  5934. }
  5935. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  5936. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  5937. vec3 modelScale;
  5938. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  5939. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  5940. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  5941. return normalize( refractionVector ) * thickness * modelScale;
  5942. }
  5943. float applyIorToRoughness( const in float roughness, const in float ior ) {
  5944. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  5945. }
  5946. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  5947. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  5948. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  5949. }
  5950. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  5951. if ( isinf( attenuationDistance ) ) {
  5952. return vec3( 1.0 );
  5953. } else {
  5954. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  5955. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  5956. }
  5957. }
  5958. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  5959. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  5960. const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
  5961. const in vec3 attenuationColor, const in float attenuationDistance ) {
  5962. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  5963. vec3 refractedRayExit = position + transmissionRay;
  5964. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  5965. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  5966. refractionCoords += 1.0;
  5967. refractionCoords /= 2.0;
  5968. vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  5969. vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  5970. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  5971. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  5972. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  5973. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  5974. }
  5975. #endif`,ebe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  5976. varying vec2 vUv;
  5977. #endif
  5978. #ifdef USE_MAP
  5979. varying vec2 vMapUv;
  5980. #endif
  5981. #ifdef USE_ALPHAMAP
  5982. varying vec2 vAlphaMapUv;
  5983. #endif
  5984. #ifdef USE_LIGHTMAP
  5985. varying vec2 vLightMapUv;
  5986. #endif
  5987. #ifdef USE_AOMAP
  5988. varying vec2 vAoMapUv;
  5989. #endif
  5990. #ifdef USE_BUMPMAP
  5991. varying vec2 vBumpMapUv;
  5992. #endif
  5993. #ifdef USE_NORMALMAP
  5994. varying vec2 vNormalMapUv;
  5995. #endif
  5996. #ifdef USE_EMISSIVEMAP
  5997. varying vec2 vEmissiveMapUv;
  5998. #endif
  5999. #ifdef USE_METALNESSMAP
  6000. varying vec2 vMetalnessMapUv;
  6001. #endif
  6002. #ifdef USE_ROUGHNESSMAP
  6003. varying vec2 vRoughnessMapUv;
  6004. #endif
  6005. #ifdef USE_ANISOTROPYMAP
  6006. varying vec2 vAnisotropyMapUv;
  6007. #endif
  6008. #ifdef USE_CLEARCOATMAP
  6009. varying vec2 vClearcoatMapUv;
  6010. #endif
  6011. #ifdef USE_CLEARCOAT_NORMALMAP
  6012. varying vec2 vClearcoatNormalMapUv;
  6013. #endif
  6014. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6015. varying vec2 vClearcoatRoughnessMapUv;
  6016. #endif
  6017. #ifdef USE_IRIDESCENCEMAP
  6018. varying vec2 vIridescenceMapUv;
  6019. #endif
  6020. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6021. varying vec2 vIridescenceThicknessMapUv;
  6022. #endif
  6023. #ifdef USE_SHEEN_COLORMAP
  6024. varying vec2 vSheenColorMapUv;
  6025. #endif
  6026. #ifdef USE_SHEEN_ROUGHNESSMAP
  6027. varying vec2 vSheenRoughnessMapUv;
  6028. #endif
  6029. #ifdef USE_SPECULARMAP
  6030. varying vec2 vSpecularMapUv;
  6031. #endif
  6032. #ifdef USE_SPECULAR_COLORMAP
  6033. varying vec2 vSpecularColorMapUv;
  6034. #endif
  6035. #ifdef USE_SPECULAR_INTENSITYMAP
  6036. varying vec2 vSpecularIntensityMapUv;
  6037. #endif
  6038. #ifdef USE_TRANSMISSIONMAP
  6039. uniform mat3 transmissionMapTransform;
  6040. varying vec2 vTransmissionMapUv;
  6041. #endif
  6042. #ifdef USE_THICKNESSMAP
  6043. uniform mat3 thicknessMapTransform;
  6044. varying vec2 vThicknessMapUv;
  6045. #endif`,tbe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6046. varying vec2 vUv;
  6047. #endif
  6048. #ifdef USE_MAP
  6049. uniform mat3 mapTransform;
  6050. varying vec2 vMapUv;
  6051. #endif
  6052. #ifdef USE_ALPHAMAP
  6053. uniform mat3 alphaMapTransform;
  6054. varying vec2 vAlphaMapUv;
  6055. #endif
  6056. #ifdef USE_LIGHTMAP
  6057. uniform mat3 lightMapTransform;
  6058. varying vec2 vLightMapUv;
  6059. #endif
  6060. #ifdef USE_AOMAP
  6061. uniform mat3 aoMapTransform;
  6062. varying vec2 vAoMapUv;
  6063. #endif
  6064. #ifdef USE_BUMPMAP
  6065. uniform mat3 bumpMapTransform;
  6066. varying vec2 vBumpMapUv;
  6067. #endif
  6068. #ifdef USE_NORMALMAP
  6069. uniform mat3 normalMapTransform;
  6070. varying vec2 vNormalMapUv;
  6071. #endif
  6072. #ifdef USE_DISPLACEMENTMAP
  6073. uniform mat3 displacementMapTransform;
  6074. varying vec2 vDisplacementMapUv;
  6075. #endif
  6076. #ifdef USE_EMISSIVEMAP
  6077. uniform mat3 emissiveMapTransform;
  6078. varying vec2 vEmissiveMapUv;
  6079. #endif
  6080. #ifdef USE_METALNESSMAP
  6081. uniform mat3 metalnessMapTransform;
  6082. varying vec2 vMetalnessMapUv;
  6083. #endif
  6084. #ifdef USE_ROUGHNESSMAP
  6085. uniform mat3 roughnessMapTransform;
  6086. varying vec2 vRoughnessMapUv;
  6087. #endif
  6088. #ifdef USE_ANISOTROPYMAP
  6089. uniform mat3 anisotropyMapTransform;
  6090. varying vec2 vAnisotropyMapUv;
  6091. #endif
  6092. #ifdef USE_CLEARCOATMAP
  6093. uniform mat3 clearcoatMapTransform;
  6094. varying vec2 vClearcoatMapUv;
  6095. #endif
  6096. #ifdef USE_CLEARCOAT_NORMALMAP
  6097. uniform mat3 clearcoatNormalMapTransform;
  6098. varying vec2 vClearcoatNormalMapUv;
  6099. #endif
  6100. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6101. uniform mat3 clearcoatRoughnessMapTransform;
  6102. varying vec2 vClearcoatRoughnessMapUv;
  6103. #endif
  6104. #ifdef USE_SHEEN_COLORMAP
  6105. uniform mat3 sheenColorMapTransform;
  6106. varying vec2 vSheenColorMapUv;
  6107. #endif
  6108. #ifdef USE_SHEEN_ROUGHNESSMAP
  6109. uniform mat3 sheenRoughnessMapTransform;
  6110. varying vec2 vSheenRoughnessMapUv;
  6111. #endif
  6112. #ifdef USE_IRIDESCENCEMAP
  6113. uniform mat3 iridescenceMapTransform;
  6114. varying vec2 vIridescenceMapUv;
  6115. #endif
  6116. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6117. uniform mat3 iridescenceThicknessMapTransform;
  6118. varying vec2 vIridescenceThicknessMapUv;
  6119. #endif
  6120. #ifdef USE_SPECULARMAP
  6121. uniform mat3 specularMapTransform;
  6122. varying vec2 vSpecularMapUv;
  6123. #endif
  6124. #ifdef USE_SPECULAR_COLORMAP
  6125. uniform mat3 specularColorMapTransform;
  6126. varying vec2 vSpecularColorMapUv;
  6127. #endif
  6128. #ifdef USE_SPECULAR_INTENSITYMAP
  6129. uniform mat3 specularIntensityMapTransform;
  6130. varying vec2 vSpecularIntensityMapUv;
  6131. #endif
  6132. #ifdef USE_TRANSMISSIONMAP
  6133. uniform mat3 transmissionMapTransform;
  6134. varying vec2 vTransmissionMapUv;
  6135. #endif
  6136. #ifdef USE_THICKNESSMAP
  6137. uniform mat3 thicknessMapTransform;
  6138. varying vec2 vThicknessMapUv;
  6139. #endif`,nbe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6140. vUv = vec3( uv, 1 ).xy;
  6141. #endif
  6142. #ifdef USE_MAP
  6143. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  6144. #endif
  6145. #ifdef USE_ALPHAMAP
  6146. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  6147. #endif
  6148. #ifdef USE_LIGHTMAP
  6149. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  6150. #endif
  6151. #ifdef USE_AOMAP
  6152. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  6153. #endif
  6154. #ifdef USE_BUMPMAP
  6155. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  6156. #endif
  6157. #ifdef USE_NORMALMAP
  6158. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  6159. #endif
  6160. #ifdef USE_DISPLACEMENTMAP
  6161. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  6162. #endif
  6163. #ifdef USE_EMISSIVEMAP
  6164. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  6165. #endif
  6166. #ifdef USE_METALNESSMAP
  6167. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  6168. #endif
  6169. #ifdef USE_ROUGHNESSMAP
  6170. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  6171. #endif
  6172. #ifdef USE_ANISOTROPYMAP
  6173. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  6174. #endif
  6175. #ifdef USE_CLEARCOATMAP
  6176. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  6177. #endif
  6178. #ifdef USE_CLEARCOAT_NORMALMAP
  6179. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  6180. #endif
  6181. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6182. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  6183. #endif
  6184. #ifdef USE_IRIDESCENCEMAP
  6185. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  6186. #endif
  6187. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6188. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  6189. #endif
  6190. #ifdef USE_SHEEN_COLORMAP
  6191. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  6192. #endif
  6193. #ifdef USE_SHEEN_ROUGHNESSMAP
  6194. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  6195. #endif
  6196. #ifdef USE_SPECULARMAP
  6197. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  6198. #endif
  6199. #ifdef USE_SPECULAR_COLORMAP
  6200. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  6201. #endif
  6202. #ifdef USE_SPECULAR_INTENSITYMAP
  6203. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  6204. #endif
  6205. #ifdef USE_TRANSMISSIONMAP
  6206. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  6207. #endif
  6208. #ifdef USE_THICKNESSMAP
  6209. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  6210. #endif`,rbe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  6211. vec4 worldPosition = vec4( transformed, 1.0 );
  6212. #ifdef USE_BATCHING
  6213. worldPosition = batchingMatrix * worldPosition;
  6214. #endif
  6215. #ifdef USE_INSTANCING
  6216. worldPosition = instanceMatrix * worldPosition;
  6217. #endif
  6218. worldPosition = modelMatrix * worldPosition;
  6219. #endif`;const ibe=`varying vec2 vUv;
  6220. uniform mat3 uvTransform;
  6221. void main() {
  6222. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  6223. gl_Position = vec4( position.xy, 1.0, 1.0 );
  6224. }`,abe=`uniform sampler2D t2D;
  6225. uniform float backgroundIntensity;
  6226. varying vec2 vUv;
  6227. void main() {
  6228. vec4 texColor = texture2D( t2D, vUv );
  6229. #ifdef DECODE_VIDEO_TEXTURE
  6230. texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
  6231. #endif
  6232. texColor.rgb *= backgroundIntensity;
  6233. gl_FragColor = texColor;
  6234. #include <tonemapping_fragment>
  6235. #include <colorspace_fragment>
  6236. }`,sbe=`varying vec3 vWorldDirection;
  6237. #include <common>
  6238. void main() {
  6239. vWorldDirection = transformDirection( position, modelMatrix );
  6240. #include <begin_vertex>
  6241. #include <project_vertex>
  6242. gl_Position.z = gl_Position.w;
  6243. }`,obe=`#ifdef ENVMAP_TYPE_CUBE
  6244. uniform samplerCube envMap;
  6245. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6246. uniform sampler2D envMap;
  6247. #endif
  6248. uniform float flipEnvMap;
  6249. uniform float backgroundBlurriness;
  6250. uniform float backgroundIntensity;
  6251. varying vec3 vWorldDirection;
  6252. #include <cube_uv_reflection_fragment>
  6253. void main() {
  6254. #ifdef ENVMAP_TYPE_CUBE
  6255. vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  6256. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6257. vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
  6258. #else
  6259. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  6260. #endif
  6261. texColor.rgb *= backgroundIntensity;
  6262. gl_FragColor = texColor;
  6263. #include <tonemapping_fragment>
  6264. #include <colorspace_fragment>
  6265. }`,lbe=`varying vec3 vWorldDirection;
  6266. #include <common>
  6267. void main() {
  6268. vWorldDirection = transformDirection( position, modelMatrix );
  6269. #include <begin_vertex>
  6270. #include <project_vertex>
  6271. gl_Position.z = gl_Position.w;
  6272. }`,cbe=`uniform samplerCube tCube;
  6273. uniform float tFlip;
  6274. uniform float opacity;
  6275. varying vec3 vWorldDirection;
  6276. void main() {
  6277. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  6278. gl_FragColor = texColor;
  6279. gl_FragColor.a *= opacity;
  6280. #include <tonemapping_fragment>
  6281. #include <colorspace_fragment>
  6282. }`,ube=`#include <common>
  6283. #include <batching_pars_vertex>
  6284. #include <uv_pars_vertex>
  6285. #include <displacementmap_pars_vertex>
  6286. #include <morphtarget_pars_vertex>
  6287. #include <skinning_pars_vertex>
  6288. #include <logdepthbuf_pars_vertex>
  6289. #include <clipping_planes_pars_vertex>
  6290. varying vec2 vHighPrecisionZW;
  6291. void main() {
  6292. #include <uv_vertex>
  6293. #include <batching_vertex>
  6294. #include <skinbase_vertex>
  6295. #ifdef USE_DISPLACEMENTMAP
  6296. #include <beginnormal_vertex>
  6297. #include <morphnormal_vertex>
  6298. #include <skinnormal_vertex>
  6299. #endif
  6300. #include <begin_vertex>
  6301. #include <morphtarget_vertex>
  6302. #include <skinning_vertex>
  6303. #include <displacementmap_vertex>
  6304. #include <project_vertex>
  6305. #include <logdepthbuf_vertex>
  6306. #include <clipping_planes_vertex>
  6307. vHighPrecisionZW = gl_Position.zw;
  6308. }`,dbe=`#if DEPTH_PACKING == 3200
  6309. uniform float opacity;
  6310. #endif
  6311. #include <common>
  6312. #include <packing>
  6313. #include <uv_pars_fragment>
  6314. #include <map_pars_fragment>
  6315. #include <alphamap_pars_fragment>
  6316. #include <alphatest_pars_fragment>
  6317. #include <alphahash_pars_fragment>
  6318. #include <logdepthbuf_pars_fragment>
  6319. #include <clipping_planes_pars_fragment>
  6320. varying vec2 vHighPrecisionZW;
  6321. void main() {
  6322. #include <clipping_planes_fragment>
  6323. vec4 diffuseColor = vec4( 1.0 );
  6324. #if DEPTH_PACKING == 3200
  6325. diffuseColor.a = opacity;
  6326. #endif
  6327. #include <map_fragment>
  6328. #include <alphamap_fragment>
  6329. #include <alphatest_fragment>
  6330. #include <alphahash_fragment>
  6331. #include <logdepthbuf_fragment>
  6332. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  6333. #if DEPTH_PACKING == 3200
  6334. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  6335. #elif DEPTH_PACKING == 3201
  6336. gl_FragColor = packDepthToRGBA( fragCoordZ );
  6337. #endif
  6338. }`,fbe=`#define DISTANCE
  6339. varying vec3 vWorldPosition;
  6340. #include <common>
  6341. #include <batching_pars_vertex>
  6342. #include <uv_pars_vertex>
  6343. #include <displacementmap_pars_vertex>
  6344. #include <morphtarget_pars_vertex>
  6345. #include <skinning_pars_vertex>
  6346. #include <clipping_planes_pars_vertex>
  6347. void main() {
  6348. #include <uv_vertex>
  6349. #include <batching_vertex>
  6350. #include <skinbase_vertex>
  6351. #ifdef USE_DISPLACEMENTMAP
  6352. #include <beginnormal_vertex>
  6353. #include <morphnormal_vertex>
  6354. #include <skinnormal_vertex>
  6355. #endif
  6356. #include <begin_vertex>
  6357. #include <morphtarget_vertex>
  6358. #include <skinning_vertex>
  6359. #include <displacementmap_vertex>
  6360. #include <project_vertex>
  6361. #include <worldpos_vertex>
  6362. #include <clipping_planes_vertex>
  6363. vWorldPosition = worldPosition.xyz;
  6364. }`,hbe=`#define DISTANCE
  6365. uniform vec3 referencePosition;
  6366. uniform float nearDistance;
  6367. uniform float farDistance;
  6368. varying vec3 vWorldPosition;
  6369. #include <common>
  6370. #include <packing>
  6371. #include <uv_pars_fragment>
  6372. #include <map_pars_fragment>
  6373. #include <alphamap_pars_fragment>
  6374. #include <alphatest_pars_fragment>
  6375. #include <alphahash_pars_fragment>
  6376. #include <clipping_planes_pars_fragment>
  6377. void main () {
  6378. #include <clipping_planes_fragment>
  6379. vec4 diffuseColor = vec4( 1.0 );
  6380. #include <map_fragment>
  6381. #include <alphamap_fragment>
  6382. #include <alphatest_fragment>
  6383. #include <alphahash_fragment>
  6384. float dist = length( vWorldPosition - referencePosition );
  6385. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  6386. dist = saturate( dist );
  6387. gl_FragColor = packDepthToRGBA( dist );
  6388. }`,pbe=`varying vec3 vWorldDirection;
  6389. #include <common>
  6390. void main() {
  6391. vWorldDirection = transformDirection( position, modelMatrix );
  6392. #include <begin_vertex>
  6393. #include <project_vertex>
  6394. }`,mbe=`uniform sampler2D tEquirect;
  6395. varying vec3 vWorldDirection;
  6396. #include <common>
  6397. void main() {
  6398. vec3 direction = normalize( vWorldDirection );
  6399. vec2 sampleUV = equirectUv( direction );
  6400. gl_FragColor = texture2D( tEquirect, sampleUV );
  6401. #include <tonemapping_fragment>
  6402. #include <colorspace_fragment>
  6403. }`,gbe=`uniform float scale;
  6404. attribute float lineDistance;
  6405. varying float vLineDistance;
  6406. #include <common>
  6407. #include <uv_pars_vertex>
  6408. #include <color_pars_vertex>
  6409. #include <fog_pars_vertex>
  6410. #include <morphtarget_pars_vertex>
  6411. #include <logdepthbuf_pars_vertex>
  6412. #include <clipping_planes_pars_vertex>
  6413. void main() {
  6414. vLineDistance = scale * lineDistance;
  6415. #include <uv_vertex>
  6416. #include <color_vertex>
  6417. #include <morphcolor_vertex>
  6418. #include <begin_vertex>
  6419. #include <morphtarget_vertex>
  6420. #include <project_vertex>
  6421. #include <logdepthbuf_vertex>
  6422. #include <clipping_planes_vertex>
  6423. #include <fog_vertex>
  6424. }`,xbe=`uniform vec3 diffuse;
  6425. uniform float opacity;
  6426. uniform float dashSize;
  6427. uniform float totalSize;
  6428. varying float vLineDistance;
  6429. #include <common>
  6430. #include <color_pars_fragment>
  6431. #include <uv_pars_fragment>
  6432. #include <map_pars_fragment>
  6433. #include <fog_pars_fragment>
  6434. #include <logdepthbuf_pars_fragment>
  6435. #include <clipping_planes_pars_fragment>
  6436. void main() {
  6437. #include <clipping_planes_fragment>
  6438. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  6439. discard;
  6440. }
  6441. vec3 outgoingLight = vec3( 0.0 );
  6442. vec4 diffuseColor = vec4( diffuse, opacity );
  6443. #include <logdepthbuf_fragment>
  6444. #include <map_fragment>
  6445. #include <color_fragment>
  6446. outgoingLight = diffuseColor.rgb;
  6447. #include <opaque_fragment>
  6448. #include <tonemapping_fragment>
  6449. #include <colorspace_fragment>
  6450. #include <fog_fragment>
  6451. #include <premultiplied_alpha_fragment>
  6452. }`,vbe=`#include <common>
  6453. #include <batching_pars_vertex>
  6454. #include <uv_pars_vertex>
  6455. #include <envmap_pars_vertex>
  6456. #include <color_pars_vertex>
  6457. #include <fog_pars_vertex>
  6458. #include <morphtarget_pars_vertex>
  6459. #include <skinning_pars_vertex>
  6460. #include <logdepthbuf_pars_vertex>
  6461. #include <clipping_planes_pars_vertex>
  6462. void main() {
  6463. #include <uv_vertex>
  6464. #include <color_vertex>
  6465. #include <morphcolor_vertex>
  6466. #include <batching_vertex>
  6467. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  6468. #include <beginnormal_vertex>
  6469. #include <morphnormal_vertex>
  6470. #include <skinbase_vertex>
  6471. #include <skinnormal_vertex>
  6472. #include <defaultnormal_vertex>
  6473. #endif
  6474. #include <begin_vertex>
  6475. #include <morphtarget_vertex>
  6476. #include <skinning_vertex>
  6477. #include <project_vertex>
  6478. #include <logdepthbuf_vertex>
  6479. #include <clipping_planes_vertex>
  6480. #include <worldpos_vertex>
  6481. #include <envmap_vertex>
  6482. #include <fog_vertex>
  6483. }`,bbe=`uniform vec3 diffuse;
  6484. uniform float opacity;
  6485. #ifndef FLAT_SHADED
  6486. varying vec3 vNormal;
  6487. #endif
  6488. #include <common>
  6489. #include <dithering_pars_fragment>
  6490. #include <color_pars_fragment>
  6491. #include <uv_pars_fragment>
  6492. #include <map_pars_fragment>
  6493. #include <alphamap_pars_fragment>
  6494. #include <alphatest_pars_fragment>
  6495. #include <alphahash_pars_fragment>
  6496. #include <aomap_pars_fragment>
  6497. #include <lightmap_pars_fragment>
  6498. #include <envmap_common_pars_fragment>
  6499. #include <envmap_pars_fragment>
  6500. #include <fog_pars_fragment>
  6501. #include <specularmap_pars_fragment>
  6502. #include <logdepthbuf_pars_fragment>
  6503. #include <clipping_planes_pars_fragment>
  6504. void main() {
  6505. #include <clipping_planes_fragment>
  6506. vec4 diffuseColor = vec4( diffuse, opacity );
  6507. #include <logdepthbuf_fragment>
  6508. #include <map_fragment>
  6509. #include <color_fragment>
  6510. #include <alphamap_fragment>
  6511. #include <alphatest_fragment>
  6512. #include <alphahash_fragment>
  6513. #include <specularmap_fragment>
  6514. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6515. #ifdef USE_LIGHTMAP
  6516. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  6517. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  6518. #else
  6519. reflectedLight.indirectDiffuse += vec3( 1.0 );
  6520. #endif
  6521. #include <aomap_fragment>
  6522. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  6523. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  6524. #include <envmap_fragment>
  6525. #include <opaque_fragment>
  6526. #include <tonemapping_fragment>
  6527. #include <colorspace_fragment>
  6528. #include <fog_fragment>
  6529. #include <premultiplied_alpha_fragment>
  6530. #include <dithering_fragment>
  6531. }`,ybe=`#define LAMBERT
  6532. varying vec3 vViewPosition;
  6533. #include <common>
  6534. #include <batching_pars_vertex>
  6535. #include <uv_pars_vertex>
  6536. #include <displacementmap_pars_vertex>
  6537. #include <envmap_pars_vertex>
  6538. #include <color_pars_vertex>
  6539. #include <fog_pars_vertex>
  6540. #include <normal_pars_vertex>
  6541. #include <morphtarget_pars_vertex>
  6542. #include <skinning_pars_vertex>
  6543. #include <shadowmap_pars_vertex>
  6544. #include <logdepthbuf_pars_vertex>
  6545. #include <clipping_planes_pars_vertex>
  6546. void main() {
  6547. #include <uv_vertex>
  6548. #include <color_vertex>
  6549. #include <morphcolor_vertex>
  6550. #include <batching_vertex>
  6551. #include <beginnormal_vertex>
  6552. #include <morphnormal_vertex>
  6553. #include <skinbase_vertex>
  6554. #include <skinnormal_vertex>
  6555. #include <defaultnormal_vertex>
  6556. #include <normal_vertex>
  6557. #include <begin_vertex>
  6558. #include <morphtarget_vertex>
  6559. #include <skinning_vertex>
  6560. #include <displacementmap_vertex>
  6561. #include <project_vertex>
  6562. #include <logdepthbuf_vertex>
  6563. #include <clipping_planes_vertex>
  6564. vViewPosition = - mvPosition.xyz;
  6565. #include <worldpos_vertex>
  6566. #include <envmap_vertex>
  6567. #include <shadowmap_vertex>
  6568. #include <fog_vertex>
  6569. }`,_be=`#define LAMBERT
  6570. uniform vec3 diffuse;
  6571. uniform vec3 emissive;
  6572. uniform float opacity;
  6573. #include <common>
  6574. #include <packing>
  6575. #include <dithering_pars_fragment>
  6576. #include <color_pars_fragment>
  6577. #include <uv_pars_fragment>
  6578. #include <map_pars_fragment>
  6579. #include <alphamap_pars_fragment>
  6580. #include <alphatest_pars_fragment>
  6581. #include <alphahash_pars_fragment>
  6582. #include <aomap_pars_fragment>
  6583. #include <lightmap_pars_fragment>
  6584. #include <emissivemap_pars_fragment>
  6585. #include <envmap_common_pars_fragment>
  6586. #include <envmap_pars_fragment>
  6587. #include <fog_pars_fragment>
  6588. #include <bsdfs>
  6589. #include <lights_pars_begin>
  6590. #include <normal_pars_fragment>
  6591. #include <lights_lambert_pars_fragment>
  6592. #include <shadowmap_pars_fragment>
  6593. #include <bumpmap_pars_fragment>
  6594. #include <normalmap_pars_fragment>
  6595. #include <specularmap_pars_fragment>
  6596. #include <logdepthbuf_pars_fragment>
  6597. #include <clipping_planes_pars_fragment>
  6598. void main() {
  6599. #include <clipping_planes_fragment>
  6600. vec4 diffuseColor = vec4( diffuse, opacity );
  6601. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6602. vec3 totalEmissiveRadiance = emissive;
  6603. #include <logdepthbuf_fragment>
  6604. #include <map_fragment>
  6605. #include <color_fragment>
  6606. #include <alphamap_fragment>
  6607. #include <alphatest_fragment>
  6608. #include <alphahash_fragment>
  6609. #include <specularmap_fragment>
  6610. #include <normal_fragment_begin>
  6611. #include <normal_fragment_maps>
  6612. #include <emissivemap_fragment>
  6613. #include <lights_lambert_fragment>
  6614. #include <lights_fragment_begin>
  6615. #include <lights_fragment_maps>
  6616. #include <lights_fragment_end>
  6617. #include <aomap_fragment>
  6618. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  6619. #include <envmap_fragment>
  6620. #include <opaque_fragment>
  6621. #include <tonemapping_fragment>
  6622. #include <colorspace_fragment>
  6623. #include <fog_fragment>
  6624. #include <premultiplied_alpha_fragment>
  6625. #include <dithering_fragment>
  6626. }`,Sbe=`#define MATCAP
  6627. varying vec3 vViewPosition;
  6628. #include <common>
  6629. #include <batching_pars_vertex>
  6630. #include <uv_pars_vertex>
  6631. #include <color_pars_vertex>
  6632. #include <displacementmap_pars_vertex>
  6633. #include <fog_pars_vertex>
  6634. #include <normal_pars_vertex>
  6635. #include <morphtarget_pars_vertex>
  6636. #include <skinning_pars_vertex>
  6637. #include <logdepthbuf_pars_vertex>
  6638. #include <clipping_planes_pars_vertex>
  6639. void main() {
  6640. #include <uv_vertex>
  6641. #include <color_vertex>
  6642. #include <morphcolor_vertex>
  6643. #include <batching_vertex>
  6644. #include <beginnormal_vertex>
  6645. #include <morphnormal_vertex>
  6646. #include <skinbase_vertex>
  6647. #include <skinnormal_vertex>
  6648. #include <defaultnormal_vertex>
  6649. #include <normal_vertex>
  6650. #include <begin_vertex>
  6651. #include <morphtarget_vertex>
  6652. #include <skinning_vertex>
  6653. #include <displacementmap_vertex>
  6654. #include <project_vertex>
  6655. #include <logdepthbuf_vertex>
  6656. #include <clipping_planes_vertex>
  6657. #include <fog_vertex>
  6658. vViewPosition = - mvPosition.xyz;
  6659. }`,wbe=`#define MATCAP
  6660. uniform vec3 diffuse;
  6661. uniform float opacity;
  6662. uniform sampler2D matcap;
  6663. varying vec3 vViewPosition;
  6664. #include <common>
  6665. #include <dithering_pars_fragment>
  6666. #include <color_pars_fragment>
  6667. #include <uv_pars_fragment>
  6668. #include <map_pars_fragment>
  6669. #include <alphamap_pars_fragment>
  6670. #include <alphatest_pars_fragment>
  6671. #include <alphahash_pars_fragment>
  6672. #include <fog_pars_fragment>
  6673. #include <normal_pars_fragment>
  6674. #include <bumpmap_pars_fragment>
  6675. #include <normalmap_pars_fragment>
  6676. #include <logdepthbuf_pars_fragment>
  6677. #include <clipping_planes_pars_fragment>
  6678. void main() {
  6679. #include <clipping_planes_fragment>
  6680. vec4 diffuseColor = vec4( diffuse, opacity );
  6681. #include <logdepthbuf_fragment>
  6682. #include <map_fragment>
  6683. #include <color_fragment>
  6684. #include <alphamap_fragment>
  6685. #include <alphatest_fragment>
  6686. #include <alphahash_fragment>
  6687. #include <normal_fragment_begin>
  6688. #include <normal_fragment_maps>
  6689. vec3 viewDir = normalize( vViewPosition );
  6690. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  6691. vec3 y = cross( viewDir, x );
  6692. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  6693. #ifdef USE_MATCAP
  6694. vec4 matcapColor = texture2D( matcap, uv );
  6695. #else
  6696. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  6697. #endif
  6698. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  6699. #include <opaque_fragment>
  6700. #include <tonemapping_fragment>
  6701. #include <colorspace_fragment>
  6702. #include <fog_fragment>
  6703. #include <premultiplied_alpha_fragment>
  6704. #include <dithering_fragment>
  6705. }`,Mbe=`#define NORMAL
  6706. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6707. varying vec3 vViewPosition;
  6708. #endif
  6709. #include <common>
  6710. #include <batching_pars_vertex>
  6711. #include <uv_pars_vertex>
  6712. #include <displacementmap_pars_vertex>
  6713. #include <normal_pars_vertex>
  6714. #include <morphtarget_pars_vertex>
  6715. #include <skinning_pars_vertex>
  6716. #include <logdepthbuf_pars_vertex>
  6717. #include <clipping_planes_pars_vertex>
  6718. void main() {
  6719. #include <uv_vertex>
  6720. #include <batching_vertex>
  6721. #include <beginnormal_vertex>
  6722. #include <morphnormal_vertex>
  6723. #include <skinbase_vertex>
  6724. #include <skinnormal_vertex>
  6725. #include <defaultnormal_vertex>
  6726. #include <normal_vertex>
  6727. #include <begin_vertex>
  6728. #include <morphtarget_vertex>
  6729. #include <skinning_vertex>
  6730. #include <displacementmap_vertex>
  6731. #include <project_vertex>
  6732. #include <logdepthbuf_vertex>
  6733. #include <clipping_planes_vertex>
  6734. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6735. vViewPosition = - mvPosition.xyz;
  6736. #endif
  6737. }`,Ebe=`#define NORMAL
  6738. uniform float opacity;
  6739. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6740. varying vec3 vViewPosition;
  6741. #endif
  6742. #include <packing>
  6743. #include <uv_pars_fragment>
  6744. #include <normal_pars_fragment>
  6745. #include <bumpmap_pars_fragment>
  6746. #include <normalmap_pars_fragment>
  6747. #include <logdepthbuf_pars_fragment>
  6748. #include <clipping_planes_pars_fragment>
  6749. void main() {
  6750. #include <clipping_planes_fragment>
  6751. #include <logdepthbuf_fragment>
  6752. #include <normal_fragment_begin>
  6753. #include <normal_fragment_maps>
  6754. gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
  6755. #ifdef OPAQUE
  6756. gl_FragColor.a = 1.0;
  6757. #endif
  6758. }`,Abe=`#define PHONG
  6759. varying vec3 vViewPosition;
  6760. #include <common>
  6761. #include <batching_pars_vertex>
  6762. #include <uv_pars_vertex>
  6763. #include <displacementmap_pars_vertex>
  6764. #include <envmap_pars_vertex>
  6765. #include <color_pars_vertex>
  6766. #include <fog_pars_vertex>
  6767. #include <normal_pars_vertex>
  6768. #include <morphtarget_pars_vertex>
  6769. #include <skinning_pars_vertex>
  6770. #include <shadowmap_pars_vertex>
  6771. #include <logdepthbuf_pars_vertex>
  6772. #include <clipping_planes_pars_vertex>
  6773. void main() {
  6774. #include <uv_vertex>
  6775. #include <color_vertex>
  6776. #include <morphcolor_vertex>
  6777. #include <batching_vertex>
  6778. #include <beginnormal_vertex>
  6779. #include <morphnormal_vertex>
  6780. #include <skinbase_vertex>
  6781. #include <skinnormal_vertex>
  6782. #include <defaultnormal_vertex>
  6783. #include <normal_vertex>
  6784. #include <begin_vertex>
  6785. #include <morphtarget_vertex>
  6786. #include <skinning_vertex>
  6787. #include <displacementmap_vertex>
  6788. #include <project_vertex>
  6789. #include <logdepthbuf_vertex>
  6790. #include <clipping_planes_vertex>
  6791. vViewPosition = - mvPosition.xyz;
  6792. #include <worldpos_vertex>
  6793. #include <envmap_vertex>
  6794. #include <shadowmap_vertex>
  6795. #include <fog_vertex>
  6796. }`,Tbe=`#define PHONG
  6797. uniform vec3 diffuse;
  6798. uniform vec3 emissive;
  6799. uniform vec3 specular;
  6800. uniform float shininess;
  6801. uniform float opacity;
  6802. #include <common>
  6803. #include <packing>
  6804. #include <dithering_pars_fragment>
  6805. #include <color_pars_fragment>
  6806. #include <uv_pars_fragment>
  6807. #include <map_pars_fragment>
  6808. #include <alphamap_pars_fragment>
  6809. #include <alphatest_pars_fragment>
  6810. #include <alphahash_pars_fragment>
  6811. #include <aomap_pars_fragment>
  6812. #include <lightmap_pars_fragment>
  6813. #include <emissivemap_pars_fragment>
  6814. #include <envmap_common_pars_fragment>
  6815. #include <envmap_pars_fragment>
  6816. #include <fog_pars_fragment>
  6817. #include <bsdfs>
  6818. #include <lights_pars_begin>
  6819. #include <normal_pars_fragment>
  6820. #include <lights_phong_pars_fragment>
  6821. #include <shadowmap_pars_fragment>
  6822. #include <bumpmap_pars_fragment>
  6823. #include <normalmap_pars_fragment>
  6824. #include <specularmap_pars_fragment>
  6825. #include <logdepthbuf_pars_fragment>
  6826. #include <clipping_planes_pars_fragment>
  6827. void main() {
  6828. #include <clipping_planes_fragment>
  6829. vec4 diffuseColor = vec4( diffuse, opacity );
  6830. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6831. vec3 totalEmissiveRadiance = emissive;
  6832. #include <logdepthbuf_fragment>
  6833. #include <map_fragment>
  6834. #include <color_fragment>
  6835. #include <alphamap_fragment>
  6836. #include <alphatest_fragment>
  6837. #include <alphahash_fragment>
  6838. #include <specularmap_fragment>
  6839. #include <normal_fragment_begin>
  6840. #include <normal_fragment_maps>
  6841. #include <emissivemap_fragment>
  6842. #include <lights_phong_fragment>
  6843. #include <lights_fragment_begin>
  6844. #include <lights_fragment_maps>
  6845. #include <lights_fragment_end>
  6846. #include <aomap_fragment>
  6847. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  6848. #include <envmap_fragment>
  6849. #include <opaque_fragment>
  6850. #include <tonemapping_fragment>
  6851. #include <colorspace_fragment>
  6852. #include <fog_fragment>
  6853. #include <premultiplied_alpha_fragment>
  6854. #include <dithering_fragment>
  6855. }`,Cbe=`#define STANDARD
  6856. varying vec3 vViewPosition;
  6857. #ifdef USE_TRANSMISSION
  6858. varying vec3 vWorldPosition;
  6859. #endif
  6860. #include <common>
  6861. #include <batching_pars_vertex>
  6862. #include <uv_pars_vertex>
  6863. #include <displacementmap_pars_vertex>
  6864. #include <color_pars_vertex>
  6865. #include <fog_pars_vertex>
  6866. #include <normal_pars_vertex>
  6867. #include <morphtarget_pars_vertex>
  6868. #include <skinning_pars_vertex>
  6869. #include <shadowmap_pars_vertex>
  6870. #include <logdepthbuf_pars_vertex>
  6871. #include <clipping_planes_pars_vertex>
  6872. void main() {
  6873. #include <uv_vertex>
  6874. #include <color_vertex>
  6875. #include <morphcolor_vertex>
  6876. #include <batching_vertex>
  6877. #include <beginnormal_vertex>
  6878. #include <morphnormal_vertex>
  6879. #include <skinbase_vertex>
  6880. #include <skinnormal_vertex>
  6881. #include <defaultnormal_vertex>
  6882. #include <normal_vertex>
  6883. #include <begin_vertex>
  6884. #include <morphtarget_vertex>
  6885. #include <skinning_vertex>
  6886. #include <displacementmap_vertex>
  6887. #include <project_vertex>
  6888. #include <logdepthbuf_vertex>
  6889. #include <clipping_planes_vertex>
  6890. vViewPosition = - mvPosition.xyz;
  6891. #include <worldpos_vertex>
  6892. #include <shadowmap_vertex>
  6893. #include <fog_vertex>
  6894. #ifdef USE_TRANSMISSION
  6895. vWorldPosition = worldPosition.xyz;
  6896. #endif
  6897. }`,Nbe=`#define STANDARD
  6898. #ifdef PHYSICAL
  6899. #define IOR
  6900. #define USE_SPECULAR
  6901. #endif
  6902. uniform vec3 diffuse;
  6903. uniform vec3 emissive;
  6904. uniform float roughness;
  6905. uniform float metalness;
  6906. uniform float opacity;
  6907. #ifdef IOR
  6908. uniform float ior;
  6909. #endif
  6910. #ifdef USE_SPECULAR
  6911. uniform float specularIntensity;
  6912. uniform vec3 specularColor;
  6913. #ifdef USE_SPECULAR_COLORMAP
  6914. uniform sampler2D specularColorMap;
  6915. #endif
  6916. #ifdef USE_SPECULAR_INTENSITYMAP
  6917. uniform sampler2D specularIntensityMap;
  6918. #endif
  6919. #endif
  6920. #ifdef USE_CLEARCOAT
  6921. uniform float clearcoat;
  6922. uniform float clearcoatRoughness;
  6923. #endif
  6924. #ifdef USE_IRIDESCENCE
  6925. uniform float iridescence;
  6926. uniform float iridescenceIOR;
  6927. uniform float iridescenceThicknessMinimum;
  6928. uniform float iridescenceThicknessMaximum;
  6929. #endif
  6930. #ifdef USE_SHEEN
  6931. uniform vec3 sheenColor;
  6932. uniform float sheenRoughness;
  6933. #ifdef USE_SHEEN_COLORMAP
  6934. uniform sampler2D sheenColorMap;
  6935. #endif
  6936. #ifdef USE_SHEEN_ROUGHNESSMAP
  6937. uniform sampler2D sheenRoughnessMap;
  6938. #endif
  6939. #endif
  6940. #ifdef USE_ANISOTROPY
  6941. uniform vec2 anisotropyVector;
  6942. #ifdef USE_ANISOTROPYMAP
  6943. uniform sampler2D anisotropyMap;
  6944. #endif
  6945. #endif
  6946. varying vec3 vViewPosition;
  6947. #include <common>
  6948. #include <packing>
  6949. #include <dithering_pars_fragment>
  6950. #include <color_pars_fragment>
  6951. #include <uv_pars_fragment>
  6952. #include <map_pars_fragment>
  6953. #include <alphamap_pars_fragment>
  6954. #include <alphatest_pars_fragment>
  6955. #include <alphahash_pars_fragment>
  6956. #include <aomap_pars_fragment>
  6957. #include <lightmap_pars_fragment>
  6958. #include <emissivemap_pars_fragment>
  6959. #include <iridescence_fragment>
  6960. #include <cube_uv_reflection_fragment>
  6961. #include <envmap_common_pars_fragment>
  6962. #include <envmap_physical_pars_fragment>
  6963. #include <fog_pars_fragment>
  6964. #include <lights_pars_begin>
  6965. #include <normal_pars_fragment>
  6966. #include <lights_physical_pars_fragment>
  6967. #include <transmission_pars_fragment>
  6968. #include <shadowmap_pars_fragment>
  6969. #include <bumpmap_pars_fragment>
  6970. #include <normalmap_pars_fragment>
  6971. #include <clearcoat_pars_fragment>
  6972. #include <iridescence_pars_fragment>
  6973. #include <roughnessmap_pars_fragment>
  6974. #include <metalnessmap_pars_fragment>
  6975. #include <logdepthbuf_pars_fragment>
  6976. #include <clipping_planes_pars_fragment>
  6977. void main() {
  6978. #include <clipping_planes_fragment>
  6979. vec4 diffuseColor = vec4( diffuse, opacity );
  6980. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6981. vec3 totalEmissiveRadiance = emissive;
  6982. #include <logdepthbuf_fragment>
  6983. #include <map_fragment>
  6984. #include <color_fragment>
  6985. #include <alphamap_fragment>
  6986. #include <alphatest_fragment>
  6987. #include <alphahash_fragment>
  6988. #include <roughnessmap_fragment>
  6989. #include <metalnessmap_fragment>
  6990. #include <normal_fragment_begin>
  6991. #include <normal_fragment_maps>
  6992. #include <clearcoat_normal_fragment_begin>
  6993. #include <clearcoat_normal_fragment_maps>
  6994. #include <emissivemap_fragment>
  6995. #include <lights_physical_fragment>
  6996. #include <lights_fragment_begin>
  6997. #include <lights_fragment_maps>
  6998. #include <lights_fragment_end>
  6999. #include <aomap_fragment>
  7000. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  7001. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  7002. #include <transmission_fragment>
  7003. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  7004. #ifdef USE_SHEEN
  7005. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  7006. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  7007. #endif
  7008. #ifdef USE_CLEARCOAT
  7009. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  7010. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  7011. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  7012. #endif
  7013. #include <opaque_fragment>
  7014. #include <tonemapping_fragment>
  7015. #include <colorspace_fragment>
  7016. #include <fog_fragment>
  7017. #include <premultiplied_alpha_fragment>
  7018. #include <dithering_fragment>
  7019. }`,Rbe=`#define TOON
  7020. varying vec3 vViewPosition;
  7021. #include <common>
  7022. #include <batching_pars_vertex>
  7023. #include <uv_pars_vertex>
  7024. #include <displacementmap_pars_vertex>
  7025. #include <color_pars_vertex>
  7026. #include <fog_pars_vertex>
  7027. #include <normal_pars_vertex>
  7028. #include <morphtarget_pars_vertex>
  7029. #include <skinning_pars_vertex>
  7030. #include <shadowmap_pars_vertex>
  7031. #include <logdepthbuf_pars_vertex>
  7032. #include <clipping_planes_pars_vertex>
  7033. void main() {
  7034. #include <uv_vertex>
  7035. #include <color_vertex>
  7036. #include <morphcolor_vertex>
  7037. #include <batching_vertex>
  7038. #include <beginnormal_vertex>
  7039. #include <morphnormal_vertex>
  7040. #include <skinbase_vertex>
  7041. #include <skinnormal_vertex>
  7042. #include <defaultnormal_vertex>
  7043. #include <normal_vertex>
  7044. #include <begin_vertex>
  7045. #include <morphtarget_vertex>
  7046. #include <skinning_vertex>
  7047. #include <displacementmap_vertex>
  7048. #include <project_vertex>
  7049. #include <logdepthbuf_vertex>
  7050. #include <clipping_planes_vertex>
  7051. vViewPosition = - mvPosition.xyz;
  7052. #include <worldpos_vertex>
  7053. #include <shadowmap_vertex>
  7054. #include <fog_vertex>
  7055. }`,Pbe=`#define TOON
  7056. uniform vec3 diffuse;
  7057. uniform vec3 emissive;
  7058. uniform float opacity;
  7059. #include <common>
  7060. #include <packing>
  7061. #include <dithering_pars_fragment>
  7062. #include <color_pars_fragment>
  7063. #include <uv_pars_fragment>
  7064. #include <map_pars_fragment>
  7065. #include <alphamap_pars_fragment>
  7066. #include <alphatest_pars_fragment>
  7067. #include <alphahash_pars_fragment>
  7068. #include <aomap_pars_fragment>
  7069. #include <lightmap_pars_fragment>
  7070. #include <emissivemap_pars_fragment>
  7071. #include <gradientmap_pars_fragment>
  7072. #include <fog_pars_fragment>
  7073. #include <bsdfs>
  7074. #include <lights_pars_begin>
  7075. #include <normal_pars_fragment>
  7076. #include <lights_toon_pars_fragment>
  7077. #include <shadowmap_pars_fragment>
  7078. #include <bumpmap_pars_fragment>
  7079. #include <normalmap_pars_fragment>
  7080. #include <logdepthbuf_pars_fragment>
  7081. #include <clipping_planes_pars_fragment>
  7082. void main() {
  7083. #include <clipping_planes_fragment>
  7084. vec4 diffuseColor = vec4( diffuse, opacity );
  7085. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7086. vec3 totalEmissiveRadiance = emissive;
  7087. #include <logdepthbuf_fragment>
  7088. #include <map_fragment>
  7089. #include <color_fragment>
  7090. #include <alphamap_fragment>
  7091. #include <alphatest_fragment>
  7092. #include <alphahash_fragment>
  7093. #include <normal_fragment_begin>
  7094. #include <normal_fragment_maps>
  7095. #include <emissivemap_fragment>
  7096. #include <lights_toon_fragment>
  7097. #include <lights_fragment_begin>
  7098. #include <lights_fragment_maps>
  7099. #include <lights_fragment_end>
  7100. #include <aomap_fragment>
  7101. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  7102. #include <opaque_fragment>
  7103. #include <tonemapping_fragment>
  7104. #include <colorspace_fragment>
  7105. #include <fog_fragment>
  7106. #include <premultiplied_alpha_fragment>
  7107. #include <dithering_fragment>
  7108. }`,kbe=`uniform float size;
  7109. uniform float scale;
  7110. #include <common>
  7111. #include <color_pars_vertex>
  7112. #include <fog_pars_vertex>
  7113. #include <morphtarget_pars_vertex>
  7114. #include <logdepthbuf_pars_vertex>
  7115. #include <clipping_planes_pars_vertex>
  7116. #ifdef USE_POINTS_UV
  7117. varying vec2 vUv;
  7118. uniform mat3 uvTransform;
  7119. #endif
  7120. void main() {
  7121. #ifdef USE_POINTS_UV
  7122. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  7123. #endif
  7124. #include <color_vertex>
  7125. #include <morphcolor_vertex>
  7126. #include <begin_vertex>
  7127. #include <morphtarget_vertex>
  7128. #include <project_vertex>
  7129. gl_PointSize = size;
  7130. #ifdef USE_SIZEATTENUATION
  7131. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7132. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  7133. #endif
  7134. #include <logdepthbuf_vertex>
  7135. #include <clipping_planes_vertex>
  7136. #include <worldpos_vertex>
  7137. #include <fog_vertex>
  7138. }`,Dbe=`uniform vec3 diffuse;
  7139. uniform float opacity;
  7140. #include <common>
  7141. #include <color_pars_fragment>
  7142. #include <map_particle_pars_fragment>
  7143. #include <alphatest_pars_fragment>
  7144. #include <alphahash_pars_fragment>
  7145. #include <fog_pars_fragment>
  7146. #include <logdepthbuf_pars_fragment>
  7147. #include <clipping_planes_pars_fragment>
  7148. void main() {
  7149. #include <clipping_planes_fragment>
  7150. vec3 outgoingLight = vec3( 0.0 );
  7151. vec4 diffuseColor = vec4( diffuse, opacity );
  7152. #include <logdepthbuf_fragment>
  7153. #include <map_particle_fragment>
  7154. #include <color_fragment>
  7155. #include <alphatest_fragment>
  7156. #include <alphahash_fragment>
  7157. outgoingLight = diffuseColor.rgb;
  7158. #include <opaque_fragment>
  7159. #include <tonemapping_fragment>
  7160. #include <colorspace_fragment>
  7161. #include <fog_fragment>
  7162. #include <premultiplied_alpha_fragment>
  7163. }`,Obe=`#include <common>
  7164. #include <batching_pars_vertex>
  7165. #include <fog_pars_vertex>
  7166. #include <morphtarget_pars_vertex>
  7167. #include <skinning_pars_vertex>
  7168. #include <logdepthbuf_pars_vertex>
  7169. #include <shadowmap_pars_vertex>
  7170. void main() {
  7171. #include <batching_vertex>
  7172. #include <beginnormal_vertex>
  7173. #include <morphnormal_vertex>
  7174. #include <skinbase_vertex>
  7175. #include <skinnormal_vertex>
  7176. #include <defaultnormal_vertex>
  7177. #include <begin_vertex>
  7178. #include <morphtarget_vertex>
  7179. #include <skinning_vertex>
  7180. #include <project_vertex>
  7181. #include <logdepthbuf_vertex>
  7182. #include <worldpos_vertex>
  7183. #include <shadowmap_vertex>
  7184. #include <fog_vertex>
  7185. }`,Lbe=`uniform vec3 color;
  7186. uniform float opacity;
  7187. #include <common>
  7188. #include <packing>
  7189. #include <fog_pars_fragment>
  7190. #include <bsdfs>
  7191. #include <lights_pars_begin>
  7192. #include <logdepthbuf_pars_fragment>
  7193. #include <shadowmap_pars_fragment>
  7194. #include <shadowmask_pars_fragment>
  7195. void main() {
  7196. #include <logdepthbuf_fragment>
  7197. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  7198. #include <tonemapping_fragment>
  7199. #include <colorspace_fragment>
  7200. #include <fog_fragment>
  7201. }`,Ibe=`uniform float rotation;
  7202. uniform vec2 center;
  7203. #include <common>
  7204. #include <uv_pars_vertex>
  7205. #include <fog_pars_vertex>
  7206. #include <logdepthbuf_pars_vertex>
  7207. #include <clipping_planes_pars_vertex>
  7208. void main() {
  7209. #include <uv_vertex>
  7210. vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  7211. vec2 scale;
  7212. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  7213. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  7214. #ifndef USE_SIZEATTENUATION
  7215. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7216. if ( isPerspective ) scale *= - mvPosition.z;
  7217. #endif
  7218. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  7219. vec2 rotatedPosition;
  7220. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  7221. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  7222. mvPosition.xy += rotatedPosition;
  7223. gl_Position = projectionMatrix * mvPosition;
  7224. #include <logdepthbuf_vertex>
  7225. #include <clipping_planes_vertex>
  7226. #include <fog_vertex>
  7227. }`,jbe=`uniform vec3 diffuse;
  7228. uniform float opacity;
  7229. #include <common>
  7230. #include <uv_pars_fragment>
  7231. #include <map_pars_fragment>
  7232. #include <alphamap_pars_fragment>
  7233. #include <alphatest_pars_fragment>
  7234. #include <alphahash_pars_fragment>
  7235. #include <fog_pars_fragment>
  7236. #include <logdepthbuf_pars_fragment>
  7237. #include <clipping_planes_pars_fragment>
  7238. void main() {
  7239. #include <clipping_planes_fragment>
  7240. vec3 outgoingLight = vec3( 0.0 );
  7241. vec4 diffuseColor = vec4( diffuse, opacity );
  7242. #include <logdepthbuf_fragment>
  7243. #include <map_fragment>
  7244. #include <alphamap_fragment>
  7245. #include <alphatest_fragment>
  7246. #include <alphahash_fragment>
  7247. outgoingLight = diffuseColor.rgb;
  7248. #include <opaque_fragment>
  7249. #include <tonemapping_fragment>
  7250. #include <colorspace_fragment>
  7251. #include <fog_fragment>
  7252. }`,an={alphahash_fragment:a0e,alphahash_pars_fragment:s0e,alphamap_fragment:o0e,alphamap_pars_fragment:l0e,alphatest_fragment:c0e,alphatest_pars_fragment:u0e,aomap_fragment:d0e,aomap_pars_fragment:f0e,batching_pars_vertex:h0e,batching_vertex:p0e,begin_vertex:m0e,beginnormal_vertex:g0e,bsdfs:x0e,iridescence_fragment:v0e,bumpmap_pars_fragment:b0e,clipping_planes_fragment:y0e,clipping_planes_pars_fragment:_0e,clipping_planes_pars_vertex:S0e,clipping_planes_vertex:w0e,color_fragment:M0e,color_pars_fragment:E0e,color_pars_vertex:A0e,color_vertex:T0e,common:C0e,cube_uv_reflection_fragment:N0e,defaultnormal_vertex:R0e,displacementmap_pars_vertex:P0e,displacementmap_vertex:k0e,emissivemap_fragment:D0e,emissivemap_pars_fragment:O0e,colorspace_fragment:L0e,colorspace_pars_fragment:I0e,envmap_fragment:j0e,envmap_common_pars_fragment:U0e,envmap_pars_fragment:F0e,envmap_pars_vertex:z0e,envmap_physical_pars_fragment:Q0e,envmap_vertex:B0e,fog_vertex:H0e,fog_pars_vertex:$0e,fog_fragment:V0e,fog_pars_fragment:G0e,gradientmap_pars_fragment:W0e,lightmap_fragment:q0e,lightmap_pars_fragment:X0e,lights_lambert_fragment:K0e,lights_lambert_pars_fragment:Y0e,lights_pars_begin:Z0e,lights_toon_fragment:J0e,lights_toon_pars_fragment:eve,lights_phong_fragment:tve,lights_phong_pars_fragment:nve,lights_physical_fragment:rve,lights_physical_pars_fragment:ive,lights_fragment_begin:ave,lights_fragment_maps:sve,lights_fragment_end:ove,logdepthbuf_fragment:lve,logdepthbuf_pars_fragment:cve,logdepthbuf_pars_vertex:uve,logdepthbuf_vertex:dve,map_fragment:fve,map_pars_fragment:hve,map_particle_fragment:pve,map_particle_pars_fragment:mve,metalnessmap_fragment:gve,metalnessmap_pars_fragment:xve,morphcolor_vertex:vve,morphnormal_vertex:bve,morphtarget_pars_vertex:yve,morphtarget_vertex:_ve,normal_fragment_begin:Sve,normal_fragment_maps:wve,normal_pars_fragment:Mve,normal_pars_vertex:Eve,normal_vertex:Ave,normalmap_pars_fragment:Tve,clearcoat_normal_fragment_begin:Cve,clearcoat_normal_fragment_maps:Nve,clearcoat_pars_fragment:Rve,iridescence_pars_fragment:Pve,opaque_fragment:kve,packing:Dve,premultiplied_alpha_fragment:Ove,project_vertex:Lve,dithering_fragment:Ive,dithering_pars_fragment:jve,roughnessmap_fragment:Uve,roughnessmap_pars_fragment:Fve,shadowmap_pars_fragment:zve,shadowmap_pars_vertex:Bve,shadowmap_vertex:Hve,shadowmask_pars_fragment:$ve,skinbase_vertex:Vve,skinning_pars_vertex:Gve,skinning_vertex:Wve,skinnormal_vertex:qve,specularmap_fragment:Xve,specularmap_pars_fragment:Kve,tonemapping_fragment:Yve,tonemapping_pars_fragment:Zve,transmission_fragment:Qve,transmission_pars_fragment:Jve,uv_pars_fragment:ebe,uv_pars_vertex:tbe,uv_vertex:nbe,worldpos_vertex:rbe,background_vert:ibe,background_frag:abe,backgroundCube_vert:sbe,backgroundCube_frag:obe,cube_vert:lbe,cube_frag:cbe,depth_vert:ube,depth_frag:dbe,distanceRGBA_vert:fbe,distanceRGBA_frag:hbe,equirect_vert:pbe,equirect_frag:mbe,linedashed_vert:gbe,linedashed_frag:xbe,meshbasic_vert:vbe,meshbasic_frag:bbe,meshlambert_vert:ybe,meshlambert_frag:_be,meshmatcap_vert:Sbe,meshmatcap_frag:wbe,meshnormal_vert:Mbe,meshnormal_frag:Ebe,meshphong_vert:Abe,meshphong_frag:Tbe,meshphysical_vert:Cbe,meshphysical_frag:Nbe,meshtoon_vert:Rbe,meshtoon_frag:Pbe,points_vert:kbe,points_frag:Dbe,shadow_vert:Obe,shadow_frag:Lbe,sprite_vert:Ibe,sprite_frag:jbe},bt={common:{diffuse:{value:new zt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new fn},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new fn}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new fn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new fn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new fn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new fn},normalScale:{value:new Kt(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 zt(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 zt(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 zt(16777215)},opacity:{value:1},center:{value:new Kt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new fn},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0}}},Oa={basic:{uniforms:ha([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.fog]),vertexShader:an.meshbasic_vert,fragmentShader:an.meshbasic_frag},lambert:{uniforms:ha([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,bt.lights,{emissive:{value:new zt(0)}}]),vertexShader:an.meshlambert_vert,fragmentShader:an.meshlambert_frag},phong:{uniforms:ha([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,bt.lights,{emissive:{value:new zt(0)},specular:{value:new zt(1118481)},shininess:{value:30}}]),vertexShader:an.meshphong_vert,fragmentShader:an.meshphong_frag},standard:{uniforms:ha([bt.common,bt.envmap,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.roughnessmap,bt.metalnessmap,bt.fog,bt.lights,{emissive:{value:new zt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:an.meshphysical_vert,fragmentShader:an.meshphysical_frag},toon:{uniforms:ha([bt.common,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.gradientmap,bt.fog,bt.lights,{emissive:{value:new zt(0)}}]),vertexShader:an.meshtoon_vert,fragmentShader:an.meshtoon_frag},matcap:{uniforms:ha([bt.common,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,{matcap:{value:null}}]),vertexShader:an.meshmatcap_vert,fragmentShader:an.meshmatcap_frag},points:{uniforms:ha([bt.points,bt.fog]),vertexShader:an.points_vert,fragmentShader:an.points_frag},dashed:{uniforms:ha([bt.common,bt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:an.linedashed_vert,fragmentShader:an.linedashed_frag},depth:{uniforms:ha([bt.common,bt.displacementmap]),vertexShader:an.depth_vert,fragmentShader:an.depth_frag},normal:{uniforms:ha([bt.common,bt.bumpmap,bt.normalmap,bt.displacementmap,{opacity:{value:1}}]),vertexShader:an.meshnormal_vert,fragmentShader:an.meshnormal_frag},sprite:{uniforms:ha([bt.sprite,bt.fog]),vertexShader:an.sprite_vert,fragmentShader:an.sprite_frag},background:{uniforms:{uvTransform:{value:new fn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:an.background_vert,fragmentShader:an.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:an.backgroundCube_vert,fragmentShader:an.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:an.cube_vert,fragmentShader:an.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:an.equirect_vert,fragmentShader:an.equirect_frag},distanceRGBA:{uniforms:ha([bt.common,bt.displacementmap,{referencePosition:{value:new Ce},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:an.distanceRGBA_vert,fragmentShader:an.distanceRGBA_frag},shadow:{uniforms:ha([bt.lights,bt.fog,{color:{value:new zt(0)},opacity:{value:1}}]),vertexShader:an.shadow_vert,fragmentShader:an.shadow_frag}};Oa.physical={uniforms:ha([Oa.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new fn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new fn},clearcoatNormalScale:{value:new Kt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new fn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new fn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new fn},sheen:{value:0},sheenColor:{value:new zt(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 Kt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new fn},attenuationDistance:{value:0},attenuationColor:{value:new zt(0)},specularColor:{value:new zt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new fn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new fn},anisotropyVector:{value:new Kt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new fn}}]),vertexShader:an.meshphysical_vert,fragmentShader:an.meshphysical_frag};const Ty={r:0,b:0,g:0};function Ube(t,e,n,r,i,a,s){const o=new zt(0);let l=a===!0?0:1,c,u,h=null,g=0,m=null;function b(v,x){let M=!1,w=x.isScene===!0?x.background:null;w&&w.isTexture&&(w=(x.backgroundBlurriness>0?n:e).get(w)),w===null?y(o,l):w&&w.isColor&&(y(w,1),M=!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||M)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),w&&(w.isCubeTexture||w.mapping===lw)?(u===void 0&&(u=new vo(new $0(1,1,1),new Ju({name:"BackgroundCubeMaterial",uniforms:nm(Oa.backgroundCube.uniforms),vertexShader:Oa.backgroundCube.vertexShader,fragmentShader:Oa.backgroundCube.fragmentShader,side:Fa,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(T,R,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),u.material.uniforms.envMap.value=w,u.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,u.material.toneMapped=$n.getTransfer(w.colorSpace)!==rr,(h!==w||g!==w.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,h=w,g=w.version,m=t.toneMapping),u.layers.enableAll(),v.unshift(u,u.geometry,u.material,0,0,null)):w&&w.isTexture&&(c===void 0&&(c=new vo(new yk(2,2),new Ju({name:"BackgroundMaterial",uniforms:nm(Oa.background.uniforms),vertexShader:Oa.background.vertexShader,fragmentShader:Oa.background.fragmentShader,side:Qu,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=w,c.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,c.material.toneMapped=$n.getTransfer(w.colorSpace)!==rr,w.matrixAutoUpdate===!0&&w.updateMatrix(),c.material.uniforms.uvTransform.value.copy(w.matrix),(h!==w||g!==w.version||m!==t.toneMapping)&&(c.material.needsUpdate=!0,h=w,g=w.version,m=t.toneMapping),c.layers.enableAll(),v.unshift(c,c.geometry,c.material,0,0,null))}function y(v,x){v.getRGB(Ty,k7(t)),r.buffers.color.setClear(Ty.r,Ty.g,Ty.b,x,s)}return{getClearColor:function(){return o},setClearColor:function(v,x=1){o.set(v),l=x,y(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(v){l=v,y(o,l)},render:b}}function Fbe(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),a=r.isWebGL2?null:e.get("OES_vertex_array_object"),s=r.isWebGL2||a!==null,o={},l=v(null);let c=l,u=!1;function h(D,B,G,V,Z){let Y=!1;if(s){const ee=y(V,G,B);c!==ee&&(c=ee,m(c.object)),Y=x(D,V,G,Z),Y&&M(D,V,G,Z)}else{const ee=B.wireframe===!0;(c.geometry!==V.id||c.program!==G.id||c.wireframe!==ee)&&(c.geometry=V.id,c.program=G.id,c.wireframe=ee,Y=!0)}Z!==null&&n.update(Z,t.ELEMENT_ARRAY_BUFFER),(Y||u)&&(u=!1,j(D,B,G,V),Z!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(Z).buffer))}function g(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function m(D){return r.isWebGL2?t.bindVertexArray(D):a.bindVertexArrayOES(D)}function b(D){return r.isWebGL2?t.deleteVertexArray(D):a.deleteVertexArrayOES(D)}function y(D,B,G){const V=G.wireframe===!0;let Z=o[D.id];Z===void 0&&(Z={},o[D.id]=Z);let Y=Z[B.id];Y===void 0&&(Y={},Z[B.id]=Y);let ee=Y[V];return ee===void 0&&(ee=v(g()),Y[V]=ee),ee}function v(D){const B=[],G=[],V=[];for(let Z=0;Z<i;Z++)B[Z]=0,G[Z]=0,V[Z]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:B,enabledAttributes:G,attributeDivisors:V,object:D,attributes:{},index:null}}function x(D,B,G,V){const Z=c.attributes,Y=B.attributes;let ee=0;const H=G.getAttributes();for(const q in H)if(H[q].location>=0){const ce=Z[q];let xe=Y[q];if(xe===void 0&&(q==="instanceMatrix"&&D.instanceMatrix&&(xe=D.instanceMatrix),q==="instanceColor"&&D.instanceColor&&(xe=D.instanceColor)),ce===void 0||ce.attribute!==xe||xe&&ce.data!==xe.data)return!0;ee++}return c.attributesNum!==ee||c.index!==V}function M(D,B,G,V){const Z={},Y=B.attributes;let ee=0;const H=G.getAttributes();for(const q in H)if(H[q].location>=0){let ce=Y[q];ce===void 0&&(q==="instanceMatrix"&&D.instanceMatrix&&(ce=D.instanceMatrix),q==="instanceColor"&&D.instanceColor&&(ce=D.instanceColor));const xe={};xe.attribute=ce,ce&&ce.data&&(xe.data=ce.data),Z[q]=xe,ee++}c.attributes=Z,c.attributesNum=ee,c.index=V}function w(){const D=c.newAttributes;for(let B=0,G=D.length;B<G;B++)D[B]=0}function C(D){T(D,0)}function T(D,B){const G=c.newAttributes,V=c.enabledAttributes,Z=c.attributeDivisors;G[D]=1,V[D]===0&&(t.enableVertexAttribArray(D),V[D]=1),Z[D]!==B&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](D,B),Z[D]=B)}function R(){const D=c.newAttributes,B=c.enabledAttributes;for(let G=0,V=B.length;G<V;G++)B[G]!==D[G]&&(t.disableVertexAttribArray(G),B[G]=0)}function A(D,B,G,V,Z,Y,ee){ee===!0?t.vertexAttribIPointer(D,B,G,Z,Y):t.vertexAttribPointer(D,B,G,V,Z,Y)}function j(D,B,G,V){if(r.isWebGL2===!1&&(D.isInstancedMesh||V.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;w();const Z=V.attributes,Y=G.getAttributes(),ee=B.defaultAttributeValues;for(const H in Y){const q=Y[H];if(q.location>=0){let ae=Z[H];if(ae===void 0&&(H==="instanceMatrix"&&D.instanceMatrix&&(ae=D.instanceMatrix),H==="instanceColor"&&D.instanceColor&&(ae=D.instanceColor)),ae!==void 0){const ce=ae.normalized,xe=ae.itemSize,ie=n.get(ae);if(ie===void 0)continue;const ve=ie.buffer,Pe=ie.type,he=ie.bytesPerElement,we=r.isWebGL2===!0&&(Pe===t.INT||Pe===t.UNSIGNED_INT||ae.gpuType===f7);if(ae.isInterleavedBufferAttribute){const Le=ae.data,de=Le.stride,lt=ae.offset;if(Le.isInstancedInterleavedBuffer){for(let $=0;$<q.locationSize;$++)T(q.location+$,Le.meshPerAttribute);D.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=Le.meshPerAttribute*Le.count)}else for(let $=0;$<q.locationSize;$++)C(q.location+$);t.bindBuffer(t.ARRAY_BUFFER,ve);for(let $=0;$<q.locationSize;$++)A(q.location+$,xe/q.locationSize,Pe,ce,de*he,(lt+xe/q.locationSize*$)*he,we)}else{if(ae.isInstancedBufferAttribute){for(let Le=0;Le<q.locationSize;Le++)T(q.location+Le,ae.meshPerAttribute);D.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=ae.meshPerAttribute*ae.count)}else for(let Le=0;Le<q.locationSize;Le++)C(q.location+Le);t.bindBuffer(t.ARRAY_BUFFER,ve);for(let Le=0;Le<q.locationSize;Le++)A(q.location+Le,xe/q.locationSize,Pe,ce,xe*he,xe/q.locationSize*Le*he,we)}}else if(ee!==void 0){const ce=ee[H];if(ce!==void 0)switch(ce.length){case 2:t.vertexAttrib2fv(q.location,ce);break;case 3:t.vertexAttrib3fv(q.location,ce);break;case 4:t.vertexAttrib4fv(q.location,ce);break;default:t.vertexAttrib1fv(q.location,ce)}}}}R()}function N(){I();for(const D in o){const B=o[D];for(const G in B){const V=B[G];for(const Z in V)b(V[Z].object),delete V[Z];delete B[G]}delete o[D]}}function k(D){if(o[D.id]===void 0)return;const B=o[D.id];for(const G in B){const V=B[G];for(const Z in V)b(V[Z].object),delete V[Z];delete B[G]}delete o[D.id]}function F(D){for(const B in o){const G=o[B];if(G[D.id]===void 0)continue;const V=G[D.id];for(const Z in V)b(V[Z].object),delete V[Z];delete G[D.id]}}function I(){W(),u=!0,c!==l&&(c=l,m(c.object))}function W(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:h,reset:I,resetDefaultState:W,dispose:N,releaseStatesOfGeometry:k,releaseStatesOfProgram:F,initAttributes:w,enableAttribute:C,disableUnusedAttributes:R}}function zbe(t,e,n,r){const i=r.isWebGL2;let a;function s(u){a=u}function o(u,h){t.drawArrays(a,u,h),n.update(h,a,1)}function l(u,h,g){if(g===0)return;let m,b;if(i)m=t,b="drawArraysInstanced";else if(m=e.get("ANGLE_instanced_arrays"),b="drawArraysInstancedANGLE",m===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}m[b](a,u,h,g),n.update(h,a,g)}function c(u,h,g){if(g===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let b=0;b<g;b++)this.render(u[b],h[b]);else{m.multiDrawArraysWEBGL(a,u,0,h,0,g);let b=0;for(let y=0;y<g;y++)b+=h[y];n.update(b,a,1)}}this.setMode=s,this.render=o,this.renderInstances=l,this.renderMultiDraw=c}function Bbe(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const A=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(A){if(A==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const s=typeof WebGL2RenderingContext<"u"&&t.constructor.name==="WebGL2RenderingContext";let o=n.precision!==void 0?n.precision:"highp";const l=a(o);l!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",l,"instead."),o=l);const c=s||e.has("WEBGL_draw_buffers"),u=n.logarithmicDepthBuffer===!0,h=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),g=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=t.getParameter(t.MAX_TEXTURE_SIZE),b=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),y=t.getParameter(t.MAX_VERTEX_ATTRIBS),v=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),x=t.getParameter(t.MAX_VARYING_VECTORS),M=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),w=g>0,C=s||e.has("OES_texture_float"),T=w&&C,R=s?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:s,drawBuffers:c,getMaxAnisotropy:i,getMaxPrecision:a,precision:o,logarithmicDepthBuffer:u,maxTextures:h,maxVertexTextures:g,maxTextureSize:m,maxCubemapSize:b,maxAttributes:y,maxVertexUniforms:v,maxVaryings:x,maxFragmentUniforms:M,vertexTextures:w,floatFragmentTextures:C,floatVertexTextures:T,maxSamples:R}}function Hbe(t){const e=this;let n=null,r=0,i=!1,a=!1;const s=new _u,o=new fn,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,g){const m=h.length!==0||g||r!==0||i;return i=g,r=h.length,m},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(h,g){n=u(h,g,0)},this.setState=function(h,g,m){const b=h.clippingPlanes,y=h.clipIntersection,v=h.clipShadows,x=t.get(h);if(!i||b===null||b.length===0||a&&!v)a?u(null):c();else{const M=a?0:r,w=M*4;let C=x.clippingState||null;l.value=C,C=u(b,g,w,m);for(let T=0;T!==w;++T)C[T]=n[T];x.clippingState=C,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=M}};function c(){l.value!==n&&(l.value=n,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function u(h,g,m,b){const y=h!==null?h.length:0;let v=null;if(y!==0){if(v=l.value,b!==!0||v===null){const x=m+y*4,M=g.matrixWorldInverse;o.getNormalMatrix(M),(v===null||v.length<x)&&(v=new Float32Array(x));for(let w=0,C=m;w!==y;++w,C+=4)s.copy(h[w]).applyMatrix4(M,o),s.normal.toArray(v,C),v[C+3]=s.constant}l.value=v,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,v}}function $be(t){let e=new WeakMap;function n(s,o){return o===P3?s.mapping=Jp:o===k3&&(s.mapping=em),s}function r(s){if(s&&s.isTexture){const o=s.mapping;if(o===P3||o===k3)if(e.has(s)){const l=e.get(s).texture;return n(l,s.mapping)}else{const l=s.image;if(l&&l.height>0){const c=new t0e(l.height/2);return c.fromEquirectangularTexture(t,s),e.set(s,c),s.addEventListener("dispose",i),n(c.texture,s.mapping)}else return null}}return s}function i(s){const o=s.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}class Vbe extends D7{constructor(e=-1,n=1,r=1,i=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=a,this.far=s,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,a,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let a=r-e,s=r+e,o=i+n,l=i-n;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=c*this.view.offsetX,s=a+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(a,s,o,l,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 Ep=4,x5=[.125,.215,.35,.446,.526,.582],Kd=20,VT=new Vbe,v5=new zt;let GT=null,WT=0,qT=0;const Hd=(1+Math.sqrt(5))/2,cp=1/Hd,b5=[new Ce(1,1,1),new Ce(-1,1,1),new Ce(1,1,-1),new Ce(-1,1,-1),new Ce(0,Hd,cp),new Ce(0,Hd,-cp),new Ce(cp,0,Hd),new Ce(-cp,0,Hd),new Ce(Hd,cp,0),new Ce(-Hd,cp,0)];class y5{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){GT=this._renderer.getRenderTarget(),WT=this._renderer.getActiveCubeFace(),qT=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=w5(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=S5(),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(GT,WT,qT),e.scissorTest=!1,Cy(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Jp||e.mapping===em?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),GT=this._renderer.getRenderTarget(),WT=this._renderer.getActiveCubeFace(),qT=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:Us,minFilter:Us,generateMipmaps:!1,type:r0,format:Fs,colorSpace:bc,depthBuffer:!1},i=_5(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=_5(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Gbe(a)),this._blurMaterial=Wbe(a,e,n)}return i}_compileMaterial(e){const n=new vo(this._lodPlanes[0],e);this._renderer.compile(n,VT)}_sceneToCubeUV(e,n,r,i){const o=new ss(90,1,n,r),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,g=u.toneMapping;u.getClearColor(v5),u.toneMapping=Bu,u.autoClear=!1;const m=new N7({name:"PMREM.Background",side:Fa,depthWrite:!1,depthTest:!1}),b=new vo(new $0,m);let y=!1;const v=e.background;v?v.isColor&&(m.color.copy(v),e.background=null,y=!0):(m.color.copy(v5),y=!0);for(let x=0;x<6;x++){const M=x%3;M===0?(o.up.set(0,l[x],0),o.lookAt(c[x],0,0)):M===1?(o.up.set(0,0,l[x]),o.lookAt(0,c[x],0)):(o.up.set(0,l[x],0),o.lookAt(0,0,c[x]));const w=this._cubeSize;Cy(i,M*w,x>2?w:0,w,w),u.setRenderTarget(i),y&&u.render(b,o),u.render(e,o)}b.geometry.dispose(),b.material.dispose(),u.toneMapping=g,u.autoClear=h,e.background=v}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Jp||e.mapping===em;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=w5()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=S5());const a=i?this._cubemapMaterial:this._equirectMaterial,s=new vo(this._lodPlanes[0],a),o=a.uniforms;o.envMap.value=e;const l=this._cubeSize;Cy(n,0,0,3*l,2*l),r.setRenderTarget(n),r.render(s,VT)}_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=b5[(i-1)%b5.length];this._blur(e,i-1,i,a,s)}n.autoClear=r}_blur(e,n,r,i,a){const s=this._pingPongRenderTarget;this._halfBlur(e,s,n,r,i,"latitudinal",a),this._halfBlur(s,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,s,o){const l=this._renderer,c=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=new vo(this._lodPlanes[i],c),g=c.uniforms,m=this._sizeLods[r]-1,b=isFinite(a)?Math.PI/(2*m):2*Math.PI/(2*Kd-1),y=a/b,v=isFinite(a)?1+Math.floor(u*y):Kd;v>Kd&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Kd}`);const x=[];let M=0;for(let A=0;A<Kd;++A){const j=A/y,N=Math.exp(-j*j/2);x.push(N),A===0?M+=N:A<v&&(M+=2*N)}for(let A=0;A<x.length;A++)x[A]=x[A]/M;g.envMap.value=e.texture,g.samples.value=v,g.weights.value=x,g.latitudinal.value=s==="latitudinal",o&&(g.poleAxis.value=o);const{_lodMax:w}=this;g.dTheta.value=b,g.mipInt.value=w-r;const C=this._sizeLods[i],T=3*C*(i>w-Ep?i-w+Ep:0),R=4*(this._cubeSize-C);Cy(n,T,R,3*C,2*C),l.setRenderTarget(n),l.render(h,VT)}}function Gbe(t){const e=[],n=[],r=[];let i=t;const a=t-Ep+1+x5.length;for(let s=0;s<a;s++){const o=Math.pow(2,i);n.push(o);let l=1/o;s>t-Ep?l=x5[s-t+Ep-1]:s===0&&(l=0),r.push(l);const c=1/(o-2),u=-c,h=1+c,g=[u,u,h,u,h,h,u,u,h,h,u,h],m=6,b=6,y=3,v=2,x=1,M=new Float32Array(y*b*m),w=new Float32Array(v*b*m),C=new Float32Array(x*b*m);for(let R=0;R<m;R++){const A=R%3*2/3-1,j=R>2?0:-1,N=[A,j,0,A+2/3,j,0,A+2/3,j+1,0,A,j,0,A+2/3,j+1,0,A,j+1,0];M.set(N,y*b*R),w.set(g,v*b*R);const k=[R,R,R,R,R,R];C.set(k,x*b*R)}const T=new oa;T.setAttribute("position",new fs(M,y)),T.setAttribute("uv",new fs(w,v)),T.setAttribute("faceIndex",new fs(C,x)),e.push(T),i>Ep&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function _5(t,e,n){const r=new kf(t,e,n);return r.texture.mapping=lw,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Cy(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function Wbe(t,e,n){const r=new Float32Array(Kd),i=new Ce(0,1,0);return new Ju({name:"SphericalGaussianBlur",defines:{n:Kd,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:_k(),fragmentShader:`
  7253. precision mediump float;
  7254. precision mediump int;
  7255. varying vec3 vOutputDirection;
  7256. uniform sampler2D envMap;
  7257. uniform int samples;
  7258. uniform float weights[ n ];
  7259. uniform bool latitudinal;
  7260. uniform float dTheta;
  7261. uniform float mipInt;
  7262. uniform vec3 poleAxis;
  7263. #define ENVMAP_TYPE_CUBE_UV
  7264. #include <cube_uv_reflection_fragment>
  7265. vec3 getSample( float theta, vec3 axis ) {
  7266. float cosTheta = cos( theta );
  7267. // Rodrigues' axis-angle rotation
  7268. vec3 sampleDirection = vOutputDirection * cosTheta
  7269. + cross( axis, vOutputDirection ) * sin( theta )
  7270. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  7271. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  7272. }
  7273. void main() {
  7274. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  7275. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  7276. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  7277. }
  7278. axis = normalize( axis );
  7279. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  7280. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  7281. for ( int i = 1; i < n; i++ ) {
  7282. if ( i >= samples ) {
  7283. break;
  7284. }
  7285. float theta = dTheta * float( i );
  7286. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  7287. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  7288. }
  7289. }
  7290. `,blending:zu,depthTest:!1,depthWrite:!1})}function S5(){return new Ju({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:_k(),fragmentShader:`
  7291. precision mediump float;
  7292. precision mediump int;
  7293. varying vec3 vOutputDirection;
  7294. uniform sampler2D envMap;
  7295. #include <common>
  7296. void main() {
  7297. vec3 outputDirection = normalize( vOutputDirection );
  7298. vec2 uv = equirectUv( outputDirection );
  7299. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  7300. }
  7301. `,blending:zu,depthTest:!1,depthWrite:!1})}function w5(){return new Ju({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:_k(),fragmentShader:`
  7302. precision mediump float;
  7303. precision mediump int;
  7304. uniform float flipEnvMap;
  7305. varying vec3 vOutputDirection;
  7306. uniform samplerCube envMap;
  7307. void main() {
  7308. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  7309. }
  7310. `,blending:zu,depthTest:!1,depthWrite:!1})}function _k(){return`
  7311. precision mediump float;
  7312. precision mediump int;
  7313. attribute float faceIndex;
  7314. varying vec3 vOutputDirection;
  7315. // RH coordinate system; PMREM face-indexing convention
  7316. vec3 getDirection( vec2 uv, float face ) {
  7317. uv = 2.0 * uv - 1.0;
  7318. vec3 direction = vec3( uv, 1.0 );
  7319. if ( face == 0.0 ) {
  7320. direction = direction.zyx; // ( 1, v, u ) pos x
  7321. } else if ( face == 1.0 ) {
  7322. direction = direction.xzy;
  7323. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  7324. } else if ( face == 2.0 ) {
  7325. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  7326. } else if ( face == 3.0 ) {
  7327. direction = direction.zyx;
  7328. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  7329. } else if ( face == 4.0 ) {
  7330. direction = direction.xzy;
  7331. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  7332. } else if ( face == 5.0 ) {
  7333. direction.z *= -1.0; // ( u, v, -1 ) neg z
  7334. }
  7335. return direction;
  7336. }
  7337. void main() {
  7338. vOutputDirection = getDirection( uv, faceIndex );
  7339. gl_Position = vec4( position, 1.0 );
  7340. }
  7341. `}function qbe(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const l=o.mapping,c=l===P3||l===k3,u=l===Jp||l===em;if(c||u)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let h=e.get(o);return n===null&&(n=new y5(t)),h=c?n.fromEquirectangular(o,h):n.fromCubemap(o,h),e.set(o,h),h.texture}else{if(e.has(o))return e.get(o).texture;{const h=o.image;if(c&&h&&h.height>0||u&&h&&i(h)){n===null&&(n=new y5(t));const g=c?n.fromEquirectangular(o):n.fromCubemap(o);return e.set(o,g),o.addEventListener("dispose",a),g.texture}else return null}}}return o}function i(o){let l=0;const c=6;for(let u=0;u<c;u++)o[u]!==void 0&&l++;return l===c}function a(o){const l=o.target;l.removeEventListener("dispose",a);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function s(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:s}}function Xbe(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 Kbe(t,e,n,r){const i={},a=new WeakMap;function s(h){const g=h.target;g.index!==null&&e.remove(g.index);for(const b in g.attributes)e.remove(g.attributes[b]);for(const b in g.morphAttributes){const y=g.morphAttributes[b];for(let v=0,x=y.length;v<x;v++)e.remove(y[v])}g.removeEventListener("dispose",s),delete i[g.id];const m=a.get(g);m&&(e.remove(m),a.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function o(h,g){return i[g.id]===!0||(g.addEventListener("dispose",s),i[g.id]=!0,n.memory.geometries++),g}function l(h){const g=h.attributes;for(const b in g)e.update(g[b],t.ARRAY_BUFFER);const m=h.morphAttributes;for(const b in m){const y=m[b];for(let v=0,x=y.length;v<x;v++)e.update(y[v],t.ARRAY_BUFFER)}}function c(h){const g=[],m=h.index,b=h.attributes.position;let y=0;if(m!==null){const M=m.array;y=m.version;for(let w=0,C=M.length;w<C;w+=3){const T=M[w+0],R=M[w+1],A=M[w+2];g.push(T,R,R,A,A,T)}}else if(b!==void 0){const M=b.array;y=b.version;for(let w=0,C=M.length/3-1;w<C;w+=3){const T=w+0,R=w+1,A=w+2;g.push(T,R,R,A,A,T)}}else return;const v=new(w7(g)?P7:R7)(g,1);v.version=y;const x=a.get(h);x&&e.remove(x),a.set(h,v)}function u(h){const g=a.get(h);if(g){const m=h.index;m!==null&&g.version<m.version&&c(h)}else c(h);return a.get(h)}return{get:o,update:l,getWireframeAttribute:u}}function Ybe(t,e,n,r){const i=r.isWebGL2;let a;function s(m){a=m}let o,l;function c(m){o=m.type,l=m.bytesPerElement}function u(m,b){t.drawElements(a,b,o,m*l),n.update(b,a,1)}function h(m,b,y){if(y===0)return;let v,x;if(i)v=t,x="drawElementsInstanced";else if(v=e.get("ANGLE_instanced_arrays"),x="drawElementsInstancedANGLE",v===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}v[x](a,b,o,m*l,y),n.update(b,a,y)}function g(m,b,y){if(y===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let x=0;x<y;x++)this.render(m[x]/l,b[x]);else{v.multiDrawElementsWEBGL(a,b,0,o,m,0,y);let x=0;for(let M=0;M<y;M++)x+=b[M];n.update(x,a,1)}}this.setMode=s,this.setIndex=c,this.render=u,this.renderInstances=h,this.renderMultiDraw=g}function Zbe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,s,o){switch(n.calls++,s){case t.TRIANGLES:n.triangles+=o*(a/3);break;case t.LINES:n.lines+=o*(a/2);break;case t.LINE_STRIP:n.lines+=o*(a-1);break;case t.LINE_LOOP:n.lines+=o*a;break;case t.POINTS:n.points+=o*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",s);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function Qbe(t,e){return t[0]-e[0]}function Jbe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function eye(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,s=new Gn,o=[];for(let c=0;c<8;c++)o[c]=[c,0];function l(c,u,h){const g=c.morphTargetInfluences;if(e.isWebGL2===!0){const b=u.morphAttributes.position||u.morphAttributes.normal||u.morphAttributes.color,y=b!==void 0?b.length:0;let v=a.get(u);if(v===void 0||v.count!==y){let B=function(){W.dispose(),a.delete(u),u.removeEventListener("dispose",B)};var m=B;v!==void 0&&v.texture.dispose();const w=u.morphAttributes.position!==void 0,C=u.morphAttributes.normal!==void 0,T=u.morphAttributes.color!==void 0,R=u.morphAttributes.position||[],A=u.morphAttributes.normal||[],j=u.morphAttributes.color||[];let N=0;w===!0&&(N=1),C===!0&&(N=2),T===!0&&(N=3);let k=u.attributes.position.count*N,F=1;k>e.maxTextureSize&&(F=Math.ceil(k/e.maxTextureSize),k=e.maxTextureSize);const I=new Float32Array(k*F*4*y),W=new A7(I,k,F,y);W.type=rc,W.needsUpdate=!0;const D=N*4;for(let G=0;G<y;G++){const V=R[G],Z=A[G],Y=j[G],ee=k*F*4*G;for(let H=0;H<V.count;H++){const q=H*D;w===!0&&(s.fromBufferAttribute(V,H),I[ee+q+0]=s.x,I[ee+q+1]=s.y,I[ee+q+2]=s.z,I[ee+q+3]=0),C===!0&&(s.fromBufferAttribute(Z,H),I[ee+q+4]=s.x,I[ee+q+5]=s.y,I[ee+q+6]=s.z,I[ee+q+7]=0),T===!0&&(s.fromBufferAttribute(Y,H),I[ee+q+8]=s.x,I[ee+q+9]=s.y,I[ee+q+10]=s.z,I[ee+q+11]=Y.itemSize===4?s.w:1)}}v={count:y,texture:W,size:new Kt(k,F)},a.set(u,v),u.addEventListener("dispose",B)}let x=0;for(let w=0;w<g.length;w++)x+=g[w];const M=u.morphTargetsRelative?1:1-x;h.getUniforms().setValue(t,"morphTargetBaseInfluence",M),h.getUniforms().setValue(t,"morphTargetInfluences",g),h.getUniforms().setValue(t,"morphTargetsTexture",v.texture,n),h.getUniforms().setValue(t,"morphTargetsTextureSize",v.size)}else{const b=g===void 0?0:g.length;let y=r[u.id];if(y===void 0||y.length!==b){y=[];for(let C=0;C<b;C++)y[C]=[C,0];r[u.id]=y}for(let C=0;C<b;C++){const T=y[C];T[0]=C,T[1]=g[C]}y.sort(Jbe);for(let C=0;C<8;C++)C<b&&y[C][1]?(o[C][0]=y[C][0],o[C][1]=y[C][1]):(o[C][0]=Number.MAX_SAFE_INTEGER,o[C][1]=0);o.sort(Qbe);const v=u.morphAttributes.position,x=u.morphAttributes.normal;let M=0;for(let C=0;C<8;C++){const T=o[C],R=T[0],A=T[1];R!==Number.MAX_SAFE_INTEGER&&A?(v&&u.getAttribute("morphTarget"+C)!==v[R]&&u.setAttribute("morphTarget"+C,v[R]),x&&u.getAttribute("morphNormal"+C)!==x[R]&&u.setAttribute("morphNormal"+C,x[R]),i[C]=A,M+=A):(v&&u.hasAttribute("morphTarget"+C)===!0&&u.deleteAttribute("morphTarget"+C),x&&u.hasAttribute("morphNormal"+C)===!0&&u.deleteAttribute("morphNormal"+C),i[C]=0)}const w=u.morphTargetsRelative?1:1-M;h.getUniforms().setValue(t,"morphTargetBaseInfluence",w),h.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:l}}function tye(t,e,n,r){let i=new WeakMap;function a(l){const c=r.render.frame,u=l.geometry,h=e.get(l,u);if(i.get(h)!==c&&(e.update(h),i.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.get(l)!==c&&(n.update(l.instanceMatrix,t.ARRAY_BUFFER),l.instanceColor!==null&&n.update(l.instanceColor,t.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){const g=l.skeleton;i.get(g)!==c&&(g.update(),i.set(g,c))}return h}function s(){i=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),n.remove(c.instanceMatrix),c.instanceColor!==null&&n.remove(c.instanceColor)}return{update:a,dispose:s}}class I7 extends za{constructor(e,n,r,i,a,s,o,l,c,u){if(u=u!==void 0?u:cf,u!==cf&&u!==tm)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&u===cf&&(r=Du),r===void 0&&u===tm&&(r=lf),super(null,i,a,s,o,l,u,r,c),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=o!==void 0?o:Hi,this.minFilter=l!==void 0?l:Hi,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 j7=new za,U7=new I7(1,1);U7.compareFunction=_7;const F7=new A7,z7=new Fxe,B7=new O7,M5=[],E5=[],A5=new Float32Array(16),T5=new Float32Array(9),C5=new Float32Array(4);function Nm(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=M5[i];if(a===void 0&&(a=new Float32Array(i),M5[i]=a),e!==0){r.toArray(a,0);for(let s=1,o=0;s!==e;++s)o+=n,t[s].toArray(a,o)}return a}function oi(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 li(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function dw(t,e){let n=E5[e];n===void 0&&(n=new Int32Array(e),E5[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function nye(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function rye(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(oi(n,e))return;t.uniform2fv(this.addr,e),li(n,e)}}function iye(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(oi(n,e))return;t.uniform3fv(this.addr,e),li(n,e)}}function aye(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(oi(n,e))return;t.uniform4fv(this.addr,e),li(n,e)}}function sye(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(oi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),li(n,e)}else{if(oi(n,r))return;C5.set(r),t.uniformMatrix2fv(this.addr,!1,C5),li(n,r)}}function oye(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(oi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),li(n,e)}else{if(oi(n,r))return;T5.set(r),t.uniformMatrix3fv(this.addr,!1,T5),li(n,r)}}function lye(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(oi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),li(n,e)}else{if(oi(n,r))return;A5.set(r),t.uniformMatrix4fv(this.addr,!1,A5),li(n,r)}}function cye(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function uye(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(oi(n,e))return;t.uniform2iv(this.addr,e),li(n,e)}}function dye(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(oi(n,e))return;t.uniform3iv(this.addr,e),li(n,e)}}function fye(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(oi(n,e))return;t.uniform4iv(this.addr,e),li(n,e)}}function hye(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function pye(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(oi(n,e))return;t.uniform2uiv(this.addr,e),li(n,e)}}function mye(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(oi(n,e))return;t.uniform3uiv(this.addr,e),li(n,e)}}function gye(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||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(oi(n,e))return;t.uniform4uiv(this.addr,e),li(n,e)}}function xye(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?U7:j7;n.setTexture2D(e||a,i)}function vye(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||z7,i)}function bye(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||B7,i)}function yye(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||F7,i)}function _ye(t){switch(t){case 5126:return nye;case 35664:return rye;case 35665:return iye;case 35666:return aye;case 35674:return sye;case 35675:return oye;case 35676:return lye;case 5124:case 35670:return cye;case 35667:case 35671:return uye;case 35668:case 35672:return dye;case 35669:case 35673:return fye;case 5125:return hye;case 36294:return pye;case 36295:return mye;case 36296:return gye;case 35678:case 36198:case 36298:case 36306:case 35682:return xye;case 35679:case 36299:case 36307:return vye;case 35680:case 36300:case 36308:case 36293:return bye;case 36289:case 36303:case 36311:case 36292:return yye}}function Sye(t,e){t.uniform1fv(this.addr,e)}function wye(t,e){const n=Nm(e,this.size,2);t.uniform2fv(this.addr,n)}function Mye(t,e){const n=Nm(e,this.size,3);t.uniform3fv(this.addr,n)}function Eye(t,e){const n=Nm(e,this.size,4);t.uniform4fv(this.addr,n)}function Aye(t,e){const n=Nm(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Tye(t,e){const n=Nm(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function Cye(t,e){const n=Nm(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Nye(t,e){t.uniform1iv(this.addr,e)}function Rye(t,e){t.uniform2iv(this.addr,e)}function Pye(t,e){t.uniform3iv(this.addr,e)}function kye(t,e){t.uniform4iv(this.addr,e)}function Dye(t,e){t.uniform1uiv(this.addr,e)}function Oye(t,e){t.uniform2uiv(this.addr,e)}function Lye(t,e){t.uniform3uiv(this.addr,e)}function Iye(t,e){t.uniform4uiv(this.addr,e)}function jye(t,e,n){const r=this.cache,i=e.length,a=dw(n,i);oi(r,a)||(t.uniform1iv(this.addr,a),li(r,a));for(let s=0;s!==i;++s)n.setTexture2D(e[s]||j7,a[s])}function Uye(t,e,n){const r=this.cache,i=e.length,a=dw(n,i);oi(r,a)||(t.uniform1iv(this.addr,a),li(r,a));for(let s=0;s!==i;++s)n.setTexture3D(e[s]||z7,a[s])}function Fye(t,e,n){const r=this.cache,i=e.length,a=dw(n,i);oi(r,a)||(t.uniform1iv(this.addr,a),li(r,a));for(let s=0;s!==i;++s)n.setTextureCube(e[s]||B7,a[s])}function zye(t,e,n){const r=this.cache,i=e.length,a=dw(n,i);oi(r,a)||(t.uniform1iv(this.addr,a),li(r,a));for(let s=0;s!==i;++s)n.setTexture2DArray(e[s]||F7,a[s])}function Bye(t){switch(t){case 5126:return Sye;case 35664:return wye;case 35665:return Mye;case 35666:return Eye;case 35674:return Aye;case 35675:return Tye;case 35676:return Cye;case 5124:case 35670:return Nye;case 35667:case 35671:return Rye;case 35668:case 35672:return Pye;case 35669:case 35673:return kye;case 5125:return Dye;case 36294:return Oye;case 36295:return Lye;case 36296:return Iye;case 35678:case 36198:case 36298:case 36306:case 35682:return jye;case 35679:case 36299:case 36307:return Uye;case 35680:case 36300:case 36308:case 36293:return Fye;case 36289:case 36303:case 36311:case 36292:return zye}}class Hye{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=_ye(n.type)}}class $ye{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=Bye(n.type)}}class Vye{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,s=i.length;a!==s;++a){const o=i[a];o.setValue(e,n[o.id],r)}}}const XT=/(\w+)(\])?(\[|\.)?/g;function N5(t,e){t.seq.push(e),t.map[e.id]=e}function Gye(t,e,n){const r=t.name,i=r.length;for(XT.lastIndex=0;;){const a=XT.exec(r),s=XT.lastIndex;let o=a[1];const l=a[2]==="]",c=a[3];if(l&&(o=o|0),c===void 0||c==="["&&s+2===i){N5(n,c===void 0?new Hye(o,t,e):new $ye(o,t,e));break}else{let h=n.map[o];h===void 0&&(h=new Vye(o),N5(n,h)),n=h}}}class A_{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);Gye(a,s,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,s=n.length;a!==s;++a){const o=n[a],l=r[o.id];l.needsUpdate!==!1&&o.setValue(e,l.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 R5(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const Wye=37297;let qye=0;function Xye(t,e){const n=t.split(`
  7342. `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let s=i;s<a;s++){const o=s+1;r.push(`${o===e?">":" "} ${o}: ${n[s]}`)}return r.join(`
  7343. `)}function Kye(t){const e=$n.getPrimaries($n.workingColorSpace),n=$n.getPrimaries(t);let r;switch(e===n?r="":e===i1&&n===r1?r="LinearDisplayP3ToLinearSRGB":e===r1&&n===i1&&(r="LinearSRGBToLinearDisplayP3"),t){case bc:case cw:return[r,"LinearTransferOETF"];case $i:case gk:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function P5(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()+`
  7344. `+i+`
  7345. `+Xye(t.getShaderSource(e),s)}else return i}function Yye(t,e){const n=Kye(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function Zye(t,e){let n;switch(e){case Yge:n="Linear";break;case Zge:n="Reinhard";break;case Qge:n="OptimizedCineon";break;case Jge:n="ACESFilmic";break;case exe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function Qye(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(ux).join(`
  7346. `)}function Jye(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  7347. `)}function e_e(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),s=a.name;let o=1;a.type===t.FLOAT_MAT2&&(o=2),a.type===t.FLOAT_MAT3&&(o=3),a.type===t.FLOAT_MAT4&&(o=4),n[s]={type:a.type,location:t.getAttribLocation(e,s),locationSize:o}}return n}function ux(t){return t!==""}function k5(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 D5(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const t_e=/^[ \t]*#include +<([\w\d./]+)>/gm;function U3(t){return t.replace(t_e,r_e)}const n_e=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function r_e(t,e){let n=an[e];if(n===void 0){const r=n_e.get(e);if(r!==void 0)n=an[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 U3(n)}const i_e=/#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 O5(t){return t.replace(i_e,a_e)}function a_e(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 L5(t){let e="precision "+t.precision+` float;
  7348. precision `+t.precision+" int;";return t.precision==="highp"?e+=`
  7349. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  7350. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  7351. #define LOW_PRECISION`),e}function s_e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===u7?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===Mge?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Wl&&(e="SHADOWMAP_TYPE_VSM"),e}function o_e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Jp:case em:e="ENVMAP_TYPE_CUBE";break;case lw:e="ENVMAP_TYPE_CUBE_UV";break}return e}function l_e(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case em:e="ENVMAP_MODE_REFRACTION";break}return e}function c_e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case pk:e="ENVMAP_BLENDING_MULTIPLY";break;case Xge:e="ENVMAP_BLENDING_MIX";break;case Kge:e="ENVMAP_BLENDING_ADD";break}return e}function u_e(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 d_e(t,e,n,r){const i=t.getContext(),a=n.defines;let s=n.vertexShader,o=n.fragmentShader;const l=s_e(n),c=o_e(n),u=l_e(n),h=c_e(n),g=u_e(n),m=n.isWebGL2?"":Qye(n),b=Jye(a),y=i.createProgram();let v,x,M=n.glslVersion?"#version "+n.glslVersion+`
  7352. `:"";n.isRawShaderMaterial?(v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(ux).join(`
  7353. `),v.length>0&&(v+=`
  7354. `),x=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(ux).join(`
  7355. `),x.length>0&&(x+=`
  7356. `)):(v=[L5(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",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 "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  7357. `].filter(ux).join(`
  7358. `),x=[m,L5(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+u:"",n.envMap?"#define "+h:"",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 "+l:"",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!==Bu?"#define TONE_MAPPING":"",n.toneMapping!==Bu?an.tonemapping_pars_fragment:"",n.toneMapping!==Bu?Zye("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",an.colorspace_pars_fragment,Yye("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  7359. `].filter(ux).join(`
  7360. `)),s=U3(s),s=k5(s,n),s=D5(s,n),o=U3(o),o=k5(o,n),o=D5(o,n),s=O5(s),o=O5(o),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(M=`#version 300 es
  7361. `,v=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
  7362. `)+`
  7363. `+v,x=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===Jz?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Jz?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
  7364. `)+`
  7365. `+x);const w=M+v+s,C=M+x+o,T=R5(i,i.VERTEX_SHADER,w),R=R5(i,i.FRAGMENT_SHADER,C);i.attachShader(y,T),i.attachShader(y,R),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function A(F){if(t.debug.checkShaderErrors){const I=i.getProgramInfoLog(y).trim(),W=i.getShaderInfoLog(T).trim(),D=i.getShaderInfoLog(R).trim();let B=!0,G=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(B=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,T,R);else{const V=P5(i,T,"vertex"),Z=P5(i,R,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
  7366. Program Info Log: `+I+`
  7367. `+V+`
  7368. `+Z)}else I!==""?console.warn("THREE.WebGLProgram: Program Info Log:",I):(W===""||D==="")&&(G=!1);G&&(F.diagnostics={runnable:B,programLog:I,vertexShader:{log:W,prefix:v},fragmentShader:{log:D,prefix:x}})}i.deleteShader(T),i.deleteShader(R),j=new A_(i,y),N=e_e(i,y)}let j;this.getUniforms=function(){return j===void 0&&A(this),j};let N;this.getAttributes=function(){return N===void 0&&A(this),N};let k=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return k===!1&&(k=i.getProgramParameter(y,Wye)),k},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=qye++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=R,this}let f_e=0;class h_e{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 p_e(e),n.set(e,r)),r}}class p_e{constructor(e){this.id=f_e++,this.code=e,this.usedTimes=0}}function m_e(t,e,n,r,i,a,s){const o=new T7,l=new h_e,c=[],u=i.isWebGL2,h=i.logarithmicDepthBuffer,g=i.vertexTextures;let m=i.precision;const b={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(N){return N===0?"uv":`uv${N}`}function v(N,k,F,I,W){const D=I.fog,B=W.geometry,G=N.isMeshStandardMaterial?I.environment:null,V=(N.isMeshStandardMaterial?n:e).get(N.envMap||G),Z=V&&V.mapping===lw?V.image.height:null,Y=b[N.type];N.precision!==null&&(m=i.getMaxPrecision(N.precision),m!==N.precision&&console.warn("THREE.WebGLProgram.getParameters:",N.precision,"not supported, using",m,"instead."));const ee=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,H=ee!==void 0?ee.length:0;let q=0;B.morphAttributes.position!==void 0&&(q=1),B.morphAttributes.normal!==void 0&&(q=2),B.morphAttributes.color!==void 0&&(q=3);let ae,ce,xe,ie;if(Y){const cn=Oa[Y];ae=cn.vertexShader,ce=cn.fragmentShader}else ae=N.vertexShader,ce=N.fragmentShader,l.update(N),xe=l.getVertexShaderID(N),ie=l.getFragmentShaderID(N);const ve=t.getRenderTarget(),Pe=W.isInstancedMesh===!0,he=W.isBatchedMesh===!0,we=!!N.map,Le=!!N.matcap,de=!!V,lt=!!N.aoMap,$=!!N.lightMap,z=!!N.bumpMap,ne=!!N.normalMap,K=!!N.displacementMap,Q=!!N.emissiveMap,oe=!!N.metalnessMap,Ne=!!N.roughnessMap,Ee=N.anisotropy>0,re=N.clearcoat>0,U=N.iridescence>0,L=N.sheen>0,J=N.transmission>0,ge=Ee&&!!N.anisotropyMap,ye=re&&!!N.clearcoatMap,me=re&&!!N.clearcoatNormalMap,et=re&&!!N.clearcoatRoughnessMap,Ie=U&&!!N.iridescenceMap,Ke=U&&!!N.iridescenceThicknessMap,st=L&&!!N.sheenColorMap,je=L&&!!N.sheenRoughnessMap,le=!!N.specularMap,Ze=!!N.specularColorMap,Fe=!!N.specularIntensityMap,Xe=J&&!!N.transmissionMap,ct=J&&!!N.thicknessMap,ue=!!N.gradientMap,Qe=!!N.alphaMap,pe=N.alphaTest>0,Oe=!!N.alphaHash,Ae=!!N.extensions,be=!!B.attributes.uv1,$e=!!B.attributes.uv2,ft=!!B.attributes.uv3;let yt=Bu;return N.toneMapped&&(ve===null||ve.isXRRenderTarget===!0)&&(yt=t.toneMapping),{isWebGL2:u,shaderID:Y,shaderType:N.type,shaderName:N.name,vertexShader:ae,fragmentShader:ce,defines:N.defines,customVertexShaderID:xe,customFragmentShaderID:ie,isRawShaderMaterial:N.isRawShaderMaterial===!0,glslVersion:N.glslVersion,precision:m,batching:he,instancing:Pe,instancingColor:Pe&&W.instanceColor!==null,supportsVertexTextures:g,outputColorSpace:ve===null?t.outputColorSpace:ve.isXRRenderTarget===!0?ve.texture.colorSpace:bc,map:we,matcap:Le,envMap:de,envMapMode:de&&V.mapping,envMapCubeUVHeight:Z,aoMap:lt,lightMap:$,bumpMap:z,normalMap:ne,displacementMap:g&&K,emissiveMap:Q,normalMapObjectSpace:ne&&N.normalMapType===fxe,normalMapTangentSpace:ne&&N.normalMapType===y7,metalnessMap:oe,roughnessMap:Ne,anisotropy:Ee,anisotropyMap:ge,clearcoat:re,clearcoatMap:ye,clearcoatNormalMap:me,clearcoatRoughnessMap:et,iridescence:U,iridescenceMap:Ie,iridescenceThicknessMap:Ke,sheen:L,sheenColorMap:st,sheenRoughnessMap:je,specularMap:le,specularColorMap:Ze,specularIntensityMap:Fe,transmission:J,transmissionMap:Xe,thicknessMap:ct,gradientMap:ue,opaque:N.transparent===!1&&N.blending===Op,alphaMap:Qe,alphaTest:pe,alphaHash:Oe,combine:N.combine,mapUv:we&&y(N.map.channel),aoMapUv:lt&&y(N.aoMap.channel),lightMapUv:$&&y(N.lightMap.channel),bumpMapUv:z&&y(N.bumpMap.channel),normalMapUv:ne&&y(N.normalMap.channel),displacementMapUv:K&&y(N.displacementMap.channel),emissiveMapUv:Q&&y(N.emissiveMap.channel),metalnessMapUv:oe&&y(N.metalnessMap.channel),roughnessMapUv:Ne&&y(N.roughnessMap.channel),anisotropyMapUv:ge&&y(N.anisotropyMap.channel),clearcoatMapUv:ye&&y(N.clearcoatMap.channel),clearcoatNormalMapUv:me&&y(N.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:et&&y(N.clearcoatRoughnessMap.channel),iridescenceMapUv:Ie&&y(N.iridescenceMap.channel),iridescenceThicknessMapUv:Ke&&y(N.iridescenceThicknessMap.channel),sheenColorMapUv:st&&y(N.sheenColorMap.channel),sheenRoughnessMapUv:je&&y(N.sheenRoughnessMap.channel),specularMapUv:le&&y(N.specularMap.channel),specularColorMapUv:Ze&&y(N.specularColorMap.channel),specularIntensityMapUv:Fe&&y(N.specularIntensityMap.channel),transmissionMapUv:Xe&&y(N.transmissionMap.channel),thicknessMapUv:ct&&y(N.thicknessMap.channel),alphaMapUv:Qe&&y(N.alphaMap.channel),vertexTangents:!!B.attributes.tangent&&(ne||Ee),vertexColors:N.vertexColors,vertexAlphas:N.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,vertexUv1s:be,vertexUv2s:$e,vertexUv3s:ft,pointsUvs:W.isPoints===!0&&!!B.attributes.uv&&(we||Qe),fog:!!D,useFog:N.fog===!0,fogExp2:D&&D.isFogExp2,flatShading:N.flatShading===!0,sizeAttenuation:N.sizeAttenuation===!0,logarithmicDepthBuffer:h,skinning:W.isSkinnedMesh===!0,morphTargets:B.morphAttributes.position!==void 0,morphNormals:B.morphAttributes.normal!==void 0,morphColors:B.morphAttributes.color!==void 0,morphTargetsCount:H,morphTextureStride:q,numDirLights:k.directional.length,numPointLights:k.point.length,numSpotLights:k.spot.length,numSpotLightMaps:k.spotLightMap.length,numRectAreaLights:k.rectArea.length,numHemiLights:k.hemi.length,numDirLightShadows:k.directionalShadowMap.length,numPointLightShadows:k.pointShadowMap.length,numSpotLightShadows:k.spotShadowMap.length,numSpotLightShadowsWithMaps:k.numSpotLightShadowsWithMaps,numLightProbes:k.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:N.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:yt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:we&&N.map.isVideoTexture===!0&&$n.getTransfer(N.map.colorSpace)===rr,premultipliedAlpha:N.premultipliedAlpha,doubleSided:N.side===Zl,flipSided:N.side===Fa,useDepthPacking:N.depthPacking>=0,depthPacking:N.depthPacking||0,index0AttributeName:N.index0AttributeName,extensionDerivatives:Ae&&N.extensions.derivatives===!0,extensionFragDepth:Ae&&N.extensions.fragDepth===!0,extensionDrawBuffers:Ae&&N.extensions.drawBuffers===!0,extensionShaderTextureLOD:Ae&&N.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:u||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||r.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:N.customProgramCacheKey()}}function x(N){const k=[];if(N.shaderID?k.push(N.shaderID):(k.push(N.customVertexShaderID),k.push(N.customFragmentShaderID)),N.defines!==void 0)for(const F in N.defines)k.push(F),k.push(N.defines[F]);return N.isRawShaderMaterial===!1&&(M(k,N),w(k,N),k.push(t.outputColorSpace)),k.push(N.customProgramCacheKey),k.join()}function M(N,k){N.push(k.precision),N.push(k.outputColorSpace),N.push(k.envMapMode),N.push(k.envMapCubeUVHeight),N.push(k.mapUv),N.push(k.alphaMapUv),N.push(k.lightMapUv),N.push(k.aoMapUv),N.push(k.bumpMapUv),N.push(k.normalMapUv),N.push(k.displacementMapUv),N.push(k.emissiveMapUv),N.push(k.metalnessMapUv),N.push(k.roughnessMapUv),N.push(k.anisotropyMapUv),N.push(k.clearcoatMapUv),N.push(k.clearcoatNormalMapUv),N.push(k.clearcoatRoughnessMapUv),N.push(k.iridescenceMapUv),N.push(k.iridescenceThicknessMapUv),N.push(k.sheenColorMapUv),N.push(k.sheenRoughnessMapUv),N.push(k.specularMapUv),N.push(k.specularColorMapUv),N.push(k.specularIntensityMapUv),N.push(k.transmissionMapUv),N.push(k.thicknessMapUv),N.push(k.combine),N.push(k.fogExp2),N.push(k.sizeAttenuation),N.push(k.morphTargetsCount),N.push(k.morphAttributeCount),N.push(k.numDirLights),N.push(k.numPointLights),N.push(k.numSpotLights),N.push(k.numSpotLightMaps),N.push(k.numHemiLights),N.push(k.numRectAreaLights),N.push(k.numDirLightShadows),N.push(k.numPointLightShadows),N.push(k.numSpotLightShadows),N.push(k.numSpotLightShadowsWithMaps),N.push(k.numLightProbes),N.push(k.shadowMapType),N.push(k.toneMapping),N.push(k.numClippingPlanes),N.push(k.numClipIntersection),N.push(k.depthPacking)}function w(N,k){o.disableAll(),k.isWebGL2&&o.enable(0),k.supportsVertexTextures&&o.enable(1),k.instancing&&o.enable(2),k.instancingColor&&o.enable(3),k.matcap&&o.enable(4),k.envMap&&o.enable(5),k.normalMapObjectSpace&&o.enable(6),k.normalMapTangentSpace&&o.enable(7),k.clearcoat&&o.enable(8),k.iridescence&&o.enable(9),k.alphaTest&&o.enable(10),k.vertexColors&&o.enable(11),k.vertexAlphas&&o.enable(12),k.vertexUv1s&&o.enable(13),k.vertexUv2s&&o.enable(14),k.vertexUv3s&&o.enable(15),k.vertexTangents&&o.enable(16),k.anisotropy&&o.enable(17),k.alphaHash&&o.enable(18),k.batching&&o.enable(19),N.push(o.mask),o.disableAll(),k.fog&&o.enable(0),k.useFog&&o.enable(1),k.flatShading&&o.enable(2),k.logarithmicDepthBuffer&&o.enable(3),k.skinning&&o.enable(4),k.morphTargets&&o.enable(5),k.morphNormals&&o.enable(6),k.morphColors&&o.enable(7),k.premultipliedAlpha&&o.enable(8),k.shadowMapEnabled&&o.enable(9),k.useLegacyLights&&o.enable(10),k.doubleSided&&o.enable(11),k.flipSided&&o.enable(12),k.useDepthPacking&&o.enable(13),k.dithering&&o.enable(14),k.transmission&&o.enable(15),k.sheen&&o.enable(16),k.opaque&&o.enable(17),k.pointsUvs&&o.enable(18),k.decodeVideoTexture&&o.enable(19),N.push(o.mask)}function C(N){const k=b[N.type];let F;if(k){const I=Oa[k];F=bk.clone(I.uniforms)}else F=N.uniforms;return F}function T(N,k){let F;for(let I=0,W=c.length;I<W;I++){const D=c[I];if(D.cacheKey===k){F=D,++F.usedTimes;break}}return F===void 0&&(F=new d_e(t,k,N,a),c.push(F)),F}function R(N){if(--N.usedTimes===0){const k=c.indexOf(N);c[k]=c[c.length-1],c.pop(),N.destroy()}}function A(N){l.remove(N)}function j(){l.dispose()}return{getParameters:v,getProgramCacheKey:x,getUniforms:C,acquireProgram:T,releaseProgram:R,releaseShaderCache:A,programs:c,dispose:j}}function g_e(){let t=new WeakMap;function e(a){let s=t.get(a);return s===void 0&&(s={},t.set(a,s)),s}function n(a){t.delete(a)}function r(a,s,o){t.get(a)[s]=o}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function x_e(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 I5(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 j5(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function s(h,g,m,b,y,v){let x=t[e];return x===void 0?(x={id:h.id,object:h,geometry:g,material:m,groupOrder:b,renderOrder:h.renderOrder,z:y,group:v},t[e]=x):(x.id=h.id,x.object=h,x.geometry=g,x.material=m,x.groupOrder=b,x.renderOrder=h.renderOrder,x.z=y,x.group=v),e++,x}function o(h,g,m,b,y,v){const x=s(h,g,m,b,y,v);m.transmission>0?r.push(x):m.transparent===!0?i.push(x):n.push(x)}function l(h,g,m,b,y,v){const x=s(h,g,m,b,y,v);m.transmission>0?r.unshift(x):m.transparent===!0?i.unshift(x):n.unshift(x)}function c(h,g){n.length>1&&n.sort(h||x_e),r.length>1&&r.sort(g||I5),i.length>1&&i.sort(g||I5)}function u(){for(let h=e,g=t.length;h<g;h++){const m=t[h];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:o,unshift:l,finish:u,sort:c}}function v_e(){let t=new WeakMap;function e(r,i){const a=t.get(r);let s;return a===void 0?(s=new j5,t.set(r,[s])):i>=a.length?(s=new j5,a.push(s)):s=a[i],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function b_e(){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 Ce,color:new zt};break;case"SpotLight":n={position:new Ce,direction:new Ce,color:new zt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Ce,color:new zt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Ce,skyColor:new zt,groundColor:new zt};break;case"RectAreaLight":n={color:new zt,position:new Ce,halfWidth:new Ce,halfHeight:new Ce};break}return t[e.id]=n,n}}}function y_e(){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 Kt};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Kt};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Kt,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let __e=0;function S_e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function w_e(t,e){const n=new b_e,r=y_e(),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 u=0;u<9;u++)i.probe.push(new Ce);const a=new Ce,s=new Jn,o=new Jn;function l(u,h){let g=0,m=0,b=0;for(let I=0;I<9;I++)i.probe[I].set(0,0,0);let y=0,v=0,x=0,M=0,w=0,C=0,T=0,R=0,A=0,j=0,N=0;u.sort(S_e);const k=h===!0?Math.PI:1;for(let I=0,W=u.length;I<W;I++){const D=u[I],B=D.color,G=D.intensity,V=D.distance,Z=D.shadow&&D.shadow.map?D.shadow.map.texture:null;if(D.isAmbientLight)g+=B.r*G*k,m+=B.g*G*k,b+=B.b*G*k;else if(D.isLightProbe){for(let Y=0;Y<9;Y++)i.probe[Y].addScaledVector(D.sh.coefficients[Y],G);N++}else if(D.isDirectionalLight){const Y=n.get(D);if(Y.color.copy(D.color).multiplyScalar(D.intensity*k),D.castShadow){const ee=D.shadow,H=r.get(D);H.shadowBias=ee.bias,H.shadowNormalBias=ee.normalBias,H.shadowRadius=ee.radius,H.shadowMapSize=ee.mapSize,i.directionalShadow[y]=H,i.directionalShadowMap[y]=Z,i.directionalShadowMatrix[y]=D.shadow.matrix,C++}i.directional[y]=Y,y++}else if(D.isSpotLight){const Y=n.get(D);Y.position.setFromMatrixPosition(D.matrixWorld),Y.color.copy(B).multiplyScalar(G*k),Y.distance=V,Y.coneCos=Math.cos(D.angle),Y.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),Y.decay=D.decay,i.spot[x]=Y;const ee=D.shadow;if(D.map&&(i.spotLightMap[A]=D.map,A++,ee.updateMatrices(D),D.castShadow&&j++),i.spotLightMatrix[x]=ee.matrix,D.castShadow){const H=r.get(D);H.shadowBias=ee.bias,H.shadowNormalBias=ee.normalBias,H.shadowRadius=ee.radius,H.shadowMapSize=ee.mapSize,i.spotShadow[x]=H,i.spotShadowMap[x]=Z,R++}x++}else if(D.isRectAreaLight){const Y=n.get(D);Y.color.copy(B).multiplyScalar(G),Y.halfWidth.set(D.width*.5,0,0),Y.halfHeight.set(0,D.height*.5,0),i.rectArea[M]=Y,M++}else if(D.isPointLight){const Y=n.get(D);if(Y.color.copy(D.color).multiplyScalar(D.intensity*k),Y.distance=D.distance,Y.decay=D.decay,D.castShadow){const ee=D.shadow,H=r.get(D);H.shadowBias=ee.bias,H.shadowNormalBias=ee.normalBias,H.shadowRadius=ee.radius,H.shadowMapSize=ee.mapSize,H.shadowCameraNear=ee.camera.near,H.shadowCameraFar=ee.camera.far,i.pointShadow[v]=H,i.pointShadowMap[v]=Z,i.pointShadowMatrix[v]=D.shadow.matrix,T++}i.point[v]=Y,v++}else if(D.isHemisphereLight){const Y=n.get(D);Y.skyColor.copy(D.color).multiplyScalar(G*k),Y.groundColor.copy(D.groundColor).multiplyScalar(G*k),i.hemi[w]=Y,w++}}M>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=bt.LTC_FLOAT_1,i.rectAreaLTC2=bt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=bt.LTC_HALF_1,i.rectAreaLTC2=bt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=g,i.ambient[1]=m,i.ambient[2]=b;const F=i.hash;(F.directionalLength!==y||F.pointLength!==v||F.spotLength!==x||F.rectAreaLength!==M||F.hemiLength!==w||F.numDirectionalShadows!==C||F.numPointShadows!==T||F.numSpotShadows!==R||F.numSpotMaps!==A||F.numLightProbes!==N)&&(i.directional.length=y,i.spot.length=x,i.rectArea.length=M,i.point.length=v,i.hemi.length=w,i.directionalShadow.length=C,i.directionalShadowMap.length=C,i.pointShadow.length=T,i.pointShadowMap.length=T,i.spotShadow.length=R,i.spotShadowMap.length=R,i.directionalShadowMatrix.length=C,i.pointShadowMatrix.length=T,i.spotLightMatrix.length=R+A-j,i.spotLightMap.length=A,i.numSpotLightShadowsWithMaps=j,i.numLightProbes=N,F.directionalLength=y,F.pointLength=v,F.spotLength=x,F.rectAreaLength=M,F.hemiLength=w,F.numDirectionalShadows=C,F.numPointShadows=T,F.numSpotShadows=R,F.numSpotMaps=A,F.numLightProbes=N,i.version=__e++)}function c(u,h){let g=0,m=0,b=0,y=0,v=0;const x=h.matrixWorldInverse;for(let M=0,w=u.length;M<w;M++){const C=u[M];if(C.isDirectionalLight){const T=i.directional[g];T.direction.setFromMatrixPosition(C.matrixWorld),a.setFromMatrixPosition(C.target.matrixWorld),T.direction.sub(a),T.direction.transformDirection(x),g++}else if(C.isSpotLight){const T=i.spot[b];T.position.setFromMatrixPosition(C.matrixWorld),T.position.applyMatrix4(x),T.direction.setFromMatrixPosition(C.matrixWorld),a.setFromMatrixPosition(C.target.matrixWorld),T.direction.sub(a),T.direction.transformDirection(x),b++}else if(C.isRectAreaLight){const T=i.rectArea[y];T.position.setFromMatrixPosition(C.matrixWorld),T.position.applyMatrix4(x),o.identity(),s.copy(C.matrixWorld),s.premultiply(x),o.extractRotation(s),T.halfWidth.set(C.width*.5,0,0),T.halfHeight.set(0,C.height*.5,0),T.halfWidth.applyMatrix4(o),T.halfHeight.applyMatrix4(o),y++}else if(C.isPointLight){const T=i.point[m];T.position.setFromMatrixPosition(C.matrixWorld),T.position.applyMatrix4(x),m++}else if(C.isHemisphereLight){const T=i.hemi[v];T.direction.setFromMatrixPosition(C.matrixWorld),T.direction.transformDirection(x),v++}}}return{setup:l,setupView:c,state:i}}function U5(t,e){const n=new w_e(t,e),r=[],i=[];function a(){r.length=0,i.length=0}function s(h){r.push(h)}function o(h){i.push(h)}function l(h){n.setup(r,h)}function c(h){n.setupView(r,h)}return{init:a,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:l,setupLightsView:c,pushLight:s,pushShadow:o}}function M_e(t,e){let n=new WeakMap;function r(a,s=0){const o=n.get(a);let l;return o===void 0?(l=new U5(t,e),n.set(a,[l])):s>=o.length?(l=new U5(t,e),o.push(l)):l=o[s],l}function i(){n=new WeakMap}return{get:r,dispose:i}}class E_e extends Cm{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=uxe,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 A_e extends Cm{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 T_e=`void main() {
  7369. gl_Position = vec4( position, 1.0 );
  7370. }`,C_e=`uniform sampler2D shadow_pass;
  7371. uniform vec2 resolution;
  7372. uniform float radius;
  7373. #include <packing>
  7374. void main() {
  7375. const float samples = float( VSM_SAMPLES );
  7376. float mean = 0.0;
  7377. float squared_mean = 0.0;
  7378. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  7379. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  7380. for ( float i = 0.0; i < samples; i ++ ) {
  7381. float uvOffset = uvStart + i * uvStride;
  7382. #ifdef HORIZONTAL_PASS
  7383. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  7384. mean += distribution.x;
  7385. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  7386. #else
  7387. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  7388. mean += depth;
  7389. squared_mean += depth * depth;
  7390. #endif
  7391. }
  7392. mean = mean / samples;
  7393. squared_mean = squared_mean / samples;
  7394. float std_dev = sqrt( squared_mean - mean * mean );
  7395. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  7396. }`;function N_e(t,e,n){let r=new uw;const i=new Kt,a=new Kt,s=new Gn,o=new E_e({depthPacking:dxe}),l=new A_e,c={},u=n.maxTextureSize,h={[Qu]:Fa,[Fa]:Qu,[Zl]:Zl},g=new Ju({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Kt},radius:{value:4}},vertexShader:T_e,fragmentShader:C_e}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const b=new oa;b.setAttribute("position",new fs(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new vo(b,g),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=u7;let x=this.type;this.render=function(T,R,A){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||T.length===0)return;const j=t.getRenderTarget(),N=t.getActiveCubeFace(),k=t.getActiveMipmapLevel(),F=t.state;F.setBlending(zu),F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const I=x!==Wl&&this.type===Wl,W=x===Wl&&this.type!==Wl;for(let D=0,B=T.length;D<B;D++){const G=T[D],V=G.shadow;if(V===void 0){console.warn("THREE.WebGLShadowMap:",G,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;i.copy(V.mapSize);const Z=V.getFrameExtents();if(i.multiply(Z),a.copy(V.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(a.x=Math.floor(u/Z.x),i.x=a.x*Z.x,V.mapSize.x=a.x),i.y>u&&(a.y=Math.floor(u/Z.y),i.y=a.y*Z.y,V.mapSize.y=a.y)),V.map===null||I===!0||W===!0){const ee=this.type!==Wl?{minFilter:Hi,magFilter:Hi}:{};V.map!==null&&V.map.dispose(),V.map=new kf(i.x,i.y,ee),V.map.texture.name=G.name+".shadowMap",V.camera.updateProjectionMatrix()}t.setRenderTarget(V.map),t.clear();const Y=V.getViewportCount();for(let ee=0;ee<Y;ee++){const H=V.getViewport(ee);s.set(a.x*H.x,a.y*H.y,a.x*H.z,a.y*H.w),F.viewport(s),V.updateMatrices(G,ee),r=V.getFrustum(),C(R,A,V.camera,G,this.type)}V.isPointLightShadow!==!0&&this.type===Wl&&M(V,A),V.needsUpdate=!1}x=this.type,v.needsUpdate=!1,t.setRenderTarget(j,N,k)};function M(T,R){const A=e.update(y);g.defines.VSM_SAMPLES!==T.blurSamples&&(g.defines.VSM_SAMPLES=T.blurSamples,m.defines.VSM_SAMPLES=T.blurSamples,g.needsUpdate=!0,m.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new kf(i.x,i.y)),g.uniforms.shadow_pass.value=T.map.texture,g.uniforms.resolution.value=T.mapSize,g.uniforms.radius.value=T.radius,t.setRenderTarget(T.mapPass),t.clear(),t.renderBufferDirect(R,null,A,g,y,null),m.uniforms.shadow_pass.value=T.mapPass.texture,m.uniforms.resolution.value=T.mapSize,m.uniforms.radius.value=T.radius,t.setRenderTarget(T.map),t.clear(),t.renderBufferDirect(R,null,A,m,y,null)}function w(T,R,A,j){let N=null;const k=A.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(k!==void 0)N=k;else if(N=A.isPointLight===!0?l:o,t.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0){const F=N.uuid,I=R.uuid;let W=c[F];W===void 0&&(W={},c[F]=W);let D=W[I];D===void 0&&(D=N.clone(),W[I]=D),N=D}if(N.visible=R.visible,N.wireframe=R.wireframe,j===Wl?N.side=R.shadowSide!==null?R.shadowSide:R.side:N.side=R.shadowSide!==null?R.shadowSide:h[R.side],N.alphaMap=R.alphaMap,N.alphaTest=R.alphaTest,N.map=R.map,N.clipShadows=R.clipShadows,N.clippingPlanes=R.clippingPlanes,N.clipIntersection=R.clipIntersection,N.displacementMap=R.displacementMap,N.displacementScale=R.displacementScale,N.displacementBias=R.displacementBias,N.wireframeLinewidth=R.wireframeLinewidth,N.linewidth=R.linewidth,A.isPointLight===!0&&N.isMeshDistanceMaterial===!0){const F=t.properties.get(N);F.light=A}return N}function C(T,R,A,j,N){if(T.visible===!1)return;if(T.layers.test(R.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&N===Wl)&&(!T.frustumCulled||r.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,T.matrixWorld);const I=e.update(T),W=T.material;if(Array.isArray(W)){const D=I.groups;for(let B=0,G=D.length;B<G;B++){const V=D[B],Z=W[V.materialIndex];if(Z&&Z.visible){const Y=w(T,Z,j,N);T.onBeforeShadow(t,T,R,A,I,Y,V),t.renderBufferDirect(A,null,I,Y,T,V),T.onAfterShadow(t,T,R,A,I,Y,V)}}}else if(W.visible){const D=w(T,W,j,N);T.onBeforeShadow(t,T,R,A,I,D,null),t.renderBufferDirect(A,null,I,D,T,null),T.onAfterShadow(t,T,R,A,I,D,null)}}const F=T.children;for(let I=0,W=F.length;I<W;I++)C(F[I],R,A,j,N)}}function R_e(t,e,n){const r=n.isWebGL2;function i(){let pe=!1;const Oe=new Gn;let Ae=null;const be=new Gn(0,0,0,0);return{setMask:function($e){Ae!==$e&&!pe&&(t.colorMask($e,$e,$e,$e),Ae=$e)},setLocked:function($e){pe=$e},setClear:function($e,ft,yt,Pt,cn){cn===!0&&($e*=Pt,ft*=Pt,yt*=Pt),Oe.set($e,ft,yt,Pt),be.equals(Oe)===!1&&(t.clearColor($e,ft,yt,Pt),be.copy(Oe))},reset:function(){pe=!1,Ae=null,be.set(-1,0,0,0)}}}function a(){let pe=!1,Oe=null,Ae=null,be=null;return{setTest:function($e){$e?he(t.DEPTH_TEST):we(t.DEPTH_TEST)},setMask:function($e){Oe!==$e&&!pe&&(t.depthMask($e),Oe=$e)},setFunc:function($e){if(Ae!==$e){switch($e){case Bge:t.depthFunc(t.NEVER);break;case Hge:t.depthFunc(t.ALWAYS);break;case $ge:t.depthFunc(t.LESS);break;case t1:t.depthFunc(t.LEQUAL);break;case Vge:t.depthFunc(t.EQUAL);break;case Gge:t.depthFunc(t.GEQUAL);break;case Wge:t.depthFunc(t.GREATER);break;case qge:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Ae=$e}},setLocked:function($e){pe=$e},setClear:function($e){be!==$e&&(t.clearDepth($e),be=$e)},reset:function(){pe=!1,Oe=null,Ae=null,be=null}}}function s(){let pe=!1,Oe=null,Ae=null,be=null,$e=null,ft=null,yt=null,Pt=null,cn=null;return{setTest:function(Ot){pe||(Ot?he(t.STENCIL_TEST):we(t.STENCIL_TEST))},setMask:function(Ot){Oe!==Ot&&!pe&&(t.stencilMask(Ot),Oe=Ot)},setFunc:function(Ot,Rn,qn){(Ae!==Ot||be!==Rn||$e!==qn)&&(t.stencilFunc(Ot,Rn,qn),Ae=Ot,be=Rn,$e=qn)},setOp:function(Ot,Rn,qn){(ft!==Ot||yt!==Rn||Pt!==qn)&&(t.stencilOp(Ot,Rn,qn),ft=Ot,yt=Rn,Pt=qn)},setLocked:function(Ot){pe=Ot},setClear:function(Ot){cn!==Ot&&(t.clearStencil(Ot),cn=Ot)},reset:function(){pe=!1,Oe=null,Ae=null,be=null,$e=null,ft=null,yt=null,Pt=null,cn=null}}}const o=new i,l=new a,c=new s,u=new WeakMap,h=new WeakMap;let g={},m={},b=new WeakMap,y=[],v=null,x=!1,M=null,w=null,C=null,T=null,R=null,A=null,j=null,N=new zt(0,0,0),k=0,F=!1,I=null,W=null,D=null,B=null,G=null;const V=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Z=!1,Y=0;const ee=t.getParameter(t.VERSION);ee.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(ee)[1]),Z=Y>=1):ee.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(ee)[1]),Z=Y>=2);let H=null,q={};const ae=t.getParameter(t.SCISSOR_BOX),ce=t.getParameter(t.VIEWPORT),xe=new Gn().fromArray(ae),ie=new Gn().fromArray(ce);function ve(pe,Oe,Ae,be){const $e=new Uint8Array(4),ft=t.createTexture();t.bindTexture(pe,ft),t.texParameteri(pe,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(pe,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let yt=0;yt<Ae;yt++)r&&(pe===t.TEXTURE_3D||pe===t.TEXTURE_2D_ARRAY)?t.texImage3D(Oe,0,t.RGBA,1,1,be,0,t.RGBA,t.UNSIGNED_BYTE,$e):t.texImage2D(Oe+yt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,$e);return ft}const Pe={};Pe[t.TEXTURE_2D]=ve(t.TEXTURE_2D,t.TEXTURE_2D,1),Pe[t.TEXTURE_CUBE_MAP]=ve(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Pe[t.TEXTURE_2D_ARRAY]=ve(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Pe[t.TEXTURE_3D]=ve(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),l.setClear(1),c.setClear(0),he(t.DEPTH_TEST),l.setFunc(t1),Q(!1),oe(yz),he(t.CULL_FACE),ne(zu);function he(pe){g[pe]!==!0&&(t.enable(pe),g[pe]=!0)}function we(pe){g[pe]!==!1&&(t.disable(pe),g[pe]=!1)}function Le(pe,Oe){return m[pe]!==Oe?(t.bindFramebuffer(pe,Oe),m[pe]=Oe,r&&(pe===t.DRAW_FRAMEBUFFER&&(m[t.FRAMEBUFFER]=Oe),pe===t.FRAMEBUFFER&&(m[t.DRAW_FRAMEBUFFER]=Oe)),!0):!1}function de(pe,Oe){let Ae=y,be=!1;if(pe)if(Ae=b.get(Oe),Ae===void 0&&(Ae=[],b.set(Oe,Ae)),pe.isWebGLMultipleRenderTargets){const $e=pe.texture;if(Ae.length!==$e.length||Ae[0]!==t.COLOR_ATTACHMENT0){for(let ft=0,yt=$e.length;ft<yt;ft++)Ae[ft]=t.COLOR_ATTACHMENT0+ft;Ae.length=$e.length,be=!0}}else Ae[0]!==t.COLOR_ATTACHMENT0&&(Ae[0]=t.COLOR_ATTACHMENT0,be=!0);else Ae[0]!==t.BACK&&(Ae[0]=t.BACK,be=!0);be&&(n.isWebGL2?t.drawBuffers(Ae):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Ae))}function lt(pe){return v!==pe?(t.useProgram(pe),v=pe,!0):!1}const $={[Xd]:t.FUNC_ADD,[Age]:t.FUNC_SUBTRACT,[Tge]:t.FUNC_REVERSE_SUBTRACT};if(r)$[Mz]=t.MIN,$[Ez]=t.MAX;else{const pe=e.get("EXT_blend_minmax");pe!==null&&($[Mz]=pe.MIN_EXT,$[Ez]=pe.MAX_EXT)}const z={[Cge]:t.ZERO,[Nge]:t.ONE,[Rge]:t.SRC_COLOR,[N3]:t.SRC_ALPHA,[Ige]:t.SRC_ALPHA_SATURATE,[Oge]:t.DST_COLOR,[kge]:t.DST_ALPHA,[Pge]:t.ONE_MINUS_SRC_COLOR,[R3]:t.ONE_MINUS_SRC_ALPHA,[Lge]:t.ONE_MINUS_DST_COLOR,[Dge]:t.ONE_MINUS_DST_ALPHA,[jge]:t.CONSTANT_COLOR,[Uge]:t.ONE_MINUS_CONSTANT_COLOR,[Fge]:t.CONSTANT_ALPHA,[zge]:t.ONE_MINUS_CONSTANT_ALPHA};function ne(pe,Oe,Ae,be,$e,ft,yt,Pt,cn,Ot){if(pe===zu){x===!0&&(we(t.BLEND),x=!1);return}if(x===!1&&(he(t.BLEND),x=!0),pe!==Ege){if(pe!==M||Ot!==F){if((w!==Xd||R!==Xd)&&(t.blendEquation(t.FUNC_ADD),w=Xd,R=Xd),Ot)switch(pe){case Op:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case _z:t.blendFunc(t.ONE,t.ONE);break;case Sz:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case wz:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",pe);break}else switch(pe){case Op:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case _z:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case Sz:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case wz:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",pe);break}C=null,T=null,A=null,j=null,N.set(0,0,0),k=0,M=pe,F=Ot}return}$e=$e||Oe,ft=ft||Ae,yt=yt||be,(Oe!==w||$e!==R)&&(t.blendEquationSeparate($[Oe],$[$e]),w=Oe,R=$e),(Ae!==C||be!==T||ft!==A||yt!==j)&&(t.blendFuncSeparate(z[Ae],z[be],z[ft],z[yt]),C=Ae,T=be,A=ft,j=yt),(Pt.equals(N)===!1||cn!==k)&&(t.blendColor(Pt.r,Pt.g,Pt.b,cn),N.copy(Pt),k=cn),M=pe,F=!1}function K(pe,Oe){pe.side===Zl?we(t.CULL_FACE):he(t.CULL_FACE);let Ae=pe.side===Fa;Oe&&(Ae=!Ae),Q(Ae),pe.blending===Op&&pe.transparent===!1?ne(zu):ne(pe.blending,pe.blendEquation,pe.blendSrc,pe.blendDst,pe.blendEquationAlpha,pe.blendSrcAlpha,pe.blendDstAlpha,pe.blendColor,pe.blendAlpha,pe.premultipliedAlpha),l.setFunc(pe.depthFunc),l.setTest(pe.depthTest),l.setMask(pe.depthWrite),o.setMask(pe.colorWrite);const be=pe.stencilWrite;c.setTest(be),be&&(c.setMask(pe.stencilWriteMask),c.setFunc(pe.stencilFunc,pe.stencilRef,pe.stencilFuncMask),c.setOp(pe.stencilFail,pe.stencilZFail,pe.stencilZPass)),Ee(pe.polygonOffset,pe.polygonOffsetFactor,pe.polygonOffsetUnits),pe.alphaToCoverage===!0?he(t.SAMPLE_ALPHA_TO_COVERAGE):we(t.SAMPLE_ALPHA_TO_COVERAGE)}function Q(pe){I!==pe&&(pe?t.frontFace(t.CW):t.frontFace(t.CCW),I=pe)}function oe(pe){pe!==Sge?(he(t.CULL_FACE),pe!==W&&(pe===yz?t.cullFace(t.BACK):pe===wge?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):we(t.CULL_FACE),W=pe}function Ne(pe){pe!==D&&(Z&&t.lineWidth(pe),D=pe)}function Ee(pe,Oe,Ae){pe?(he(t.POLYGON_OFFSET_FILL),(B!==Oe||G!==Ae)&&(t.polygonOffset(Oe,Ae),B=Oe,G=Ae)):we(t.POLYGON_OFFSET_FILL)}function re(pe){pe?he(t.SCISSOR_TEST):we(t.SCISSOR_TEST)}function U(pe){pe===void 0&&(pe=t.TEXTURE0+V-1),H!==pe&&(t.activeTexture(pe),H=pe)}function L(pe,Oe,Ae){Ae===void 0&&(H===null?Ae=t.TEXTURE0+V-1:Ae=H);let be=q[Ae];be===void 0&&(be={type:void 0,texture:void 0},q[Ae]=be),(be.type!==pe||be.texture!==Oe)&&(H!==Ae&&(t.activeTexture(Ae),H=Ae),t.bindTexture(pe,Oe||Pe[pe]),be.type=pe,be.texture=Oe)}function J(){const pe=q[H];pe!==void 0&&pe.type!==void 0&&(t.bindTexture(pe.type,null),pe.type=void 0,pe.texture=void 0)}function ge(){try{t.compressedTexImage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function ye(){try{t.compressedTexImage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function me(){try{t.texSubImage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function et(){try{t.texSubImage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function Ie(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function Ke(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function st(){try{t.texStorage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function je(){try{t.texStorage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function le(){try{t.texImage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function Ze(){try{t.texImage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function Fe(pe){xe.equals(pe)===!1&&(t.scissor(pe.x,pe.y,pe.z,pe.w),xe.copy(pe))}function Xe(pe){ie.equals(pe)===!1&&(t.viewport(pe.x,pe.y,pe.z,pe.w),ie.copy(pe))}function ct(pe,Oe){let Ae=h.get(Oe);Ae===void 0&&(Ae=new WeakMap,h.set(Oe,Ae));let be=Ae.get(pe);be===void 0&&(be=t.getUniformBlockIndex(Oe,pe.name),Ae.set(pe,be))}function ue(pe,Oe){const be=h.get(Oe).get(pe);u.get(Oe)!==be&&(t.uniformBlockBinding(Oe,be,pe.__bindingPointIndex),u.set(Oe,be))}function Qe(){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={},H=null,q={},m={},b=new WeakMap,y=[],v=null,x=!1,M=null,w=null,C=null,T=null,R=null,A=null,j=null,N=new zt(0,0,0),k=0,F=!1,I=null,W=null,D=null,B=null,G=null,xe.set(0,0,t.canvas.width,t.canvas.height),ie.set(0,0,t.canvas.width,t.canvas.height),o.reset(),l.reset(),c.reset()}return{buffers:{color:o,depth:l,stencil:c},enable:he,disable:we,bindFramebuffer:Le,drawBuffers:de,useProgram:lt,setBlending:ne,setMaterial:K,setFlipSided:Q,setCullFace:oe,setLineWidth:Ne,setPolygonOffset:Ee,setScissorTest:re,activeTexture:U,bindTexture:L,unbindTexture:J,compressedTexImage2D:ge,compressedTexImage3D:ye,texImage2D:le,texImage3D:Ze,updateUBOMapping:ct,uniformBlockBinding:ue,texStorage2D:st,texStorage3D:je,texSubImage2D:me,texSubImage3D:et,compressedTexSubImage2D:Ie,compressedTexSubImage3D:Ke,scissor:Fe,viewport:Xe,reset:Qe}}function P_e(t,e,n,r,i,a,s){const o=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,u=i.maxTextureSize,h=i.maxSamples,g=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,m=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),b=new WeakMap;let y;const v=new WeakMap;let x=!1;try{x=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function M(U,L){return x?new OffscreenCanvas(U,L):s1("canvas")}function w(U,L,J,ge){let ye=1;if((U.width>ge||U.height>ge)&&(ye=ge/Math.max(U.width,U.height)),ye<1||L===!0)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap){const me=L?a1:Math.floor,et=me(ye*U.width),Ie=me(ye*U.height);y===void 0&&(y=M(et,Ie));const Ke=J?M(et,Ie):y;return Ke.width=et,Ke.height=Ie,Ke.getContext("2d").drawImage(U,0,0,et,Ie),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+U.width+"x"+U.height+") to ("+et+"x"+Ie+")."),Ke}else return"data"in U&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+U.width+"x"+U.height+")."),U;return U}function C(U){return j3(U.width)&&j3(U.height)}function T(U){return o?!1:U.wrapS!==fo||U.wrapT!==fo||U.minFilter!==Hi&&U.minFilter!==Us}function R(U,L){return U.generateMipmaps&&L&&U.minFilter!==Hi&&U.minFilter!==Us}function A(U){t.generateMipmap(U)}function j(U,L,J,ge,ye=!1){if(o===!1)return L;if(U!==null){if(t[U]!==void 0)return t[U];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let me=L;if(L===t.RED&&(J===t.FLOAT&&(me=t.R32F),J===t.HALF_FLOAT&&(me=t.R16F),J===t.UNSIGNED_BYTE&&(me=t.R8)),L===t.RED_INTEGER&&(J===t.UNSIGNED_BYTE&&(me=t.R8UI),J===t.UNSIGNED_SHORT&&(me=t.R16UI),J===t.UNSIGNED_INT&&(me=t.R32UI),J===t.BYTE&&(me=t.R8I),J===t.SHORT&&(me=t.R16I),J===t.INT&&(me=t.R32I)),L===t.RG&&(J===t.FLOAT&&(me=t.RG32F),J===t.HALF_FLOAT&&(me=t.RG16F),J===t.UNSIGNED_BYTE&&(me=t.RG8)),L===t.RGBA){const et=ye?n1:$n.getTransfer(ge);J===t.FLOAT&&(me=t.RGBA32F),J===t.HALF_FLOAT&&(me=t.RGBA16F),J===t.UNSIGNED_BYTE&&(me=et===rr?t.SRGB8_ALPHA8:t.RGBA8),J===t.UNSIGNED_SHORT_4_4_4_4&&(me=t.RGBA4),J===t.UNSIGNED_SHORT_5_5_5_1&&(me=t.RGB5_A1)}return(me===t.R16F||me===t.R32F||me===t.RG16F||me===t.RG32F||me===t.RGBA16F||me===t.RGBA32F)&&e.get("EXT_color_buffer_float"),me}function N(U,L,J){return R(U,J)===!0||U.isFramebufferTexture&&U.minFilter!==Hi&&U.minFilter!==Us?Math.log2(Math.max(L.width,L.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?L.mipmaps.length:1}function k(U){return U===Hi||U===Az||U===_T?t.NEAREST:t.LINEAR}function F(U){const L=U.target;L.removeEventListener("dispose",F),W(L),L.isVideoTexture&&b.delete(L)}function I(U){const L=U.target;L.removeEventListener("dispose",I),B(L)}function W(U){const L=r.get(U);if(L.__webglInit===void 0)return;const J=U.source,ge=v.get(J);if(ge){const ye=ge[L.__cacheKey];ye.usedTimes--,ye.usedTimes===0&&D(U),Object.keys(ge).length===0&&v.delete(J)}r.remove(U)}function D(U){const L=r.get(U);t.deleteTexture(L.__webglTexture);const J=U.source,ge=v.get(J);delete ge[L.__cacheKey],s.memory.textures--}function B(U){const L=U.texture,J=r.get(U),ge=r.get(L);if(ge.__webglTexture!==void 0&&(t.deleteTexture(ge.__webglTexture),s.memory.textures--),U.depthTexture&&U.depthTexture.dispose(),U.isWebGLCubeRenderTarget)for(let ye=0;ye<6;ye++){if(Array.isArray(J.__webglFramebuffer[ye]))for(let me=0;me<J.__webglFramebuffer[ye].length;me++)t.deleteFramebuffer(J.__webglFramebuffer[ye][me]);else t.deleteFramebuffer(J.__webglFramebuffer[ye]);J.__webglDepthbuffer&&t.deleteRenderbuffer(J.__webglDepthbuffer[ye])}else{if(Array.isArray(J.__webglFramebuffer))for(let ye=0;ye<J.__webglFramebuffer.length;ye++)t.deleteFramebuffer(J.__webglFramebuffer[ye]);else t.deleteFramebuffer(J.__webglFramebuffer);if(J.__webglDepthbuffer&&t.deleteRenderbuffer(J.__webglDepthbuffer),J.__webglMultisampledFramebuffer&&t.deleteFramebuffer(J.__webglMultisampledFramebuffer),J.__webglColorRenderbuffer)for(let ye=0;ye<J.__webglColorRenderbuffer.length;ye++)J.__webglColorRenderbuffer[ye]&&t.deleteRenderbuffer(J.__webglColorRenderbuffer[ye]);J.__webglDepthRenderbuffer&&t.deleteRenderbuffer(J.__webglDepthRenderbuffer)}if(U.isWebGLMultipleRenderTargets)for(let ye=0,me=L.length;ye<me;ye++){const et=r.get(L[ye]);et.__webglTexture&&(t.deleteTexture(et.__webglTexture),s.memory.textures--),r.remove(L[ye])}r.remove(L),r.remove(U)}let G=0;function V(){G=0}function Z(){const U=G;return U>=l&&console.warn("THREE.WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+l),G+=1,U}function Y(U){const L=[];return L.push(U.wrapS),L.push(U.wrapT),L.push(U.wrapR||0),L.push(U.magFilter),L.push(U.minFilter),L.push(U.anisotropy),L.push(U.internalFormat),L.push(U.format),L.push(U.type),L.push(U.generateMipmaps),L.push(U.premultiplyAlpha),L.push(U.flipY),L.push(U.unpackAlignment),L.push(U.colorSpace),L.join()}function ee(U,L){const J=r.get(U);if(U.isVideoTexture&&Ee(U),U.isRenderTargetTexture===!1&&U.version>0&&J.__version!==U.version){const ge=U.image;if(ge===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ge.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{he(J,U,L);return}}n.bindTexture(t.TEXTURE_2D,J.__webglTexture,t.TEXTURE0+L)}function H(U,L){const J=r.get(U);if(U.version>0&&J.__version!==U.version){he(J,U,L);return}n.bindTexture(t.TEXTURE_2D_ARRAY,J.__webglTexture,t.TEXTURE0+L)}function q(U,L){const J=r.get(U);if(U.version>0&&J.__version!==U.version){he(J,U,L);return}n.bindTexture(t.TEXTURE_3D,J.__webglTexture,t.TEXTURE0+L)}function ae(U,L){const J=r.get(U);if(U.version>0&&J.__version!==U.version){we(J,U,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,J.__webglTexture,t.TEXTURE0+L)}const ce={[D3]:t.REPEAT,[fo]:t.CLAMP_TO_EDGE,[O3]:t.MIRRORED_REPEAT},xe={[Hi]:t.NEAREST,[Az]:t.NEAREST_MIPMAP_NEAREST,[_T]:t.NEAREST_MIPMAP_LINEAR,[Us]:t.LINEAR,[txe]:t.LINEAR_MIPMAP_NEAREST,[n0]:t.LINEAR_MIPMAP_LINEAR},ie={[hxe]:t.NEVER,[bxe]:t.ALWAYS,[pxe]:t.LESS,[_7]:t.LEQUAL,[mxe]:t.EQUAL,[vxe]:t.GEQUAL,[gxe]:t.GREATER,[xxe]:t.NOTEQUAL};function ve(U,L,J){if(J?(t.texParameteri(U,t.TEXTURE_WRAP_S,ce[L.wrapS]),t.texParameteri(U,t.TEXTURE_WRAP_T,ce[L.wrapT]),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,ce[L.wrapR]),t.texParameteri(U,t.TEXTURE_MAG_FILTER,xe[L.magFilter]),t.texParameteri(U,t.TEXTURE_MIN_FILTER,xe[L.minFilter])):(t.texParameteri(U,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(U,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(L.wrapS!==fo||L.wrapT!==fo)&&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,k(L.magFilter)),t.texParameteri(U,t.TEXTURE_MIN_FILTER,k(L.minFilter)),L.minFilter!==Hi&&L.minFilter!==Us&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),L.compareFunction&&(t.texParameteri(U,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(U,t.TEXTURE_COMPARE_FUNC,ie[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ge=e.get("EXT_texture_filter_anisotropic");if(L.magFilter===Hi||L.minFilter!==_T&&L.minFilter!==n0||L.type===rc&&e.has("OES_texture_float_linear")===!1||o===!1&&L.type===r0&&e.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||r.get(L).__currentAnisotropy)&&(t.texParameterf(U,ge.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy)}}function Pe(U,L){let J=!1;U.__webglInit===void 0&&(U.__webglInit=!0,L.addEventListener("dispose",F));const ge=L.source;let ye=v.get(ge);ye===void 0&&(ye={},v.set(ge,ye));const me=Y(L);if(me!==U.__cacheKey){ye[me]===void 0&&(ye[me]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,J=!0),ye[me].usedTimes++;const et=ye[U.__cacheKey];et!==void 0&&(ye[U.__cacheKey].usedTimes--,et.usedTimes===0&&D(L)),U.__cacheKey=me,U.__webglTexture=ye[me].texture}return J}function he(U,L,J){let ge=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ge=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ge=t.TEXTURE_3D);const ye=Pe(U,L),me=L.source;n.bindTexture(ge,U.__webglTexture,t.TEXTURE0+J);const et=r.get(me);if(me.version!==et.__version||ye===!0){n.activeTexture(t.TEXTURE0+J);const Ie=$n.getPrimaries($n.workingColorSpace),Ke=L.colorSpace===zs?null:$n.getPrimaries(L.colorSpace),st=L.colorSpace===zs||Ie===Ke?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,st);const je=T(L)&&C(L.image)===!1;let le=w(L.image,je,!1,u);le=re(L,le);const Ze=C(le)||o,Fe=a.convert(L.format,L.colorSpace);let Xe=a.convert(L.type),ct=j(L.internalFormat,Fe,Xe,L.colorSpace,L.isVideoTexture);ve(ge,L,Ze);let ue;const Qe=L.mipmaps,pe=o&&L.isVideoTexture!==!0&&ct!==v7,Oe=et.__version===void 0||ye===!0,Ae=N(L,le,Ze);if(L.isDepthTexture)ct=t.DEPTH_COMPONENT,o?L.type===rc?ct=t.DEPTH_COMPONENT32F:L.type===Du?ct=t.DEPTH_COMPONENT24:L.type===lf?ct=t.DEPTH24_STENCIL8:ct=t.DEPTH_COMPONENT16:L.type===rc&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===cf&&ct===t.DEPTH_COMPONENT&&L.type!==mk&&L.type!==Du&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=Du,Xe=a.convert(L.type)),L.format===tm&&ct===t.DEPTH_COMPONENT&&(ct=t.DEPTH_STENCIL,L.type!==lf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=lf,Xe=a.convert(L.type))),Oe&&(pe?n.texStorage2D(t.TEXTURE_2D,1,ct,le.width,le.height):n.texImage2D(t.TEXTURE_2D,0,ct,le.width,le.height,0,Fe,Xe,null));else if(L.isDataTexture)if(Qe.length>0&&Ze){pe&&Oe&&n.texStorage2D(t.TEXTURE_2D,Ae,ct,Qe[0].width,Qe[0].height);for(let be=0,$e=Qe.length;be<$e;be++)ue=Qe[be],pe?n.texSubImage2D(t.TEXTURE_2D,be,0,0,ue.width,ue.height,Fe,Xe,ue.data):n.texImage2D(t.TEXTURE_2D,be,ct,ue.width,ue.height,0,Fe,Xe,ue.data);L.generateMipmaps=!1}else pe?(Oe&&n.texStorage2D(t.TEXTURE_2D,Ae,ct,le.width,le.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,le.width,le.height,Fe,Xe,le.data)):n.texImage2D(t.TEXTURE_2D,0,ct,le.width,le.height,0,Fe,Xe,le.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){pe&&Oe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ae,ct,Qe[0].width,Qe[0].height,le.depth);for(let be=0,$e=Qe.length;be<$e;be++)ue=Qe[be],L.format!==Fs?Fe!==null?pe?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,be,0,0,0,ue.width,ue.height,le.depth,Fe,ue.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,be,ct,ue.width,ue.height,le.depth,0,ue.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):pe?n.texSubImage3D(t.TEXTURE_2D_ARRAY,be,0,0,0,ue.width,ue.height,le.depth,Fe,Xe,ue.data):n.texImage3D(t.TEXTURE_2D_ARRAY,be,ct,ue.width,ue.height,le.depth,0,Fe,Xe,ue.data)}else{pe&&Oe&&n.texStorage2D(t.TEXTURE_2D,Ae,ct,Qe[0].width,Qe[0].height);for(let be=0,$e=Qe.length;be<$e;be++)ue=Qe[be],L.format!==Fs?Fe!==null?pe?n.compressedTexSubImage2D(t.TEXTURE_2D,be,0,0,ue.width,ue.height,Fe,ue.data):n.compressedTexImage2D(t.TEXTURE_2D,be,ct,ue.width,ue.height,0,ue.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):pe?n.texSubImage2D(t.TEXTURE_2D,be,0,0,ue.width,ue.height,Fe,Xe,ue.data):n.texImage2D(t.TEXTURE_2D,be,ct,ue.width,ue.height,0,Fe,Xe,ue.data)}else if(L.isDataArrayTexture)pe?(Oe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ae,ct,le.width,le.height,le.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,le.width,le.height,le.depth,Fe,Xe,le.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,ct,le.width,le.height,le.depth,0,Fe,Xe,le.data);else if(L.isData3DTexture)pe?(Oe&&n.texStorage3D(t.TEXTURE_3D,Ae,ct,le.width,le.height,le.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,le.width,le.height,le.depth,Fe,Xe,le.data)):n.texImage3D(t.TEXTURE_3D,0,ct,le.width,le.height,le.depth,0,Fe,Xe,le.data);else if(L.isFramebufferTexture){if(Oe)if(pe)n.texStorage2D(t.TEXTURE_2D,Ae,ct,le.width,le.height);else{let be=le.width,$e=le.height;for(let ft=0;ft<Ae;ft++)n.texImage2D(t.TEXTURE_2D,ft,ct,be,$e,0,Fe,Xe,null),be>>=1,$e>>=1}}else if(Qe.length>0&&Ze){pe&&Oe&&n.texStorage2D(t.TEXTURE_2D,Ae,ct,Qe[0].width,Qe[0].height);for(let be=0,$e=Qe.length;be<$e;be++)ue=Qe[be],pe?n.texSubImage2D(t.TEXTURE_2D,be,0,0,Fe,Xe,ue):n.texImage2D(t.TEXTURE_2D,be,ct,Fe,Xe,ue);L.generateMipmaps=!1}else pe?(Oe&&n.texStorage2D(t.TEXTURE_2D,Ae,ct,le.width,le.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,Fe,Xe,le)):n.texImage2D(t.TEXTURE_2D,0,ct,Fe,Xe,le);R(L,Ze)&&A(ge),et.__version=me.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function we(U,L,J){if(L.image.length!==6)return;const ge=Pe(U,L),ye=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,U.__webglTexture,t.TEXTURE0+J);const me=r.get(ye);if(ye.version!==me.__version||ge===!0){n.activeTexture(t.TEXTURE0+J);const et=$n.getPrimaries($n.workingColorSpace),Ie=L.colorSpace===zs?null:$n.getPrimaries(L.colorSpace),Ke=L.colorSpace===zs||et===Ie?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ke);const st=L.isCompressedTexture||L.image[0].isCompressedTexture,je=L.image[0]&&L.image[0].isDataTexture,le=[];for(let be=0;be<6;be++)!st&&!je?le[be]=w(L.image[be],!1,!0,c):le[be]=je?L.image[be].image:L.image[be],le[be]=re(L,le[be]);const Ze=le[0],Fe=C(Ze)||o,Xe=a.convert(L.format,L.colorSpace),ct=a.convert(L.type),ue=j(L.internalFormat,Xe,ct,L.colorSpace),Qe=o&&L.isVideoTexture!==!0,pe=me.__version===void 0||ge===!0;let Oe=N(L,Ze,Fe);ve(t.TEXTURE_CUBE_MAP,L,Fe);let Ae;if(st){Qe&&pe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Oe,ue,Ze.width,Ze.height);for(let be=0;be<6;be++){Ae=le[be].mipmaps;for(let $e=0;$e<Ae.length;$e++){const ft=Ae[$e];L.format!==Fs?Xe!==null?Qe?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,$e,0,0,ft.width,ft.height,Xe,ft.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,$e,ue,ft.width,ft.height,0,ft.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Qe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,$e,0,0,ft.width,ft.height,Xe,ct,ft.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,$e,ue,ft.width,ft.height,0,Xe,ct,ft.data)}}}else{Ae=L.mipmaps,Qe&&pe&&(Ae.length>0&&Oe++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Oe,ue,le[0].width,le[0].height));for(let be=0;be<6;be++)if(je){Qe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,0,0,le[be].width,le[be].height,Xe,ct,le[be].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,ue,le[be].width,le[be].height,0,Xe,ct,le[be].data);for(let $e=0;$e<Ae.length;$e++){const yt=Ae[$e].image[be].image;Qe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,$e+1,0,0,yt.width,yt.height,Xe,ct,yt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,$e+1,ue,yt.width,yt.height,0,Xe,ct,yt.data)}}else{Qe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,0,0,Xe,ct,le[be]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,ue,Xe,ct,le[be]);for(let $e=0;$e<Ae.length;$e++){const ft=Ae[$e];Qe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,$e+1,0,0,Xe,ct,ft.image[be]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,$e+1,ue,Xe,ct,ft.image[be])}}}R(L,Fe)&&A(t.TEXTURE_CUBE_MAP),me.__version=ye.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function Le(U,L,J,ge,ye,me){const et=a.convert(J.format,J.colorSpace),Ie=a.convert(J.type),Ke=j(J.internalFormat,et,Ie,J.colorSpace);if(!r.get(L).__hasExternalTextures){const je=Math.max(1,L.width>>me),le=Math.max(1,L.height>>me);ye===t.TEXTURE_3D||ye===t.TEXTURE_2D_ARRAY?n.texImage3D(ye,me,Ke,je,le,L.depth,0,et,Ie,null):n.texImage2D(ye,me,Ke,je,le,0,et,Ie,null)}n.bindFramebuffer(t.FRAMEBUFFER,U),Ne(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ge,ye,r.get(J).__webglTexture,0,oe(L)):(ye===t.TEXTURE_2D||ye>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&ye<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ge,ye,r.get(J).__webglTexture,me),n.bindFramebuffer(t.FRAMEBUFFER,null)}function de(U,L,J){if(t.bindRenderbuffer(t.RENDERBUFFER,U),L.depthBuffer&&!L.stencilBuffer){let ge=o===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(J||Ne(L)){const ye=L.depthTexture;ye&&ye.isDepthTexture&&(ye.type===rc?ge=t.DEPTH_COMPONENT32F:ye.type===Du&&(ge=t.DEPTH_COMPONENT24));const me=oe(L);Ne(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,me,ge,L.width,L.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,me,ge,L.width,L.height)}else t.renderbufferStorage(t.RENDERBUFFER,ge,L.width,L.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,U)}else if(L.depthBuffer&&L.stencilBuffer){const ge=oe(L);J&&Ne(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ge,t.DEPTH24_STENCIL8,L.width,L.height):Ne(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ge,t.DEPTH24_STENCIL8,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,U)}else{const ge=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let ye=0;ye<ge.length;ye++){const me=ge[ye],et=a.convert(me.format,me.colorSpace),Ie=a.convert(me.type),Ke=j(me.internalFormat,et,Ie,me.colorSpace),st=oe(L);J&&Ne(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,st,Ke,L.width,L.height):Ne(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,st,Ke,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,Ke,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function lt(U,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,U),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(L.depthTexture).__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),ee(L.depthTexture,0);const ge=r.get(L.depthTexture).__webglTexture,ye=oe(L);if(L.depthTexture.format===cf)Ne(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ge,0,ye):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ge,0);else if(L.depthTexture.format===tm)Ne(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ge,0,ye):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ge,0);else throw new Error("Unknown depthTexture format")}function $(U){const L=r.get(U),J=U.isWebGLCubeRenderTarget===!0;if(U.depthTexture&&!L.__autoAllocateDepthBuffer){if(J)throw new Error("target.depthTexture not supported in Cube render targets");lt(L.__webglFramebuffer,U)}else if(J){L.__webglDepthbuffer=[];for(let ge=0;ge<6;ge++)n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ge]),L.__webglDepthbuffer[ge]=t.createRenderbuffer(),de(L.__webglDepthbuffer[ge],U,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer=t.createRenderbuffer(),de(L.__webglDepthbuffer,U,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function z(U,L,J){const ge=r.get(U);L!==void 0&&Le(ge.__webglFramebuffer,U,U.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),J!==void 0&&$(U)}function ne(U){const L=U.texture,J=r.get(U),ge=r.get(L);U.addEventListener("dispose",I),U.isWebGLMultipleRenderTargets!==!0&&(ge.__webglTexture===void 0&&(ge.__webglTexture=t.createTexture()),ge.__version=L.version,s.memory.textures++);const ye=U.isWebGLCubeRenderTarget===!0,me=U.isWebGLMultipleRenderTargets===!0,et=C(U)||o;if(ye){J.__webglFramebuffer=[];for(let Ie=0;Ie<6;Ie++)if(o&&L.mipmaps&&L.mipmaps.length>0){J.__webglFramebuffer[Ie]=[];for(let Ke=0;Ke<L.mipmaps.length;Ke++)J.__webglFramebuffer[Ie][Ke]=t.createFramebuffer()}else J.__webglFramebuffer[Ie]=t.createFramebuffer()}else{if(o&&L.mipmaps&&L.mipmaps.length>0){J.__webglFramebuffer=[];for(let Ie=0;Ie<L.mipmaps.length;Ie++)J.__webglFramebuffer[Ie]=t.createFramebuffer()}else J.__webglFramebuffer=t.createFramebuffer();if(me)if(i.drawBuffers){const Ie=U.texture;for(let Ke=0,st=Ie.length;Ke<st;Ke++){const je=r.get(Ie[Ke]);je.__webglTexture===void 0&&(je.__webglTexture=t.createTexture(),s.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&U.samples>0&&Ne(U)===!1){const Ie=me?L:[L];J.__webglMultisampledFramebuffer=t.createFramebuffer(),J.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,J.__webglMultisampledFramebuffer);for(let Ke=0;Ke<Ie.length;Ke++){const st=Ie[Ke];J.__webglColorRenderbuffer[Ke]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,J.__webglColorRenderbuffer[Ke]);const je=a.convert(st.format,st.colorSpace),le=a.convert(st.type),Ze=j(st.internalFormat,je,le,st.colorSpace,U.isXRRenderTarget===!0),Fe=oe(U);t.renderbufferStorageMultisample(t.RENDERBUFFER,Fe,Ze,U.width,U.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ke,t.RENDERBUFFER,J.__webglColorRenderbuffer[Ke])}t.bindRenderbuffer(t.RENDERBUFFER,null),U.depthBuffer&&(J.__webglDepthRenderbuffer=t.createRenderbuffer(),de(J.__webglDepthRenderbuffer,U,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ye){n.bindTexture(t.TEXTURE_CUBE_MAP,ge.__webglTexture),ve(t.TEXTURE_CUBE_MAP,L,et);for(let Ie=0;Ie<6;Ie++)if(o&&L.mipmaps&&L.mipmaps.length>0)for(let Ke=0;Ke<L.mipmaps.length;Ke++)Le(J.__webglFramebuffer[Ie][Ke],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,Ke);else Le(J.__webglFramebuffer[Ie],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,0);R(L,et)&&A(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(me){const Ie=U.texture;for(let Ke=0,st=Ie.length;Ke<st;Ke++){const je=Ie[Ke],le=r.get(je);n.bindTexture(t.TEXTURE_2D,le.__webglTexture),ve(t.TEXTURE_2D,je,et),Le(J.__webglFramebuffer,U,je,t.COLOR_ATTACHMENT0+Ke,t.TEXTURE_2D,0),R(je,et)&&A(t.TEXTURE_2D)}n.unbindTexture()}else{let Ie=t.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(o?Ie=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Ie,ge.__webglTexture),ve(Ie,L,et),o&&L.mipmaps&&L.mipmaps.length>0)for(let Ke=0;Ke<L.mipmaps.length;Ke++)Le(J.__webglFramebuffer[Ke],U,L,t.COLOR_ATTACHMENT0,Ie,Ke);else Le(J.__webglFramebuffer,U,L,t.COLOR_ATTACHMENT0,Ie,0);R(L,et)&&A(Ie),n.unbindTexture()}U.depthBuffer&&$(U)}function K(U){const L=C(U)||o,J=U.isWebGLMultipleRenderTargets===!0?U.texture:[U.texture];for(let ge=0,ye=J.length;ge<ye;ge++){const me=J[ge];if(R(me,L)){const et=U.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Ie=r.get(me).__webglTexture;n.bindTexture(et,Ie),A(et),n.unbindTexture()}}}function Q(U){if(o&&U.samples>0&&Ne(U)===!1){const L=U.isWebGLMultipleRenderTargets?U.texture:[U.texture],J=U.width,ge=U.height;let ye=t.COLOR_BUFFER_BIT;const me=[],et=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ie=r.get(U),Ke=U.isWebGLMultipleRenderTargets===!0;if(Ke)for(let st=0;st<L.length;st++)n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ie.__webglFramebuffer);for(let st=0;st<L.length;st++){me.push(t.COLOR_ATTACHMENT0+st),U.depthBuffer&&me.push(et);const je=Ie.__ignoreDepthValues!==void 0?Ie.__ignoreDepthValues:!1;if(je===!1&&(U.depthBuffer&&(ye|=t.DEPTH_BUFFER_BIT),U.stencilBuffer&&(ye|=t.STENCIL_BUFFER_BIT)),Ke&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ie.__webglColorRenderbuffer[st]),je===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[et]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[et])),Ke){const le=r.get(L[st]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,le,0)}t.blitFramebuffer(0,0,J,ge,0,0,J,ge,ye,t.NEAREST),m&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,me)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ke)for(let st=0;st<L.length;st++){n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,Ie.__webglColorRenderbuffer[st]);const je=r.get(L[st]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ie.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,je,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ie.__webglMultisampledFramebuffer)}}function oe(U){return Math.min(h,U.samples)}function Ne(U){const L=r.get(U);return o&&U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ee(U){const L=s.render.frame;b.get(U)!==L&&(b.set(U,L),U.update())}function re(U,L){const J=U.colorSpace,ge=U.format,ye=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||U.format===I3||J!==bc&&J!==zs&&($n.getTransfer(J)===rr?o===!1?e.has("EXT_sRGB")===!0&&ge===Fs?(U.format=I3,U.minFilter=Us,U.generateMipmaps=!1):L=M7.sRGBToLinear(L):(ge!==Fs||ye!==Hu)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",J)),L}this.allocateTextureUnit=Z,this.resetTextureUnits=V,this.setTexture2D=ee,this.setTexture2DArray=H,this.setTexture3D=q,this.setTextureCube=ae,this.rebindTextures=z,this.setupRenderTarget=ne,this.updateRenderTargetMipmap=K,this.updateMultisampleRenderTarget=Q,this.setupDepthRenderbuffer=$,this.setupFrameBufferTexture=Le,this.useMultisampledRTT=Ne}function k_e(t,e,n){const r=n.isWebGL2;function i(a,s=zs){let o;const l=$n.getTransfer(s);if(a===Hu)return t.UNSIGNED_BYTE;if(a===h7)return t.UNSIGNED_SHORT_4_4_4_4;if(a===p7)return t.UNSIGNED_SHORT_5_5_5_1;if(a===nxe)return t.BYTE;if(a===rxe)return t.SHORT;if(a===mk)return t.UNSIGNED_SHORT;if(a===f7)return t.INT;if(a===Du)return t.UNSIGNED_INT;if(a===rc)return t.FLOAT;if(a===r0)return r?t.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(a===ixe)return t.ALPHA;if(a===Fs)return t.RGBA;if(a===axe)return t.LUMINANCE;if(a===sxe)return t.LUMINANCE_ALPHA;if(a===cf)return t.DEPTH_COMPONENT;if(a===tm)return t.DEPTH_STENCIL;if(a===I3)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(a===oxe)return t.RED;if(a===m7)return t.RED_INTEGER;if(a===lxe)return t.RG;if(a===g7)return t.RG_INTEGER;if(a===x7)return t.RGBA_INTEGER;if(a===ST||a===wT||a===MT||a===ET)if(l===rr)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(a===ST)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===wT)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===MT)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===ET)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(a===ST)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===wT)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===MT)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===ET)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===Tz||a===Cz||a===Nz||a===Rz)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(a===Tz)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===Cz)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===Nz)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===Rz)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===v7)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===Pz||a===kz)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(a===Pz)return l===rr?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(a===kz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===Dz||a===Oz||a===Lz||a===Iz||a===jz||a===Uz||a===Fz||a===zz||a===Bz||a===Hz||a===$z||a===Vz||a===Gz||a===Wz)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(a===Dz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===Oz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===Lz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===Iz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===jz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===Uz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===Fz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===zz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===Bz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===Hz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===$z)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===Vz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===Gz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===Wz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===AT||a===qz||a===Xz)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(a===AT)return l===rr?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===qz)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===Xz)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===cxe||a===Kz||a===Yz||a===Zz)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(a===AT)return o.COMPRESSED_RED_RGTC1_EXT;if(a===Kz)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===Yz)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===Zz)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===lf?r?t.UNSIGNED_INT_24_8:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):t[a]!==void 0?t[a]:null}return{convert:i}}class D_e extends ss{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class dx extends va{constructor(){super(),this.isGroup=!0,this.type="Group"}}const O_e={type:"move"};class KT{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new dx,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 dx,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ce,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ce),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new dx,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ce,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ce),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,s=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(const y of e.hand.values()){const v=n.getJointPose(y,r),x=this._getHandJoint(c,y);v!==null&&(x.matrix.fromArray(v.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.matrixWorldNeedsUpdate=!0,x.jointRadius=v.radius),x.visible=v!==null}const u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],g=u.position.distanceTo(h.position),m=.02,b=.005;c.inputState.pinching&&g>m+b?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&g<=m-b&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(l.matrix.fromArray(a.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,a.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(a.linearVelocity)):l.hasLinearVelocity=!1,a.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(a.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(O_e)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=a!==null),c!==null&&(c.visible=s!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new dx;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class L_e extends Xf{constructor(e,n){super();const r=this;let i=null,a=1,s=null,o="local-floor",l=1,c=null,u=null,h=null,g=null,m=null,b=null;const y=n.getContextAttributes();let v=null,x=null;const M=[],w=[],C=new Kt;let T=null;const R=new ss;R.layers.enable(1),R.viewport=new Gn;const A=new ss;A.layers.enable(2),A.viewport=new Gn;const j=[R,A],N=new D_e;N.layers.enable(1),N.layers.enable(2);let k=null,F=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ae){let ce=M[ae];return ce===void 0&&(ce=new KT,M[ae]=ce),ce.getTargetRaySpace()},this.getControllerGrip=function(ae){let ce=M[ae];return ce===void 0&&(ce=new KT,M[ae]=ce),ce.getGripSpace()},this.getHand=function(ae){let ce=M[ae];return ce===void 0&&(ce=new KT,M[ae]=ce),ce.getHandSpace()};function I(ae){const ce=w.indexOf(ae.inputSource);if(ce===-1)return;const xe=M[ce];xe!==void 0&&(xe.update(ae.inputSource,ae.frame,c||s),xe.dispatchEvent({type:ae.type,data:ae.inputSource}))}function W(){i.removeEventListener("select",I),i.removeEventListener("selectstart",I),i.removeEventListener("selectend",I),i.removeEventListener("squeeze",I),i.removeEventListener("squeezestart",I),i.removeEventListener("squeezeend",I),i.removeEventListener("end",W),i.removeEventListener("inputsourceschange",D);for(let ae=0;ae<M.length;ae++){const ce=w[ae];ce!==null&&(w[ae]=null,M[ae].disconnect(ce))}k=null,F=null,e.setRenderTarget(v),m=null,g=null,h=null,i=null,x=null,q.stop(),r.isPresenting=!1,e.setPixelRatio(T),e.setSize(C.width,C.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ae){a=ae,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ae){o=ae,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(ae){c=ae},this.getBaseLayer=function(){return g!==null?g:m},this.getBinding=function(){return h},this.getFrame=function(){return b},this.getSession=function(){return i},this.setSession=async function(ae){if(i=ae,i!==null){if(v=e.getRenderTarget(),i.addEventListener("select",I),i.addEventListener("selectstart",I),i.addEventListener("selectend",I),i.addEventListener("squeeze",I),i.addEventListener("squeezestart",I),i.addEventListener("squeezeend",I),i.addEventListener("end",W),i.addEventListener("inputsourceschange",D),y.xrCompatible!==!0&&await n.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(C),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ce={antialias:i.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(i,n,ce),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),x=new kf(m.framebufferWidth,m.framebufferHeight,{format:Fs,type:Hu,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let ce=null,xe=null,ie=null;y.depth&&(ie=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ce=y.stencil?tm:cf,xe=y.stencil?lf:Du);const ve={colorFormat:n.RGBA8,depthFormat:ie,scaleFactor:a};h=new XRWebGLBinding(i,n),g=h.createProjectionLayer(ve),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),x=new kf(g.textureWidth,g.textureHeight,{format:Fs,type:Hu,depthTexture:new I7(g.textureWidth,g.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,ce),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});const Pe=e.properties.get(x);Pe.__ignoreDepthValues=g.ignoreDepthValues}x.isXRRenderTarget=!0,this.setFoveation(l),c=null,s=await i.requestReferenceSpace(o),q.setContext(i),q.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function D(ae){for(let ce=0;ce<ae.removed.length;ce++){const xe=ae.removed[ce],ie=w.indexOf(xe);ie>=0&&(w[ie]=null,M[ie].disconnect(xe))}for(let ce=0;ce<ae.added.length;ce++){const xe=ae.added[ce];let ie=w.indexOf(xe);if(ie===-1){for(let Pe=0;Pe<M.length;Pe++)if(Pe>=w.length){w.push(xe),ie=Pe;break}else if(w[Pe]===null){w[Pe]=xe,ie=Pe;break}if(ie===-1)break}const ve=M[ie];ve&&ve.connect(xe)}}const B=new Ce,G=new Ce;function V(ae,ce,xe){B.setFromMatrixPosition(ce.matrixWorld),G.setFromMatrixPosition(xe.matrixWorld);const ie=B.distanceTo(G),ve=ce.projectionMatrix.elements,Pe=xe.projectionMatrix.elements,he=ve[14]/(ve[10]-1),we=ve[14]/(ve[10]+1),Le=(ve[9]+1)/ve[5],de=(ve[9]-1)/ve[5],lt=(ve[8]-1)/ve[0],$=(Pe[8]+1)/Pe[0],z=he*lt,ne=he*$,K=ie/(-lt+$),Q=K*-lt;ce.matrixWorld.decompose(ae.position,ae.quaternion,ae.scale),ae.translateX(Q),ae.translateZ(K),ae.matrixWorld.compose(ae.position,ae.quaternion,ae.scale),ae.matrixWorldInverse.copy(ae.matrixWorld).invert();const oe=he+K,Ne=we+K,Ee=z-Q,re=ne+(ie-Q),U=Le*we/Ne*oe,L=de*we/Ne*oe;ae.projectionMatrix.makePerspective(Ee,re,U,L,oe,Ne),ae.projectionMatrixInverse.copy(ae.projectionMatrix).invert()}function Z(ae,ce){ce===null?ae.matrixWorld.copy(ae.matrix):ae.matrixWorld.multiplyMatrices(ce.matrixWorld,ae.matrix),ae.matrixWorldInverse.copy(ae.matrixWorld).invert()}this.updateCamera=function(ae){if(i===null)return;N.near=A.near=R.near=ae.near,N.far=A.far=R.far=ae.far,(k!==N.near||F!==N.far)&&(i.updateRenderState({depthNear:N.near,depthFar:N.far}),k=N.near,F=N.far);const ce=ae.parent,xe=N.cameras;Z(N,ce);for(let ie=0;ie<xe.length;ie++)Z(xe[ie],ce);xe.length===2?V(N,R,A):N.projectionMatrix.copy(R.projectionMatrix),Y(ae,N,ce)};function Y(ae,ce,xe){xe===null?ae.matrix.copy(ce.matrixWorld):(ae.matrix.copy(xe.matrixWorld),ae.matrix.invert(),ae.matrix.multiply(ce.matrixWorld)),ae.matrix.decompose(ae.position,ae.quaternion,ae.scale),ae.updateMatrixWorld(!0),ae.projectionMatrix.copy(ce.projectionMatrix),ae.projectionMatrixInverse.copy(ce.projectionMatrixInverse),ae.isPerspectiveCamera&&(ae.fov=a0*2*Math.atan(1/ae.projectionMatrix.elements[5]),ae.zoom=1)}this.getCamera=function(){return N},this.getFoveation=function(){if(!(g===null&&m===null))return l},this.setFoveation=function(ae){l=ae,g!==null&&(g.fixedFoveation=ae),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=ae)};let ee=null;function H(ae,ce){if(u=ce.getViewerPose(c||s),b=ce,u!==null){const xe=u.views;m!==null&&(e.setRenderTargetFramebuffer(x,m.framebuffer),e.setRenderTarget(x));let ie=!1;xe.length!==N.cameras.length&&(N.cameras.length=0,ie=!0);for(let ve=0;ve<xe.length;ve++){const Pe=xe[ve];let he=null;if(m!==null)he=m.getViewport(Pe);else{const Le=h.getViewSubImage(g,Pe);he=Le.viewport,ve===0&&(e.setRenderTargetTextures(x,Le.colorTexture,g.ignoreDepthValues?void 0:Le.depthStencilTexture),e.setRenderTarget(x))}let we=j[ve];we===void 0&&(we=new ss,we.layers.enable(ve),we.viewport=new Gn,j[ve]=we),we.matrix.fromArray(Pe.transform.matrix),we.matrix.decompose(we.position,we.quaternion,we.scale),we.projectionMatrix.fromArray(Pe.projectionMatrix),we.projectionMatrixInverse.copy(we.projectionMatrix).invert(),we.viewport.set(he.x,he.y,he.width,he.height),ve===0&&(N.matrix.copy(we.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale)),ie===!0&&N.cameras.push(we)}}for(let xe=0;xe<M.length;xe++){const ie=w[xe],ve=M[xe];ie!==null&&ve!==void 0&&ve.update(ie,ce,c||s)}ee&&ee(ae,ce),ce.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ce}),b=null}const q=new L7;q.setAnimationLoop(H),this.setAnimationLoop=function(ae){ee=ae},this.dispose=function(){}}}function I_e(t,e){function n(v,x){v.matrixAutoUpdate===!0&&v.updateMatrix(),x.value.copy(v.matrix)}function r(v,x){x.color.getRGB(v.fogColor.value,k7(t)),x.isFog?(v.fogNear.value=x.near,v.fogFar.value=x.far):x.isFogExp2&&(v.fogDensity.value=x.density)}function i(v,x,M,w,C){x.isMeshBasicMaterial||x.isMeshLambertMaterial?a(v,x):x.isMeshToonMaterial?(a(v,x),h(v,x)):x.isMeshPhongMaterial?(a(v,x),u(v,x)):x.isMeshStandardMaterial?(a(v,x),g(v,x),x.isMeshPhysicalMaterial&&m(v,x,C)):x.isMeshMatcapMaterial?(a(v,x),b(v,x)):x.isMeshDepthMaterial?a(v,x):x.isMeshDistanceMaterial?(a(v,x),y(v,x)):x.isMeshNormalMaterial?a(v,x):x.isLineBasicMaterial?(s(v,x),x.isLineDashedMaterial&&o(v,x)):x.isPointsMaterial?l(v,x,M,w):x.isSpriteMaterial?c(v,x):x.isShadowMaterial?(v.color.value.copy(x.color),v.opacity.value=x.opacity):x.isShaderMaterial&&(x.uniformsNeedUpdate=!1)}function a(v,x){v.opacity.value=x.opacity,x.color&&v.diffuse.value.copy(x.color),x.emissive&&v.emissive.value.copy(x.emissive).multiplyScalar(x.emissiveIntensity),x.map&&(v.map.value=x.map,n(x.map,v.mapTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.bumpMap&&(v.bumpMap.value=x.bumpMap,n(x.bumpMap,v.bumpMapTransform),v.bumpScale.value=x.bumpScale,x.side===Fa&&(v.bumpScale.value*=-1)),x.normalMap&&(v.normalMap.value=x.normalMap,n(x.normalMap,v.normalMapTransform),v.normalScale.value.copy(x.normalScale),x.side===Fa&&v.normalScale.value.negate()),x.displacementMap&&(v.displacementMap.value=x.displacementMap,n(x.displacementMap,v.displacementMapTransform),v.displacementScale.value=x.displacementScale,v.displacementBias.value=x.displacementBias),x.emissiveMap&&(v.emissiveMap.value=x.emissiveMap,n(x.emissiveMap,v.emissiveMapTransform)),x.specularMap&&(v.specularMap.value=x.specularMap,n(x.specularMap,v.specularMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest);const M=e.get(x).envMap;if(M&&(v.envMap.value=M,v.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=x.reflectivity,v.ior.value=x.ior,v.refractionRatio.value=x.refractionRatio),x.lightMap){v.lightMap.value=x.lightMap;const w=t._useLegacyLights===!0?Math.PI:1;v.lightMapIntensity.value=x.lightMapIntensity*w,n(x.lightMap,v.lightMapTransform)}x.aoMap&&(v.aoMap.value=x.aoMap,v.aoMapIntensity.value=x.aoMapIntensity,n(x.aoMap,v.aoMapTransform))}function s(v,x){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,x.map&&(v.map.value=x.map,n(x.map,v.mapTransform))}function o(v,x){v.dashSize.value=x.dashSize,v.totalSize.value=x.dashSize+x.gapSize,v.scale.value=x.scale}function l(v,x,M,w){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,v.size.value=x.size*M,v.scale.value=w*.5,x.map&&(v.map.value=x.map,n(x.map,v.uvTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest)}function c(v,x){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,v.rotation.value=x.rotation,x.map&&(v.map.value=x.map,n(x.map,v.mapTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest)}function u(v,x){v.specular.value.copy(x.specular),v.shininess.value=Math.max(x.shininess,1e-4)}function h(v,x){x.gradientMap&&(v.gradientMap.value=x.gradientMap)}function g(v,x){v.metalness.value=x.metalness,x.metalnessMap&&(v.metalnessMap.value=x.metalnessMap,n(x.metalnessMap,v.metalnessMapTransform)),v.roughness.value=x.roughness,x.roughnessMap&&(v.roughnessMap.value=x.roughnessMap,n(x.roughnessMap,v.roughnessMapTransform)),e.get(x).envMap&&(v.envMapIntensity.value=x.envMapIntensity)}function m(v,x,M){v.ior.value=x.ior,x.sheen>0&&(v.sheenColor.value.copy(x.sheenColor).multiplyScalar(x.sheen),v.sheenRoughness.value=x.sheenRoughness,x.sheenColorMap&&(v.sheenColorMap.value=x.sheenColorMap,n(x.sheenColorMap,v.sheenColorMapTransform)),x.sheenRoughnessMap&&(v.sheenRoughnessMap.value=x.sheenRoughnessMap,n(x.sheenRoughnessMap,v.sheenRoughnessMapTransform))),x.clearcoat>0&&(v.clearcoat.value=x.clearcoat,v.clearcoatRoughness.value=x.clearcoatRoughness,x.clearcoatMap&&(v.clearcoatMap.value=x.clearcoatMap,n(x.clearcoatMap,v.clearcoatMapTransform)),x.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=x.clearcoatRoughnessMap,n(x.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),x.clearcoatNormalMap&&(v.clearcoatNormalMap.value=x.clearcoatNormalMap,n(x.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(x.clearcoatNormalScale),x.side===Fa&&v.clearcoatNormalScale.value.negate())),x.iridescence>0&&(v.iridescence.value=x.iridescence,v.iridescenceIOR.value=x.iridescenceIOR,v.iridescenceThicknessMinimum.value=x.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=x.iridescenceThicknessRange[1],x.iridescenceMap&&(v.iridescenceMap.value=x.iridescenceMap,n(x.iridescenceMap,v.iridescenceMapTransform)),x.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=x.iridescenceThicknessMap,n(x.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),x.transmission>0&&(v.transmission.value=x.transmission,v.transmissionSamplerMap.value=M.texture,v.transmissionSamplerSize.value.set(M.width,M.height),x.transmissionMap&&(v.transmissionMap.value=x.transmissionMap,n(x.transmissionMap,v.transmissionMapTransform)),v.thickness.value=x.thickness,x.thicknessMap&&(v.thicknessMap.value=x.thicknessMap,n(x.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=x.attenuationDistance,v.attenuationColor.value.copy(x.attenuationColor)),x.anisotropy>0&&(v.anisotropyVector.value.set(x.anisotropy*Math.cos(x.anisotropyRotation),x.anisotropy*Math.sin(x.anisotropyRotation)),x.anisotropyMap&&(v.anisotropyMap.value=x.anisotropyMap,n(x.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=x.specularIntensity,v.specularColor.value.copy(x.specularColor),x.specularColorMap&&(v.specularColorMap.value=x.specularColorMap,n(x.specularColorMap,v.specularColorMapTransform)),x.specularIntensityMap&&(v.specularIntensityMap.value=x.specularIntensityMap,n(x.specularIntensityMap,v.specularIntensityMapTransform))}function b(v,x){x.matcap&&(v.matcap.value=x.matcap)}function y(v,x){const M=e.get(x).light;v.referencePosition.value.setFromMatrixPosition(M.matrixWorld),v.nearDistance.value=M.shadow.camera.near,v.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function j_e(t,e,n,r){let i={},a={},s=[];const o=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(M,w){const C=w.program;r.uniformBlockBinding(M,C)}function c(M,w){let C=i[M.id];C===void 0&&(b(M),C=u(M),i[M.id]=C,M.addEventListener("dispose",v));const T=w.program;r.updateUBOMapping(M,T);const R=e.render.frame;a[M.id]!==R&&(g(M),a[M.id]=R)}function u(M){const w=h();M.__bindingPointIndex=w;const C=t.createBuffer(),T=M.__size,R=M.usage;return t.bindBuffer(t.UNIFORM_BUFFER,C),t.bufferData(t.UNIFORM_BUFFER,T,R),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,C),C}function h(){for(let M=0;M<o;M++)if(s.indexOf(M)===-1)return s.push(M),M;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(M){const w=i[M.id],C=M.uniforms,T=M.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let R=0,A=C.length;R<A;R++){const j=C[R];if(m(j,R,T)===!0){const N=j.__offset,k=Array.isArray(j.value)?j.value:[j.value];let F=0;for(let I=0;I<k.length;I++){const W=k[I],D=y(W);typeof W=="number"?(j.__data[0]=W,t.bufferSubData(t.UNIFORM_BUFFER,N+F,j.__data)):W.isMatrix3?(j.__data[0]=W.elements[0],j.__data[1]=W.elements[1],j.__data[2]=W.elements[2],j.__data[3]=W.elements[0],j.__data[4]=W.elements[3],j.__data[5]=W.elements[4],j.__data[6]=W.elements[5],j.__data[7]=W.elements[0],j.__data[8]=W.elements[6],j.__data[9]=W.elements[7],j.__data[10]=W.elements[8],j.__data[11]=W.elements[0]):(W.toArray(j.__data,F),F+=D.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,N,j.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(M,w,C){const T=M.value;if(C[w]===void 0){if(typeof T=="number")C[w]=T;else{const R=Array.isArray(T)?T:[T],A=[];for(let j=0;j<R.length;j++)A.push(R[j].clone());C[w]=A}return!0}else if(typeof T=="number"){if(C[w]!==T)return C[w]=T,!0}else{const R=Array.isArray(C[w])?C[w]:[C[w]],A=Array.isArray(T)?T:[T];for(let j=0;j<R.length;j++){const N=R[j];if(N.equals(A[j])===!1)return N.copy(A[j]),!0}}return!1}function b(M){const w=M.uniforms;let C=0;const T=16;let R=0;for(let A=0,j=w.length;A<j;A++){const N=w[A],k={boundary:0,storage:0},F=Array.isArray(N.value)?N.value:[N.value];for(let I=0,W=F.length;I<W;I++){const D=F[I],B=y(D);k.boundary+=B.boundary,k.storage+=B.storage}if(N.__data=new Float32Array(k.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=C,A>0){R=C%T;const I=T-R;R!==0&&I-k.boundary<0&&(C+=T-R,N.__offset=C)}C+=k.storage}return R=C%T,R>0&&(C+=T-R),M.__size=C,M.__cache={},this}function y(M){const w={boundary:0,storage:0};return typeof M=="number"?(w.boundary=4,w.storage=4):M.isVector2?(w.boundary=8,w.storage=8):M.isVector3||M.isColor?(w.boundary=16,w.storage=12):M.isVector4?(w.boundary=16,w.storage=16):M.isMatrix3?(w.boundary=48,w.storage=48):M.isMatrix4?(w.boundary=64,w.storage=64):M.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",M),w}function v(M){const w=M.target;w.removeEventListener("dispose",v);const C=s.indexOf(w.__bindingPointIndex);s.splice(C,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete a[w.id]}function x(){for(const M in i)t.deleteBuffer(i[M]);s=[],i={},a={}}return{bind:l,update:c,dispose:x}}class F3{constructor(e={}){const{canvas:n=Oxe(),context:r=null,depth:i=!0,stencil:a=!0,alpha:s=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let g;r!==null?g=r.getContextAttributes().alpha:g=s;const m=new Uint32Array(4),b=new Int32Array(4);let y=null,v=null;const x=[],M=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=$i,this._useLegacyLights=!1,this.toneMapping=Bu,this.toneMappingExposure=1;const w=this;let C=!1,T=0,R=0,A=null,j=-1,N=null;const k=new Gn,F=new Gn;let I=null;const W=new zt(0);let D=0,B=n.width,G=n.height,V=1,Z=null,Y=null;const ee=new Gn(0,0,B,G),H=new Gn(0,0,B,G);let q=!1;const ae=new uw;let ce=!1,xe=!1,ie=null;const ve=new Jn,Pe=new Kt,he=new Ce,we={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Le(){return A===null?V:1}let de=r;function lt(fe,Ue){for(let Je=0;Je<fe.length;Je++){const tt=fe[Je],Ye=n.getContext(tt,Ue);if(Ye!==null)return Ye}return null}try{const fe={alpha:!0,depth:i,stencil:a,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${ow}`),n.addEventListener("webglcontextlost",Qe,!1),n.addEventListener("webglcontextrestored",pe,!1),n.addEventListener("webglcontextcreationerror",Oe,!1),de===null){const Ue=["webgl2","webgl","experimental-webgl"];if(w.isWebGL1Renderer===!0&&Ue.shift(),de=lt(Ue,fe),de===null)throw lt(Ue)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&de instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),de.getShaderPrecisionFormat===void 0&&(de.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(fe){throw console.error("THREE.WebGLRenderer: "+fe.message),fe}let $,z,ne,K,Q,oe,Ne,Ee,re,U,L,J,ge,ye,me,et,Ie,Ke,st,je,le,Ze,Fe,Xe;function ct(){$=new Xbe(de),z=new Bbe(de,$,e),$.init(z),Ze=new k_e(de,$,z),ne=new R_e(de,$,z),K=new Zbe(de),Q=new g_e,oe=new P_e(de,$,ne,Q,z,Ze,K),Ne=new $be(w),Ee=new qbe(w),re=new i0e(de,z),Fe=new Fbe(de,$,re,z),U=new Kbe(de,re,K,Fe),L=new tye(de,U,re,K),st=new eye(de,z,oe),et=new Hbe(Q),J=new m_e(w,Ne,Ee,$,z,Fe,et),ge=new I_e(w,Q),ye=new v_e,me=new M_e($,z),Ke=new Ube(w,Ne,Ee,ne,L,g,l),Ie=new N_e(w,L,z),Xe=new j_e(de,K,z,ne),je=new zbe(de,$,K,z),le=new Ybe(de,$,K,z),K.programs=J.programs,w.capabilities=z,w.extensions=$,w.properties=Q,w.renderLists=ye,w.shadowMap=Ie,w.state=ne,w.info=K}ct();const ue=new L_e(w,de);this.xr=ue,this.getContext=function(){return de},this.getContextAttributes=function(){return de.getContextAttributes()},this.forceContextLoss=function(){const fe=$.get("WEBGL_lose_context");fe&&fe.loseContext()},this.forceContextRestore=function(){const fe=$.get("WEBGL_lose_context");fe&&fe.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(fe){fe!==void 0&&(V=fe,this.setSize(B,G,!1))},this.getSize=function(fe){return fe.set(B,G)},this.setSize=function(fe,Ue,Je=!0){if(ue.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}B=fe,G=Ue,n.width=Math.floor(fe*V),n.height=Math.floor(Ue*V),Je===!0&&(n.style.width=fe+"px",n.style.height=Ue+"px"),this.setViewport(0,0,fe,Ue)},this.getDrawingBufferSize=function(fe){return fe.set(B*V,G*V).floor()},this.setDrawingBufferSize=function(fe,Ue,Je){B=fe,G=Ue,V=Je,n.width=Math.floor(fe*Je),n.height=Math.floor(Ue*Je),this.setViewport(0,0,fe,Ue)},this.getCurrentViewport=function(fe){return fe.copy(k)},this.getViewport=function(fe){return fe.copy(ee)},this.setViewport=function(fe,Ue,Je,tt){fe.isVector4?ee.set(fe.x,fe.y,fe.z,fe.w):ee.set(fe,Ue,Je,tt),ne.viewport(k.copy(ee).multiplyScalar(V).floor())},this.getScissor=function(fe){return fe.copy(H)},this.setScissor=function(fe,Ue,Je,tt){fe.isVector4?H.set(fe.x,fe.y,fe.z,fe.w):H.set(fe,Ue,Je,tt),ne.scissor(F.copy(H).multiplyScalar(V).floor())},this.getScissorTest=function(){return q},this.setScissorTest=function(fe){ne.setScissorTest(q=fe)},this.setOpaqueSort=function(fe){Z=fe},this.setTransparentSort=function(fe){Y=fe},this.getClearColor=function(fe){return fe.copy(Ke.getClearColor())},this.setClearColor=function(){Ke.setClearColor.apply(Ke,arguments)},this.getClearAlpha=function(){return Ke.getClearAlpha()},this.setClearAlpha=function(){Ke.setClearAlpha.apply(Ke,arguments)},this.clear=function(fe=!0,Ue=!0,Je=!0){let tt=0;if(fe){let Ye=!1;if(A!==null){const _t=A.texture.format;Ye=_t===x7||_t===g7||_t===m7}if(Ye){const _t=A.texture.type,te=_t===Hu||_t===Du||_t===mk||_t===lf||_t===h7||_t===p7,_e=Ke.getClearColor(),ke=Ke.getClearAlpha(),Re=_e.r,Me=_e.g,it=_e.b;te?(m[0]=Re,m[1]=Me,m[2]=it,m[3]=ke,de.clearBufferuiv(de.COLOR,0,m)):(b[0]=Re,b[1]=Me,b[2]=it,b[3]=ke,de.clearBufferiv(de.COLOR,0,b))}else tt|=de.COLOR_BUFFER_BIT}Ue&&(tt|=de.DEPTH_BUFFER_BIT),Je&&(tt|=de.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),de.clear(tt)},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",Qe,!1),n.removeEventListener("webglcontextrestored",pe,!1),n.removeEventListener("webglcontextcreationerror",Oe,!1),ye.dispose(),me.dispose(),Q.dispose(),Ne.dispose(),Ee.dispose(),L.dispose(),Fe.dispose(),Xe.dispose(),J.dispose(),ue.dispose(),ue.removeEventListener("sessionstart",cn),ue.removeEventListener("sessionend",Ot),ie&&(ie.dispose(),ie=null),Rn.stop()};function Qe(fe){fe.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),C=!0}function pe(){console.log("THREE.WebGLRenderer: Context Restored."),C=!1;const fe=K.autoReset,Ue=Ie.enabled,Je=Ie.autoUpdate,tt=Ie.needsUpdate,Ye=Ie.type;ct(),K.autoReset=fe,Ie.enabled=Ue,Ie.autoUpdate=Je,Ie.needsUpdate=tt,Ie.type=Ye}function Oe(fe){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",fe.statusMessage)}function Ae(fe){const Ue=fe.target;Ue.removeEventListener("dispose",Ae),be(Ue)}function be(fe){$e(fe),Q.remove(fe)}function $e(fe){const Ue=Q.get(fe).programs;Ue!==void 0&&(Ue.forEach(function(Je){J.releaseProgram(Je)}),fe.isShaderMaterial&&J.releaseShaderCache(fe))}this.renderBufferDirect=function(fe,Ue,Je,tt,Ye,_t){Ue===null&&(Ue=we);const te=Ye.isMesh&&Ye.matrixWorld.determinant()<0,_e=Tr(fe,Ue,Je,tt,Ye);ne.setMaterial(tt,te);let ke=Je.index,Re=1;if(tt.wireframe===!0){if(ke=U.getWireframeAttribute(Je),ke===void 0)return;Re=2}const Me=Je.drawRange,it=Je.attributes.position;let ht=Me.start*Re,vt=(Me.start+Me.count)*Re;_t!==null&&(ht=Math.max(ht,_t.start*Re),vt=Math.min(vt,(_t.start+_t.count)*Re)),ke!==null?(ht=Math.max(ht,0),vt=Math.min(vt,ke.count)):it!=null&&(ht=Math.max(ht,0),vt=Math.min(vt,it.count));const xt=vt-ht;if(xt<0||xt===1/0)return;Fe.setup(Ye,tt,_e,Je,ke);let kt,wt=je;if(ke!==null&&(kt=re.get(ke),wt=le,wt.setIndex(kt)),Ye.isMesh)tt.wireframe===!0?(ne.setLineWidth(tt.wireframeLinewidth*Le()),wt.setMode(de.LINES)):wt.setMode(de.TRIANGLES);else if(Ye.isLine){let mt=tt.linewidth;mt===void 0&&(mt=1),ne.setLineWidth(mt*Le()),Ye.isLineSegments?wt.setMode(de.LINES):Ye.isLineLoop?wt.setMode(de.LINE_LOOP):wt.setMode(de.LINE_STRIP)}else Ye.isPoints?wt.setMode(de.POINTS):Ye.isSprite&&wt.setMode(de.TRIANGLES);if(Ye.isBatchedMesh)wt.renderMultiDraw(Ye._multiDrawStarts,Ye._multiDrawCounts,Ye._multiDrawCount);else if(Ye.isInstancedMesh)wt.renderInstances(ht,xt,Ye.count);else if(Je.isInstancedBufferGeometry){const mt=Je._maxInstanceCount!==void 0?Je._maxInstanceCount:1/0,qt=Math.min(Je.instanceCount,mt);wt.renderInstances(ht,xt,qt)}else wt.render(ht,xt)};function ft(fe,Ue,Je){fe.transparent===!0&&fe.side===Zl&&fe.forceSinglePass===!1?(fe.side=Fa,fe.needsUpdate=!0,qi(fe,Ue,Je),fe.side=Qu,fe.needsUpdate=!0,qi(fe,Ue,Je),fe.side=Zl):qi(fe,Ue,Je)}this.compile=function(fe,Ue,Je=null){Je===null&&(Je=fe),v=me.get(Je),v.init(),M.push(v),Je.traverseVisible(function(Ye){Ye.isLight&&Ye.layers.test(Ue.layers)&&(v.pushLight(Ye),Ye.castShadow&&v.pushShadow(Ye))}),fe!==Je&&fe.traverseVisible(function(Ye){Ye.isLight&&Ye.layers.test(Ue.layers)&&(v.pushLight(Ye),Ye.castShadow&&v.pushShadow(Ye))}),v.setupLights(w._useLegacyLights);const tt=new Set;return fe.traverse(function(Ye){const _t=Ye.material;if(_t)if(Array.isArray(_t))for(let te=0;te<_t.length;te++){const _e=_t[te];ft(_e,Je,Ye),tt.add(_e)}else ft(_t,Je,Ye),tt.add(_t)}),M.pop(),v=null,tt},this.compileAsync=function(fe,Ue,Je=null){const tt=this.compile(fe,Ue,Je);return new Promise(Ye=>{function _t(){if(tt.forEach(function(te){Q.get(te).currentProgram.isReady()&&tt.delete(te)}),tt.size===0){Ye(fe);return}setTimeout(_t,10)}$.get("KHR_parallel_shader_compile")!==null?_t():setTimeout(_t,10)})};let yt=null;function Pt(fe){yt&&yt(fe)}function cn(){Rn.stop()}function Ot(){Rn.start()}const Rn=new L7;Rn.setAnimationLoop(Pt),typeof self<"u"&&Rn.setContext(self),this.setAnimationLoop=function(fe){yt=fe,ue.setAnimationLoop(fe),fe===null?Rn.stop():Rn.start()},ue.addEventListener("sessionstart",cn),ue.addEventListener("sessionend",Ot),this.render=function(fe,Ue){if(Ue!==void 0&&Ue.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;fe.matrixWorldAutoUpdate===!0&&fe.updateMatrixWorld(),Ue.parent===null&&Ue.matrixWorldAutoUpdate===!0&&Ue.updateMatrixWorld(),ue.enabled===!0&&ue.isPresenting===!0&&(ue.cameraAutoUpdate===!0&&ue.updateCamera(Ue),Ue=ue.getCamera()),fe.isScene===!0&&fe.onBeforeRender(w,fe,Ue,A),v=me.get(fe,M.length),v.init(),M.push(v),ve.multiplyMatrices(Ue.projectionMatrix,Ue.matrixWorldInverse),ae.setFromProjectionMatrix(ve),xe=this.localClippingEnabled,ce=et.init(this.clippingPlanes,xe),y=ye.get(fe,x.length),y.init(),x.push(y),qn(fe,Ue,0,w.sortObjects),y.finish(),w.sortObjects===!0&&y.sort(Z,Y),this.info.render.frame++,ce===!0&&et.beginShadows();const Je=v.state.shadowsArray;if(Ie.render(Je,fe,Ue),ce===!0&&et.endShadows(),this.info.autoReset===!0&&this.info.reset(),Ke.render(y,fe),v.setupLights(w._useLegacyLights),Ue.isArrayCamera){const tt=Ue.cameras;for(let Ye=0,_t=tt.length;Ye<_t;Ye++){const te=tt[Ye];pi(y,fe,te,te.viewport)}}else pi(y,fe,Ue);A!==null&&(oe.updateMultisampleRenderTarget(A),oe.updateRenderTargetMipmap(A)),fe.isScene===!0&&fe.onAfterRender(w,fe,Ue),Fe.resetDefaultState(),j=-1,N=null,M.pop(),M.length>0?v=M[M.length-1]:v=null,x.pop(),x.length>0?y=x[x.length-1]:y=null};function qn(fe,Ue,Je,tt){if(fe.visible===!1)return;if(fe.layers.test(Ue.layers)){if(fe.isGroup)Je=fe.renderOrder;else if(fe.isLOD)fe.autoUpdate===!0&&fe.update(Ue);else if(fe.isLight)v.pushLight(fe),fe.castShadow&&v.pushShadow(fe);else if(fe.isSprite){if(!fe.frustumCulled||ae.intersectsSprite(fe)){tt&&he.setFromMatrixPosition(fe.matrixWorld).applyMatrix4(ve);const te=L.update(fe),_e=fe.material;_e.visible&&y.push(fe,te,_e,Je,he.z,null)}}else if((fe.isMesh||fe.isLine||fe.isPoints)&&(!fe.frustumCulled||ae.intersectsObject(fe))){const te=L.update(fe),_e=fe.material;if(tt&&(fe.boundingSphere!==void 0?(fe.boundingSphere===null&&fe.computeBoundingSphere(),he.copy(fe.boundingSphere.center)):(te.boundingSphere===null&&te.computeBoundingSphere(),he.copy(te.boundingSphere.center)),he.applyMatrix4(fe.matrixWorld).applyMatrix4(ve)),Array.isArray(_e)){const ke=te.groups;for(let Re=0,Me=ke.length;Re<Me;Re++){const it=ke[Re],ht=_e[it.materialIndex];ht&&ht.visible&&y.push(fe,te,ht,Je,he.z,it)}}else _e.visible&&y.push(fe,te,_e,Je,he.z,null)}}const _t=fe.children;for(let te=0,_e=_t.length;te<_e;te++)qn(_t[te],Ue,Je,tt)}function pi(fe,Ue,Je,tt){const Ye=fe.opaque,_t=fe.transmissive,te=fe.transparent;v.setupLightsView(Je),ce===!0&&et.setGlobalState(w.clippingPlanes,Je),_t.length>0&&Qr(Ye,_t,Ue,Je),tt&&ne.viewport(k.copy(tt)),Ye.length>0&&mi(Ye,Ue,Je),_t.length>0&&mi(_t,Ue,Je),te.length>0&&mi(te,Ue,Je),ne.buffers.depth.setTest(!0),ne.buffers.depth.setMask(!0),ne.buffers.color.setMask(!0),ne.setPolygonOffset(!1)}function Qr(fe,Ue,Je,tt){if((Je.isScene===!0?Je.overrideMaterial:null)!==null)return;const _t=z.isWebGL2;ie===null&&(ie=new kf(1,1,{generateMipmaps:!0,type:$.has("EXT_color_buffer_half_float")?r0:Hu,minFilter:n0,samples:_t?4:0})),w.getDrawingBufferSize(Pe),_t?ie.setSize(Pe.x,Pe.y):ie.setSize(a1(Pe.x),a1(Pe.y));const te=w.getRenderTarget();w.setRenderTarget(ie),w.getClearColor(W),D=w.getClearAlpha(),D<1&&w.setClearColor(16777215,.5),w.clear();const _e=w.toneMapping;w.toneMapping=Bu,mi(fe,Je,tt),oe.updateMultisampleRenderTarget(ie),oe.updateRenderTargetMipmap(ie);let ke=!1;for(let Re=0,Me=Ue.length;Re<Me;Re++){const it=Ue[Re],ht=it.object,vt=it.geometry,xt=it.material,kt=it.group;if(xt.side===Zl&&ht.layers.test(tt.layers)){const wt=xt.side;xt.side=Fa,xt.needsUpdate=!0,Pi(ht,Je,tt,vt,xt,kt),xt.side=wt,xt.needsUpdate=!0,ke=!0}}ke===!0&&(oe.updateMultisampleRenderTarget(ie),oe.updateRenderTargetMipmap(ie)),w.setRenderTarget(te),w.setClearColor(W,D),w.toneMapping=_e}function mi(fe,Ue,Je){const tt=Ue.isScene===!0?Ue.overrideMaterial:null;for(let Ye=0,_t=fe.length;Ye<_t;Ye++){const te=fe[Ye],_e=te.object,ke=te.geometry,Re=tt===null?te.material:tt,Me=te.group;_e.layers.test(Je.layers)&&Pi(_e,Ue,Je,ke,Re,Me)}}function Pi(fe,Ue,Je,tt,Ye,_t){fe.onBeforeRender(w,Ue,Je,tt,Ye,_t),fe.modelViewMatrix.multiplyMatrices(Je.matrixWorldInverse,fe.matrixWorld),fe.normalMatrix.getNormalMatrix(fe.modelViewMatrix),Ye.onBeforeRender(w,Ue,Je,tt,fe,_t),Ye.transparent===!0&&Ye.side===Zl&&Ye.forceSinglePass===!1?(Ye.side=Fa,Ye.needsUpdate=!0,w.renderBufferDirect(Je,Ue,tt,Ye,fe,_t),Ye.side=Qu,Ye.needsUpdate=!0,w.renderBufferDirect(Je,Ue,tt,Ye,fe,_t),Ye.side=Zl):w.renderBufferDirect(Je,Ue,tt,Ye,fe,_t),fe.onAfterRender(w,Ue,Je,tt,Ye,_t)}function qi(fe,Ue,Je){Ue.isScene!==!0&&(Ue=we);const tt=Q.get(fe),Ye=v.state.lights,_t=v.state.shadowsArray,te=Ye.state.version,_e=J.getParameters(fe,Ye.state,_t,Ue,Je),ke=J.getProgramCacheKey(_e);let Re=tt.programs;tt.environment=fe.isMeshStandardMaterial?Ue.environment:null,tt.fog=Ue.fog,tt.envMap=(fe.isMeshStandardMaterial?Ee:Ne).get(fe.envMap||tt.environment),Re===void 0&&(fe.addEventListener("dispose",Ae),Re=new Map,tt.programs=Re);let Me=Re.get(ke);if(Me!==void 0){if(tt.currentProgram===Me&&tt.lightsStateVersion===te)return pr(fe,_e),Me}else _e.uniforms=J.getUniforms(fe),fe.onBuild(Je,_e,w),fe.onBeforeCompile(_e,w),Me=J.acquireProgram(_e,ke),Re.set(ke,Me),tt.uniforms=_e.uniforms;const it=tt.uniforms;return(!fe.isShaderMaterial&&!fe.isRawShaderMaterial||fe.clipping===!0)&&(it.clippingPlanes=et.uniform),pr(fe,_e),tt.needsLights=Lc(fe),tt.lightsStateVersion=te,tt.needsLights&&(it.ambientLightColor.value=Ye.state.ambient,it.lightProbe.value=Ye.state.probe,it.directionalLights.value=Ye.state.directional,it.directionalLightShadows.value=Ye.state.directionalShadow,it.spotLights.value=Ye.state.spot,it.spotLightShadows.value=Ye.state.spotShadow,it.rectAreaLights.value=Ye.state.rectArea,it.ltc_1.value=Ye.state.rectAreaLTC1,it.ltc_2.value=Ye.state.rectAreaLTC2,it.pointLights.value=Ye.state.point,it.pointLightShadows.value=Ye.state.pointShadow,it.hemisphereLights.value=Ye.state.hemi,it.directionalShadowMap.value=Ye.state.directionalShadowMap,it.directionalShadowMatrix.value=Ye.state.directionalShadowMatrix,it.spotShadowMap.value=Ye.state.spotShadowMap,it.spotLightMatrix.value=Ye.state.spotLightMatrix,it.spotLightMap.value=Ye.state.spotLightMap,it.pointShadowMap.value=Ye.state.pointShadowMap,it.pointShadowMatrix.value=Ye.state.pointShadowMatrix),tt.currentProgram=Me,tt.uniformsList=null,Me}function Ir(fe){if(fe.uniformsList===null){const Ue=fe.currentProgram.getUniforms();fe.uniformsList=A_.seqWithValue(Ue.seq,fe.uniforms)}return fe.uniformsList}function pr(fe,Ue){const Je=Q.get(fe);Je.outputColorSpace=Ue.outputColorSpace,Je.batching=Ue.batching,Je.instancing=Ue.instancing,Je.instancingColor=Ue.instancingColor,Je.skinning=Ue.skinning,Je.morphTargets=Ue.morphTargets,Je.morphNormals=Ue.morphNormals,Je.morphColors=Ue.morphColors,Je.morphTargetsCount=Ue.morphTargetsCount,Je.numClippingPlanes=Ue.numClippingPlanes,Je.numIntersection=Ue.numClipIntersection,Je.vertexAlphas=Ue.vertexAlphas,Je.vertexTangents=Ue.vertexTangents,Je.toneMapping=Ue.toneMapping}function Tr(fe,Ue,Je,tt,Ye){Ue.isScene!==!0&&(Ue=we),oe.resetTextureUnits();const _t=Ue.fog,te=tt.isMeshStandardMaterial?Ue.environment:null,_e=A===null?w.outputColorSpace:A.isXRRenderTarget===!0?A.texture.colorSpace:bc,ke=(tt.isMeshStandardMaterial?Ee:Ne).get(tt.envMap||te),Re=tt.vertexColors===!0&&!!Je.attributes.color&&Je.attributes.color.itemSize===4,Me=!!Je.attributes.tangent&&(!!tt.normalMap||tt.anisotropy>0),it=!!Je.morphAttributes.position,ht=!!Je.morphAttributes.normal,vt=!!Je.morphAttributes.color;let xt=Bu;tt.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(xt=w.toneMapping);const kt=Je.morphAttributes.position||Je.morphAttributes.normal||Je.morphAttributes.color,wt=kt!==void 0?kt.length:0,mt=Q.get(tt),qt=v.state.lights;if(ce===!0&&(xe===!0||fe!==N)){const Cr=fe===N&&tt.id===j;et.setState(tt,fe,Cr)}let It=!1;tt.version===mt.__version?(mt.needsLights&&mt.lightsStateVersion!==qt.state.version||mt.outputColorSpace!==_e||Ye.isBatchedMesh&&mt.batching===!1||!Ye.isBatchedMesh&&mt.batching===!0||Ye.isInstancedMesh&&mt.instancing===!1||!Ye.isInstancedMesh&&mt.instancing===!0||Ye.isSkinnedMesh&&mt.skinning===!1||!Ye.isSkinnedMesh&&mt.skinning===!0||Ye.isInstancedMesh&&mt.instancingColor===!0&&Ye.instanceColor===null||Ye.isInstancedMesh&&mt.instancingColor===!1&&Ye.instanceColor!==null||mt.envMap!==ke||tt.fog===!0&&mt.fog!==_t||mt.numClippingPlanes!==void 0&&(mt.numClippingPlanes!==et.numPlanes||mt.numIntersection!==et.numIntersection)||mt.vertexAlphas!==Re||mt.vertexTangents!==Me||mt.morphTargets!==it||mt.morphNormals!==ht||mt.morphColors!==vt||mt.toneMapping!==xt||z.isWebGL2===!0&&mt.morphTargetsCount!==wt)&&(It=!0):(It=!0,mt.__version=tt.version);let tn=mt.currentProgram;It===!0&&(tn=qi(tt,Ue,Ye));let dn=!1,gn=!1,Lt=!1;const Yt=tn.getUniforms(),Qt=mt.uniforms;if(ne.useProgram(tn.program)&&(dn=!0,gn=!0,Lt=!0),tt.id!==j&&(j=tt.id,gn=!0),dn||N!==fe){Yt.setValue(de,"projectionMatrix",fe.projectionMatrix),Yt.setValue(de,"viewMatrix",fe.matrixWorldInverse);const Cr=Yt.map.cameraPosition;Cr!==void 0&&Cr.setValue(de,he.setFromMatrixPosition(fe.matrixWorld)),z.logarithmicDepthBuffer&&Yt.setValue(de,"logDepthBufFC",2/(Math.log(fe.far+1)/Math.LN2)),(tt.isMeshPhongMaterial||tt.isMeshToonMaterial||tt.isMeshLambertMaterial||tt.isMeshBasicMaterial||tt.isMeshStandardMaterial||tt.isShaderMaterial)&&Yt.setValue(de,"isOrthographic",fe.isOrthographicCamera===!0),N!==fe&&(N=fe,gn=!0,Lt=!0)}if(Ye.isSkinnedMesh){Yt.setOptional(de,Ye,"bindMatrix"),Yt.setOptional(de,Ye,"bindMatrixInverse");const Cr=Ye.skeleton;Cr&&(z.floatVertexTextures?(Cr.boneTexture===null&&Cr.computeBoneTexture(),Yt.setValue(de,"boneTexture",Cr.boneTexture,oe)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}Ye.isBatchedMesh&&(Yt.setOptional(de,Ye,"batchingTexture"),Yt.setValue(de,"batchingTexture",Ye._matricesTexture,oe));const yr=Je.morphAttributes;if((yr.position!==void 0||yr.normal!==void 0||yr.color!==void 0&&z.isWebGL2===!0)&&st.update(Ye,Je,tn),(gn||mt.receiveShadow!==Ye.receiveShadow)&&(mt.receiveShadow=Ye.receiveShadow,Yt.setValue(de,"receiveShadow",Ye.receiveShadow)),tt.isMeshGouraudMaterial&&tt.envMap!==null&&(Qt.envMap.value=ke,Qt.flipEnvMap.value=ke.isCubeTexture&&ke.isRenderTargetTexture===!1?-1:1),gn&&(Yt.setValue(de,"toneMappingExposure",w.toneMappingExposure),mt.needsLights&&Js(Qt,Lt),_t&&tt.fog===!0&&ge.refreshFogUniforms(Qt,_t),ge.refreshMaterialUniforms(Qt,tt,V,G,ie),A_.upload(de,Ir(mt),Qt,oe)),tt.isShaderMaterial&&tt.uniformsNeedUpdate===!0&&(A_.upload(de,Ir(mt),Qt,oe),tt.uniformsNeedUpdate=!1),tt.isSpriteMaterial&&Yt.setValue(de,"center",Ye.center),Yt.setValue(de,"modelViewMatrix",Ye.modelViewMatrix),Yt.setValue(de,"normalMatrix",Ye.normalMatrix),Yt.setValue(de,"modelMatrix",Ye.matrixWorld),tt.isShaderMaterial||tt.isRawShaderMaterial){const Cr=tt.uniformsGroups;for(let Nn=0,eo=Cr.length;Nn<eo;Nn++)if(z.isWebGL2){const Pn=Cr[Nn];Xe.update(Pn,tn),Xe.bind(Pn,tn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return tn}function Js(fe,Ue){fe.ambientLightColor.needsUpdate=Ue,fe.lightProbe.needsUpdate=Ue,fe.directionalLights.needsUpdate=Ue,fe.directionalLightShadows.needsUpdate=Ue,fe.pointLights.needsUpdate=Ue,fe.pointLightShadows.needsUpdate=Ue,fe.spotLights.needsUpdate=Ue,fe.spotLightShadows.needsUpdate=Ue,fe.rectAreaLights.needsUpdate=Ue,fe.hemisphereLights.needsUpdate=Ue}function Lc(fe){return fe.isMeshLambertMaterial||fe.isMeshToonMaterial||fe.isMeshPhongMaterial||fe.isMeshStandardMaterial||fe.isShadowMaterial||fe.isShaderMaterial&&fe.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return A},this.setRenderTargetTextures=function(fe,Ue,Je){Q.get(fe.texture).__webglTexture=Ue,Q.get(fe.depthTexture).__webglTexture=Je;const tt=Q.get(fe);tt.__hasExternalTextures=!0,tt.__hasExternalTextures&&(tt.__autoAllocateDepthBuffer=Je===void 0,tt.__autoAllocateDepthBuffer||$.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),tt.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(fe,Ue){const Je=Q.get(fe);Je.__webglFramebuffer=Ue,Je.__useDefaultFramebuffer=Ue===void 0},this.setRenderTarget=function(fe,Ue=0,Je=0){A=fe,T=Ue,R=Je;let tt=!0,Ye=null,_t=!1,te=!1;if(fe){const ke=Q.get(fe);ke.__useDefaultFramebuffer!==void 0?(ne.bindFramebuffer(de.FRAMEBUFFER,null),tt=!1):ke.__webglFramebuffer===void 0?oe.setupRenderTarget(fe):ke.__hasExternalTextures&&oe.rebindTextures(fe,Q.get(fe.texture).__webglTexture,Q.get(fe.depthTexture).__webglTexture);const Re=fe.texture;(Re.isData3DTexture||Re.isDataArrayTexture||Re.isCompressedArrayTexture)&&(te=!0);const Me=Q.get(fe).__webglFramebuffer;fe.isWebGLCubeRenderTarget?(Array.isArray(Me[Ue])?Ye=Me[Ue][Je]:Ye=Me[Ue],_t=!0):z.isWebGL2&&fe.samples>0&&oe.useMultisampledRTT(fe)===!1?Ye=Q.get(fe).__webglMultisampledFramebuffer:Array.isArray(Me)?Ye=Me[Je]:Ye=Me,k.copy(fe.viewport),F.copy(fe.scissor),I=fe.scissorTest}else k.copy(ee).multiplyScalar(V).floor(),F.copy(H).multiplyScalar(V).floor(),I=q;if(ne.bindFramebuffer(de.FRAMEBUFFER,Ye)&&z.drawBuffers&&tt&&ne.drawBuffers(fe,Ye),ne.viewport(k),ne.scissor(F),ne.setScissorTest(I),_t){const ke=Q.get(fe.texture);de.framebufferTexture2D(de.FRAMEBUFFER,de.COLOR_ATTACHMENT0,de.TEXTURE_CUBE_MAP_POSITIVE_X+Ue,ke.__webglTexture,Je)}else if(te){const ke=Q.get(fe.texture),Re=Ue||0;de.framebufferTextureLayer(de.FRAMEBUFFER,de.COLOR_ATTACHMENT0,ke.__webglTexture,Je||0,Re)}j=-1},this.readRenderTargetPixels=function(fe,Ue,Je,tt,Ye,_t,te){if(!(fe&&fe.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let _e=Q.get(fe).__webglFramebuffer;if(fe.isWebGLCubeRenderTarget&&te!==void 0&&(_e=_e[te]),_e){ne.bindFramebuffer(de.FRAMEBUFFER,_e);try{const ke=fe.texture,Re=ke.format,Me=ke.type;if(Re!==Fs&&Ze.convert(Re)!==de.getParameter(de.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const it=Me===r0&&($.has("EXT_color_buffer_half_float")||z.isWebGL2&&$.has("EXT_color_buffer_float"));if(Me!==Hu&&Ze.convert(Me)!==de.getParameter(de.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Me===rc&&(z.isWebGL2||$.has("OES_texture_float")||$.has("WEBGL_color_buffer_float")))&&!it){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ue>=0&&Ue<=fe.width-tt&&Je>=0&&Je<=fe.height-Ye&&de.readPixels(Ue,Je,tt,Ye,Ze.convert(Re),Ze.convert(Me),_t)}finally{const ke=A!==null?Q.get(A).__webglFramebuffer:null;ne.bindFramebuffer(de.FRAMEBUFFER,ke)}}},this.copyFramebufferToTexture=function(fe,Ue,Je=0){const tt=Math.pow(2,-Je),Ye=Math.floor(Ue.image.width*tt),_t=Math.floor(Ue.image.height*tt);oe.setTexture2D(Ue,0),de.copyTexSubImage2D(de.TEXTURE_2D,Je,0,0,fe.x,fe.y,Ye,_t),ne.unbindTexture()},this.copyTextureToTexture=function(fe,Ue,Je,tt=0){const Ye=Ue.image.width,_t=Ue.image.height,te=Ze.convert(Je.format),_e=Ze.convert(Je.type);oe.setTexture2D(Je,0),de.pixelStorei(de.UNPACK_FLIP_Y_WEBGL,Je.flipY),de.pixelStorei(de.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Je.premultiplyAlpha),de.pixelStorei(de.UNPACK_ALIGNMENT,Je.unpackAlignment),Ue.isDataTexture?de.texSubImage2D(de.TEXTURE_2D,tt,fe.x,fe.y,Ye,_t,te,_e,Ue.image.data):Ue.isCompressedTexture?de.compressedTexSubImage2D(de.TEXTURE_2D,tt,fe.x,fe.y,Ue.mipmaps[0].width,Ue.mipmaps[0].height,te,Ue.mipmaps[0].data):de.texSubImage2D(de.TEXTURE_2D,tt,fe.x,fe.y,te,_e,Ue.image),tt===0&&Je.generateMipmaps&&de.generateMipmap(de.TEXTURE_2D),ne.unbindTexture()},this.copyTextureToTexture3D=function(fe,Ue,Je,tt,Ye=0){if(w.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const _t=fe.max.x-fe.min.x+1,te=fe.max.y-fe.min.y+1,_e=fe.max.z-fe.min.z+1,ke=Ze.convert(tt.format),Re=Ze.convert(tt.type);let Me;if(tt.isData3DTexture)oe.setTexture3D(tt,0),Me=de.TEXTURE_3D;else if(tt.isDataArrayTexture)oe.setTexture2DArray(tt,0),Me=de.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}de.pixelStorei(de.UNPACK_FLIP_Y_WEBGL,tt.flipY),de.pixelStorei(de.UNPACK_PREMULTIPLY_ALPHA_WEBGL,tt.premultiplyAlpha),de.pixelStorei(de.UNPACK_ALIGNMENT,tt.unpackAlignment);const it=de.getParameter(de.UNPACK_ROW_LENGTH),ht=de.getParameter(de.UNPACK_IMAGE_HEIGHT),vt=de.getParameter(de.UNPACK_SKIP_PIXELS),xt=de.getParameter(de.UNPACK_SKIP_ROWS),kt=de.getParameter(de.UNPACK_SKIP_IMAGES),wt=Je.isCompressedTexture?Je.mipmaps[0]:Je.image;de.pixelStorei(de.UNPACK_ROW_LENGTH,wt.width),de.pixelStorei(de.UNPACK_IMAGE_HEIGHT,wt.height),de.pixelStorei(de.UNPACK_SKIP_PIXELS,fe.min.x),de.pixelStorei(de.UNPACK_SKIP_ROWS,fe.min.y),de.pixelStorei(de.UNPACK_SKIP_IMAGES,fe.min.z),Je.isDataTexture||Je.isData3DTexture?de.texSubImage3D(Me,Ye,Ue.x,Ue.y,Ue.z,_t,te,_e,ke,Re,wt.data):Je.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),de.compressedTexSubImage3D(Me,Ye,Ue.x,Ue.y,Ue.z,_t,te,_e,ke,wt.data)):de.texSubImage3D(Me,Ye,Ue.x,Ue.y,Ue.z,_t,te,_e,ke,Re,wt),de.pixelStorei(de.UNPACK_ROW_LENGTH,it),de.pixelStorei(de.UNPACK_IMAGE_HEIGHT,ht),de.pixelStorei(de.UNPACK_SKIP_PIXELS,vt),de.pixelStorei(de.UNPACK_SKIP_ROWS,xt),de.pixelStorei(de.UNPACK_SKIP_IMAGES,kt),Ye===0&&tt.generateMipmaps&&de.generateMipmap(Me),ne.unbindTexture()},this.initTexture=function(fe){fe.isCubeTexture?oe.setTextureCube(fe,0):fe.isData3DTexture?oe.setTexture3D(fe,0):fe.isDataArrayTexture||fe.isCompressedArrayTexture?oe.setTexture2DArray(fe,0):oe.setTexture2D(fe,0),ne.unbindTexture()},this.resetState=function(){T=0,R=0,A=null,ne.reset(),Fe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ko}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===gk?"display-p3":"srgb",n.unpackColorSpace=$n.workingColorSpace===cw?"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===$i?uf:b7}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===uf?$i:bc}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 U_e extends F3{}U_e.prototype.isWebGL1Renderer=!0;class Sk{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new zt(e),this.near=n,this.far=r}clone(){return new Sk(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class F_e extends va{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 z_e{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=L3,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=uc()}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=uc()),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=uc()),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 da=new Ce;class Ou{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++)da.fromBufferAttribute(this,n),da.applyMatrix4(e),this.setXYZ(n,da.x,da.y,da.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)da.fromBufferAttribute(this,n),da.applyNormalMatrix(e),this.setXYZ(n,da.x,da.y,da.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)da.fromBufferAttribute(this,n),da.transformDirection(e),this.setXYZ(n,da.x,da.y,da.z);return this}setX(e,n){return this.normalized&&(n=Hn(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=Hn(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=Hn(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=Hn(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=Go(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=Go(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=Go(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=Go(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=Hn(n,this.array),r=Hn(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=Hn(n,this.array),r=Hn(r,this.array),i=Hn(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=Hn(n,this.array),r=Hn(r,this.array),i=Hn(i,this.array),a=Hn(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 fs(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 Ou(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 B_e extends za{constructor(e=null,n=1,r=1,i,a,s,o,l,c=Hi,u=Hi,h,g){super(null,s,o,l,c,u,i,a,h,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function H_e(t,e){return t.z-e.z}function $_e(t,e){return e.z-t.z}class V_e{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 up="batchId",gu=new Jn,F5=new Jn,G_e=new Jn,z5=new Jn,YT=new uw,Ny=new Gs,zd=new Zo,Kg=new Ce,ZT=new V_e,Ji=new vo,Ry=[];function W_e(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 q_e extends vo{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new oa,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 B_e(n,e,e,Fs,rc);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,a=this._maxIndexCount;if(this._geometryInitialized===!1){for(const o in e.attributes){const l=e.getAttribute(o),{array:c,itemSize:u,normalized:h}=l,g=new c.constructor(r*u),m=new l.constructor(g,u,h);m.setUsage(l.usage),n.setAttribute(o,m)}if(e.getIndex()!==null){const o=r>65536?new Uint32Array(a):new Uint16Array(a);n.setIndex(new fs(o,1))}const s=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(up,new fs(s,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(up))throw new Error(`BatchedMesh: Geometry cannot use attribute "${up}"`);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===up)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 Gs);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,gu),this.getBoundingBoxAt(i,Ny).applyMatrix4(gu),n.union(Ny))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Zo);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,gu),this.getBoundingSphereAt(i,zd).applyMatrix4(gu),n.union(zd))}addGeometry(e,n=-1,r=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let a=null;const s=this._reservedRanges,o=this._drawRanges,l=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 c=e.getIndex(),u=c!==null;if(u&&(r===-1?i.indexCount=c.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 h=this._visibility,g=this._active,m=this._matricesTexture,b=this._matricesTexture.image.data;h.push(!0),g.push(!0);const y=this._geometryCount;this._geometryCount++,G_e.toArray(b,y*16),m.needsUpdate=!0,s.push(i),o.push({start:u?i.indexStart:i.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Gs,sphereInitialized:!1,sphere:new Zo});const v=this.geometry.getAttribute(up);for(let x=0;x<i.vertexCount;x++)v.setX(i.vertexStart+x,y);return v.needsUpdate=!0,this.setGeometryAt(y,e),y}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,a=r.getIndex(),s=n.getIndex(),o=this._reservedRanges[e];if(i&&s.count>o.indexCount||n.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.vertexCount;for(const m in r.attributes){if(m===up)continue;const b=n.getAttribute(m),y=r.getAttribute(m);W_e(b,y,l);const v=b.itemSize;for(let x=b.count,M=c;x<M;x++){const w=l+x;for(let C=0;C<v;C++)y.setComponent(w,C,0)}y.needsUpdate=!0}if(i){const m=o.indexStart;for(let b=0;b<s.count;b++)a.setX(m+b,l+s.getX(b));for(let b=s.count,y=o.indexCount;b<y;b++)a.setX(m+b,l);a.needsUpdate=!0}const u=this._bounds[e];n.boundingBox!==null?(u.box.copy(n.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,n.boundingSphere!==null?(u.sphere.copy(n.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;const h=this._drawRanges[e],g=n.getAttribute("position");return h.count=i?s.count:g.count,this._visibilityChanged=!0,e}deleteGeometry(e){const n=this._active;return e>=n.length||n[e]===!1?this:(n[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.box,s=this.geometry;if(i.boxInitialized===!1){a.makeEmpty();const o=s.index,l=s.attributes.position,c=this._drawRanges[e];for(let u=c.start,h=c.start+c.count;u<h;u++){let g=u;o&&(g=o.getX(g)),a.expandByPoint(Kg.fromBufferAttribute(l,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,Ny),Ny.getCenter(a.center);const o=s.index,l=s.attributes.position,c=this._drawRanges[e];let u=0;for(let h=c.start,g=c.start+c.count;h<g;h++){let m=h;o&&(m=o.getX(m)),Kg.fromBufferAttribute(l,m),u=Math.max(u,a.center.distanceToSquared(Kg))}a.radius=Math.sqrt(u),i.sphereInitialized=!0}return n.copy(a),n}setMatrixAt(e,n){const r=this._active,i=this._matricesTexture,a=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||r[e]===!1?this:(n.toArray(a,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,n){const r=this._active,i=this._matricesTexture.image.data,a=this._geometryCount;return e>=a||r[e]===!1?null:n.fromArray(i,e*16)}setVisibleAt(e,n){const r=this._visibility,i=this._active,a=this._geometryCount;return e>=a||i[e]===!1||r[e]===n?this:(r[e]=n,this._visibilityChanged=!0,this)}getVisibleAt(e){const n=this._visibility,r=this._active,i=this._geometryCount;return e>=i||r[e]===!1?!1:n[e]}raycast(e,n){const r=this._visibility,i=this._active,a=this._drawRanges,s=this._geometryCount,o=this.matrixWorld,l=this.geometry;Ji.material=this.material,Ji.geometry.index=l.index,Ji.geometry.attributes=l.attributes,Ji.geometry.boundingBox===null&&(Ji.geometry.boundingBox=new Gs),Ji.geometry.boundingSphere===null&&(Ji.geometry.boundingSphere=new Zo);for(let c=0;c<s;c++){if(!r[c]||!i[c])continue;const u=a[c];Ji.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(c,Ji.matrixWorld).premultiply(o),this.getBoundingBoxAt(c,Ji.geometry.boundingBox),this.getBoundingSphereAt(c,Ji.geometry.boundingSphere),Ji.raycast(e,Ry);for(let h=0,g=Ry.length;h<g;h++){const m=Ry[h];m.object=this,m.batchId=c,n.push(m)}Ry.length=0}Ji.material=null,Ji.geometry.index=null,Ji.geometry.attributes={},Ji.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(n=>({...n})),this._reservedRanges=e._reservedRanges.map(n=>({...n})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(n=>({boxInitialized:n.boxInitialized,box:n.box.clone(),sphereInitialized:n.sphereInitialized,sphere:n.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,n,r,i,a){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=i.getIndex(),o=s===null?1:s.array.BYTES_PER_ELEMENT,l=this._visibility,c=this._multiDrawStarts,u=this._multiDrawCounts,h=this._drawRanges,g=this.perObjectFrustumCulled;g&&(z5.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),YT.setFromProjectionMatrix(z5,e.isWebGPURenderer?i0:Ko));let m=0;if(this.sortObjects){F5.copy(this.matrixWorld).invert(),Kg.setFromMatrixPosition(r.matrixWorld).applyMatrix4(F5);for(let v=0,x=l.length;v<x;v++)if(l[v]){this.getMatrixAt(v,gu),this.getBoundingSphereAt(v,zd).applyMatrix4(gu);let M=!1;if(g&&(M=!YT.intersectsSphere(zd)),!M){const w=Kg.distanceTo(zd.center);ZT.push(h[v],w)}}const b=ZT.list,y=this.customSort;y===null?b.sort(a.transparent?$_e:H_e):y.call(this,b,r);for(let v=0,x=b.length;v<x;v++){const M=b[v];c[m]=M.start*o,u[m]=M.count,m++}ZT.reset()}else for(let b=0,y=l.length;b<y;b++)if(l[b]){let v=!1;if(g&&(this.getMatrixAt(b,gu),this.getBoundingSphereAt(b,zd).applyMatrix4(gu),v=!YT.intersectsSphere(zd)),!v){const x=h[b];c[m]=x.start*o,u[m]=x.count,m++}}this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,a,s){this.onBeforeRender(e,null,i,a,s)}}class V0 extends Cm{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new zt(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 B5=new Ce,H5=new Ce,$5=new Jn,QT=new vk,Py=new Zo;class X_e extends va{constructor(e=new oa,n=new V0){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++)B5.fromBufferAttribute(n,i-1),H5.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=B5.distanceTo(H5);e.setAttribute("lineDistance",new Or(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(),Py.copy(r.boundingSphere),Py.applyMatrix4(i),Py.radius+=a,e.ray.intersectsSphere(Py)===!1)return;$5.copy(i).invert(),QT.copy(e.ray).applyMatrix4($5);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=new Ce,u=new Ce,h=new Ce,g=new Ce,m=this.isLineSegments?2:1,b=r.index,v=r.attributes.position;if(b!==null){const x=Math.max(0,s.start),M=Math.min(b.count,s.start+s.count);for(let w=x,C=M-1;w<C;w+=m){const T=b.getX(w),R=b.getX(w+1);if(c.fromBufferAttribute(v,T),u.fromBufferAttribute(v,R),QT.distanceSqToSegment(c,u,g,h)>l)continue;g.applyMatrix4(this.matrixWorld);const j=e.ray.origin.distanceTo(g);j<e.near||j>e.far||n.push({distance:j,point:h.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{const x=Math.max(0,s.start),M=Math.min(v.count,s.start+s.count);for(let w=x,C=M-1;w<C;w+=m){if(c.fromBufferAttribute(v,w),u.fromBufferAttribute(v,w+1),QT.distanceSqToSegment(c,u,g,h)>l)continue;g.applyMatrix4(this.matrixWorld);const R=e.ray.origin.distanceTo(g);R<e.near||R>e.far||n.push({distance:R,point:h.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 o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}}const V5=new Ce,G5=new Ce;class fw extends X_e{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)V5.fromBufferAttribute(n,i),G5.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+V5.distanceTo(G5);e.setAttribute("lineDistance",new Or(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class K_e extends oa{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new Ce,a=new Ce;if(e.index!==null){const s=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,u=l.length;c<u;++c){const h=l[c],g=h.start,m=h.count;for(let b=g,y=g+m;b<y;b+=3)for(let v=0;v<3;v++){const x=o.getX(b+v),M=o.getX(b+(v+1)%3);i.fromBufferAttribute(s,x),a.fromBufferAttribute(s,M),W5(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}}else{const s=e.attributes.position;for(let o=0,l=s.count/3;o<l;o++)for(let c=0;c<3;c++){const u=3*o+c,h=3*o+(c+1)%3;i.fromBufferAttribute(s,u),a.fromBufferAttribute(s,h),W5(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new Or(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function W5(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 Y_e extends Cm{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new zt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new zt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=y7,this.normalScale=new Kt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=pk,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 Z_e extends V0{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 H7 extends va{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new zt(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 JT=new Jn,q5=new Ce,X5=new Ce;class Q_e{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Kt(512,512),this.map=null,this.mapPass=null,this.matrix=new Jn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new uw,this._frameExtents=new Kt(1,1),this._viewportCount=1,this._viewports=[new Gn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;q5.setFromMatrixPosition(e.matrixWorld),n.position.copy(q5),X5.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(X5),n.updateMatrixWorld(),JT.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(JT),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(JT)}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 K5=new Jn,Yg=new Ce,e2=new Ce;class J_e extends Q_e{constructor(){super(new ss(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Kt(4,2),this._viewportCount=6,this._viewports=[new Gn(2,1,1,1),new Gn(0,1,1,1),new Gn(3,1,1,1),new Gn(1,1,1,1),new Gn(3,0,1,1),new Gn(1,0,1,1)],this._cubeDirections=[new Ce(1,0,0),new Ce(-1,0,0),new Ce(0,0,1),new Ce(0,0,-1),new Ce(0,1,0),new Ce(0,-1,0)],this._cubeUps=[new Ce(0,1,0),new Ce(0,1,0),new Ce(0,1,0),new Ce(0,1,0),new Ce(0,0,1),new Ce(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()),Yg.setFromMatrixPosition(e.matrixWorld),r.position.copy(Yg),e2.copy(r.position),e2.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(e2),r.updateMatrixWorld(),i.makeTranslation(-Yg.x,-Yg.y,-Yg.z),K5.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(K5)}}class e1e extends H7{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 J_e}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 t1e extends H7{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class n1e extends oa{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 z3 extends z_e{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 Y5{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(Vi(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const Z5=new Ce,ky=new Ce;class r1e{constructor(e=new Ce,n=new Ce){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){Z5.subVectors(e,this.start),ky.subVectors(this.end,this.start);const r=ky.dot(ky);let a=ky.dot(Z5)/r;return n&&(a=Vi(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 i1e extends fw{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 oa;i.setAttribute("position",new Or(n,3)),i.setAttribute("color",new Or(r,3));const a=new V0({vertexColors:!0,toneMapped:!1});super(i,a),this.type="AxesHelper"}setColors(e,n,r){const i=new zt,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:ow}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ow);class Qo{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"),Qo.nextNameID=Qo.nextNameID||0,this.$name.id=`lil-gui-name-${++Qo.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 a1e extends Qo{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 B3(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 s1e={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:B3,toHexString:B3},s0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},o1e={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=s0.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 s0.toHexString(i)}},l1e={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=s0.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 s0.toHexString(i)}},c1e=[s1e,s0,o1e,l1e];function u1e(t){return c1e.find(e=>e.match(t))}class d1e extends Qo{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=u1e(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=B3(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 t2 extends Qo{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 f1e extends Qo{constructor(e,n,r,i,a,s){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(a);const o=s!==void 0;this.step(o?s:this._getImplicitStep(),o),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,n=!0){return this._step=e,this._stepExplicit=n,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let n=(e-this._min)/(this._max-this._min);n=Math.max(0,Math.min(n,1)),this.$fill.style.width=n*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const n=()=>{let M=parseFloat(this.$input.value);isNaN(M)||(this._stepExplicit&&(M=this._snap(M)),this.setValue(this._clamp(M)))},r=M=>{const w=parseFloat(this.$input.value);isNaN(w)||(this._snapClampSetValue(w+M),this.$input.value=this.getValue())},i=M=>{M.key==="Enter"&&this.$input.blur(),M.code==="ArrowUp"&&(M.preventDefault(),r(this._step*this._arrowKeyMultiplier(M))),M.code==="ArrowDown"&&(M.preventDefault(),r(this._step*this._arrowKeyMultiplier(M)*-1))},a=M=>{this._inputFocused&&(M.preventDefault(),r(this._step*this._normalizeMouseWheel(M)))};let s=!1,o,l,c,u,h;const g=5,m=M=>{o=M.clientX,l=c=M.clientY,s=!0,u=this.getValue(),h=0,window.addEventListener("mousemove",b),window.addEventListener("mouseup",y)},b=M=>{if(s){const w=M.clientX-o,C=M.clientY-l;Math.abs(C)>g?(M.preventDefault(),this.$input.blur(),s=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(w)>g&&y()}if(!s){const w=M.clientY-c;h-=w*this._step*this._arrowKeyMultiplier(M),u+h>this._max?h=this._max-u:u+h<this._min&&(h=this._min-u),this._snapClampSetValue(u+h)}c=M.clientY},y=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",y)},v=()=>{this._inputFocused=!0},x=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",a,{passive:!1}),this.$input.addEventListener("mousedown",m),this.$input.addEventListener("focus",v),this.$input.addEventListener("blur",x)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=(x,M,w,C,T)=>(x-M)/(w-M)*(T-C)+C,n=x=>{const M=this.$slider.getBoundingClientRect();let w=e(x,M.left,M.right,this._min,this._max);this._snapClampSetValue(w)},r=x=>{this._setDraggingStyle(!0),n(x.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",a)},i=x=>{n(x.clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",a)};let s=!1,o,l;const c=x=>{x.preventDefault(),this._setDraggingStyle(!0),n(x.touches[0].clientX),s=!1},u=x=>{x.touches.length>1||(this._hasScrollBar?(o=x.touches[0].clientX,l=x.touches[0].clientY,s=!0):c(x),window.addEventListener("touchmove",h,{passive:!1}),window.addEventListener("touchend",g))},h=x=>{if(s){const M=x.touches[0].clientX-o,w=x.touches[0].clientY-l;Math.abs(M)>Math.abs(w)?c(x):(window.removeEventListener("touchmove",h),window.removeEventListener("touchend",g))}else x.preventDefault(),n(x.touches[0].clientX)},g=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",h),window.removeEventListener("touchend",g)},m=this._callOnFinishChange.bind(this),b=400;let y;const v=x=>{if(Math.abs(x.deltaX)<Math.abs(x.deltaY)&&this._hasScrollBar)return;x.preventDefault();const w=this._normalizeMouseWheel(x)*this._step;this._snapClampSetValue(this.getValue()+w),this.$input.value=this.getValue(),clearTimeout(y),y=setTimeout(m,b)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",u,{passive:!1}),this.$slider.addEventListener("wheel",v,{passive:!1})}_setDraggingStyle(e,n="horizontal"){this.$slider&&this.$slider.classList.toggle("active",e),document.body.classList.toggle("lil-gui-dragging",e),document.body.classList.toggle(`lil-gui-${n}`,e)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(e){let{deltaX:n,deltaY:r}=e;return Math.floor(e.deltaY)!==e.deltaY&&e.wheelDelta&&(n=0,r=-e.wheelDelta/120,r*=this._stepExplicit?1:10),n+-r}_arrowKeyMultiplier(e){let n=this._stepExplicit?1:10;return e.shiftKey?n*=10:e.altKey&&(n/=10),n}_snap(e){const n=Math.round(e/this._step)*this._step;return parseFloat(n.toPrecision(15))}_clamp(e){return e<this._min&&(e=this._min),e>this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){const e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class h1e extends Qo{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 p1e extends Qo{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 m1e=`.lil-gui {
  7397. font-family: var(--font-family);
  7398. font-size: var(--font-size);
  7399. line-height: 1;
  7400. font-weight: normal;
  7401. font-style: normal;
  7402. text-align: left;
  7403. color: var(--text-color);
  7404. user-select: none;
  7405. -webkit-user-select: none;
  7406. touch-action: manipulation;
  7407. --background-color: #1f1f1f;
  7408. --text-color: #ebebeb;
  7409. --title-background-color: #111111;
  7410. --title-text-color: #ebebeb;
  7411. --widget-color: #424242;
  7412. --hover-color: #4f4f4f;
  7413. --focus-color: #595959;
  7414. --number-color: #2cc9ff;
  7415. --string-color: #a2db3c;
  7416. --font-size: 11px;
  7417. --input-font-size: 11px;
  7418. --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  7419. --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
  7420. --padding: 4px;
  7421. --spacing: 4px;
  7422. --widget-height: 20px;
  7423. --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
  7424. --name-width: 45%;
  7425. --slider-knob-width: 2px;
  7426. --slider-input-width: 27%;
  7427. --color-input-width: 27%;
  7428. --slider-input-min-width: 45px;
  7429. --color-input-min-width: 45px;
  7430. --folder-indent: 7px;
  7431. --widget-padding: 0 0 0 3px;
  7432. --widget-border-radius: 2px;
  7433. --checkbox-size: calc(0.75 * var(--widget-height));
  7434. --scrollbar-width: 5px;
  7435. }
  7436. .lil-gui, .lil-gui * {
  7437. box-sizing: border-box;
  7438. margin: 0;
  7439. padding: 0;
  7440. }
  7441. .lil-gui.root {
  7442. width: var(--width, 245px);
  7443. display: flex;
  7444. flex-direction: column;
  7445. background: var(--background-color);
  7446. }
  7447. .lil-gui.root > .title {
  7448. background: var(--title-background-color);
  7449. color: var(--title-text-color);
  7450. }
  7451. .lil-gui.root > .children {
  7452. overflow-x: hidden;
  7453. overflow-y: auto;
  7454. }
  7455. .lil-gui.root > .children::-webkit-scrollbar {
  7456. width: var(--scrollbar-width);
  7457. height: var(--scrollbar-width);
  7458. background: var(--background-color);
  7459. }
  7460. .lil-gui.root > .children::-webkit-scrollbar-thumb {
  7461. border-radius: var(--scrollbar-width);
  7462. background: var(--focus-color);
  7463. }
  7464. @media (pointer: coarse) {
  7465. .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
  7466. --widget-height: 28px;
  7467. --padding: 6px;
  7468. --spacing: 6px;
  7469. --font-size: 13px;
  7470. --input-font-size: 16px;
  7471. --folder-indent: 10px;
  7472. --scrollbar-width: 7px;
  7473. --slider-input-min-width: 50px;
  7474. --color-input-min-width: 65px;
  7475. }
  7476. }
  7477. .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
  7478. --widget-height: 28px;
  7479. --padding: 6px;
  7480. --spacing: 6px;
  7481. --font-size: 13px;
  7482. --input-font-size: 16px;
  7483. --folder-indent: 10px;
  7484. --scrollbar-width: 7px;
  7485. --slider-input-min-width: 50px;
  7486. --color-input-min-width: 65px;
  7487. }
  7488. .lil-gui.autoPlace {
  7489. max-height: 100%;
  7490. position: fixed;
  7491. top: 0;
  7492. right: 15px;
  7493. z-index: 1001;
  7494. }
  7495. .lil-gui .controller {
  7496. display: flex;
  7497. align-items: center;
  7498. padding: 0 var(--padding);
  7499. margin: var(--spacing) 0;
  7500. }
  7501. .lil-gui .controller.disabled {
  7502. opacity: 0.5;
  7503. }
  7504. .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
  7505. pointer-events: none !important;
  7506. }
  7507. .lil-gui .controller > .name {
  7508. min-width: var(--name-width);
  7509. flex-shrink: 0;
  7510. white-space: pre;
  7511. padding-right: var(--spacing);
  7512. line-height: var(--widget-height);
  7513. }
  7514. .lil-gui .controller .widget {
  7515. position: relative;
  7516. display: flex;
  7517. align-items: center;
  7518. width: 100%;
  7519. min-height: var(--widget-height);
  7520. }
  7521. .lil-gui .controller.string input {
  7522. color: var(--string-color);
  7523. }
  7524. .lil-gui .controller.boolean {
  7525. cursor: pointer;
  7526. }
  7527. .lil-gui .controller.color .display {
  7528. width: 100%;
  7529. height: var(--widget-height);
  7530. border-radius: var(--widget-border-radius);
  7531. position: relative;
  7532. }
  7533. @media (hover: hover) {
  7534. .lil-gui .controller.color .display:hover:before {
  7535. content: " ";
  7536. display: block;
  7537. position: absolute;
  7538. border-radius: var(--widget-border-radius);
  7539. border: 1px solid #fff9;
  7540. top: 0;
  7541. right: 0;
  7542. bottom: 0;
  7543. left: 0;
  7544. }
  7545. }
  7546. .lil-gui .controller.color input[type=color] {
  7547. opacity: 0;
  7548. width: 100%;
  7549. height: 100%;
  7550. cursor: pointer;
  7551. }
  7552. .lil-gui .controller.color input[type=text] {
  7553. margin-left: var(--spacing);
  7554. font-family: var(--font-family-mono);
  7555. min-width: var(--color-input-min-width);
  7556. width: var(--color-input-width);
  7557. flex-shrink: 0;
  7558. }
  7559. .lil-gui .controller.option select {
  7560. opacity: 0;
  7561. position: absolute;
  7562. width: 100%;
  7563. max-width: 100%;
  7564. }
  7565. .lil-gui .controller.option .display {
  7566. position: relative;
  7567. pointer-events: none;
  7568. border-radius: var(--widget-border-radius);
  7569. height: var(--widget-height);
  7570. line-height: var(--widget-height);
  7571. max-width: 100%;
  7572. overflow: hidden;
  7573. word-break: break-all;
  7574. padding-left: 0.55em;
  7575. padding-right: 1.75em;
  7576. background: var(--widget-color);
  7577. }
  7578. @media (hover: hover) {
  7579. .lil-gui .controller.option .display.focus {
  7580. background: var(--focus-color);
  7581. }
  7582. }
  7583. .lil-gui .controller.option .display.active {
  7584. background: var(--focus-color);
  7585. }
  7586. .lil-gui .controller.option .display:after {
  7587. font-family: "lil-gui";
  7588. content: "↕";
  7589. position: absolute;
  7590. top: 0;
  7591. right: 0;
  7592. bottom: 0;
  7593. padding-right: 0.375em;
  7594. }
  7595. .lil-gui .controller.option .widget,
  7596. .lil-gui .controller.option select {
  7597. cursor: pointer;
  7598. }
  7599. @media (hover: hover) {
  7600. .lil-gui .controller.option .widget:hover .display {
  7601. background: var(--hover-color);
  7602. }
  7603. }
  7604. .lil-gui .controller.number input {
  7605. color: var(--number-color);
  7606. }
  7607. .lil-gui .controller.number.hasSlider input {
  7608. margin-left: var(--spacing);
  7609. width: var(--slider-input-width);
  7610. min-width: var(--slider-input-min-width);
  7611. flex-shrink: 0;
  7612. }
  7613. .lil-gui .controller.number .slider {
  7614. width: 100%;
  7615. height: var(--widget-height);
  7616. background: var(--widget-color);
  7617. border-radius: var(--widget-border-radius);
  7618. padding-right: var(--slider-knob-width);
  7619. overflow: hidden;
  7620. cursor: ew-resize;
  7621. touch-action: pan-y;
  7622. }
  7623. @media (hover: hover) {
  7624. .lil-gui .controller.number .slider:hover {
  7625. background: var(--hover-color);
  7626. }
  7627. }
  7628. .lil-gui .controller.number .slider.active {
  7629. background: var(--focus-color);
  7630. }
  7631. .lil-gui .controller.number .slider.active .fill {
  7632. opacity: 0.95;
  7633. }
  7634. .lil-gui .controller.number .fill {
  7635. height: 100%;
  7636. border-right: var(--slider-knob-width) solid var(--number-color);
  7637. box-sizing: content-box;
  7638. }
  7639. .lil-gui-dragging .lil-gui {
  7640. --hover-color: var(--widget-color);
  7641. }
  7642. .lil-gui-dragging * {
  7643. cursor: ew-resize !important;
  7644. }
  7645. .lil-gui-dragging.lil-gui-vertical * {
  7646. cursor: ns-resize !important;
  7647. }
  7648. .lil-gui .title {
  7649. height: var(--title-height);
  7650. line-height: calc(var(--title-height) - 4px);
  7651. font-weight: 600;
  7652. padding: 0 var(--padding);
  7653. -webkit-tap-highlight-color: transparent;
  7654. cursor: pointer;
  7655. outline: none;
  7656. text-decoration-skip: objects;
  7657. }
  7658. .lil-gui .title:before {
  7659. font-family: "lil-gui";
  7660. content: "▾";
  7661. padding-right: 2px;
  7662. display: inline-block;
  7663. }
  7664. .lil-gui .title:active {
  7665. background: var(--title-background-color);
  7666. opacity: 0.75;
  7667. }
  7668. @media (hover: hover) {
  7669. body:not(.lil-gui-dragging) .lil-gui .title:hover {
  7670. background: var(--title-background-color);
  7671. opacity: 0.85;
  7672. }
  7673. .lil-gui .title:focus {
  7674. text-decoration: underline var(--focus-color);
  7675. }
  7676. }
  7677. .lil-gui.root > .title:focus {
  7678. text-decoration: none !important;
  7679. }
  7680. .lil-gui.closed > .title:before {
  7681. content: "▸";
  7682. }
  7683. .lil-gui.closed > .children {
  7684. transform: translateY(-7px);
  7685. opacity: 0;
  7686. }
  7687. .lil-gui.closed:not(.transition) > .children {
  7688. display: none;
  7689. }
  7690. .lil-gui.transition > .children {
  7691. transition-duration: 300ms;
  7692. transition-property: height, opacity, transform;
  7693. transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
  7694. overflow: hidden;
  7695. pointer-events: none;
  7696. }
  7697. .lil-gui .children:empty:before {
  7698. content: "Empty";
  7699. padding: 0 var(--padding);
  7700. margin: var(--spacing) 0;
  7701. display: block;
  7702. height: var(--widget-height);
  7703. font-style: italic;
  7704. line-height: var(--widget-height);
  7705. opacity: 0.5;
  7706. }
  7707. .lil-gui.root > .children > .lil-gui > .title {
  7708. border: 0 solid var(--widget-color);
  7709. border-width: 1px 0;
  7710. transition: border-color 300ms;
  7711. }
  7712. .lil-gui.root > .children > .lil-gui.closed > .title {
  7713. border-bottom-color: transparent;
  7714. }
  7715. .lil-gui + .controller {
  7716. border-top: 1px solid var(--widget-color);
  7717. margin-top: 0;
  7718. padding-top: var(--spacing);
  7719. }
  7720. .lil-gui .lil-gui .lil-gui > .title {
  7721. border: none;
  7722. }
  7723. .lil-gui .lil-gui .lil-gui > .children {
  7724. border: none;
  7725. margin-left: var(--folder-indent);
  7726. border-left: 2px solid var(--widget-color);
  7727. }
  7728. .lil-gui .lil-gui .controller {
  7729. border: none;
  7730. }
  7731. .lil-gui label, .lil-gui input, .lil-gui button {
  7732. -webkit-tap-highlight-color: transparent;
  7733. }
  7734. .lil-gui input {
  7735. border: 0;
  7736. outline: none;
  7737. font-family: var(--font-family);
  7738. font-size: var(--input-font-size);
  7739. border-radius: var(--widget-border-radius);
  7740. height: var(--widget-height);
  7741. background: var(--widget-color);
  7742. color: var(--text-color);
  7743. width: 100%;
  7744. }
  7745. @media (hover: hover) {
  7746. .lil-gui input:hover {
  7747. background: var(--hover-color);
  7748. }
  7749. .lil-gui input:active {
  7750. background: var(--focus-color);
  7751. }
  7752. }
  7753. .lil-gui input:disabled {
  7754. opacity: 1;
  7755. }
  7756. .lil-gui input[type=text],
  7757. .lil-gui input[type=number] {
  7758. padding: var(--widget-padding);
  7759. -moz-appearance: textfield;
  7760. }
  7761. .lil-gui input[type=text]:focus,
  7762. .lil-gui input[type=number]:focus {
  7763. background: var(--focus-color);
  7764. }
  7765. .lil-gui input[type=checkbox] {
  7766. appearance: none;
  7767. width: var(--checkbox-size);
  7768. height: var(--checkbox-size);
  7769. border-radius: var(--widget-border-radius);
  7770. text-align: center;
  7771. cursor: pointer;
  7772. }
  7773. .lil-gui input[type=checkbox]:checked:before {
  7774. font-family: "lil-gui";
  7775. content: "✓";
  7776. font-size: var(--checkbox-size);
  7777. line-height: var(--checkbox-size);
  7778. }
  7779. @media (hover: hover) {
  7780. .lil-gui input[type=checkbox]:focus {
  7781. box-shadow: inset 0 0 0 1px var(--focus-color);
  7782. }
  7783. }
  7784. .lil-gui button {
  7785. outline: none;
  7786. cursor: pointer;
  7787. font-family: var(--font-family);
  7788. font-size: var(--font-size);
  7789. color: var(--text-color);
  7790. width: 100%;
  7791. height: var(--widget-height);
  7792. text-transform: none;
  7793. background: var(--widget-color);
  7794. border-radius: var(--widget-border-radius);
  7795. border: none;
  7796. }
  7797. @media (hover: hover) {
  7798. .lil-gui button:hover {
  7799. background: var(--hover-color);
  7800. }
  7801. .lil-gui button:focus {
  7802. box-shadow: inset 0 0 0 1px var(--focus-color);
  7803. }
  7804. }
  7805. .lil-gui button:active {
  7806. background: var(--focus-color);
  7807. }
  7808. @font-face {
  7809. font-family: "lil-gui";
  7810. src: url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff");
  7811. }`;function g1e(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 Q5=!1;class o1{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:a="Controls",closeFolders:s=!1,injectStyles:o=!0,touchStyles:l=!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",c=>{(c.code==="Enter"||c.code==="Space")&&(c.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"),l&&this.domElement.classList.add("allow-touch-styles"),!Q5&&o&&(g1e(m1e),Q5=!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 h1e(this,e,n,r);const s=e[n];switch(typeof s){case"number":return new f1e(this,e,n,r,i,a);case"boolean":return new a1e(this,e,n);case"string":return new p1e(this,e,n);case"function":return new t2(this,e,n)}console.error(`gui.add failed
  7812. property:`,n,`
  7813. object:`,e,`
  7814. value:`,s)}addColor(e,n,r=1){return new d1e(this,e,n,r)}addFolder(e){const n=new o1({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof t2||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 t2)){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 n2(t,e,n,r){return new(n||(n=Promise))((function(i,a){function s(c){try{l(r.next(c))}catch(u){a(u)}}function o(c){try{l(r.throw(c))}catch(u){a(u)}}function l(c){var u;c.done?i(c.value):(u=c.value,u instanceof n?u:new n((function(h){h(u)}))).then(s,o)}l((r=r.apply(t,[])).next())}))}class wk{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 wk(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 Mk{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class J5 extends Mk{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class xu extends Mk{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class eB{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class l1{constructor(e){this.lines=[],this.preamble=new eB(-1,[],0),this.layers=[],this.curZ=0,this.maxZ=0,this.metadata={thumbnails:{}},this.tolerance=0,this.tolerance=e??this.tolerance}parseGCode(e){const n=Array.isArray(e)?e:e.split(`
  7815. `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((a=>a.comment))).thumbnails;for(const[a,s]of Object.entries(i))this.metadata.thumbnails[a]=s;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((n=>this.parseCommand(n)))}parseCommand(e,n=!0){var r;const i=e.trim().split(";"),a=i[0],s=n&&i[1]||void 0,o=a.split(/([a-zA-Z])/g).slice(1).map((u=>u.trim())),l=o.length?`${(r=o[0])===null||r===void 0?void 0:r.toLowerCase()}${o[1]}`:"",c=this.parseParams(o.slice(2));switch(l){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new J5(e,l,c,s);case"t0":return new xu(e,l,s,0);case"t1":return new xu(e,l,s,1);case"t2":return new xu(e,l,s,2);case"t3":return new xu(e,l,s,3);case"t4":return new xu(e,l,s,4);case"t5":return new xu(e,l,s,5);case"t6":return new xu(e,l,s,6);case"t7":return new xu(e,l,s,7);default:return new Mk(e,l,c,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 J5){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 eB(this.layers.length,[],r,s))}}this.maxLayer.commands.push(i)}return this.layers}get maxLayer(){var e;return(e=this.layers[this.layers.length-1])!==null&&e!==void 0?e:this.preamble}parseMetadata(e){const n={};let r;for(const i of e){const a=i.comment;if(!a)continue;const s=a.indexOf("thumbnail begin"),o=a.indexOf("thumbnail end");s>-1?r=wk.parse(a.slice(s+15).trim()):r&&(o==-1?r.chars+=a.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}l1.prototype.parseGcode=l1.prototype.parseGCode;const tB={type:"change"},r2={type:"start"},nB={type:"end"},Dy=new vk,rB=new _u,x1e=Math.cos(70*S7.DEG2RAD);class v1e extends Xf{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Ce,this.cursor=new Ce,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:Wh.ROTATE,MIDDLE:Wh.DOLLY,RIGHT:Wh.PAN},this.touches={ONE:qh.ROTATE,TWO:qh.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return o.phi},this.getAzimuthalAngle=function(){return o.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(z){z.addEventListener("keydown",Le),this._domElementKeyEvents=z},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Le),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(tB),r.update(),a=i.NONE},this.update=(function(){const z=new Ce,ne=new Df().setFromUnitVectors(e.up,new Ce(0,1,0)),K=ne.clone().invert(),Q=new Ce,oe=new Df,Ne=new Ce,Ee=2*Math.PI;return function(re=null){const U=r.object.position;z.copy(U).sub(r.target),z.applyQuaternion(ne),o.setFromVector3(z),r.autoRotate&&a===i.NONE&&k((function(ye){return ye!==null?2*Math.PI/60*r.autoRotateSpeed*ye:2*Math.PI/60/60*r.autoRotateSpeed})(re)),r.enableDamping?(o.theta+=l.theta*r.dampingFactor,o.phi+=l.phi*r.dampingFactor):(o.theta+=l.theta,o.phi+=l.phi);let L=r.minAzimuthAngle,J=r.maxAzimuthAngle;isFinite(L)&&isFinite(J)&&(L<-Math.PI?L+=Ee:L>Math.PI&&(L-=Ee),J<-Math.PI?J+=Ee:J>Math.PI&&(J-=Ee),o.theta=L<=J?Math.max(L,Math.min(J,o.theta)):o.theta>(L+J)/2?Math.max(L,o.theta):Math.min(J,o.theta)),o.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,o.phi)),o.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(u,r.dampingFactor):r.target.add(u),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&R||r.object.isOrthographicCamera?o.radius=Z(o.radius):o.radius=Z(o.radius*c),z.setFromSpherical(o),z.applyQuaternion(K),U.copy(r.target).add(z),r.object.lookAt(r.target),r.enableDamping===!0?(l.theta*=1-r.dampingFactor,l.phi*=1-r.dampingFactor,u.multiplyScalar(1-r.dampingFactor)):(l.set(0,0,0),u.set(0,0,0));let ge=!1;if(r.zoomToCursor&&R){let ye=null;if(r.object.isPerspectiveCamera){const me=z.length();ye=Z(me*c);const et=me-ye;r.object.position.addScaledVector(C,et),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const me=new Ce(T.x,T.y,0);me.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/c)),r.object.updateProjectionMatrix(),ge=!0;const et=new Ce(T.x,T.y,0);et.unproject(r.object),r.object.position.sub(et).add(me),r.object.updateMatrixWorld(),ye=z.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):(Dy.origin.copy(r.object.position),Dy.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(Dy.direction))<x1e?e.lookAt(r.target):(rB.setFromNormalAndCoplanarPoint(r.object.up,r.target),Dy.intersectPlane(rB,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/c)),r.object.updateProjectionMatrix(),ge=!0);return c=1,R=!1,!!(ge||Q.distanceToSquared(r.object.position)>s||8*(1-oe.dot(r.object.quaternion))>s||Ne.distanceToSquared(r.target)>0)&&(r.dispatchEvent(tB),Q.copy(r.object.position),oe.copy(r.object.quaternion),Ne.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",de),r.domElement.removeEventListener("pointerdown",ve),r.domElement.removeEventListener("pointercancel",he),r.domElement.removeEventListener("wheel",we),r.domElement.removeEventListener("pointermove",Pe),r.domElement.removeEventListener("pointerup",he),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",Le),r._domElementKeyEvents=null)};const r=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let a=i.NONE;const s=1e-6,o=new Y5,l=new Y5;let c=1;const u=new Ce,h=new Kt,g=new Kt,m=new Kt,b=new Kt,y=new Kt,v=new Kt,x=new Kt,M=new Kt,w=new Kt,C=new Ce,T=new Kt;let R=!1;const A=[],j={};function N(){return Math.pow(.95,r.zoomSpeed)}function k(z){l.theta-=z}function F(z){l.phi-=z}const I=(function(){const z=new Ce;return function(ne,K){z.setFromMatrixColumn(K,0),z.multiplyScalar(-ne),u.add(z)}})(),W=(function(){const z=new Ce;return function(ne,K){r.screenSpacePanning===!0?z.setFromMatrixColumn(K,1):(z.setFromMatrixColumn(K,0),z.crossVectors(r.object.up,z)),z.multiplyScalar(ne),u.add(z)}})(),D=(function(){const z=new Ce;return function(ne,K){const Q=r.domElement;if(r.object.isPerspectiveCamera){const oe=r.object.position;z.copy(oe).sub(r.target);let Ne=z.length();Ne*=Math.tan(r.object.fov/2*Math.PI/180),I(2*ne*Ne/Q.clientHeight,r.object.matrix),W(2*K*Ne/Q.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(I(ne*(r.object.right-r.object.left)/r.object.zoom/Q.clientWidth,r.object.matrix),W(K*(r.object.top-r.object.bottom)/r.object.zoom/Q.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function B(z){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?c/=z:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function G(z){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?c*=z:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function V(z){if(!r.zoomToCursor)return;R=!0;const ne=r.domElement.getBoundingClientRect(),K=z.clientX-ne.left,Q=z.clientY-ne.top,oe=ne.width,Ne=ne.height;T.x=K/oe*2-1,T.y=-Q/Ne*2+1,C.set(T.x,T.y,1).unproject(r.object).sub(r.object.position).normalize()}function Z(z){return Math.max(r.minDistance,Math.min(r.maxDistance,z))}function Y(z){h.set(z.clientX,z.clientY)}function ee(z){b.set(z.clientX,z.clientY)}function H(){if(A.length===1)h.set(A[0].pageX,A[0].pageY);else{const z=.5*(A[0].pageX+A[1].pageX),ne=.5*(A[0].pageY+A[1].pageY);h.set(z,ne)}}function q(){if(A.length===1)b.set(A[0].pageX,A[0].pageY);else{const z=.5*(A[0].pageX+A[1].pageX),ne=.5*(A[0].pageY+A[1].pageY);b.set(z,ne)}}function ae(){const z=A[0].pageX-A[1].pageX,ne=A[0].pageY-A[1].pageY,K=Math.sqrt(z*z+ne*ne);x.set(0,K)}function ce(z){if(A.length==1)g.set(z.pageX,z.pageY);else{const K=$(z),Q=.5*(z.pageX+K.x),oe=.5*(z.pageY+K.y);g.set(Q,oe)}m.subVectors(g,h).multiplyScalar(r.rotateSpeed);const ne=r.domElement;k(2*Math.PI*m.x/ne.clientHeight),F(2*Math.PI*m.y/ne.clientHeight),h.copy(g)}function xe(z){if(A.length===1)y.set(z.pageX,z.pageY);else{const ne=$(z),K=.5*(z.pageX+ne.x),Q=.5*(z.pageY+ne.y);y.set(K,Q)}v.subVectors(y,b).multiplyScalar(r.panSpeed),D(v.x,v.y),b.copy(y)}function ie(z){const ne=$(z),K=z.pageX-ne.x,Q=z.pageY-ne.y,oe=Math.sqrt(K*K+Q*Q);M.set(0,oe),w.set(0,Math.pow(M.y/x.y,r.zoomSpeed)),B(w.y),x.copy(M)}function ve(z){r.enabled!==!1&&(A.length===0&&(r.domElement.setPointerCapture(z.pointerId),r.domElement.addEventListener("pointermove",Pe),r.domElement.addEventListener("pointerup",he)),(function(ne){A.push(ne)})(z),z.pointerType==="touch"?(function(ne){switch(lt(ne),A.length){case 1:switch(r.touches.ONE){case qh.ROTATE:if(r.enableRotate===!1)return;H(),a=i.TOUCH_ROTATE;break;case qh.PAN:if(r.enablePan===!1)return;q(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case qh.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&ae(),r.enablePan&&q(),a=i.TOUCH_DOLLY_PAN;break;case qh.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&ae(),r.enableRotate&&H(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(r2)})(z):(function(ne){let K;switch(ne.button){case 0:K=r.mouseButtons.LEFT;break;case 1:K=r.mouseButtons.MIDDLE;break;case 2:K=r.mouseButtons.RIGHT;break;default:K=-1}switch(K){case Wh.DOLLY:if(r.enableZoom===!1)return;(function(Q){V(Q),x.set(Q.clientX,Q.clientY)})(ne),a=i.DOLLY;break;case Wh.ROTATE:if(ne.ctrlKey||ne.metaKey||ne.shiftKey){if(r.enablePan===!1)return;ee(ne),a=i.PAN}else{if(r.enableRotate===!1)return;Y(ne),a=i.ROTATE}break;case Wh.PAN:if(ne.ctrlKey||ne.metaKey||ne.shiftKey){if(r.enableRotate===!1)return;Y(ne),a=i.ROTATE}else{if(r.enablePan===!1)return;ee(ne),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(r2)})(z))}function Pe(z){r.enabled!==!1&&(z.pointerType==="touch"?(function(ne){switch(lt(ne),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;ce(ne),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;xe(ne),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(K){r.enableZoom&&ie(K),r.enablePan&&xe(K)})(ne),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(K){r.enableZoom&&ie(K),r.enableRotate&&ce(K)})(ne),r.update();break;default:a=i.NONE}})(z):(function(ne){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function(K){g.set(K.clientX,K.clientY),m.subVectors(g,h).multiplyScalar(r.rotateSpeed);const Q=r.domElement;k(2*Math.PI*m.x/Q.clientHeight),F(2*Math.PI*m.y/Q.clientHeight),h.copy(g),r.update()})(ne);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(K){M.set(K.clientX,K.clientY),w.subVectors(M,x),w.y>0?B(N()):w.y<0&&G(N()),x.copy(M),r.update()})(ne);break;case i.PAN:if(r.enablePan===!1)return;(function(K){y.set(K.clientX,K.clientY),v.subVectors(y,b).multiplyScalar(r.panSpeed),D(v.x,v.y),b.copy(y),r.update()})(ne)}})(z))}function he(z){(function(ne){delete j[ne.pointerId];for(let K=0;K<A.length;K++)if(A[K].pointerId==ne.pointerId)return void A.splice(K,1)})(z),A.length===0&&(r.domElement.releasePointerCapture(z.pointerId),r.domElement.removeEventListener("pointermove",Pe),r.domElement.removeEventListener("pointerup",he)),r.dispatchEvent(nB),a=i.NONE}function we(z){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&(z.preventDefault(),r.dispatchEvent(r2),(function(ne){V(ne),ne.deltaY<0?G(N()):ne.deltaY>0&&B(N()),r.update()})(z),r.dispatchEvent(nB))}function Le(z){r.enabled!==!1&&r.enablePan!==!1&&(function(ne){let K=!1;switch(ne.code){case r.keys.UP:ne.ctrlKey||ne.metaKey||ne.shiftKey?F(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(0,r.keyPanSpeed),K=!0;break;case r.keys.BOTTOM:ne.ctrlKey||ne.metaKey||ne.shiftKey?F(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(0,-r.keyPanSpeed),K=!0;break;case r.keys.LEFT:ne.ctrlKey||ne.metaKey||ne.shiftKey?k(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(r.keyPanSpeed,0),K=!0;break;case r.keys.RIGHT:ne.ctrlKey||ne.metaKey||ne.shiftKey?k(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(-r.keyPanSpeed,0),K=!0}K&&(ne.preventDefault(),r.update())})(z)}function de(z){r.enabled!==!1&&z.preventDefault()}function lt(z){let ne=j[z.pointerId];ne===void 0&&(ne=new Kt,j[z.pointerId]=ne),ne.set(z.pageX,z.pageY)}function $(z){const ne=z.pointerId===A[0].pointerId?A[1]:A[0];return j[ne.pointerId]}r.domElement.addEventListener("contextmenu",de),r.domElement.addEventListener("pointerdown",ve),r.domElement.addEventListener("pointercancel",he),r.domElement.addEventListener("wheel",we,{passive:!1}),this.update()}}bt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Kt(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},Oa.line={uniforms:bk.merge([bt.common,bt.fog,bt.line]),vertexShader:`
  7816. #include <common>
  7817. #include <color_pars_vertex>
  7818. #include <fog_pars_vertex>
  7819. #include <logdepthbuf_pars_vertex>
  7820. #include <clipping_planes_pars_vertex>
  7821. uniform float linewidth;
  7822. uniform vec2 resolution;
  7823. attribute vec3 instanceStart;
  7824. attribute vec3 instanceEnd;
  7825. attribute vec3 instanceColorStart;
  7826. attribute vec3 instanceColorEnd;
  7827. #ifdef WORLD_UNITS
  7828. varying vec4 worldPos;
  7829. varying vec3 worldStart;
  7830. varying vec3 worldEnd;
  7831. #ifdef USE_DASH
  7832. varying vec2 vUv;
  7833. #endif
  7834. #else
  7835. varying vec2 vUv;
  7836. #endif
  7837. #ifdef USE_DASH
  7838. uniform float dashScale;
  7839. attribute float instanceDistanceStart;
  7840. attribute float instanceDistanceEnd;
  7841. varying float vLineDistance;
  7842. #endif
  7843. void trimSegment( const in vec4 start, inout vec4 end ) {
  7844. // trim end segment so it terminates between the camera plane and the near plane
  7845. // conservative estimate of the near plane
  7846. float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
  7847. float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
  7848. float nearEstimate = - 0.5 * b / a;
  7849. float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
  7850. end.xyz = mix( start.xyz, end.xyz, alpha );
  7851. }
  7852. void main() {
  7853. #ifdef USE_COLOR
  7854. vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
  7855. #endif
  7856. #ifdef USE_DASH
  7857. vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
  7858. vUv = uv;
  7859. #endif
  7860. float aspect = resolution.x / resolution.y;
  7861. // camera space
  7862. vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
  7863. vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
  7864. #ifdef WORLD_UNITS
  7865. worldStart = start.xyz;
  7866. worldEnd = end.xyz;
  7867. #else
  7868. vUv = uv;
  7869. #endif
  7870. // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
  7871. // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
  7872. // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
  7873. // perhaps there is a more elegant solution -- WestLangley
  7874. bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
  7875. if ( perspective ) {
  7876. if ( start.z < 0.0 && end.z >= 0.0 ) {
  7877. trimSegment( start, end );
  7878. } else if ( end.z < 0.0 && start.z >= 0.0 ) {
  7879. trimSegment( end, start );
  7880. }
  7881. }
  7882. // clip space
  7883. vec4 clipStart = projectionMatrix * start;
  7884. vec4 clipEnd = projectionMatrix * end;
  7885. // ndc space
  7886. vec3 ndcStart = clipStart.xyz / clipStart.w;
  7887. vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
  7888. // direction
  7889. vec2 dir = ndcEnd.xy - ndcStart.xy;
  7890. // account for clip-space aspect ratio
  7891. dir.x *= aspect;
  7892. dir = normalize( dir );
  7893. #ifdef WORLD_UNITS
  7894. // get the offset direction as perpendicular to the view vector
  7895. vec3 worldDir = normalize( end.xyz - start.xyz );
  7896. vec3 offset;
  7897. if ( position.y < 0.5 ) {
  7898. offset = normalize( cross( start.xyz, worldDir ) );
  7899. } else {
  7900. offset = normalize( cross( end.xyz, worldDir ) );
  7901. }
  7902. // sign flip
  7903. if ( position.x < 0.0 ) offset *= - 1.0;
  7904. float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
  7905. // don't extend the line if we're rendering dashes because we
  7906. // won't be rendering the endcaps
  7907. #ifndef USE_DASH
  7908. // extend the line bounds to encompass endcaps
  7909. start.xyz += - worldDir * linewidth * 0.5;
  7910. end.xyz += worldDir * linewidth * 0.5;
  7911. // shift the position of the quad so it hugs the forward edge of the line
  7912. offset.xy -= dir * forwardOffset;
  7913. offset.z += 0.5;
  7914. #endif
  7915. // endcaps
  7916. if ( position.y > 1.0 || position.y < 0.0 ) {
  7917. offset.xy += dir * 2.0 * forwardOffset;
  7918. }
  7919. // adjust for linewidth
  7920. offset *= linewidth * 0.5;
  7921. // set the world position
  7922. worldPos = ( position.y < 0.5 ) ? start : end;
  7923. worldPos.xyz += offset;
  7924. // project the worldpos
  7925. vec4 clip = projectionMatrix * worldPos;
  7926. // shift the depth of the projected points so the line
  7927. // segments overlap neatly
  7928. vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
  7929. clip.z = clipPose.z * clip.w;
  7930. #else
  7931. vec2 offset = vec2( dir.y, - dir.x );
  7932. // undo aspect ratio adjustment
  7933. dir.x /= aspect;
  7934. offset.x /= aspect;
  7935. // sign flip
  7936. if ( position.x < 0.0 ) offset *= - 1.0;
  7937. // endcaps
  7938. if ( position.y < 0.0 ) {
  7939. offset += - dir;
  7940. } else if ( position.y > 1.0 ) {
  7941. offset += dir;
  7942. }
  7943. // adjust for linewidth
  7944. offset *= linewidth;
  7945. // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
  7946. offset /= resolution.y;
  7947. // select end
  7948. vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
  7949. // back to clip space
  7950. offset *= clip.w;
  7951. clip.xy += offset;
  7952. #endif
  7953. gl_Position = clip;
  7954. vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
  7955. #include <logdepthbuf_vertex>
  7956. #include <clipping_planes_vertex>
  7957. #include <fog_vertex>
  7958. }
  7959. `,fragmentShader:`
  7960. uniform vec3 diffuse;
  7961. uniform float opacity;
  7962. uniform float linewidth;
  7963. #ifdef USE_DASH
  7964. uniform float dashOffset;
  7965. uniform float dashSize;
  7966. uniform float gapSize;
  7967. #endif
  7968. varying float vLineDistance;
  7969. #ifdef WORLD_UNITS
  7970. varying vec4 worldPos;
  7971. varying vec3 worldStart;
  7972. varying vec3 worldEnd;
  7973. #ifdef USE_DASH
  7974. varying vec2 vUv;
  7975. #endif
  7976. #else
  7977. varying vec2 vUv;
  7978. #endif
  7979. #include <common>
  7980. #include <color_pars_fragment>
  7981. #include <fog_pars_fragment>
  7982. #include <logdepthbuf_pars_fragment>
  7983. #include <clipping_planes_pars_fragment>
  7984. vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
  7985. float mua;
  7986. float mub;
  7987. vec3 p13 = p1 - p3;
  7988. vec3 p43 = p4 - p3;
  7989. vec3 p21 = p2 - p1;
  7990. float d1343 = dot( p13, p43 );
  7991. float d4321 = dot( p43, p21 );
  7992. float d1321 = dot( p13, p21 );
  7993. float d4343 = dot( p43, p43 );
  7994. float d2121 = dot( p21, p21 );
  7995. float denom = d2121 * d4343 - d4321 * d4321;
  7996. float numer = d1343 * d4321 - d1321 * d4343;
  7997. mua = numer / denom;
  7998. mua = clamp( mua, 0.0, 1.0 );
  7999. mub = ( d1343 + d4321 * ( mua ) ) / d4343;
  8000. mub = clamp( mub, 0.0, 1.0 );
  8001. return vec2( mua, mub );
  8002. }
  8003. void main() {
  8004. #include <clipping_planes_fragment>
  8005. #ifdef USE_DASH
  8006. if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
  8007. if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
  8008. #endif
  8009. float alpha = opacity;
  8010. #ifdef WORLD_UNITS
  8011. // Find the closest points on the view ray and the line segment
  8012. vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
  8013. vec3 lineDir = worldEnd - worldStart;
  8014. vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
  8015. vec3 p1 = worldStart + lineDir * params.x;
  8016. vec3 p2 = rayEnd * params.y;
  8017. vec3 delta = p1 - p2;
  8018. float len = length( delta );
  8019. float norm = len / linewidth;
  8020. #ifndef USE_DASH
  8021. #ifdef USE_ALPHA_TO_COVERAGE
  8022. float dnorm = fwidth( norm );
  8023. alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
  8024. #else
  8025. if ( norm > 0.5 ) {
  8026. discard;
  8027. }
  8028. #endif
  8029. #endif
  8030. #else
  8031. #ifdef USE_ALPHA_TO_COVERAGE
  8032. // artifacts appear on some hardware if a derivative is taken within a conditional
  8033. float a = vUv.x;
  8034. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8035. float len2 = a * a + b * b;
  8036. float dlen = fwidth( len2 );
  8037. if ( abs( vUv.y ) > 1.0 ) {
  8038. alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
  8039. }
  8040. #else
  8041. if ( abs( vUv.y ) > 1.0 ) {
  8042. float a = vUv.x;
  8043. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8044. float len2 = a * a + b * b;
  8045. if ( len2 > 1.0 ) discard;
  8046. }
  8047. #endif
  8048. #endif
  8049. vec4 diffuseColor = vec4( diffuse, alpha );
  8050. #include <logdepthbuf_fragment>
  8051. #include <color_fragment>
  8052. gl_FragColor = vec4( diffuseColor.rgb, alpha );
  8053. #include <tonemapping_fragment>
  8054. #include <colorspace_fragment>
  8055. #include <fog_fragment>
  8056. #include <premultiplied_alpha_fragment>
  8057. }
  8058. `};class $7 extends Ju{constructor(e){super({type:"LineMaterial",uniforms:bk.clone(Oa.line.uniforms),vertexShader:Oa.line.vertexShader,fragmentShader:Oa.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 iB=new Gs,Oy=new Ce;class V7 extends n1e{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 Or([-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 Or([-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 z3(n,6,1);return this.setAttribute("instanceStart",new Ou(r,3,0)),this.setAttribute("instanceEnd",new Ou(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 z3(n,6,1);return this.setAttribute("instanceColorStart",new Ou(r,3,0)),this.setAttribute("instanceColorEnd",new Ou(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 K_e(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Gs);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),iB.setFromBufferAttribute(n),this.boundingBox.union(iB))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Zo),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++)Oy.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Oy)),Oy.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(Oy));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 aB=new Ce,sB=new Ce,ji=new Gn,Ui=new Gn,Io=new Gn,i2=new Ce,a2=new Jn,Fi=new r1e,oB=new Ce,Ly=new Gs,Iy=new Zo,jo=new Gn;let Uo,Yd;function lB(t,e,n){return jo.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),jo.multiplyScalar(1/jo.w),jo.x=Yd/n.width,jo.y=Yd/n.height,jo.applyMatrix4(t.projectionMatrixInverse),jo.multiplyScalar(1/jo.w),Math.abs(Math.max(jo.x,jo.y))}class b1e extends vo{constructor(e=new V7,n=new $7({color:16777215*Math.random()})){super(e,n),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,n=e.attributes.instanceStart,r=e.attributes.instanceEnd,i=new Float32Array(2*n.count);for(let s=0,o=0,l=n.count;s<l;s++,o+=2)aB.fromBufferAttribute(n,s),sB.fromBufferAttribute(r,s),i[o]=o===0?0:i[o-1],i[o+1]=i[o]+aB.distanceTo(sB);const a=new z3(i,2,1);return e.setAttribute("instanceDistanceStart",new Ou(a,1,0)),e.setAttribute("instanceDistanceEnd",new Ou(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;Uo=e.ray;const s=this.matrixWorld,o=this.geometry,l=this.material;let c,u;Yd=l.linewidth+a,o.boundingSphere===null&&o.computeBoundingSphere(),Iy.copy(o.boundingSphere).applyMatrix4(s),r?c=.5*Yd:c=lB(i,Math.max(i.near,Iy.distanceToPoint(Uo.origin)),l.resolution),Iy.radius+=c,Uo.intersectsSphere(Iy)!==!1&&(o.boundingBox===null&&o.computeBoundingBox(),Ly.copy(o.boundingBox).applyMatrix4(s),r?u=.5*Yd:u=lB(i,Math.max(i.near,Ly.distanceToPoint(Uo.origin)),l.resolution),Ly.expandByScalar(u),Uo.intersectsBox(Ly)!==!1&&(r?(function(h,g){const m=h.matrixWorld,b=h.geometry,y=b.attributes.instanceStart,v=b.attributes.instanceEnd;for(let x=0,M=Math.min(b.instanceCount,y.count);x<M;x++){Fi.start.fromBufferAttribute(y,x),Fi.end.fromBufferAttribute(v,x),Fi.applyMatrix4(m);const w=new Ce,C=new Ce;Uo.distanceSqToSegment(Fi.start,Fi.end,C,w),C.distanceTo(w)<.5*Yd&&g.push({point:C,pointOnLine:w,distance:Uo.origin.distanceTo(C),object:h,face:null,faceIndex:x,uv:null,uv1:null})}})(this,n):(function(h,g,m){const b=g.projectionMatrix,y=h.material.resolution,v=h.matrixWorld,x=h.geometry,M=x.attributes.instanceStart,w=x.attributes.instanceEnd,C=Math.min(x.instanceCount,M.count),T=-g.near;Uo.at(1,Io),Io.w=1,Io.applyMatrix4(g.matrixWorldInverse),Io.applyMatrix4(b),Io.multiplyScalar(1/Io.w),Io.x*=y.x/2,Io.y*=y.y/2,Io.z=0,i2.copy(Io),a2.multiplyMatrices(g.matrixWorldInverse,v);for(let R=0,A=C;R<A;R++){if(ji.fromBufferAttribute(M,R),Ui.fromBufferAttribute(w,R),ji.w=1,Ui.w=1,ji.applyMatrix4(a2),Ui.applyMatrix4(a2),ji.z>T&&Ui.z>T)continue;if(ji.z>T){const I=ji.z-Ui.z,W=(ji.z-T)/I;ji.lerp(Ui,W)}else if(Ui.z>T){const I=Ui.z-ji.z,W=(Ui.z-T)/I;Ui.lerp(ji,W)}ji.applyMatrix4(b),Ui.applyMatrix4(b),ji.multiplyScalar(1/ji.w),Ui.multiplyScalar(1/Ui.w),ji.x*=y.x/2,ji.y*=y.y/2,Ui.x*=y.x/2,Ui.y*=y.y/2,Fi.start.copy(ji),Fi.start.z=0,Fi.end.copy(Ui),Fi.end.z=0;const j=Fi.closestPointToPointParameter(i2,!0);Fi.at(j,oB);const N=S7.lerp(ji.z,Ui.z,j),k=N>=-1&&N<=1,F=i2.distanceTo(oB)<.5*Yd;if(k&&F){Fi.start.fromBufferAttribute(M,R),Fi.end.fromBufferAttribute(w,R),Fi.start.applyMatrix4(v),Fi.end.applyMatrix4(v);const I=new Ce,W=new Ce;Uo.distanceSqToSegment(Fi.start,Fi.end,W,I),m.push({point:W,pointOnLine:I,distance:Uo.origin.distanceTo(W),object:h,face:null,faceIndex:R,uv:null,uv1:null})}}})(this,i,n)))}}class y1e extends fw{constructor(e,n,r,i,a=4473924,s=8947848){a=new zt(a),s=new zt(s);const o=Math.round(e/n);r=Math.round(r/i)*i/2;const l=[],c=[];let u=0;for(let g=-1*(e=o*n/2);g<=e;g+=n){l.push(g,0,-1*r,g,0,r);const m=g===0?a:s;m.toArray(c,u),u+=3,m.toArray(c,u),u+=3,m.toArray(c,u),u+=3,m.toArray(c,u),u+=3}for(let g=-1*r;g<=r;g+=i){l.push(-1*e,0,g,e,0,g);const m=g===0?a:s;m.toArray(c,u),u+=3,m.toArray(c,u),u+=3,m.toArray(c,u),u+=3,m.toArray(c,u),u+=3}const h=new oa;h.setAttribute("position",new Or(l,3)),h.setAttribute("color",new Or(c,3)),super(h,new V0({vertexColors:!0,toneMapped:!1}))}}function _1e(t,e,n,r){const i=(function(s,o,l){s*=.5,o*=.5,l*=.5;const c=new oa,u=[];return u.push(-s,-o,-l,-s,o,-l,-s,o,-l,s,o,-l,s,o,-l,s,-o,-l,s,-o,-l,-s,-o,-l,-s,-o,l,-s,o,l,-s,o,l,s,o,l,s,o,l,s,-o,l,s,-o,l,-s,-o,l,-s,-o,-l,-s,-o,l,-s,o,-l,-s,o,l,s,o,-l,s,o,l,s,-o,-l,s,-o,l),c.setAttribute("position",new Or(u,3)),c})(t,e,n),a=new fw(i,new Z_e({color:new zt(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var Ex=function(){var t=0,e=document.createElement("div");function n(u){return e.appendChild(u.dom),u}function r(u){for(var h=0;h<e.children.length;h++)e.children[h].style.display=h===u?"block":"none";t=u}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(u){u.preventDefault(),r(++t%e.children.length)}),!1);var i=(performance||Date).now(),a=i,s=0,o=n(new Ex.Panel("FPS","#0ff","#002")),l=n(new Ex.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=n(new Ex.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 u=(performance||Date).now();if(l.update(u-i,200),u>=a+1e3&&(o.update(1e3*s/(u-a),100),a=u,s=0,c)){var h=performance.memory;c.update(h.usedJSHeapSize/1048576,h.jsHeapSizeLimit/1048576)}return u},update:function(){i=this.end()},domElement:e,setMode:r}};Ex.Panel=function(t,e,n){var r=1/0,i=0,a=Math.round,s=a(window.devicePixelRatio||1),o=80*s,l=48*s,c=3*s,u=2*s,h=3*s,g=15*s,m=74*s,b=30*s,y=document.createElement("canvas");y.width=o,y.height=l,y.style.cssText="width:80px;height:48px";var v=y.getContext("2d");return v.font="bold "+9*s+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=n,v.fillRect(0,0,o,l),v.fillStyle=e,v.fillText(t,c,u),v.fillRect(h,g,m,b),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(h,g,m,b),{dom:y,update:function(x,M){r=Math.min(r,x),i=Math.max(i,x),v.fillStyle=n,v.globalAlpha=1,v.fillRect(0,0,o,g),v.fillStyle=e,v.fillText(a(x)+" "+t+" ("+a(r)+"-"+a(i)+")",c,u),v.drawImage(y,h+s,g,m-s,b,h,g,m-s,b),v.fillRect(h+m-s,g,s,b),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(h+m-s,g,s,a((1-x/M)*b))}}};var S1e=Ex;class cB{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new o1,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 o1,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 w1e extends oa{constructor(e=[new Ce],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 Ce,s=new Ce,o=new Kt,l=[],c=[],u=[],h=[];function g(m){const[b,y,v]=(function(x){const M=e[x],w=new Ce,C=new Ce,T=new Ce,R=new Ce;w.copy(M).sub(e[x-1]||M).normalize().add((e[x+1]||M).clone().sub(M).normalize()).normalize();let A=Number.MAX_VALUE;const j=Math.abs(w.x),N=Math.abs(w.y),k=Math.abs(w.z);return j<=A&&(A=j,C.set(1,0,0)),N<=A&&(A=N,C.set(0,1,0)),k<=A&&C.set(0,0,1),R.crossVectors(w,C).normalize(),C.crossVectors(w,R),T.crossVectors(w,C),[M,C,T]})(m);for(let x=0;x<=i;x++){const M=x/i*Math.PI*2,w=Math.sin(M),C=-Math.cos(M);s.x=C*y.x+w*v.x,s.y=C*y.y+w*v.y,s.z=C*y.z+w*v.z,s.normalize(),c.push(s.x,s.y,s.z),a.x=b.x+n*s.x*.5,a.y=b.y+n*s.y*.5,a.z=b.z+r*s.z*.5,l.push(a.x,a.y,a.z)}}(function(){for(let m=0;m<e.length;m++)g(m);g(closed===!1?e.length-1:0),(function(){for(let m=0;m<e.length;m++)for(let b=0;b<=i;b++)o.x=m/e.length,o.y=b/i,u.push(o.x,o.y)})(),(function(){for(let m=1;m<e.length;m++)for(let b=1;b<=i;b++){const y=(i+1)*(m-1)+(b-1),v=(i+1)*m+(b-1),x=(i+1)*m+b,M=(i+1)*(m-1)+b;h.push(y,v,M),h.push(v,x,M)}})()})(),this.setIndex(h),this.setAttribute("position",new Or(l,3)),this.setAttribute("normal",new Or(c,3)),this.setAttribute("uv",new Or(u,2))}}class Ax{static get initial(){const e=new Ax;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const s2={h:0,s:0,l:0};class Ip{constructor(e){var n,r,i,a,s,o,l,c,u;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=Ax.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=Ip.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new zt(14737632),this._travelColor=new zt(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 l1(this.minLayerThreshold),this.scene=new F_e,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new zt(e.backgroundColor)),this.targetId=e.targetId,this.endLayer=e.endLayer,this.startLayer=e.startLayer,this.lineWidth=e.lineWidth,this.lineHeight=e.lineHeight,this.buildVolume=e.buildVolume,this.initialCameraPosition=(r=e.initialCameraPosition)!==null&&r!==void 0?r:this.initialCameraPosition,this.debug=(i=e.debug)!==null&&i!==void 0?i:this.debug,this.renderExtrusion=(a=e.renderExtrusion)!==null&&a!==void 0?a:this.renderExtrusion,this.renderTravel=(s=e.renderTravel)!==null&&s!==void 0?s:this.renderTravel,this.nonTravelmoves=(o=e.nonTravelMoves)!==null&&o!==void 0?o:this.nonTravelmoves,this.renderTubes=(l=e.renderTubes)!==null&&l!==void 0?l:this.renderTubes,this.extrusionWidth=(c=e.extrusionWidth)!==null&&c!==void 0?c:this.extrusionWidth,this.devMode=(u=e.devMode)!==null&&u!==void 0?u:this.devMode,this.stats=this.devMode?new S1e:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new zt(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new zt(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new zt(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[m,b]of Object.entries(e.toolColors))this._toolColors[parseInt(m)]=new zt(b)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+ow),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 F3({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const m=document.getElementById(this.targetId);if(!m)throw new Error("Unable to find element "+this.targetId);this.renderer=new F3({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,m.appendChild(this.canvas)}this.camera=new ss(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const h=this.camera.far,g=.8*h;this.scene.fog=new Sk(this._backgroundColor,g,h),this.resize(),this.controls=new v1e(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 zt(r)}else this._extrusionColor=new zt(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?Ip.defaultExtrusionColor:this._extrusionColor instanceof zt?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:Ip.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new zt(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new zt(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new zt(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new zt(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 i1e(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 t1e(13421772,.3*Math.PI),n=new e1e(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 dx;return n.name=e,n.quaternion.setFromEuler(new H0(-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=Ax.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 n2(this,void 0,void 0,(function*(){return this.initScene(),this.renderLayerIndex=0,this.renderFrameLoop(e>0?e:1)}))}renderFrameLoop(e){return new Promise((n=>{const r=()=>{this.renderLayerIndex>this.layers.length-1?n():(this.renderFrame(e),requestAnimationFrame(r))};r()}))}renderFrame(e){this.group=this.createGroup("layer"+this.renderLayerIndex);for(let n=0;n<e&&this.renderLayerIndex+n<this.layers.length;n++)this.renderLayer(this.renderLayerIndex),this.renderLayerIndex++;this.batchGeometries(),this.scene.add(this.group)}renderLayer(e){var n,r,i,a,s,o,l,c;if(e>this.maxLayerIndex)return;const u=this.layers[e],h={extrusion:[],travel:[],z:this.state.z,height:u.height};for(const g of u.commands)if(g.gcode!="g20"){if(g.gcode.startsWith("t")){this.doRenderExtrusion(h,e),h.extrusion=[];const m=g;this.state.t=m.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(g.gcode)>-1){const m=g,b={x:(n=m.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=m.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=m.params.z)!==null&&i!==void 0?i:this.state.z,r:(a=m.params.r)!==null&&a!==void 0?a:this.state.r,e:(s=m.params.e)!==null&&s!==void 0?s:this.state.e,i:(o=m.params.i)!==null&&o!==void 0?o:this.state.i,j:(l=m.params.j)!==null&&l!==void 0?l:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const y=((c=m.params.e)!==null&&c!==void 0?c:0)>0||this.nonTravelmoves.indexOf(g.gcode)>-1;(b.x!=this.state.x||b.y!=this.state.y||b.z!=this.state.z)&&(y&&this.renderExtrusion||!y&&this.renderTravel)&&(g.gcode=="g2"||g.gcode=="g3"||g.gcode=="g02"||g.gcode=="g03"?this.addArcSegment(h,this.state,b,y,g.gcode=="g2"||g.gcode=="g02"):this.addLineSegment(h,this.state,b,y))}this.state.x=b.x,this.state.y=b.y,this.state.z=b.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(h,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(s2),a=new zt().setHSL(s2.h,s2.s,s)}if(n==this.layers.length-1){const s=(r=this._topLayerColor)!==null&&r!==void 0?r:a,o=(i=this._lastSegmentColor)!==null&&i!==void 0?i:s,l=e.extrusion.splice(-3),c=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,s.getHex(),e.height),this.addTubeLine([...c,...l],o.getHex(),e.height)):(this.addLine(e.extrusion,s.getHex()),this.addLine([...c,...l],o.getHex()))}else this.renderTubes?this.addTubeLine(e.extrusion,a.getHex(),e.height):this.addLine(e.extrusion,a.getHex())}this.renderTravel&&this.addLine(e.travel,this._travelColor.getHex())}setInches(){this.beyondFirstMove?console.warn("Switching units after movement is already made is discouraged and is not supported."):this.inches=!0}drawBuildVolume(){if(!this.buildVolume)return;this.scene.add(new y1e(this.buildVolume.x,10,this.buildVolume.y,10));const e=_1e(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 l1(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=Ax.initial,(e=this.devGui)===null||e===void 0||e.reset(),this._geometries={}}resize(){const[e,n]=[this.canvas.offsetWidth,this.canvas.offsetHeight];this.camera.aspect=e/n,this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,n,!1)}addLineSegment(e,n,r,i){(i?e.extrusion:e.travel).push(n.x,n.y,n.z,r.x,r.y,r.z)}addArcSegment(e,n,r,i,a){const s=i?e.extrusion:e.travel,o=n.x,l=n.y,c=n.z,u=r.x,h=r.y,g=r.z;let m=r.r,b=r.i,y=r.j;if(m){const B=u-o,G=h-l,V=Math.sqrt(Math.pow(B/2,2)+Math.pow(G/2,2));m=Math.max(m,V);const Z=Math.pow(B,2)+Math.pow(G,2),Y=Math.pow(m,2)-Z/4;let ee=Math.sqrt(Y/Z);(a&&m<0||!a&&m>0)&&(ee=-ee),b=B/2+G*ee,y=G/2-B*ee}const v=o==u&&l==h,x=o+b,M=l+y,w=Math.sqrt(b*b+y*y),C=Math.atan2(-y,-b),T=Math.atan2(h-M,u-x);let R;v?R=2*Math.PI:(R=a?C-T:T-C,R<0&&(R+=2*Math.PI));let A=w*R/1.8;this.inches&&(A*=25),A<1&&(A=1);let j=R/A;j*=a?-1:1;const N=[];N.push({x:o,y:l,z:c});const k=(c-g)/A;let F=o,I=l,W=c,D=C;for(let B=0;B<A-1;B++)D+=j,F=x+w*Math.cos(D),I=M+w*Math.sin(D),W+=k,N.push({x:F,y:I,z:W});N.push({x:r.x,y:r.y,z:r.z});for(let B=0;B<N.length-1;B++)s.push(N[B].x,N[B].y,N[B].z,N[B+1].x,N[B+1].y,N[B+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new oa;i.setAttribute("position",new Or(e,3)),this.disposables.push(i);const a=new V0({color:n});this.disposables.push(a);const s=new fw(i,a);(r=this.group)===null||r===void 0||r.add(s)}addTubeLine(e,n,r=.2){let i=[];const a=[];for(let s=0;s<e.length;s+=6){const o=e.slice(s,s+9),l=new Ce(o[0],o[1],o[2]),c=new Ce(o[3],o[4],o[5]),u=new Ce(o[6],o[7],o[8]);i.push(l),c.equals(u)||(i.push(c),a.push(i),i=[])}a.forEach((s=>{var o;const l=new w1e(s,this.extrusionWidth,this.lineHeight||r,4);(o=this._geometries)[n]||(o[n]=[]),this._geometries[n].push(l)}))}addThickLine(e,n){var r;if(!e.length||!this.lineWidth)return;const i=new V7;this.disposables.push(i);const a=new $7({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const s=new b1e(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=>n2(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 Y_e({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((o,l)=>3*l.attributes.position.count+o),0),s=new q_e(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 n2(this,void 0,void 0,(function*(){const i=e.getReader();let a,s="",o=0;do{console.debug("reading from stream"),a=yield i.read(),o+=(r=(n=a.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const c=(l=a.value,new TextDecoder("utf-8").decode(l)),u=c.lastIndexOf(`
  8059. `),h=c.slice(0,u);this.parser.parseGCode(s+h),s=c.slice(u)}while(!a.done);var l;console.debug("read from stream",o)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new cB(this):typeof this.devMode=="object"&&(this.devGui=new cB(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())}}Ip.defaultExtrusionColor=new zt("hotpink");const M1e=function(t){return new Ip(t)};function E1e({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const r=E.useRef(null),i=E.useRef(null),[a,s]=E.useState(!0),[o,l]=E.useState(null),[c,u]=E.useState(!1),[h,g]=E.useState(0),[m,b]=E.useState(0);E.useEffect(()=>{if(!r.current)return;const x=r.current,M=M1e({canvas:x,buildVolume:e,backgroundColor:1710618,travelColor:4473924,extrusionColor:44610,topLayerColor:65370,lastSegmentColor:16777215,lineWidth:2,renderTravel:!1,renderExtrusion:!0});i.current=M,s(!0),l(null),u(!1),fetch(t).then(async C=>{if(!C.ok)throw C.status===404&&(await C.json().catch(()=>({}))).detail?.includes("sliced")?(u(!0),new Error("not_sliced")):new Error("Failed to load G-code");return C.text()}).then(C=>{M.processGCode(C);const T=M.layers?.length||0;b(T),g(T),M.render(),s(!1)}).catch(C=>{l(C.message),s(!1)});const w=()=>{if(x.parentElement){const C=x.parentElement.getBoundingClientRect();x.width=C.width,x.height=C.height,M.resize()}};return w(),window.addEventListener("resize",w),()=>{window.removeEventListener("resize",w),M.dispose()}},[t,e]);const y=x=>{if(!i.current)return;const M=Math.max(1,Math.min(x,m));g(M),i.current.render()},v=x=>{y(parseInt(x.target.value,10))};return f.jsxs("div",{className:`relative flex flex-col h-full ${n}`,children:[f.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[f.jsx("canvas",{ref:r,className:"w-full h-full"}),a&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:f.jsxs("div",{className:"text-center",children:[f.jsx($t,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),f.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),c&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:f.jsxs("div",{className:"text-center max-w-sm px-4",children:[f.jsx(Bse,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),f.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),f.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."})]})}),o&&!c&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:f.jsx("div",{className:"text-center text-red-400",children:f.jsx("p",{className:"text-sm",children:o})})})]}),!a&&!o&&!c&&m>0&&f.jsx("div",{className:"mt-4 px-2",children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(Gp,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),f.jsx("button",{onClick:()=>y(h-1),disabled:h<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:f.jsx(Ef,{className:"w-4 h-4"})}),f.jsx("input",{type:"range",min:1,max:m,value:h,onChange:v,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),f.jsx("button",{onClick:()=>y(h+1),disabled:h>=m,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:f.jsx(Mm,{className:"w-4 h-4"})}),f.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[h," / ",m]})]})})]})}function A1e({archiveId:t,title:e,onClose:n}){const[r,i]=E.useState(null),[a,s]=E.useState(null),[o,l]=E.useState(!0);E.useEffect(()=>{const u=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[n]),E.useEffect(()=>{ze.getArchiveCapabilities(t).then(u=>{s(u),u.has_model?i("3d"):u.has_gcode&&i("gcode"),l(!1)}).catch(()=>{s({has_model:!0,has_gcode:!1,build_volume:{x:256,y:256,z:256}}),i("3d"),l(!1)})},[t]);const c=()=>{const u=e||"model",h=`${window.location.origin}${ze.getArchiveForSlicer(t,u)}`;window.location.href=`bambustudioopen://${encodeURIComponent(h)}`};return f.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:f.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:u=>u.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[f.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(qe,{variant:"secondary",size:"sm",onClick:c,children:[f.jsx(xc,{className:"w-4 h-4"}),"Open in Slicer"]}),f.jsx(qe,{variant:"ghost",size:"sm",onClick:n,children:f.jsx(ln,{className:"w-5 h-5"})})]})]}),a&&f.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[f.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:[f.jsx(qx,{className:"w-4 h-4"}),"3D Model",!a.has_model&&f.jsx("span",{className:"text-xs",children:"(not available)"})]}),f.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:[f.jsx(_se,{className:"w-4 h-4"}),"G-code Preview",!a.has_gcode&&f.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),f.jsx("div",{className:"flex-1 overflow-hidden p-4",children:o?f.jsx("div",{className:"w-full h-full flex items-center justify-center",children:f.jsx($t,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?f.jsx(_ge,{url:ze.getArchiveDownload(t),buildVolume:a.build_volume,className:"w-full h-full"}):r==="gcode"&&a?f.jsx(E1e,{gcodeUrl:ze.getArchiveGcode(t),buildVolume:a.build_volume,className:"w-full h-full"}):f.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}function T1e({archiveId:t,archiveName:e,onClose:n,onSuccess:r}){const[i,a]=E.useState(null);E.useEffect(()=>{const u=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[n]);const{data:s,isLoading:o}=Nt({queryKey:["printers"],queryFn:ze.getPrinters}),l=Rt({mutationFn:()=>{if(!i)throw new Error("No printer selected");return ze.reprintArchive(t,i)},onSuccess:()=>{r(),n()}}),c=s?.filter(u=>u.is_active)||[];return f.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",children:f.jsx(Ht,{className:"w-full max-w-md",children:f.jsxs(Gt,{children:[f.jsxs("div",{className:"flex items-center justify-between mb-4",children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:"Re-print"}),f.jsx(qe,{variant:"ghost",size:"sm",onClick:n,children:f.jsx(ln,{className:"w-5 h-5"})})]}),f.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:["Send ",f.jsx("span",{className:"text-white",children:e})," to a printer"]}),o?f.jsx("div",{className:"flex justify-center py-8",children:f.jsx($t,{className:"w-6 h-6 text-bambu-green animate-spin"})}):c.length===0?f.jsx("div",{className:"text-center py-8 text-bambu-gray",children:"No active printers available"}):f.jsx("div",{className:"space-y-2 mb-6",children:c.map(u=>f.jsxs("button",{onClick:()=>a(u.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${i===u.id?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[f.jsx("div",{className:`p-2 rounded-lg ${i===u.id?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:f.jsx(nl,{className:`w-5 h-5 ${i===u.id?"text-bambu-green":"text-bambu-gray"}`})}),f.jsxs("div",{className:"text-left",children:[f.jsx("p",{className:"text-white font-medium",children:u.name}),f.jsxs("p",{className:"text-xs text-bambu-gray",children:[u.model||"Unknown model"," • ",u.ip_address]})]})]},u.id))}),l.isError&&f.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:l.error.message||"Failed to start print"}),f.jsxs("div",{className:"flex gap-3",children:[f.jsx(qe,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),f.jsx(qe,{onClick:()=>l.mutate(),disabled:!i||l.isPending,className:"flex-1",children:l.isPending?f.jsxs(f.Fragment,{children:[f.jsx($t,{className:"w-4 h-4 animate-spin"}),"Sending..."]}):f.jsxs(f.Fragment,{children:[f.jsx(nl,{className:"w-4 h-4"}),"Print"]})})]})]})})})}function C1e({onClose:t,initialFiles:e}){const n=In(),{showToast:r}=sa(),i=E.useRef(null),[a,s]=E.useState(()=>e?.filter(A=>A.name.endsWith(".3mf")).map(A=>({file:A,status:"pending"}))||[]),[o,l]=E.useState(!1),[c,u]=E.useState(),[h,g]=E.useState(null);E.useEffect(()=>{const A=j=>{j.key==="Escape"&&t()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t]);const{data:m}=Nt({queryKey:["printers"],queryFn:ze.getPrinters}),b=Rt({mutationFn:A=>ze.uploadArchivesBulk(A,c),onSuccess:A=>{g(A),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),s(j=>j.map(N=>{const k=A.results.find(I=>I.filename===N.file.name),F=A.errors.find(I=>I.filename===N.file.name);return k?{...N,status:"success",archiveId:k.id}:F?{...N,status:"error",error:F.error}:N})),A.failed===0?r(`${A.uploaded} file${A.uploaded!==1?"s":""} uploaded`):A.uploaded===0?r(`Failed to upload ${A.failed} file${A.failed!==1?"s":""}`,"error"):r(`${A.uploaded} uploaded, ${A.failed} failed`,"warning")},onError:()=>{s(A=>A.map(j=>({...j,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),y=E.useCallback(A=>{A.preventDefault(),l(!0)},[]),v=E.useCallback(A=>{A.preventDefault(),l(!1)},[]),x=E.useCallback(A=>{A.preventDefault(),l(!1);const j=Array.from(A.dataTransfer.files).filter(N=>N.name.endsWith(".3mf"));j.length>0&&s(N=>[...N,...j.map(k=>({file:k,status:"pending"}))])},[]),M=E.useCallback(A=>{const j=Array.from(A.target.files||[]).filter(N=>N.name.endsWith(".3mf"));j.length>0&&s(N=>[...N,...j.map(k=>({file:k,status:"pending"}))]),i.current&&(i.current.value="")},[]),w=E.useCallback(A=>{s(j=>j.filter((N,k)=>k!==A))},[]),C=()=>{if(a.length===0)return;const A=a.filter(j=>j.status==="pending");A.length!==0&&(s(j=>j.map(N=>N.status==="pending"?{...N,status:"uploading"}:N)),b.mutate(A.map(j=>j.file)))},T=a.filter(A=>A.status==="pending").length,R=b.isPending;return f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:f.jsx(Ht,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:f.jsxs(Gt,{className:"p-0 flex flex-col h-full",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),f.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(ln,{className:"w-5 h-5"})})]}),f.jsx("div",{className:"p-4",children:f.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:y,onDragLeave:v,onDrop:x,children:[f.jsx(Ku,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),f.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),f.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),f.jsx(qe,{variant:"secondary",onClick:()=>i.current?.click(),disabled:R,children:"Browse Files"}),f.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:M})]})}),f.jsxs("div",{className:"px-4 pb-4",children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Associate with printer (optional)"}),f.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:c||"",onChange:A=>u(A.target.value?Number(A.target.value):void 0),disabled:R,children:[f.jsx("option",{value:"",children:"No printer"}),m?.map(A=>f.jsx("option",{value:A.id,children:A.name},A.id))]})]}),a.length>0&&f.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:f.jsx("div",{className:"space-y-2",children:a.map((A,j)=>f.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[f.jsx(i9,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),f.jsx("span",{className:"flex-1 text-white text-sm truncate",children:A.file.name}),f.jsxs("span",{className:"text-xs text-bambu-gray",children:[(A.file.size/(1024*1024)).toFixed(1)," MB"]}),A.status==="pending"&&f.jsx("button",{onClick:()=>w(j),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:R,children:f.jsx(ln,{className:"w-4 h-4"})}),A.status==="uploading"&&f.jsx($t,{className:"w-4 h-4 text-bambu-green animate-spin"}),A.status==="success"&&f.jsx(gc,{className:"w-4 h-4 text-bambu-green"}),A.status==="error"&&f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-xs text-red-400",children:A.error}),f.jsx(wo,{className:"w-4 h-4 text-red-400"})]})]},`${A.file.name}-${j}`))})}),h&&f.jsx("div",{className:"px-4 pb-4",children:f.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:f.jsxs("p",{className:"text-sm text-white",children:[f.jsx("span",{className:"text-bambu-green",children:h.uploaded})," uploaded",h.failed>0&&f.jsxs(f.Fragment,{children:[", ",f.jsx("span",{className:"text-red-400",children:h.failed})," failed"]})]})})}),f.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[f.jsx(qe,{variant:"secondary",onClick:t,className:"flex-1",children:h?"Close":"Cancel"}),!h&&f.jsx(qe,{onClick:C,disabled:T===0||R,className:"flex-1",children:R?f.jsxs(f.Fragment,{children:[f.jsx($t,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):f.jsxs(f.Fragment,{children:[f.jsx(Ku,{className:"w-4 h-4"}),"Upload ",T>0&&`(${T})`]})})]})]})})})}const N1e=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"];function R1e({archive:t,onClose:e,existingTags:n=[]}){E.useEffect(()=>{const Z=Y=>{Y.key==="Escape"&&e()};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[e]);const r=In(),[i,a]=E.useState(t.print_name||""),[s,o]=E.useState(t.printer_id),[l,c]=E.useState(t.notes||""),[u,h]=E.useState(t.tags||""),[g,m]=E.useState(t.failure_reason||""),[b,y]=E.useState(t.photos||[]),[v,x]=E.useState(!1),[M,w]=E.useState(!1),C=E.useRef(null),T=E.useRef(null),R=E.useRef(null),{data:A}=Nt({queryKey:["printers"],queryFn:ze.getPrinters}),{data:j}=Nt({queryKey:["archives"],queryFn:()=>ze.getArchives(void 0,1e3,0),enabled:n.length===0}),N=n.length>0?n:[...new Set(j?.flatMap(Z=>Z.tags?.split(",").map(Y=>Y.trim())||[]).filter(Boolean)||[])].sort(),k=u.split(",").map(Z=>Z.trim()).filter(Boolean),F=N.filter(Z=>!k.includes(Z)),I=Z=>{if(!k.includes(Z)){const Y=[...k,Z].join(", ");h(Y)}R.current!==null&&clearTimeout(R.current),C.current?.focus()},W=Z=>{const Y=k.filter(ee=>ee!==Z).join(", ");h(Y)},D=Rt({mutationFn:Z=>ze.updateArchive(t.id,Z),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),e()}}),B=async Z=>{const Y=Z.target.files?.[0];if(Y){x(!0);try{const ee=await ze.uploadArchivePhoto(t.id,Y);y(ee.photos),r.invalidateQueries({queryKey:["archives"]})}catch(ee){console.error("Failed to upload photo:",ee)}finally{x(!1),T.current&&(T.current.value="")}}},G=async Z=>{try{const Y=await ze.deleteArchivePhoto(t.id,Z);y(Y.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(Y){console.error("Failed to delete photo:",Y)}},V=Z=>{Z.preventDefault(),D.mutate({print_name:i||void 0,printer_id:s,notes:l||void 0,tags:u||void 0,failure_reason:t.status==="failed"&&g||void 0})};return f.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:f.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:[f.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),f.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(ln,{className:"w-5 h-5"})})]}),f.jsxs("form",{onSubmit:V,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),f.jsx("input",{type:"text",value:i,onChange:Z=>a(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",placeholder:"Print name"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),f.jsxs("select",{value:s??"",onChange:Z=>o(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:[f.jsx("option",{value:"",children:"No printer"}),A?.map(Z=>f.jsx("option",{value:Z.id,children:Z.name},Z.id))]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),f.jsx("textarea",{value:l,onChange:Z=>c(Z.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..."})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),k.length>0&&f.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:k.map(Z=>f.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[f.jsx(Yx,{className:"w-3 h-3"}),Z,f.jsx("button",{type:"button",onClick:()=>W(Z),className:"ml-0.5 text-bambu-gray hover:text-white",children:f.jsx(ln,{className:"w-3 h-3"})})]},Z))}),f.jsxs("div",{className:"relative",children:[f.jsx("input",{ref:C,type:"text",value:u,onChange:Z=>h(Z.target.value),onFocus:()=>{R.current!==null&&clearTimeout(R.current),w(!0)},onBlur:()=>{R.current=window.setTimeout(()=>w(!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:k.length>0?"Add more tags...":"Add tags..."}),M&&F.length>0&&f.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:[f.jsx("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:"Existing tags (click to add)"}),f.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:F.map(Z=>f.jsx("button",{type:"button",onClick:()=>I(Z),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:Z},Z))})]})]})]}),t.status==="failed"&&f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),f.jsxs("select",{value:g,onChange:Z=>m(Z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"",children:"Select reason..."}),N1e.map(Z=>f.jsx("option",{value:Z,children:Z},Z))]})]}),f.jsxs("div",{children:[f.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[f.jsx(G_,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),f.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[b.map(Z=>f.jsxs("div",{className:"relative group",children:[f.jsx("img",{src:ze.getArchivePhotoUrl(t.id,Z),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),f.jsx("button",{type:"button",onClick:()=>G(Z),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:f.jsx(fr,{className:"w-3 h-3 text-white"})})]},Z)),f.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:[f.jsx("input",{ref:T,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:B,className:"hidden",disabled:v}),v?f.jsx($t,{className:"w-6 h-6 text-bambu-gray animate-spin"}):f.jsx(ra,{className:"w-6 h-6 text-bambu-gray"})]})]}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),f.jsxs("div",{className:"flex gap-3 pt-2",children:[f.jsx(qe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),f.jsxs(qe,{type:"submit",disabled:D.isPending,className:"flex-1",children:[f.jsx(qo,{className:"w-4 h-4"}),D.isPending?"Saving...":"Save"]})]})]})]})})}function P1e({x:t,y:e,items:n,onClose:r}){const i=E.useRef(null);return E.useEffect(()=>{const a=l=>{i.current&&!i.current.contains(l.target)&&r()},s=l=>{l.key==="Escape"&&r()},o=()=>{r()};return document.addEventListener("mousedown",a),document.addEventListener("keydown",s),document.addEventListener("scroll",o,!0),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",s),document.removeEventListener("scroll",o,!0)}},[r]),E.useEffect(()=>{if(i.current){const a=i.current.getBoundingClientRect(),s=window.innerWidth,o=window.innerHeight;let l=t,c=e;t+a.width>s&&(l=s-a.width-8),e+a.height>o&&(c=o-a.height-8),i.current.style.left=`${l}px`,i.current.style.top=`${c}px`}},[t,e]),f.jsx("div",{ref:i,className:"fixed z-50 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden",style:{left:t,top:e},children:n.map((a,s)=>a.divider?f.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},s):f.jsxs("button",{onClick:()=>{a.disabled||(a.onClick(),r())},disabled:a.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${a.disabled?"text-bambu-gray cursor-not-allowed":a.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[a.icon&&f.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:a.icon}),a.label]},s))})}function k1e({selectedIds:t,existingTags:e,onClose:n}){const r=In(),{showToast:i}=sa(),[a,s]=E.useState(""),[o,l]=E.useState(new Set),[c,u]=E.useState("add");E.useEffect(()=>{const y=v=>{v.key==="Escape"&&n()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[n]);const h=Rt({mutationFn:async()=>{const y=Array.from(o);let v=0;for(const x of t)try{const M=await ze.getArchive(x),w=M.tags?M.tags.split(",").map(T=>T.trim()).filter(Boolean):[];let C;c==="add"?C=[...new Set([...w,...y])]:C=w.filter(T=>!o.has(T)),await ze.updateArchive(x,{tags:C.join(", ")}),v++}catch(M){throw console.error(`Failed to update archive ${x}:`,M),new Error(`Failed on archive ${x}: ${M instanceof Error?M.message:"Unknown error"}`)}return{count:v,mode:c,tags:y}},onSuccess:({count:y,mode:v,tags:x})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${v==="add"?"Added":"Removed"} ${x.length} tag${x.length!==1?"s":""} ${v==="add"?"to":"from"} ${y} archive${y!==1?"s":""}`),n()},onError:y=>{i(y.message||"Failed to update tags","error")}}),g=y=>{l(v=>{const x=new Set(v);return x.has(y)?x.delete(y):x.add(y),x})},m=()=>{a.trim()&&!o.has(a.trim())&&(l(y=>new Set([...y,a.trim()])),s(""))},b=y=>{y.key==="Enter"&&(y.preventDefault(),m())};return f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:f.jsx(Ht,{className:"w-full max-w-md",children:f.jsxs(Gt,{className:"p-0",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Yx,{className:"w-5 h-5 text-bambu-green"}),f.jsx("h2",{className:"text-xl font-semibold text-white",children:c==="add"?"Add Tags":"Remove Tags"})]}),f.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(ln,{className:"w-5 h-5"})})]}),f.jsxs("div",{className:"p-4 space-y-4",children:[f.jsxs("p",{className:"text-sm text-bambu-gray",children:[c==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(qe,{size:"sm",variant:c==="add"?"primary":"secondary",onClick:()=>u("add"),children:"Add Tags"}),f.jsx(qe,{size:"sm",variant:c==="remove"?"primary":"secondary",onClick:()=>u("remove"),children:"Remove Tags"})]}),c==="add"&&f.jsxs("div",{className:"flex gap-2",children:[f.jsx("input",{type:"text",placeholder:"Enter new tag...",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:a,onChange:y=>s(y.target.value),onKeyDown:b}),f.jsx(qe,{size:"sm",variant:"secondary",onClick:m,disabled:!a.trim(),children:f.jsx(ra,{className:"w-4 h-4"})})]}),e.length>0&&f.jsxs("div",{children:[f.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),f.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(y=>f.jsx("button",{onClick:()=>g(y),className:`px-2 py-1 rounded text-sm transition-colors ${o.has(y)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:y},y))})]}),o.size>0&&f.jsxs("div",{children:[f.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",c==="add"?"add":"remove",":"]}),f.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(o).map(y=>f.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${c==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[y,f.jsx("button",{onClick:()=>g(y),className:"hover:opacity-70",children:f.jsx(ln,{className:"w-3 h-3"})})]},y))})]})]}),f.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[f.jsx(qe,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),f.jsx(qe,{onClick:()=>h.mutate(),disabled:o.size===0||h.isPending,className:"flex-1",children:h.isPending?f.jsxs(f.Fragment,{children:[f.jsx($t,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):f.jsxs(f.Fragment,{children:[f.jsx(Yx,{className:"w-4 h-4"}),c==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function D1e(t,e){return new Date(t,e+1,0).getDate()}function O1e(t,e){return new Date(t,e,1).getDay()}const L1e=["January","February","March","April","May","June","July","August","September","October","November","December"],I1e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function j1e({archives:t,onArchiveClick:e}){const n=new Date,[r,i]=E.useState(n.getMonth()),[a,s]=E.useState(n.getFullYear()),[o,l]=E.useState(null),c=E.useMemo(()=>{const x=new Map;return t.forEach(M=>{const w=new Date(M.completed_at||M.created_at),C=`${w.getFullYear()}-${String(w.getMonth()+1).padStart(2,"0")}-${String(w.getDate()).padStart(2,"0")}`,T=x.get(C)||[];T.push(M),x.set(C,T)}),x},[t]),u=D1e(a,r),h=O1e(a,r),g=()=>{r===0?(i(11),s(a-1)):i(r-1)},m=()=>{r===11?(i(0),s(a+1)):i(r+1)},b=()=>{i(n.getMonth()),s(n.getFullYear())},y=[];for(let x=0;x<h;x++)y.push(null);for(let x=1;x<=u;x++)y.push(x);const v=o?c.get(o)||[]:[];return f.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[f.jsxs("div",{className:"flex-1",children:[f.jsxs("div",{className:"flex items-center justify-between mb-4",children:[f.jsx("button",{onClick:g,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:f.jsx(Ef,{className:"w-5 h-5 text-bambu-gray"})}),f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsxs("h2",{className:"text-lg font-semibold text-white",children:[L1e[r]," ",a]}),f.jsx("button",{onClick:b,className:"px-2 py-1 text-xs bg-bambu-dark-tertiary hover:bg-bambu-green/20 text-bambu-gray hover:text-white rounded transition-colors",children:"Today"})]}),f.jsx("button",{onClick:m,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:f.jsx(Mm,{className:"w-5 h-5 text-bambu-gray"})})]}),f.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:I1e.map(x=>f.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:x},x))}),f.jsx("div",{className:"grid grid-cols-7 gap-1",children:y.map((x,M)=>{if(x===null)return f.jsx("div",{className:"aspect-square"},`empty-${M}`);const w=`${a}-${String(r+1).padStart(2,"0")}-${String(x).padStart(2,"0")}`,C=c.get(w)||[],T=C.length>0,R=x===n.getDate()&&r===n.getMonth()&&a===n.getFullYear(),A=w===o,j=C.filter(k=>k.status==="completed").length,N=C.filter(k=>k.status==="failed").length;return f.jsxs("button",{onClick:()=>l(A?null:w),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${A?"bg-bambu-green text-white":R?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":T?"bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white":"hover:bg-bambu-dark-tertiary/50 text-bambu-gray"}`,children:[f.jsx("span",{className:`text-sm font-medium ${R&&!A?"text-bambu-green":""}`,children:x}),T&&f.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[f.jsx("div",{className:`w-2 h-2 rounded-full ${N>0&&j===0?"bg-red-400":N>0?"bg-yellow-400":"bg-green-400"}`}),f.jsx("span",{className:"text-xs font-medium",children:C.length})]})]},x)})}),f.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:f.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[f.jsxs("div",{children:[f.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(x=>{const M=new Date(x.completed_at||x.created_at);return M.getMonth()===r&&M.getFullYear()===a}).length}),f.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),f.jsxs("div",{children:[f.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(x=>{const M=new Date(x.completed_at||x.created_at);return M.getMonth()===r&&M.getFullYear()===a&&x.status==="completed"}).length}),f.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),f.jsxs("div",{children:[f.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(x=>{const M=new Date(x.completed_at||x.created_at);return M.getMonth()===r&&M.getFullYear()===a&&x.status==="failed"}).length}),f.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),f.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:o?f.jsxs(f.Fragment,{children:[f.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:new Date(o+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),v.length>0?f.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:v.map(x=>f.jsxs("button",{onClick:()=>e?.(x),className:"w-full flex items-center gap-3 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-left",children:[x.thumbnail_path?f.jsx("img",{src:ze.getArchiveThumbnail(x.id),alt:"",className:"w-12 h-12 rounded object-cover"}):f.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:f.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("p",{className:"text-sm text-white truncate",children:x.print_name||x.filename}),f.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[f.jsx("span",{className:x.status==="failed"?"text-red-400":"text-green-400",children:x.status==="failed"?"Failed":"Completed"}),x.filament_color&&f.jsx("div",{className:"flex gap-0.5",children:x.filament_color.split(",").map((M,w)=>f.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:M}},w))})]})]})]},x.id))}):f.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):f.jsx("div",{className:"text-center py-8",children:f.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function U1e({archiveId:t,archiveName:e,onClose:n}){const r=ze.getArchiveQRCodeUrl(t,300);E.useEffect(()=>{const a=s=>{s.key==="Escape"&&n()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[n]);const i=()=>{const a=document.createElement("a");a.href=r,a.download=`${e}_qrcode.png`,a.click()};return f.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:f.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:a=>a.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),f.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(ln,{className:"w-5 h-5"})})]}),f.jsxs("div",{className:"p-6 flex flex-col items-center",children:[f.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),f.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:f.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),f.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),f.jsxs(qe,{onClick:i,className:"w-full",children:[f.jsx(tl,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function F1e({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[a,s]=E.useState(0),[o,l]=E.useState(!1);if(E.useEffect(()=>{const m=b=>{b.key==="Escape"&&r(),b.key==="ArrowLeft"&&s(y=>Math.max(0,y-1)),b.key==="ArrowRight"&&s(y=>Math.min(n.length-1,y+1))};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r,n.length]),E.useEffect(()=>{a>=n.length&&s(Math.max(0,n.length-1))},[n.length,a]),n.length===0)return r(),null;const c=n[a],u=ze.getArchivePhotoUrl(t,c),h=()=>{const m=document.createElement("a");m.href=u,m.download=`${e}_photo_${a+1}.jpg`,m.click()},g=()=>{i&&l(!0)};return f.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[f.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:m=>m.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[f.jsxs("div",{children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),f.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",a+1," of ",n.length]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(qe,{variant:"secondary",size:"sm",onClick:h,children:[f.jsx(tl,{className:"w-4 h-4"}),"Download"]}),i&&f.jsx(qe,{variant:"secondary",size:"sm",onClick:g,className:"text-red-400 hover:text-red-300",children:f.jsx(fr,{className:"w-4 h-4"})}),f.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:f.jsx(ln,{className:"w-6 h-6"})})]})]}),f.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[a>0&&f.jsx("button",{onClick:()=>s(m=>m-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:f.jsx(Ef,{className:"w-8 h-8 text-white"})}),f.jsx("img",{src:u,alt:`Photo ${a+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),a<n.length-1&&f.jsx("button",{onClick:()=>s(m=>m+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:f.jsx(Mm,{className:"w-8 h-8 text-white"})})]}),n.length>1&&f.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((m,b)=>f.jsx("button",{onClick:()=>s(b),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${b===a?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:f.jsx("img",{src:ze.getArchivePhotoUrl(t,m),alt:`Thumbnail ${b+1}`,className:"w-full h-full object-cover"})},m))})]}),o&&f.jsx(ja,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(c),l(!1)},onCancel:()=>l(!1)})]})}function Bi(t){this.content=t}Bi.prototype={constructor:Bi,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 Bi(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 Bi(n)},addToStart:function(t,e){return new Bi([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Bi(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 Bi(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=Bi.from(t),t.size?new Bi(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Bi.from(t),t.size?new Bi(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Bi.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}};Bi.from=function(t){if(t instanceof Bi)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Bi(e)};function G7(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=G7(i.content,a.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function W7(t,e,n,r){for(let i=t.childCount,a=e.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let s=t.child(--i),o=e.child(--a),l=s.nodeSize;if(s==o){n-=l,r-=l;continue}if(!s.sameMarkup(o))return{a:n,b:r};if(s.isText&&s.text!=o.text){let c=0,u=Math.min(s.text.length,o.text.length);for(;c<u&&s.text[s.text.length-c-1]==o.text[o.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(s.content.size||o.content.size){let c=W7(s.content,o.content,n-1,r-1);if(c)return c}n-=l,r-=l}}class pt{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,a){for(let s=0,o=0;o<n;s++){let l=this.content[s],c=o+l.nodeSize;if(c>e&&r(l,i+o,a||null,s)!==!1&&l.content.size){let u=o+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,n-u),r,i+u)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let a="",s=!0;return this.nodesBetween(e,n,(o,l)=>{let c=o.isText?o.text.slice(Math.max(e,l)-l,n-l):o.isLeaf?i?typeof i=="function"?i(o):i:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&r&&(s?s=!1:a+=r),a+=c},0),a}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<e.content.length;a++)i.push(e.content[a]);return new pt(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let a=0,s=0;s<n;a++){let o=this.content[a],l=s+o.nodeSize;l>e&&((s<e||l>n)&&(o.isText?o=o.cut(Math.max(0,e-s),Math.min(o.text.length,n-s)):o=o.cut(Math.max(0,e-s-1),Math.min(o.content.size,n-s-1))),r.push(o),i+=o.nodeSize),s=l}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 G7(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return W7(this,e,n,r)}findIndex(e){if(e==0)return jy(0,e);if(e==this.size)return jy(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?jy(n+1,a):jy(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 o2={index:0,offset:0};function jy(t,e){return o2.index=t,o2.offset=e,o2}function c1(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(!c1(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!c1(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Kn=class H3{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&&c1(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 H3.none;if(e instanceof H3)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Kn.none=[];class u1 extends Error{}class Mt{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=X7(this.content,e+this.openStart,n);return r&&new Mt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Mt(q7(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 Mt.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 Mt(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 Mt(e,r,i)}}Mt.empty=new Mt(pt.empty,0,0);function q7(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:s,offset:o}=t.findIndex(n);if(i==e||a.isText){if(o!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,a.copy(q7(a.content,e-i-1,n-i-1)))}function X7(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),s=t.maybeChild(i);if(a==e||s.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=X7(s.content,e-a-1,n,s);return o&&t.replaceChild(i,s.copy(o))}function z1e(t,e,n){if(n.openStart>t.depth)throw new u1("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new u1("Inconsistent open depths");return K7(t,e,n,0)}function K7(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=K7(t,e,n,r+1);return a.copy(a.content.replaceChild(i,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,o=s.content;return ff(s,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:s,end:o}=B1e(n,t);return ff(a,Z7(t,s,o,e,r))}else return ff(a,d1(t,e,r))}function Y7(t,e){if(!e.type.compatibleContent(t.type))throw new u1("Cannot join "+e.type.name+" onto "+t.type.name)}function $3(t,e,n){let r=t.node(n);return Y7(r,e.node(n)),r}function df(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Tx(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&&(df(t.nodeAfter,r),a++));for(let o=a;o<s;o++)df(i.child(o),r);e&&e.depth==n&&e.textOffset&&df(e.nodeBefore,r)}function ff(t,e){return t.type.checkContent(e),t.copy(e)}function Z7(t,e,n,r,i){let a=t.depth>i&&$3(t,e,i+1),s=r.depth>i&&$3(n,r,i+1),o=[];return Tx(null,t,i,o),a&&s&&e.index(i)==n.index(i)?(Y7(a,s),df(ff(a,Z7(t,e,n,r,i+1)),o)):(a&&df(ff(a,d1(t,e,i+1)),o),Tx(e,n,i,o),s&&df(ff(s,d1(n,r,i+1)),o)),Tx(r,null,i,o),new pt(o)}function d1(t,e,n){let r=[];if(Tx(null,t,n,r),t.depth>n){let i=$3(t,e,n+1);df(ff(i,d1(t,e,n+1)),r)}return Tx(e,null,n,r),new pt(r)}function B1e(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 o0{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 Kn.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let o=r;r=i,i=o}let a=r.marks;for(var s=0;s<a.length;s++)a[s].type.spec.inclusive===!1&&(!i||!a[s].isInSet(i.marks))&&(a=a[s--].removeFromSet(a));return a}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var a=0;a<r.length;a++)r[a].type.spec.inclusive===!1&&(!i||!r[a].isInSet(i.marks))&&(r=r[a--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new f1(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,a=n;for(let s=e;;){let{index:o,offset:l}=s.content.findIndex(a),c=a-l;if(r.push(s,o,i+l),!c||(s=s.child(o),s.isText))break;a=c-1,i+=l+1}return new o0(n,r,a)}static resolveCached(e,n){let r=uB.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 uB.set(e,r=new H1e);let i=r.elts[r.i]=o0.resolve(e,n);return r.i=(r.i+1)%$1e,i}}class H1e{constructor(){this.elts=[],this.i=0}}const $1e=12,uB=new WeakMap;class f1{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 V1e=Object.create(null);let $u=class V3{constructor(e,n,r,i=Kn.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&&c1(this.attrs,n||e.defaultAttrs||V1e)&&Kn.sameSet(this.marks,r||Kn.none)}copy(e=null){return e==this.content?this:new V3(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new V3(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 Mt.empty;let i=this.resolve(e),a=this.resolve(n),s=r?0:i.sharedDepth(n),o=i.start(s),c=i.node(s).content.cut(i.pos-o,a.pos-o);return new Mt(c,i.depth-s,a.depth-s)}replace(e,n,r){return z1e(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 o0.resolveCached(this,e)}resolveNoCache(e){return o0.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()+")"),Q7(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=pt.empty,i=0,a=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,a),o=s&&s.matchFragment(this.content,n);if(!o||!o.validEnd)return!1;for(let l=i;l<a;l++)if(!this.type.allowsMarks(r.child(l).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=Kn.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(!Kn.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}};$u.prototype.text=void 0;class h1 extends $u{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):Q7(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 h1(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new h1(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 Q7(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Of{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new G1e(e,n);if(r.next==null)return Of.empty;let i=J7(r);r.next&&r.err("Unexpected trailing text");let a=Q1e(Z1e(i));return J1e(a,r),a}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let a=n;i&&a<r;a++)i=i.matchType(e.child(a).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function a(s,o){let l=s.matchFragment(e,r);if(l&&(!n||l.validEnd))return pt.from(o.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:h}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(h)==-1){i.push(h);let g=a(h,o.concat(u));if(g)return g}}return null}return a(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),a=i.match;if(a.matchType(e)){let s=[];for(let o=i;o.type;o=o.via)s.push(o.type);return s.reverse()}for(let s=0;s<a.next.length;s++){let{type:o,next:l}=a.next[s];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!i.type||l.validEnd)&&(r.push({match:o.contentMatch,type:o,via:i}),n[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let a=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)a+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return a}).join(`
  8060. `)}}Of.empty=new Of(!0);class G1e{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 J7(t){let e=[];do e.push(W1e(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function W1e(t){let e=[];do e.push(q1e(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function q1e(t){let e=Y1e(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=X1e(t,e);else break;return e}function dB(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function X1e(t,e){let n=dB(t),r=n;return t.eat(",")&&(t.next!="}"?r=dB(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function K1e(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 Y1e(t){if(t.eat("(")){let e=J7(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=K1e(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 Z1e(t){let e=[[]];return i(a(t,0),n()),e;function n(){return e.push([])-1}function r(s,o,l){let c={term:l,to:o};return e[s].push(c),c}function i(s,o){s.forEach(l=>l.to=o)}function a(s,o){if(s.type=="choice")return s.exprs.reduce((l,c)=>l.concat(a(c,o)),[]);if(s.type=="seq")for(let l=0;;l++){let c=a(s.exprs[l],o);if(l==s.exprs.length-1)return c;i(c,o=n())}else if(s.type=="star"){let l=n();return r(o,l),i(a(s.expr,l),l),[r(l)]}else if(s.type=="plus"){let l=n();return i(a(s.expr,o),l),i(a(s.expr,l),l),[r(l)]}else{if(s.type=="opt")return[r(o)].concat(a(s.expr,o));if(s.type=="range"){let l=o;for(let c=0;c<s.min;c++){let u=n();i(a(s.expr,l),u),l=u}if(s.max==-1)i(a(s.expr,l),l);else for(let c=s.min;c<s.max;c++){let u=n();r(l,u),i(a(s.expr,l),u),l=u}return[r(l)]}else{if(s.type=="name")return[r(o,void 0,s.value)];throw new Error("Unknown expr type")}}}}function eW(t,e){return e-t}function fB(t,e){let n=[];return r(e),n.sort(eW);function r(i){let a=t[i];if(a.length==1&&!a[0].term)return r(a[0].to);n.push(i);for(let s=0;s<a.length;s++){let{term:o,to:l}=a[s];!o&&n.indexOf(l)==-1&&r(l)}}}function Q1e(t){let e=Object.create(null);return n(fB(t,0));function n(r){let i=[];r.forEach(s=>{t[s].forEach(({term:o,to:l})=>{if(!o)return;let c;for(let u=0;u<i.length;u++)i[u][0]==o&&(c=i[u][1]);fB(t,l).forEach(u=>{c||i.push([o,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let a=e[r.join(",")]=new Of(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let o=i[s][1].sort(eW);a.next.push({type:i[s][0],next:e[o.join(",")]||n(o)})}return a}}function J1e(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],a=!i.validEnd,s=[];for(let o=0;o<i.next.length;o++){let{type:l,next:c}=i.next[o];s.push(l.name),a&&!(l.isText||l.hasRequiredAttrs())&&(a=!1),r.indexOf(c)==-1&&r.push(c)}a&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function tW(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 nW(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 rW(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 iW(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new tSe(t,r,e[r]);return n}let hB=class aW{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=iW(e,r.attrs),this.defaultAttrs=tW(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==Of.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:nW(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new $u(this,this.computeAttrs(e),pt.from(n),Kn.setFrom(r))}createChecked(e=null,n,r){return n=pt.from(n),this.checkContent(n),new $u(this,this.computeAttrs(e),n,Kn.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 $u(this,e,n.append(a),Kn.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){rW(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:Kn.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,s)=>r[a]=new aW(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 eSe(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 tSe{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?eSe(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class hw{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=iW(e,i.attrs),this.excluded=null;let a=tW(this.attrs);this.instance=a?new Kn(this,a):null}create(e=null){return!e&&this.instance?this.instance:new Kn(this,nW(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,s)=>r[a]=new hw(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){rW(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class sW{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=Bi.from(e.nodes),n.marks=Bi.from(e.marks||{}),this.nodes=hB.compile(this.spec.nodes,this),this.marks=hw.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let a=this.nodes[i],s=a.spec.content||"",o=a.spec.marks;if(a.contentMatch=r[s]||(r[s]=Of.parse(s,this.nodes)),a.inlineContent=a.contentMatch.inlineContent,a.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!a.isInline||!a.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=a}a.markSet=o=="_"?null:o?pB(this,o.split(" ")):o==""||!a.inlineContent?[]:null}for(let i in this.marks){let a=this.marks[i],s=a.spec.excludes;a.excluded=s==null?[a]:s==""?[]:pB(this,s.split(" "))}this.nodeFromJSON=i=>$u.fromJSON(this,i),this.markFromJSON=i=>Kn.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 hB){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 h1(r,r.defaultAttrs,e,Kn.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 pB(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t.marks[i],s=a;if(a)n.push(a);else for(let o in t.marks){let l=t.marks[o];(i=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function nSe(t){return t.tag!=null}function rSe(t){return t.style!=null}let Cx=class G3{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(nSe(i))this.tags.push(i);else if(rSe(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 gB(this,n,!1);return r.addAll(e,Kn.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new gB(this,n,!0);return r.addAll(e,Kn.none,n.from,n.to),Mt.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(sSe(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let s=a.getAttrs(e);if(s===!1)continue;a.attrs=s||void 0}return a}}}matchStyle(e,n,r,i){for(let a=i?this.styles.indexOf(i)+1:0;a<this.styles.length;a++){let s=this.styles[a],o=s.style;if(!(o.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||o.length>e.length&&(o.charCodeAt(e.length)!=61||o.slice(e.length+1)!=n))){if(s.getAttrs){let l=s.getAttrs(n);if(l===!1)continue;s.attrs=l||void 0}return s}}}static schemaRules(e){let n=[];function r(i){let a=i.priority==null?50:i.priority,s=0;for(;s<n.length;s++){let o=n[s];if((o.priority==null?50:o.priority)<a)break}n.splice(s,0,i)}for(let i in e.marks){let a=e.marks[i].spec.parseDOM;a&&a.forEach(s=>{r(s=xB(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=xB(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new G3(e,G3.schemaRules(e)))}};const oW={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},iSe={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},lW={ol:!0,ul:!0},l0=1,W3=2,Nx=4;function mB(t,e,n){return e!=null?(e?l0:0)|(e==="full"?W3:0):t&&t.whitespace=="pre"?l0|W3:n&~Nx}class Uy{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=Kn.none,this.match=a||(s&Nx?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&l0)){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&&!oW.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class gB{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=mB(null,n.preserveWhitespace,0)|(r?Nx:0);i?a=new Uy(i.type,i.attrs,Kn.none,!0,n.topMatch||i.type.contentMatch,s):r?a=new Uy(null,null,Kn.none,!0,null,s):a=new Uy(e.schema.topNodeType,null,Kn.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&W3?"full":this.localPreserveWS||(i.options&l0)>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,`
  8061. `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let o=r.split(/\r?\n|\r/);for(let l=0;l<o.length;l++)l&&this.insertNode(s.linebreakReplacement.create(),n,!0),o[l]&&this.insertNode(s.text(o[l]),n,!/\S/.test(o[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=i.content[i.content.length-1],l=e.previousSibling;(!o||l&&l.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,a=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),o;lW.hasOwnProperty(s)&&this.parser.normalizeLists&&aSe(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));e:if(l?l.ignore:iSe.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,u=this.needsBlock;if(oW.hasOwnProperty(s))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),c=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let h=l&&l.skip?n:this.readStyles(e,n);h&&this.addAll(e,h),c&&this.sync(a),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,l,c,l.consuming===!1?o:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
  8062. `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let a=this.parser.matchedStyles[i],s=r.getPropertyValue(a);if(s)for(let o=void 0;;){let l=this.parser.matchStyle(a,s,this,o);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(c=>!l.clearMark(c)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)o=l;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 l=this.enter(s,n.attrs||null,r,n.preserveWhitespace);l&&(a=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let o=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}a&&this.sync(o)&&this.open--}addAll(e,n,r,i){let a=r||0;for(let s=r?e.childNodes[r]:e.firstChild,o=i==null?null:e.childNodes[i];s!=o;s=s.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(s,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;for(let s=this.open,o=0;s>=0;s--){let l=this.nodes[s],c=l.findWrapping(e);if(c&&(!i||i.length>c.length+o)&&(i=c,a=l,!c.length))break;if(l.solid){if(r)break;o+=2}}if(!i)return null;this.sync(a);for(let s=0;s<i.length;s++)n=this.enterInner(i[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(n=this.enterInner(a,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let a=this.top;a.match&&(a.match=a.match.matchType(e.type));let s=Kn.none;for(let o of i.concat(e.marks))(a.type?a.type.allowsMarkType(o.type):vB(o.type,e.type))&&(s=o.addToSet(s));return a.content.push(e.mark(s)),!0}return!1}enter(e,n,r,i){let a=this.findPlace(e.create(n),r,!1);return a&&(a=this.enterInner(e,n,r,!0,i)),a}enterInner(e,n,r,i=!1,a){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let o=mB(e,a,s.options);s.options&Nx&&s.content.length==0&&(o|=Nx);let l=Kn.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):vB(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new Uy(e,n,l,i,null,o)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=l0)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),a=-(r?r.depth+1:0)+(i?0:1),s=(o,l)=>{for(;o>=0;o--){let c=n[o];if(c==""){if(o==n.length-1||o==0)continue;for(;l>=a;l--)if(s(o-1,l))return!0;return!1}else{let u=l>0||l==0&&i?this.nodes[l].type:r&&l>=a?r.node(l-a).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;l--}}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 aSe(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&lW.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function sSe(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function xB(t){let e={};for(let n in t)e[n]=t[n];return e}function vB(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let a=[],s=o=>{a.push(o);for(let l=0;l<o.edgeCount;l++){let{type:c,next:u}=o.edge(l);if(c==e||a.indexOf(u)<0&&s(u))return!0}};if(s(i.contentMatch))return!0}}class Kf{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=l2(n).createDocumentFragment());let i=r,a=[];return e.forEach(s=>{if(a.length||s.marks.length){let o=0,l=0;for(;o<a.length&&l<s.marks.length;){let c=s.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(a[o][0])||c.type.spec.spanning===!1)break;o++,l++}for(;o<a.length;)i=a.pop()[1];for(;l<s.marks.length;){let c=s.marks[l++],u=this.serializeMark(c,s.isInline,n);u&&(a.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=T_(l2(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&&T_(l2(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return T_(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Kf(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=bB(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return bB(e.marks)}}function bB(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function l2(t){return t.document||window.document}const yB=new WeakMap;function oSe(t){let e=yB.get(t);return e===void 0&&yB.set(t,e=lSe(t)),e}function lSe(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 T_(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=oSe(r))&&a.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let o,l=n?t.createElementNS(n,i):t.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let h in c)if(c[h]!=null){let g=h.indexOf(" ");g>0?l.setAttributeNS(h.slice(0,g),h.slice(g+1),c[h]):h=="style"&&l.style?l.style.cssText=c[h]:l.setAttribute(h,c[h])}}for(let h=u;h<e.length;h++){let g=e[h];if(g===0){if(h<e.length-1||h>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:m,contentDOM:b}=T_(t,g,n,r);if(l.appendChild(m),b){if(o)throw new RangeError("Multiple content holes");o=b}}}return{dom:l,contentDOM:o}}const cW=65535,uW=Math.pow(2,16);function cSe(t,e){return t+e*uW}function _B(t){return t&cW}function uSe(t){return(t-(t&cW))/uW}const dW=1,fW=2,C_=4,hW=8;class q3{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&hW)>0}get deletedBefore(){return(this.delInfo&(dW|C_))>0}get deletedAfter(){return(this.delInfo&(fW|C_))>0}get deletedAcross(){return(this.delInfo&C_)>0}}class ls{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ls.empty)return ls.empty}recover(e){let n=0,r=_B(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+uSe(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,a=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?i:0);if(l>e)break;let c=this.ranges[o+a],u=this.ranges[o+s],h=l+c;if(e<=h){let g=c?e==l?-1:e==h?1:n:n,m=l+i+(g<0?0:u);if(r)return m;let b=e==(n<0?l:h)?null:cSe(o/3,e-l),y=e==l?fW:e==h?dW:C_;return(n<0?e!=l:e!=h)&&(y|=hW),new q3(m,y,b)}i+=u-c}return r?e+i:new q3(e+i,0,null)}touches(e,n){let r=0,i=_B(n),a=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[o+a],u=l+c;if(e<=u&&o==i*3)return!0;r+=this.ranges[o+s]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,a=0;i<this.ranges.length;i+=3){let s=this.ranges[i],o=s-(this.inverted?a:0),l=s+(this.inverted?0:a),c=this.ranges[i+n],u=this.ranges[i+r];e(o,o+c,l,l+u),a+=u-c}}invert(){return new ls(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ls.empty:new ls(e<0?[0,-e,0]:[0,0,e])}}ls.empty=new ls([]);class c0{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 c0(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 c0;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let a=this.from;a<this.to;a++){let s=this._maps[a],o=s.mapResult(e,n);if(o.recover!=null){let l=this.getMirror(a);if(l!=null&&l>a&&l<this.to){a=l,e=this._maps[l].recover(o.recover);continue}}i|=o.delInfo,e=o.pos}return r?e:new q3(e,i,null)}}const c2=Object.create(null);let la=class{getMap(){return ls.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=c2[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 c2)throw new RangeError("Duplicate use of step JSON ID "+e);return c2[e]=n,n.prototype.jsonID=e,n}};class Gr{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Gr(e,null)}static fail(e){return new Gr(null,e)}static fromReplace(e,n,r,i){try{return Gr.ok(e.replace(n,r,i))}catch(a){if(a instanceof u1)return Gr.fail(a.message);throw a}}}function Ek(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(Ek(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return pt.fromArray(r)}class Lu extends la{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 Mt(Ek(n.content,(s,o)=>!s.isAtom||!o.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return Gr.fromReplace(e,this.from,this.to,a)}invert(){return new bo(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Lu(n.pos,r.pos,this.mark)}merge(e){return e instanceof Lu&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Lu(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 Lu(n.from,n.to,e.markFromJSON(n.mark))}}la.jsonID("addMark",Lu);class bo extends la{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 Mt(Ek(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Gr.fromReplace(e,this.from,this.to,r)}invert(){return new Lu(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new bo(n.pos,r.pos,this.mark)}merge(e){return e instanceof bo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new bo(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new bo(n.from,n.to,e.markFromJSON(n.mark))}}la.jsonID("removeMark",bo);class Iu extends la{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Gr.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Gr.fromReplace(e,this.pos,this.pos+1,new Mt(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 Iu(this.pos,n.marks[i]);return new Iu(this.pos,this.mark)}}return new Lf(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Iu(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 Iu(n.pos,e.markFromJSON(n.mark))}}la.jsonID("addNodeMark",Iu);class Lf extends la{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Gr.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Gr.fromReplace(e,this.pos,this.pos+1,new Mt(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 Iu(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Lf(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 Lf(n.pos,e.markFromJSON(n.mark))}}la.jsonID("removeNodeMark",Lf);class Ei extends la{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&X3(e,this.from,this.to)?Gr.fail("Structure replace would overwrite content"):Gr.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ls([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ei(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 Ei(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ei)||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?Mt.empty:new Mt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ei(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?Mt.empty:new Mt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ei(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 Ei(n.from,n.to,Mt.fromJSON(e,n.slice),!!n.structure)}}la.jsonID("replace",Ei);class Ti extends la{constructor(e,n,r,i,a,s,o=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=a,this.insert=s,this.structure=o}apply(e){if(this.structure&&(X3(e,this.from,this.gapFrom)||X3(e,this.gapTo,this.to)))return Gr.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Gr.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Gr.fromReplace(e,this.from,this.to,r):Gr.fail("Content does not fit in gap")}getMap(){return new ls([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 Ti(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 Ti(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 Ti(n.from,n.to,n.gapFrom,n.gapTo,Mt.fromJSON(e,n.slice),n.insert,!!n.structure)}}la.jsonID("replaceAround",Ti);function X3(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 dSe(t,e,n,r){let i=[],a=[],s,o;t.doc.nodesBetween(e,n,(l,c,u)=>{if(!l.isInline)return;let h=l.marks;if(!r.isInSet(h)&&u.type.allowsMarkType(r.type)){let g=Math.max(c,e),m=Math.min(c+l.nodeSize,n),b=r.addToSet(h);for(let y=0;y<h.length;y++)h[y].isInSet(b)||(s&&s.to==g&&s.mark.eq(h[y])?s.to=m:i.push(s=new bo(g,m,h[y])));o&&o.to==g?o.to=m:a.push(o=new Lu(g,m,r))}}),i.forEach(l=>t.step(l)),a.forEach(l=>t.step(l))}function fSe(t,e,n,r){let i=[],a=0;t.doc.nodesBetween(e,n,(s,o)=>{if(!s.isInline)return;a++;let l=null;if(r instanceof hw){let c=s.marks,u;for(;u=r.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(l=[r]):l=s.marks;if(l&&l.length){let c=Math.min(o+s.nodeSize,n);for(let u=0;u<l.length;u++){let h=l[u],g;for(let m=0;m<i.length;m++){let b=i[m];b.step==a-1&&h.eq(i[m].style)&&(g=b)}g?(g.to=c,g.step=a):i.push({style:h,from:Math.max(o,e),to:c,step:a})}}}),i.forEach(s=>t.step(new bo(s.from,s.to,s.style)))}function Ak(t,e,n,r=n.contentMatch,i=!0){let a=t.doc.nodeAt(e),s=[],o=e+1;for(let l=0;l<a.childCount;l++){let c=a.child(l),u=o+c.nodeSize,h=r.matchType(c.type);if(!h)s.push(new Ei(o,u,Mt.empty));else{r=h;for(let g=0;g<c.marks.length;g++)n.allowsMarkType(c.marks[g].type)||t.step(new bo(o,u,c.marks[g]));if(i&&c.isText&&n.whitespace!="pre"){let g,m=/\r?\n|\r/g,b;for(;g=m.exec(c.text);)b||(b=new Mt(pt.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new Ei(o+g.index,o+g.index+g[0].length,b))}}o=u}if(!r.validEnd){let l=r.fillBefore(pt.empty,!0);t.replace(o,o,new Mt(l,0,0))}for(let l=s.length-1;l>=0;l--)t.step(s[l])}function hSe(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Rm(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,a=0;;--r){let s=t.$from.node(r),o=t.$from.index(r)+i,l=t.$to.indexAfter(r)-a;if(r<t.depth&&s.canReplace(o,l,n))return r;if(r==0||s.type.spec.isolating||!hSe(s,o,l))break;o&&(i=1),l<s.childCount&&(a=1)}return null}function pSe(t,e,n){let{$from:r,$to:i,depth:a}=e,s=r.before(a+1),o=i.after(a+1),l=s,c=o,u=pt.empty,h=0;for(let b=a,y=!1;b>n;b--)y||r.index(b)>0?(y=!0,u=pt.from(r.node(b).copy(u)),h++):l--;let g=pt.empty,m=0;for(let b=a,y=!1;b>n;b--)y||i.after(b+1)<i.end(b)?(y=!0,g=pt.from(i.node(b).copy(g)),m++):c++;t.step(new Ti(l,c,s,o,new Mt(u.append(g),h,m),u.size-h,!0))}function Tk(t,e,n=null,r=t){let i=mSe(t,e),a=i&&gSe(r,e);return a?i.map(SB).concat({type:e,attrs:n}).concat(a.map(SB)):null}function SB(t){return{type:t,attrs:null}}function mSe(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 gSe(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 l=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;l&&c<i;c++)l=l.matchType(n.child(c).type);return!l||!l.validEnd?null:s}function xSe(t,e,n){let r=pt.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let o=n[s].type.contentMatch.matchFragment(r);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=pt.from(n[s].type.create(n[s].attrs,r))}let i=e.start,a=e.end;t.step(new Ti(i,a,i,a,new Mt(r,0,0),n.length,!0))}function vSe(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let a=t.steps.length;t.doc.nodesBetween(e,n,(s,o)=>{let l=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,l)&&bSe(t.doc,t.mapping.slice(a).map(o),r)){let c=null;if(r.schema.linebreakReplacement){let m=r.whitespace=="pre",b=!!r.contentMatch.matchType(r.schema.linebreakReplacement);m&&!b?c=!1:!m&&b&&(c=!0)}c===!1&&mW(t,s,o,a),Ak(t,t.mapping.slice(a).map(o,1),r,void 0,c===null);let u=t.mapping.slice(a),h=u.map(o,1),g=u.map(o+s.nodeSize,1);return t.step(new Ti(h,g,h+1,g-1,new Mt(pt.from(r.create(l,null,s.marks)),0,0),1,!0)),c===!0&&pW(t,s,o,a),!1}})}function pW(t,e,n,r){e.forEach((i,a)=>{if(i.isText){let s,o=/\r?\n|\r/g;for(;s=o.exec(i.text);){let l=t.mapping.slice(r).map(n+1+a+s.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function mW(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(`
  8063. `))}})}function bSe(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function ySe(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 Ti(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Mt(pt.from(s),0,0),1,!0))}function dc(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 c=i.depth-1,u=n-2;c>a;c--,u--){let h=i.node(c),g=i.index(c);if(h.type.spec.isolating)return!1;let m=h.content.cutByIndex(g,h.childCount),b=r&&r[u+1];b&&(m=m.replaceChild(0,b.type.create(b.attrs)));let y=r&&r[u]||h;if(!h.canReplace(g+1,h.childCount)||!y.type.validContent(m))return!1}let o=i.indexAfter(a),l=r&&r[0];return i.node(a).canReplaceWith(o,o,l?l.type:i.node(a+1).type)}function _Se(t,e,n=1,r){let i=t.doc.resolve(e),a=pt.empty,s=pt.empty;for(let o=i.depth,l=i.depth-n,c=n-1;o>l;o--,c--){a=pt.from(i.node(o).copy(a));let u=r&&r[c];s=pt.from(u?u.type.create(u.attrs,s):i.node(o).copy(s))}t.step(new Ei(e,e,new Mt(a.append(s),n,n),!0))}function ld(t,e){let n=t.resolve(e),r=n.index();return gW(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function SSe(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 gW(t,e){return!!(t&&e&&!t.isLeaf&&SSe(t,e))}function pw(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let a,s,o=r.index(i);if(i==r.depth?(a=r.nodeBefore,s=r.nodeAfter):n>0?(a=r.node(i+1),o++,s=r.node(i).maybeChild(o)):(a=r.node(i).maybeChild(o-1),s=r.node(i+1)),a&&!a.isTextblock&&gW(a,s)&&r.node(i).canReplace(o,o+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function wSe(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 u=s.whitespace=="pre",h=!!s.contentMatch.matchType(i);u&&!h?r=!1:!u&&h&&(r=!0)}let o=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);mW(t,u.node(),u.before(),o)}s.inlineContent&&Ak(t,e+n-1,s,a.node().contentMatchAt(a.index()),r==null);let l=t.mapping.slice(o),c=l.map(e-n);if(t.step(new Ei(c,l.map(e+n,-1),Mt.empty,!0)),r===!0){let u=t.doc.resolve(c);pW(t,u.node(),u.before(),t.steps.length)}return t}function MSe(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 xW(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let a=0;a<n.openStart;a++)i=i.firstChild.content;for(let a=1;a<=(n.openStart==0&&n.size?2:1);a++)for(let s=r.depth;s>=0;s--){let o=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,l=r.index(s)+(o>0?1:0),c=r.node(s),u=!1;if(a==1)u=c.canReplace(l,l,i);else{let h=c.contentMatchAt(l).findWrapping(i.firstChild.type);u=h&&c.canReplaceWith(l,l,h[0])}if(u)return o==0?r.pos:o<0?r.before(s+1):r.after(s+1)}return null}function mw(t,e,n=e,r=Mt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return vW(i,a,r)?new Ei(e,n,r):new ESe(i,a,r).fit()}function vW(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class ESe{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 c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let a=this.placed,s=r.depth,o=i.depth;for(;s&&o&&a.childCount==1;)a=a.firstChild.content,s--,o--;let l=new Mt(a,s,o);return e>-1?new Ti(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new Ei(r.pos,i.pos,l):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=u2(this.unplaced.content,r-1).firstChild,i=a.content):i=this.unplaced.content;let s=i.firstChild;for(let o=this.depth;o>=0;o--){let{type:l,match:c}=this.frontier[o],u,h=null;if(n==1&&(s?c.matchType(s.type)||(h=c.fillBefore(pt.from(s),!1)):a&&l.compatibleContent(a.type)))return{sliceDepth:r,frontierDepth:o,parent:a,inject:h};if(n==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:o,parent:a,wrap:u};if(a&&c.matchType(a.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=u2(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Mt(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=u2(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Mt(fx(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Mt(fx(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let y=0;y<a.length;y++)this.openFrontierNode(a[y]);let s=this.unplaced,o=r?r.content:s.content,l=s.openStart-e,c=0,u=[],{match:h,type:g}=this.frontier[n];if(i){for(let y=0;y<i.childCount;y++)u.push(i.child(y));h=h.matchFragment(i)}let m=o.size+e-(s.content.size-s.openEnd);for(;c<o.childCount;){let y=o.child(c),v=h.matchType(y.type);if(!v)break;c++,(c>1||l==0||y.content.size)&&(h=v,u.push(bW(y.mark(g.allowedMarks(y.marks)),c==1?l:0,c==o.childCount?m:-1)))}let b=c==o.childCount;b||(m=-1),this.placed=hx(this.placed,n,pt.from(u)),this.frontier[n].match=h,b&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,v=o;y<m;y++){let x=v.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),v=x.content}this.unplaced=b?e==0?Mt.empty:new Mt(fx(s.content,e-1,1),e-1,m<0?s.openEnd:e-1):new Mt(fx(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!d2(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=d2(e,n,i,r,a);if(s){for(let o=n-1;o>=0;o--){let{match:l,type:c}=this.frontier[o],u=d2(e,o,c,l,!0);if(!u||u.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=hx(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=hx(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=hx(this.placed,this.frontier.length,n))}}function fx(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(fx(t.firstChild.content,e-1,n)))}function hx(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(hx(t.lastChild.content,e-1,n)))}function u2(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function bW(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,bW(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 d2(t,e,n,r,i){let a=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==a.childCount&&!n.compatibleContent(a.type))return null;let o=r.fillBefore(a.content,!0,s);return o&&!ASe(n,a.content,s)?o:null}function ASe(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function TSe(t){return t.spec.defining||t.spec.definingForContent}function CSe(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(vW(i,a,r))return t.step(new Ei(e,n,r));let s=_W(i,a);s[s.length-1]==0&&s.pop();let o=-(i.depth+1);s.unshift(o);for(let g=i.depth,m=i.pos-1;g>0;g--,m--){let b=i.node(g).type.spec;if(b.defining||b.definingAsContext||b.isolating)break;s.indexOf(g)>-1?o=g:i.before(g)==m&&s.splice(1,0,-g)}let l=s.indexOf(o),c=[],u=r.openStart;for(let g=r.content,m=0;;m++){let b=g.firstChild;if(c.push(b),m==r.openStart)break;g=b.content}for(let g=u-1;g>=0;g--){let m=c[g],b=TSe(m.type);if(b&&!m.sameMarkup(i.node(Math.abs(o)-1)))u=g;else if(b||!m.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let m=(g+u+1)%(r.openStart+1),b=c[m];if(b)for(let y=0;y<s.length;y++){let v=s[(y+l)%s.length],x=!0;v<0&&(x=!1,v=-v);let M=i.node(v-1),w=i.index(v-1);if(M.canReplaceWith(w,w,b.type,b.marks))return t.replace(i.before(v),x?a.after(v):n,new Mt(yW(r.content,0,r.openStart,m),m,r.openEnd))}}let h=t.steps.length;for(let g=s.length-1;g>=0&&(t.replace(e,n,r),!(t.steps.length>h));g--){let m=s[g];m<0||(e=i.before(m),n=a.after(m))}}function yW(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(yW(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 NSe(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=MSe(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Mt(pt.from(r),0,0))}function RSe(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=_W(r,i);for(let s=0;s<a.length;s++){let o=a[s],l=s==a.length-1;if(l&&o==0||r.node(o).type.contentMatch.validEnd)return t.delete(r.start(o),i.end(o));if(o>0&&(l||r.node(o-1).canReplace(r.index(o-1),i.indexAfter(o-1))))return t.delete(r.before(o),i.after(o))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function _W(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 jp extends la{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 Gr.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 Gr.fromReplace(e,this.pos,this.pos+1,new Mt(pt.from(i),0,n.isLeaf?0:1))}getMap(){return ls.empty}invert(e){return new jp(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 jp(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 jp(n.pos,n.attr,n.value)}}la.jsonID("attr",jp);class u0 extends la{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 Gr.ok(r)}getMap(){return ls.empty}invert(e){return new u0(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 u0(n.attr,n.value)}}la.jsonID("docAttr",u0);let rm=class extends Error{};rm=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};rm.prototype=Object.create(Error.prototype);rm.prototype.constructor=rm;rm.prototype.name="TransformError";class SW{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new c0}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new rm(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=Mt.empty){let i=mw(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Mt(pt.from(r),0,0))}delete(e,n){return this.replace(e,n,Mt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return CSe(this,e,n,r),this}replaceRangeWith(e,n,r){return NSe(this,e,n,r),this}deleteRange(e,n){return RSe(this,e,n),this}lift(e,n){return pSe(this,e,n),this}join(e,n=1){return wSe(this,e,n),this}wrap(e,n){return xSe(this,e,n),this}setBlockType(e,n=e,r,i=null){return vSe(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return ySe(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new jp(e,n,r)),this}setDocAttribute(e,n){return this.step(new u0(e,n)),this}addNodeMark(e,n){return this.step(new Iu(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 Kn)n.isInSet(r.marks)&&this.step(new Lf(e,n));else{let i=r.marks,a,s=[];for(;a=n.isInSet(i);)s.push(new Lf(e,a)),i=a.removeFromSet(i);for(let o=s.length-1;o>=0;o--)this.step(s[o])}return this}split(e,n=1,r){return _Se(this,e,n,r),this}addMark(e,n,r){return dSe(this,e,n,r),this}removeMark(e,n,r){return fSe(this,e,n,r),this}clearIncompatible(e,n,r){return Ak(this,e,n,r),this}}const f2=Object.create(null);class on{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new PSe(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=Mt.empty){let r=n.content.lastChild,i=null;for(let o=0;o<n.openEnd;o++)i=r,r=r.lastChild;let a=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:l,$to:c}=s[o],u=e.mapping.slice(a);e.replaceRange(u.map(l.pos),u.map(c.pos),o?Mt.empty:n),o==0&&EB(e,a,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:s,$to:o}=i[a],l=e.mapping.slice(r),c=l.map(s.pos),u=l.map(o.pos);a?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),EB(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new Wt(e):vp(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?vp(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):vp(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 hs(e.node(0))}static atStart(e){return vp(e,e,0,0,1)||new hs(e)}static atEnd(e){return vp(e,e,e.content.size,e.childCount,-1)||new hs(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=f2[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 f2)throw new RangeError("Duplicate use of selection JSON ID "+e);return f2[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Wt.between(this.$anchor,this.$head).getBookmark()}}on.prototype.visible=!0;class PSe{constructor(e,n){this.$from=e,this.$to=n}}let wB=!1;function MB(t){!wB&&!t.parent.inlineContent&&(wB=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Wt extends on{constructor(e,n=e){MB(e),MB(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 on.near(r);let i=e.resolve(n.map(this.anchor));return new Wt(i.parent.inlineContent?i:r,r)}replace(e,n=Mt.empty){if(super.replace(e,n),n==Mt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Wt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new gw(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 Wt(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=on.findFrom(n,r,!0)||on.findFrom(n,-r,!0);if(a)n=a.$head;else return on.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(on.findFrom(e,-r,!0)||on.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new Wt(e,n)}}on.jsonID("text",Wt);class gw{constructor(e,n){this.anchor=e,this.head=n}map(e){return new gw(e.map(this.anchor),e.map(this.head))}resolve(e){return Wt.between(e.resolve(this.anchor),e.resolve(this.head))}}class Ft extends on{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?on.near(a):new Ft(a)}content(){return new Mt(pt.from(this.node),0,0)}eq(e){return e instanceof Ft&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ck(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ft(e.resolve(n.anchor))}static create(e,n){return new Ft(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Ft.prototype.visible=!1;on.jsonID("node",Ft);class Ck{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new gw(r,r):new Ck(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Ft.isSelectable(r)?new Ft(n):on.near(n)}}class hs extends on{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Mt.empty){if(n==Mt.empty){e.delete(0,e.doc.content.size);let r=on.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new hs(e)}map(e){return new hs(e)}eq(e){return e instanceof hs}getBookmark(){return kSe}}on.jsonID("all",hs);const kSe={map(){return this},resolve(t){return new hs(t)}};function vp(t,e,n,r,i,a=!1){if(e.inlineContent)return Wt.create(t,n);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let o=e.child(s);if(o.isAtom){if(!a&&Ft.isSelectable(o))return Ft.create(t,n-(i<0?o.nodeSize:0))}else{let l=vp(t,o,n+i,i<0?o.childCount:0,i,a);if(l)return l}n+=o.nodeSize*i}return null}function EB(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Ei||i instanceof Ti))return;let a=t.mapping.maps[r],s;a.forEach((o,l,c,u)=>{s==null&&(s=u)}),t.setSelection(on.near(t.doc.resolve(s),n))}const AB=1,Fy=2,TB=4;class DSe extends SW{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|AB)&~Fy,this.storedMarks=null,this}get selectionSet(){return(this.updated&AB)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Fy,this}ensureMarks(e){return Kn.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&Fy)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Fy,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)||Kn.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(on.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|=TB,this}get scrolledIntoView(){return(this.updated&TB)>0}}function CB(t,e){return!e||!t?t:t.bind(e)}class px{constructor(e,n,r){this.name=e,this.init=CB(n.init,r),this.apply=CB(n.apply,r)}}const OSe=[new px("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new px("selection",{init(t,e){return t.selection||on.atStart(e.doc)},apply(t){return t.selection}}),new px("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new px("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class h2{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=OSe.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 px(r.key,r.spec.state,r))})}}class Ap{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let a=!1;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let l=i?i[s].n:0,c=i?i[s].state:this,u=l<n.length&&o.spec.appendTransaction.call(o,l?n.slice(l):n,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let h=0;h<this.config.plugins.length;h++)i.push(h<s?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),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 Ap(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 DSe(this)}static create(e){let n=new h2(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Ap(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 h2(this.schema,e.plugins),r=n.fields,i=new Ap(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 h2(e.schema,e.plugins),a=new Ap(i);return i.fields.forEach(s=>{if(s.name=="doc")a.doc=$u.fromJSON(e.schema,n.doc);else if(s.name=="selection")a.selection=on.fromJSON(a.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(a.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let o in r){let l=r[o],c=l.spec.state;if(l.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,o)){a[s.name]=c.fromJSON.call(l,e,n[o],a);return}}a[s.name]=s.init(e,a)}}),a}}function wW(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=wW(i,e,{})),n[r]=i}return n}class vr{constructor(e){this.spec=e,this.props={},e.props&&wW(e.props,this,this.props),this.key=e.key?e.key.key:MW("plugin")}getState(e){return e[this.key]}}const p2=Object.create(null);function MW(t){return t in p2?t+"$"+ ++p2[t]:(p2[t]=0,t+"$")}class ci{constructor(e="key"){this.key=MW(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Nk=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function EW(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const AW=(t,e,n)=>{let r=EW(t,n);if(!r)return!1;let i=Rk(r);if(!i){let s=r.blockRange(),o=s&&Rm(s);return o==null?!1:(e&&e(t.tr.lift(s,o).scrollIntoView()),!0)}let a=i.nodeBefore;if(LW(t,i,e,-1))return!0;if(r.parent.content.size==0&&(im(a,"end")||Ft.isSelectable(a)))for(let s=r.depth;;s--){let o=mw(t.doc,r.before(s),r.after(s),Mt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(im(a,"end")?on.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):Ft.create(l.doc,i.pos-a.nodeSize)),e(l.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},LSe=(t,e,n)=>{let r=EW(t,n);if(!r)return!1;let i=Rk(r);return i?TW(t,i,e):!1},ISe=(t,e,n)=>{let r=NW(t,n);if(!r)return!1;let i=Pk(r);return i?TW(t,i,e):!1};function TW(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 u=i.lastChild;if(!u)return!1;i=u}let s=e.nodeAfter,o=s,l=e.pos+1;for(;!o.isTextblock;l++){if(o.type.spec.isolating)return!1;let u=o.firstChild;if(!u)return!1;o=u}let c=mw(t.doc,a,l,Mt.empty);if(!c||c.from!=a||c instanceof Ei&&c.slice.size>=l-a)return!1;if(n){let u=t.tr.step(c);u.setSelection(Wt.create(u.doc,a)),n(u.scrollIntoView())}return!0}function im(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 CW=(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=Rk(r)}let s=a&&a.nodeBefore;return!s||!Ft.isSelectable(s)?!1:(e&&e(t.tr.setSelection(Ft.create(t.doc,a.pos-s.nodeSize)).scrollIntoView()),!0)};function Rk(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 NW(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const RW=(t,e,n)=>{let r=NW(t,n);if(!r)return!1;let i=Pk(r);if(!i)return!1;let a=i.nodeAfter;if(LW(t,i,e,1))return!0;if(r.parent.content.size==0&&(im(a,"start")||Ft.isSelectable(a))){let s=mw(t.doc,r.before(),r.after(),Mt.empty);if(s&&s.slice.size<s.to-s.from){if(e){let o=t.tr.step(s);o.setSelection(im(a,"start")?on.findFrom(o.doc.resolve(o.mapping.map(i.pos)),1):Ft.create(o.doc,o.mapping.map(i.pos))),e(o.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},PW=(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=Pk(r)}let s=a&&a.nodeAfter;return!s||!Ft.isSelectable(s)?!1:(e&&e(t.tr.setSelection(Ft.create(t.doc,a.pos)).scrollIntoView()),!0)};function Pk(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 jSe=(t,e)=>{let n=t.selection,r=n instanceof Ft,i;if(r){if(n.node.isTextblock||!ld(t.doc,n.from))return!1;i=n.from}else if(i=pw(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(Ft.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},USe=(t,e)=>{let n=t.selection,r;if(n instanceof Ft){if(n.node.isTextblock||!ld(t.doc,n.to))return!1;r=n.to}else if(r=pw(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},FSe=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&Rm(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},kW=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
  8064. `).scrollIntoView()),!0)};function kk(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 zSe=(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=kk(i.contentMatchAt(a));if(!s||!i.canReplaceWith(a,a,s))return!1;if(e){let o=n.after(),l=t.tr.replaceWith(o,o,s.createAndFill());l.setSelection(on.near(l.doc.resolve(o),1)),e(l.scrollIntoView())}return!0},DW=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof hs||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=kk(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=t.tr.insert(s,a.createAndFill());o.setSelection(Wt.create(o.doc,s+1)),e(o.scrollIntoView())}return!0},OW=(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(dc(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Rm(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function BSe(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Ft&&e.selection.node.isBlock)return!r.parentOffset||!dc(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],s,o,l=!1,c=!1;for(let m=r.depth;;m--)if(r.node(m).isBlock){l=r.end(m)==r.pos+(r.depth-m),c=r.start(m)==r.pos-(r.depth-m),o=kk(r.node(m-1).contentMatchAt(r.indexAfter(m-1))),a.unshift(l&&o?{type:o}:null),s=m;break}else{if(m==1)return!1;a.unshift(null)}let u=e.tr;(e.selection instanceof Wt||e.selection instanceof hs)&&u.deleteSelection();let h=u.mapping.map(r.pos),g=dc(u.doc,h,a.length,a);if(g||(a[0]=o?{type:o}:null,g=dc(u.doc,h,a.length,a)),!g)return!1;if(u.split(h,a.length,a),!l&&c&&r.node(s).type!=o){let m=u.mapping.map(r.before(s)),b=u.doc.resolve(m);o&&r.node(s-1).canReplaceWith(b.index(),b.index()+1,o)&&u.setNodeMarkup(u.mapping.map(r.before(s)),o)}return n&&n(u.scrollIntoView()),!0}}const HSe=BSe(),$Se=(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(Ft.create(t.doc,i))),!0)};function VSe(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||ld(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function LW(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,s,o,l=i.type.spec.isolating||a.type.spec.isolating;if(!l&&VSe(t,e,n))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(o=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&o.matchType(s[0]||a.type).validEnd){if(n){let m=e.pos+a.nodeSize,b=pt.empty;for(let x=s.length-1;x>=0;x--)b=pt.from(s[x].create(null,b));b=pt.from(i.copy(b));let y=t.tr.step(new Ti(e.pos-1,m,e.pos,m,new Mt(b,1,0),s.length,!0)),v=y.doc.resolve(m+2*s.length);v.nodeAfter&&v.nodeAfter.type==i.type&&ld(y.doc,v.pos)&&y.join(v.pos),n(y.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&l?null:on.findFrom(e,1),h=u&&u.$from.blockRange(u.$to),g=h&&Rm(h);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(h,g).scrollIntoView()),!0;if(c&&im(a,"start",!0)&&im(i,"end")){let m=i,b=[];for(;b.push(m),!m.isTextblock;)m=m.lastChild;let y=a,v=1;for(;!y.isTextblock;y=y.firstChild)v++;if(m.canReplace(m.childCount,m.childCount,y.content)){if(n){let x=pt.empty;for(let w=b.length-1;w>=0;w--)x=pt.from(b[w].copy(x));let M=t.tr.step(new Ti(e.pos-b.length,e.pos+a.nodeSize,e.pos+v,e.pos+a.nodeSize-v,new Mt(x,b.length,0),0,!0));n(M.scrollIntoView())}return!0}}return!1}function IW(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(Wt.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const GSe=IW(-1),WSe=IW(1);function qSe(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,s=i.blockRange(a),o=s&&Tk(s,t,e);return o?(r&&r(n.tr.wrap(s,o).scrollIntoView()),!0):!1}}function NB(t,e=null){return function(n,r){let i=!1;for(let a=0;a<n.selection.ranges.length&&!i;a++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[a];n.doc.nodesBetween(s,o,(l,c)=>{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)i=!0;else{let u=n.doc.resolve(c),h=u.index();i=u.parent.canReplaceWith(h,h+1,t)}})}if(!i)return!1;if(r){let a=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[s];a.setBlockType(o,l,t,e)}r(a.scrollIntoView())}return!0}}function Dk(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}Dk(Nk,AW,CW);Dk(Nk,RW,PW);Dk(kW,DW,OW,HSe);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function XSe(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,s=i.blockRange(a);if(!s)return!1;let o=r?n.tr:null;return KSe(o,s,t,e)?(r&&r(o.scrollIntoView()),!0):!1}}function KSe(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 l=s.resolve(e.start-2);a=new f1(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new f1(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let o=Tk(a,n,r,e);return o?(t&&YSe(t,e,o,i,n),!0):!1}function YSe(t,e,n,r,i){let a=pt.empty;for(let u=n.length-1;u>=0;u--)a=pt.from(n[u].type.create(n[u].attrs,a));t.step(new Ti(e.start-(r?2:0),e.end,e.start,e.end,new Mt(a,0,0),n.length,!0));let s=0;for(let u=0;u<n.length;u++)n[u].type==i&&(s=u+1);let o=n.length-s,l=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,h=e.endIndex,g=!0;u<h;u++,g=!1)!g&&dc(t.doc,l,o)&&(t.split(l,o),l+=2*o),l+=c.child(u).nodeSize;return t}function ZSe(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?QSe(e,n,t,a):JSe(e,n,a):!0:!1}}function QSe(t,e,n,r){let i=t.tr,a=r.end,s=r.$to.end(r.depth);a<s&&(i.step(new Ti(a-1,s,a,s,new Mt(pt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new f1(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const o=Rm(r);if(o==null)return!1;i.lift(r,o);let l=i.doc.resolve(i.mapping.map(a,-1)-1);return ld(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function JSe(t,e,n){let r=t.tr,i=n.parent;for(let m=n.end,b=n.endIndex-1,y=n.startIndex;b>y;b--)m-=i.child(b).nodeSize,r.delete(m-1,m+1);let a=r.doc.resolve(n.start),s=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let o=n.startIndex==0,l=n.endIndex==i.childCount,c=a.node(-1),u=a.index(-1);if(!c.canReplace(u+(o?0:1),u+1,s.content.append(l?pt.empty:pt.from(i))))return!1;let h=a.pos,g=h+s.nodeSize;return r.step(new Ti(h-(o?1:0),g+(l?1:0),h+1,g-1,new Mt((o?pt.empty:pt.from(i.copy(pt.empty))).append(l?pt.empty:pt.from(i.copy(pt.empty))),o?0:1,l?0:1),o?0:1)),e(r.scrollIntoView()),!0}function ewe(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==t);if(!a)return!1;let s=a.startIndex;if(s==0)return!1;let o=a.parent,l=o.child(s-1);if(l.type!=t)return!1;if(n){let c=l.lastChild&&l.lastChild.type==o.type,u=pt.from(c?t.create():null),h=new Mt(pt.from(t.create(null,pt.from(o.type.create(null,u)))),c?3:1,0),g=a.start,m=a.end;n(e.tr.step(new Ti(g-(c?3:1),m,g,m,h,1,!0)).scrollIntoView())}return!0}}const Gi=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},am=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let K3=null;const Kl=function(t,e,n){let r=K3||(K3=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},twe=function(){K3=null},If=function(t,e,n,r){return n&&(RB(t,e,n,r,-1)||RB(t,e,n,r,1))},nwe=/^(img|br|input|textarea|hr)$/i;function RB(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Bs(t))){let s=t.parentNode;if(!s||s.nodeType!=1||G0(t)||nwe.test(t.nodeName)||t.contentEditable=="false")return!1;e=Gi(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?Bs(t):0}else return!1}}function Bs(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function rwe(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=Bs(t)}else if(t.parentNode&&!G0(t))e=Gi(t),t=t.parentNode;else return null}}function iwe(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&&!G0(t))e=Gi(t)+1,t=t.parentNode;else return null}}function awe(t,e,n){for(let r=e==0,i=e==Bs(t);r||i;){if(t==n)return!0;let a=Gi(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==Bs(t)}}function G0(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 xw=function(t){return t.focusNode&&If(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Zd(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function swe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function owe(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Bs(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Bs(r.startContainer),r.startOffset)}}}const al=typeof navigator<"u"?navigator:null,PB=typeof document<"u"?document:null,cd=al&&al.userAgent||"",Y3=/Edge\/(\d+)/.exec(cd),jW=/MSIE \d/.exec(cd),Z3=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(cd),Ba=!!(jW||Z3||Y3),Vu=jW?document.documentMode:Z3?+Z3[1]:Y3?+Y3[1]:0,Ws=!Ba&&/gecko\/(\d+)/i.test(cd);Ws&&+(/Firefox\/(\d+)/.exec(cd)||[0,0])[1];const Q3=!Ba&&/Chrome\/(\d+)/.exec(cd),ia=!!Q3,UW=Q3?+Q3[1]:0,ba=!Ba&&!!al&&/Apple Computer/.test(al.vendor),sm=ba&&(/Mobile\/\w+/.test(cd)||!!al&&al.maxTouchPoints>2),Ls=sm||(al?/Mac/.test(al.platform):!1),lwe=al?/Win/.test(al.platform):!1,ic=/Android \d/.test(cd),W0=!!PB&&"webkitFontSmoothing"in PB.documentElement.style,cwe=W0?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function uwe(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 Hl(t,e){return typeof t=="number"?t:t[e]}function dwe(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 kB(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=am(s);continue}let o=s,l=o==a.body,c=l?uwe(a):dwe(o),u=0,h=0;if(e.top<c.top+Hl(r,"top")?h=-(c.top-e.top+Hl(i,"top")):e.bottom>c.bottom-Hl(r,"bottom")&&(h=e.bottom-e.top>c.bottom-c.top?e.top+Hl(i,"top")-c.top:e.bottom-c.bottom+Hl(i,"bottom")),e.left<c.left+Hl(r,"left")?u=-(c.left-e.left+Hl(i,"left")):e.right>c.right-Hl(r,"right")&&(u=e.right-c.right+Hl(i,"right")),u||h)if(l)a.defaultView.scrollBy(u,h);else{let m=o.scrollLeft,b=o.scrollTop;h&&(o.scrollTop+=h),u&&(o.scrollLeft+=u);let y=o.scrollLeft-m,v=o.scrollTop-b;e={left:e.left-y,top:e.top-v,right:e.right-y,bottom:e.bottom-v}}let g=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(g))break;s=g=="absolute"?s.offsetParent:am(s)}}function fwe(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let a=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let o=t.root.elementFromPoint(a,s);if(!o||o==t.dom||!t.dom.contains(o))continue;let l=o.getBoundingClientRect();if(l.top>=n-20){r=o,i=l.top;break}}return{refDOM:r,refTop:i,stack:FW(t.dom)}}function FW(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=am(r));return e}function hwe({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;zW(n,r==0?0:r-e)}function zW(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:a}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=a&&(r.scrollLeft=a)}}let dp=null;function pwe(t){if(t.setActive)return t.setActive();if(dp)return t.focus(dp);let e=FW(t);t.focus(dp==null?{get preventScroll(){return dp={preventScroll:!0},!0}}:void 0),dp||(dp=!1,zW(e,0))}function BW(t,e){let n,r=2e8,i,a=0,s=e.top,o=e.top,l,c;for(let u=t.firstChild,h=0;u;u=u.nextSibling,h++){let g;if(u.nodeType==1)g=u.getClientRects();else if(u.nodeType==3)g=Kl(u).getClientRects();else continue;for(let m=0;m<g.length;m++){let b=g[m];if(b.top<=s&&b.bottom>=o){s=Math.max(b.bottom,s),o=Math.min(b.top,o);let y=b.left>e.left?b.left-e.left:b.right<e.left?e.left-b.right:0;if(y<r){n=u,r=y,i=y&&n.nodeType==3?{left:b.right<e.left?b.right:b.left,top:e.top}:e,u.nodeType==1&&y&&(a=h+(e.left>=(b.left+b.right)/2?1:0));continue}}else b.top>e.top&&!l&&b.left<=e.left&&b.right>=e.left&&(l=u,c={left:Math.max(b.left,Math.min(b.right,e.left)),top:b.top});!n&&(e.left>=b.right&&e.top>=b.top||e.left>=b.left&&e.top>=b.bottom)&&(a=h+1)}}return!n&&l&&(n=l,i=c,r=0),n&&n.nodeType==3?mwe(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:BW(n,i)}function mwe(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=bu(r,1);if(a.top!=a.bottom&&Ok(e,a))return{node:t,offset:i+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function Ok(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function gwe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function xwe(t,e,n){let{node:r,offset:i}=BW(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 vwe(t,e,n,r){let i=-1;for(let a=e,s=!1;a!=t.dom;){let o=t.docView.nearestDesc(a,!0),l;if(!o)return null;if(o.dom.nodeType==1&&(o.node.isBlock&&o.parent||!o.contentDOM)&&((l=o.dom.getBoundingClientRect()).width||l.height)&&(o.node.isBlock&&o.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(o.dom.nodeName)&&(!s&&l.left>r.left||l.top>r.top?i=o.posBefore:(!s&&l.right<r.left||l.bottom<r.top)&&(i=o.posAfter),s=!0),!o.contentDOM&&i<0&&!o.node.isText))return(o.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?o.posBefore:o.posAfter;a=o.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function HW(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let s=t.childNodes[a];if(s.nodeType==1){let o=s.getClientRects();for(let l=0;l<o.length;l++){let c=o[l];if(Ok(e,c))return HW(s,e,c)}}if((a=(a+1)%r)==i)break}return t}function bwe(t,e){let n=t.dom.ownerDocument,r,i=0,a=owe(n,e.left,e.top);a&&({node:r,offset:i}=a);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),o;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=t.dom.getBoundingClientRect();if(!Ok(e,c)||(s=HW(t.dom,e,c),!s))return null}if(ba)for(let c=s;r&&c;c=am(c))c.draggable&&(r=void 0);if(s=gwe(s,e),r){if(Ws&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],h;u.nodeName=="IMG"&&(h=u.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&i++}let c;W0&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?o=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(o=vwe(t,r,i,e))}o==null&&(o=xwe(t,s,e));let l=t.docView.nearestDesc(s,!0);return{pos:o,inside:l?l.posAtStart-l.border:-1}}function DB(t){return t.top<t.bottom||t.left<t.right}function bu(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(DB(r))return r}return Array.prototype.find.call(n,DB)||t.getBoundingClientRect()}const ywe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function $W(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),s=W0||Ws;if(r.nodeType==3)if(s&&(ywe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let l=bu(Kl(r,i,i),n);if(Ws&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=bu(Kl(r,i-1,i-1),-1);if(c.top==l.top){let u=bu(Kl(r,i,i+1),-1);if(u.top!=l.top)return Zg(u,u.left<c.left)}}return l}else{let l=i,c=i,u=n<0?1:-1;return n<0&&!i?(c++,u=-1):n>=0&&i==r.nodeValue.length?(l--,u=1):n<0?l--:c++,Zg(bu(Kl(r,l,c),u),u<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Bs(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return m2(l.getBoundingClientRect(),!1)}if(a==null&&i<Bs(r)){let l=r.childNodes[i];if(l.nodeType==1)return m2(l.getBoundingClientRect(),!0)}return m2(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==Bs(r))){let l=r.childNodes[i-1],c=l.nodeType==3?Kl(l,Bs(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return Zg(bu(c,1),!1)}if(a==null&&i<Bs(r)){let l=r.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?Kl(l,0,s?0:1):l.nodeType==1?l:null:null;if(c)return Zg(bu(c,-1),!0)}return Zg(bu(r.nodeType==3?Kl(r):r,-n),n>=0)}function Zg(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 m2(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 VW(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 _we(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return VW(t,e,()=>{let{node:a}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let o=t.docView.nearestDesc(a,!0);if(!o)break;if(o.node.isBlock){a=o.contentDOM||o.dom;break}a=o.dom.parentNode}let s=$W(t,i.pos,1);for(let o=a.firstChild;o;o=o.nextSibling){let l;if(o.nodeType==1)l=o.getClientRects();else if(o.nodeType==3)l=Kl(o,0,o.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let u=l[c];if(u.bottom>u.top+1&&(n=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}const Swe=/[\u0590-\u08ac]/;function wwe(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,s=i==r.parent.content.size,o=t.domSelection();return o?!Swe.test(r.parent.textContent)||!o.modify?n=="left"||n=="backward"?a:s:VW(t,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:h}=t.domSelectionRange(),g=o.caretBidiLevel;o.modify("move",n,"character");let m=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:b,focusOffset:y}=t.domSelectionRange(),v=b&&!m.contains(b.nodeType==1?b:b.parentNode)||l==b&&c==y;try{o.collapse(u,h),l&&(l!=u||c!=h)&&o.extend&&o.extend(l,c)}catch{}return g!=null&&(o.caretBidiLevel=g),v}):r.pos==r.start()||r.pos==r.end()}let OB=null,LB=null,IB=!1;function Mwe(t,e,n){return OB==e&&LB==n?IB:(OB=e,LB=n,IB=n=="up"||n=="down"?_we(t,e,n):wwe(t,e,n))}const qs=0,jB=1,ef=2,sl=3;class q0{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=qs,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>Gi(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!1;break}if(a.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!0;break}if(a.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let a=this.getDesc(i),s;if(a&&(!n||a.node))if(r&&(s=a.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return a}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let a=this.getDesc(i);if(a)return a.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],a=r+i.size;if(r==e&&a!=r){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let o=i.children[s];if(o.size){i=o;break}}return i}if(e<a)return i.descAt(e-r-i.border);r=a}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let a=0;r<this.children.length;r++){let s=this.children[r],o=a+s.size;if(o>e||s instanceof WW){i=e-a;break}a=o}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let a;r&&!(a=this.children[r-1]).size&&a instanceof GW&&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?Gi(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?Gi(a.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,a=-1;for(let s=r,o=0;;o++){let l=this.children[o],c=s+l.size;if(i==-1&&e<=c){let u=s+l.border;if(e>=u&&n<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,u);e=s;for(let h=o;h>0;h--){let g=this.children[h-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){i=Gi(g.dom)+1;break}e-=g.size}i==-1&&(i=0)}if(i>-1&&(c>n||o==this.children.length-1)){n=c;for(let u=o+1;u<this.children.length;u++){let h=this.children[u];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){a=Gi(h.dom);break}n+=h.size}a==-1&&(a=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:a}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let a=Math.min(e,n),s=Math.max(e,n);for(let m=0,b=0;m<this.children.length;m++){let y=this.children[m],v=b+y.size;if(a>b&&s<v)return y.setSelection(e-b-y.border,n-b-y.border,r,i);b=v}let o=this.domFromPos(e,e?-1:1),l=n==e?o:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),h=!1;if((Ws||ba)&&e==n){let{node:m,offset:b}=o;if(m.nodeType==3){if(h=!!(b&&m.nodeValue[b-1]==`
  8065. `),h&&b==m.nodeValue.length)for(let y=m,v;y;y=y.parentNode){if(v=y.nextSibling){v.nodeName=="BR"&&(o=l={node:v.parentNode,offset:Gi(v)+1});break}let x=y.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let y=m.childNodes[b-1];h=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(Ws&&u.focusNode&&u.focusNode!=l.node&&u.focusNode.nodeType==1){let m=u.focusNode.childNodes[u.focusOffset];m&&m.contentEditable=="false"&&(i=!0)}if(!(i||h&&ba)&&If(o.node,o.offset,u.anchorNode,u.anchorOffset)&&If(l.node,l.offset,u.focusNode,u.focusOffset))return;let g=!1;if((c.extend||e==n)&&!(h&&Ws)){c.collapse(o.node,o.offset);try{e!=n&&c.extend(l.node,l.offset),g=!0}catch{}}if(!g){if(e>n){let b=o;o=l,l=b}let m=document.createRange();m.setEnd(l.node,l.offset),m.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(m)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let a=this.children[i],s=r+a.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let o=r+a.border,l=s-a.border;if(e>=o&&n<=l){this.dirty=e==r||n==s?ef:jB,e==o&&n==l&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=sl:a.markDirty(e-o,n-o);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?ef:sl}r=s}this.dirty=ef}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?ef:jB;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class GW extends q0{constructor(e,n,r,i){let a,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)})),!n.type.spec.raw){if(s.nodeType!=1){let o=document.createElement("span");o.appendChild(s),s=o}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,a=this}matchesWidget(e){return this.dirty==qs&&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 Ewe extends q0{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 jf extends q0{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=Kf.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new jf(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&sl||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=sl&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=qs){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=qs}}slice(e,n,r){let i=jf.create(this.parent,this.mark,!0,r),a=this.children,s=this.size;n<s&&(a=eR(a,n,s,r)),e>0&&(a=eR(a,0,e,r));for(let o=0;o<a.length;o++)a[o].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Gu extends q0{constructor(e,n,r,i,a,s,o,l,c){super(e,[],a,s),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=o}static create(e,n,r,i,a,s){let o=a.nodeViews[n.type.name],l,c=o&&o(n,a,()=>{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},r,i),u=c&&c.dom,h=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:h}=Kf.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!h&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let g=u;return u=KW(u,r,n),c?l=new Awe(e,n,r,i,u,h||null,g,c,a,s+1):n.isText?new vw(e,n,r,i,u,g,a):new Gu(e,n,r,i,u,h||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==qs&&e.eq(this.node)&&p1(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,a=e.composing?this.localCompositionInfo(e,n):null,s=a&&a.pos>-1?a:null,o=a&&a.pos<0,l=new Cwe(this,s&&s.node,e);Pwe(this.node,this.innerDeco,(c,u,h)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!h&&l.syncToMarks(u==this.node.childCount?Kn.none:this.node.child(u).marks,r,e),l.placeWidget(c,e,i)},(c,u,h,g)=>{l.syncToMarks(c.marks,r,e);let m;l.findNodeMatch(c,u,h,g)||o&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(m=l.findIndexWithChild(a.node))>-1&&l.updateNodeAt(c,u,h,m,e)||l.updateNextNode(c,u,h,e,g,i)||l.addNode(c,u,h,e,i),i+=c.nodeSize}),l.syncToMarks([],r,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==ef)&&(s&&this.protectLocalComposition(e,s),qW(this.contentDOM,this.children,e),sm&&kwe(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof Wt)||r<n||i>n+this.node.content.size)return null;let a=e.input.compositionNode;if(!a||!this.dom.contains(a.parentNode))return null;if(this.node.inlineContent){let s=a.nodeValue,o=Dwe(this.node.content,s,r-n,i-n);return o<0?null:{node:a,pos:o,text:s}}else return{node:a,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let a=n;for(;a.parentNode!=this.contentDOM;a=a.parentNode){for(;a.previousSibling;)a.parentNode.removeChild(a.previousSibling);for(;a.nextSibling;)a.parentNode.removeChild(a.nextSibling);a.pmViewDesc&&(a.pmViewDesc=void 0)}let s=new Ewe(this,a,n,i);e.input.compositionNodes.push(s),this.children=eR(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==sl||!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=qs}updateOuterDeco(e){if(p1(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=XW(this.dom,this.nodeDOM,J3(this.outerDeco,this.node,n),J3(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 UB(t,e,n,r,i){KW(r,e,t);let a=new Gu(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class vw extends Gu{constructor(e,n,r,i,a,s,o){super(e,n,r,i,a,null,s,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==sl||this.dirty!=qs&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=qs||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=qs,!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 vw(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=sl)}get domAtom(){return!1}isText(e){return this.node.text==e}}class WW extends q0{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==qs&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Awe extends Gu{constructor(e,n,r,i,a,s,o,l,c,u){super(e,n,r,i,a,s,o,c,u),this.spec=l}update(e,n,r,i){if(this.dirty==sl)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 qW(t,e,n){let r=t.firstChild,i=!1;for(let a=0;a<e.length;a++){let s=e[a],o=s.dom;if(o.parentNode==t){for(;o!=r;)r=FB(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(o,r);if(s instanceof jf){let l=r?r.previousSibling:t.lastChild;qW(s.contentDOM,s.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=FB(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const Rx=function(t){t&&(this.nodeName=t)};Rx.prototype=Object.create(null);const tf=[new Rx];function J3(t,e,n){if(t.length==0)return tf;let r=n?tf[0]:new Rx,i=[r];for(let a=0;a<t.length;a++){let s=t[a].type.attrs;if(s){s.nodeName&&i.push(r=new Rx(s.nodeName));for(let o in s){let l=s[o];l!=null&&(n&&i.length==1&&i.push(r=new Rx(e.isInline?"span":"div")),o=="class"?r.class=(r.class?r.class+" ":"")+l:o=="style"?r.style=(r.style?r.style+";":"")+l:o!="nodeName"&&(r[o]=l))}}}return i}function XW(t,e,n,r){if(n==tf&&r==tf)return e;let i=e;for(let a=0;a<r.length;a++){let s=r[a],o=n[a];if(a){let l;o&&o.nodeName==s.nodeName&&i!=t&&(l=i.parentNode)&&l.nodeName.toLowerCase()==s.nodeName||(l=document.createElement(s.nodeName),l.pmIsDeco=!0,l.appendChild(i),o=tf[0]),i=l}Twe(i,o||tf[0],s)}return i}function Twe(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 KW(t,e,n){return XW(t,t,tf,J3(e,n,t.nodeType!=1))}function p1(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 FB(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Cwe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Nwe(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=qs,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let o=-1;for(let l=this.index;l<Math.min(this.index+3,this.top.children.length);l++){let c=this.top.children[l];if(c.matchesMark(e[a])&&!this.isLocked(c.dom)){o=l;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let l=jf.create(this.top,e[a],n,r);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,a++}}findNodeMatch(e,n,r,i){let a=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))a=this.top.children.indexOf(s,this.index);else for(let o=this.index,l=Math.min(this.top.children.length,o+5);o<l;o++){let c=this.top.children[o];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){a=o;break}}return a<0?!1:(this.destroyBetween(this.index,a),this.index++,!0)}updateNodeAt(e,n,r,i,a){let s=this.top.children[i];return s.dirty==sl&&s.dom==s.contentDOM&&(s.dirty=ef),s.update(e,n,r,a)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,a,s){for(let o=this.index;o<this.top.children.length;o++){let l=this.top.children[o];if(l instanceof Gu){let c=this.preMatch.matched.get(l);if(c!=null&&c!=a)return!1;let u=l.dom,h,g=this.isLocked(u)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=sl&&p1(n,l.outerDeco));if(!g&&l.update(e,n,r,i))return this.destroyBetween(this.index,o),l.dom!=u&&(this.changed=!0),this.index++,!0;if(!g&&(h=this.recreateWrapper(l,e,n,r,i,s)))return this.destroyBetween(this.index,o),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=ef,h.updateChildren(i,s+1),h.dirty=qs),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)||!p1(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let o=Gu.create(this.top,n,r,i,a,s);if(o.contentDOM){o.children=e.children,e.children=[];for(let l of o.children)l.parent=o}return e.destroy(),o}addNode(e,n,r,i,a){let s=Gu.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 GW(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 jf;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof vw)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ba||ia)&&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 WW(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 Nwe(t,e){let n=e,r=n.children.length,i=t.childCount,a=new Map,s=[];e:for(;i>0;){let o;for(;;)if(r){let c=n.children[r-1];if(c instanceof jf)n=c,r=c.children.length;else{o=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=o.node;if(l){if(l!=t.child(i-1))break;--i,a.set(o,i),s.push(o)}}return{index:i,matched:a,matches:s.reverse()}}function Rwe(t,e){return t.type.side-e.type.side}function Pwe(t,e,n,r){let i=e.locals(t),a=0;if(i.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,i,e.forChild(a,u),c),a+=u.nodeSize}return}let s=0,o=[],l=null;for(let c=0;;){let u,h;for(;s<i.length&&i[s].to==a;){let v=i[s++];v.widget&&(u?(h||(h=[u])).push(v):u=v)}if(u)if(h){h.sort(Rwe);for(let v=0;v<h.length;v++)n(h[v],c,!!l)}else n(u,c,!!l);let g,m;if(l)m=-1,g=l,l=null;else if(c<t.childCount)m=c,g=t.child(c++);else break;for(let v=0;v<o.length;v++)o[v].to<=a&&o.splice(v--,1);for(;s<i.length&&i[s].from<=a&&i[s].to>a;)o.push(i[s++]);let b=a+g.nodeSize;if(g.isText){let v=b;s<i.length&&i[s].from<v&&(v=i[s].from);for(let x=0;x<o.length;x++)o[x].to<v&&(v=o[x].to);v<b&&(l=g.cut(v-a),g=g.cut(0,v-a),b=v,m=-1)}else for(;s<i.length&&i[s].to<b;)s++;let y=g.isInline&&!g.isLeaf?o.filter(v=>!v.inline):o.slice();r(g,y,e.forChild(a,g),m),a=b}}function kwe(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 Dwe(t,e,n,r){for(let i=0,a=0;i<t.childCount&&a<=r;){let s=t.child(i++),o=a;if(a+=s.nodeSize,!s.isText)continue;let l=s.text;for(;i<t.childCount;){let c=t.child(i++);if(a+=c.nodeSize,!c.isText)break;l+=c.text}if(a>=n){if(a>=r&&l.slice(r-e.length-o,r-o)==e)return r-e.length;let c=o<r?l.lastIndexOf(e,r-o-1):-1;if(c>=0&&c+e.length+o>=n)return o+c;if(n==r&&l.length>=r+e.length-o&&l.slice(r-o,r-o+e.length)==e)return r}}return-1}function eR(t,e,n,r,i){let a=[];for(let s=0,o=0;s<t.length;s++){let l=t[s],c=o,u=o+=l.size;c>=n||u<=e?a.push(l):(c<e&&a.push(l.slice(0,e-c,r)),i&&(a.push(i),i=void 0),u>n&&a.push(l.slice(n-c,l.size,r)))}return a}function Lk(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),a=i&&i.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let o=r.resolve(s),l,c;if(xw(n)){for(l=s;i&&!i.node;)i=i.parent;let h=i.node;if(i&&h.isAtom&&Ft.isSelectable(h)&&i.parent&&!(h.isInline&&awe(n.focusNode,n.focusOffset,i.dom))){let g=i.posBefore;c=new Ft(s==g?o:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let h=s,g=s;for(let m=0;m<n.rangeCount;m++){let b=n.getRangeAt(m);h=Math.min(h,t.docView.posFromDOM(b.startContainer,b.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(b.endContainer,b.endOffset,-1))}if(h<0)return null;[l,s]=g==t.state.selection.anchor?[g,h]:[h,g],o=r.resolve(s)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);if(!c){let h=e=="pointer"||t.state.selection.head<o.pos&&!a?1:-1;c=Ik(t,u,o,h)}return c}function YW(t){return t.editable?t.hasFocus():QW(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function fc(t,e=!1){let n=t.state.selection;if(ZW(t,n),!!YW(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ia){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&If(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Lwe(t);else{let{anchor:r,head:i}=n,a,s;zB&&!(n instanceof Wt)&&(n.$from.parent.inlineContent||(a=BB(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(s=BB(t,n.to))),t.docView.setSelection(r,i,t,e),zB&&(a&&HB(a),s&&HB(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Owe(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const zB=ba||ia&&UW<63;function BB(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(ba&&i&&i.contentEditable=="false")return g2(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return g2(i);if(a)return g2(a)}}function g2(t){return t.contentEditable="true",ba&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function HB(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Owe(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(()=>{(!YW(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Lwe(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Gi(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ba&&Vu<=11&&(n.disabled=!0,n.disabled=!1)}function ZW(t,e){if(e instanceof Ft){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&($B(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else $B(t)}function $B(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ik(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||Wt.between(e,n,r)}function VB(t){return t.editable&&!t.hasFocus()?!1:QW(t)}function QW(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 Iwe(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return If(e.node,e.offset,n.anchorNode,n.anchorOffset)}function tR(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return a&&on.findFrom(a,e)}function Su(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function GB(t,e,n){let r=t.state.selection;if(r instanceof Wt)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 Su(t,new Wt(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=tR(t.state,e);return i&&i instanceof Ft?Su(t,i):!1}else if(!(Ls&&n.indexOf("m")>-1)){let i=r.$head,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!a||a.isText)return!1;let o=e<0?i.pos-a.nodeSize:i.pos;return a.isAtom||(s=t.docView.descAt(o))&&!s.contentDOM?Ft.isSelectable(a)?Su(t,new Ft(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):W0?Su(t,new Wt(t.state.doc.resolve(e<0?o:o+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Ft&&r.node.isInline)return Su(t,new Wt(e>0?r.$to:r.$from));{let i=tR(t.state,e);return i?Su(t,i):!1}}}function m1(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Px(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function fp(t,e){return e<0?jwe(t):Uwe(t)}function jwe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,s=!1;for(Ws&&n.nodeType==1&&r<m1(n)&&Px(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let o=n.childNodes[r-1];if(Px(o,-1))i=n,a=--r;else if(o.nodeType==3)n=o,r=n.nodeValue.length;else break}}else{if(JW(n))break;{let o=n.previousSibling;for(;o&&Px(o,-1);)i=n.parentNode,a=Gi(o),o=o.previousSibling;if(o)n=o,r=m1(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?nR(t,n,r):i&&nR(t,i,a)}function Uwe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=m1(n),a,s;for(;;)if(r<i){if(n.nodeType!=1)break;let o=n.childNodes[r];if(Px(o,1))a=n,s=++r;else break}else{if(JW(n))break;{let o=n.nextSibling;for(;o&&Px(o,1);)a=o.parentNode,s=Gi(o)+1,o=o.nextSibling;if(o)n=o,r=0,i=m1(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&nR(t,a,s)}function JW(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Fwe(t,e){for(;t&&e==t.childNodes.length&&!G0(t);)e=Gi(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 zwe(t,e){for(;t&&!e&&!G0(t);)e=Gi(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function nR(t,e,n){if(e.nodeType!=3){let a,s;(s=Fwe(e,n))?(e=s,n=0):(a=zwe(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(xw(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&&fc(t)},50)}function WB(t,e){let n=t.state.doc.resolve(e);if(!(ia||lwe)&&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 qB(t,e,n){let r=t.state.selection;if(r instanceof Wt&&!r.empty||n.indexOf("s")>-1||Ls&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=tR(t.state,e);if(s&&s instanceof Ft)return Su(t,s)}if(!i.parent.inlineContent){let s=e<0?i:a,o=r instanceof hs?on.near(s,e):on.findFrom(s,e);return o?Su(t,o):!1}return!1}function XB(t,e){if(!(t.state.selection instanceof Wt))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 KB(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Bwe(t){if(!ba||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;KB(t,r,"true"),setTimeout(()=>KB(t,r,"false"),20)}return!1}function Hwe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function $we(t,e){let n=e.keyCode,r=Hwe(e);if(n==8||Ls&&n==72&&r=="c")return XB(t,-1)||fp(t,-1);if(n==46&&!e.shiftKey||Ls&&n==68&&r=="c")return XB(t,1)||fp(t,1);if(n==13||n==27)return!0;if(n==37||Ls&&n==66&&r=="c"){let i=n==37?WB(t,t.state.selection.from)=="ltr"?-1:1:-1;return GB(t,i,r)||fp(t,i)}else if(n==39||Ls&&n==70&&r=="c"){let i=n==39?WB(t,t.state.selection.from)=="ltr"?1:-1:1;return GB(t,i,r)||fp(t,i)}else{if(n==38||Ls&&n==80&&r=="c")return qB(t,-1,r)||fp(t,-1);if(n==40||Ls&&n==78&&r=="c")return Bwe(t)||qB(t,1,r)||fp(t,1);if(r==(Ls?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function jk(t,e){t.someProp("transformCopied",m=>{e=m(e,t)});let n=[],{content:r,openStart:i,openEnd:a}=e;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let s=t.someProp("clipboardSerializer")||Kf.fromSchema(t.state.schema),o=aq(),l=o.createElement("div");l.appendChild(s.serializeFragment(r,{document:o}));let c=l.firstChild,u,h=0;for(;c&&c.nodeType==1&&(u=iq[c.nodeName.toLowerCase()]);){for(let m=u.length-1;m>=0;m--){let b=o.createElement(u[m]);for(;l.firstChild;)b.appendChild(l.firstChild);l.appendChild(b),h++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${a}${h?` -${h}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",m=>m(e,t))||e.content.textBetween(0,e.content.size,`
  8066. `);return{dom:l,text:g,slice:e}}function eq(t,e,n,r,i){let a=i.parent.type.spec.code,s,o;if(!n&&!e)return null;let l=!!e&&(r||a||!n);if(l){if(t.someProp("transformPastedText",g=>{e=g(e,a||r,t)}),a)return o=new Mt(pt.from(t.state.schema.text(e.replace(/\r\n?/g,`
  8067. `))),0,0),t.someProp("transformPasted",g=>{o=g(o,t,!0)}),o;let h=t.someProp("clipboardTextParser",g=>g(e,i,r,t));if(h)o=h;else{let g=i.marks(),{schema:m}=t.state,b=Kf.fromSchema(m);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let v=s.appendChild(document.createElement("p"));y&&v.appendChild(b.serializeNode(m.text(y,g)))})}}else t.someProp("transformPastedHTML",h=>{n=h(n,t)}),s=qwe(n),W0&&Xwe(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let h=+u[3];h>0;h--){let g=s.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;s=g}if(o||(o=(t.someProp("clipboardParser")||t.someProp("domParser")||Cx.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||u),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!Vwe.test(g.parentNode.nodeName)?{ignore:!0}:null}})),u)o=Kwe(YB(o,+u[1],+u[2]),u[4]);else if(o=Mt.maxOpen(Gwe(o.content,i),!0),o.openStart||o.openEnd){let h=0,g=0;for(let m=o.content.firstChild;h<o.openStart&&!m.type.spec.isolating;h++,m=m.firstChild);for(let m=o.content.lastChild;g<o.openEnd&&!m.type.spec.isolating;g++,m=m.lastChild);o=YB(o,h,g)}return t.someProp("transformPasted",h=>{o=h(o,t,l)}),o}const Vwe=/^(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 Gwe(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),a,s=[];if(t.forEach(o=>{if(!s)return;let l=i.findWrapping(o.type),c;if(!l)return s=null;if(c=s.length&&a.length&&nq(l,a,o,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=rq(s[s.length-1],a.length));let u=tq(o,l);s.push(u),i=i.matchType(u.type),a=l}}),s)return pt.from(s)}return t}function tq(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,pt.from(t));return t}function nq(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=nq(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(tq(n,t,i+1))))}}function rq(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,rq(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(pt.empty,!0);return t.copy(n.append(r))}function rR(t,e,n,r,i,a){let s=e<0?t.firstChild:t.lastChild,o=s.content;return t.childCount>1&&(a=0),i<r-1&&(o=rR(o,e,n,r,i+1,a)),i>=n&&(o=e<0?s.contentMatchAt(0).fillBefore(o,a<=i).append(o):o.append(s.contentMatchAt(s.childCount).fillBefore(pt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(o))}function YB(t,e,n){return e<t.openStart&&(t=new Mt(rR(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Mt(rR(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const iq={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 ZB=null;function aq(){return ZB||(ZB=document.implementation.createHTMLDocument("title"))}let x2=null;function Wwe(t){let e=window.trustedTypes;return e?(x2||(x2=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),x2.createHTML(t)):t}function qwe(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=aq().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&iq[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=Wwe(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function Xwe(t){let e=t.querySelectorAll(ia?"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 Kwe(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:a,openEnd:s}=t;for(let o=r.length-2;o>=0;o-=2){let l=n.nodes[r[o]];if(!l||l.hasRequiredAttrs())break;i=pt.from(l.create(r[o+1],i)),a++,s++}return new Mt(i,a,s)}const ya={},_a={},Ywe={touchstart:!0,touchmove:!0};class Zwe{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 Qwe(t){for(let e in ya){let n=ya[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{eMe(t,r)&&!Uk(t,r)&&(t.editable||!(r.type in _a))&&n(t,r)},Ywe[e]?{passive:!0}:void 0)}ba&&t.dom.addEventListener("input",()=>null),iR(t)}function ju(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Jwe(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function iR(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Uk(t,r))})}function Uk(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function eMe(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 tMe(t,e){!Uk(t,e)&&ya[e.type]&&(t.editable||!(e.type in _a))&&ya[e.type](t,e)}_a.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!oq(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(ic&&ia&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),sm&&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,Zd(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||$we(t,n)?n.preventDefault():ju(t,"key")};_a.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};_a.keypress=(t,e)=>{let n=e;if(oq(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ls&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Wt)||!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 bw(t){return{left:t.clientX,top:t.clientY}}function nMe(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Fk(t,e,n,r,i){if(r==-1)return!1;let a=t.state.doc.resolve(r);for(let s=a.depth+1;s>0;s--)if(t.someProp(e,o=>s>a.depth?o(t,n,a.nodeAfter,a.before(s),i,!0):o(t,n,a.node(s),a.before(s),i,!1)))return!0;return!1}function Up(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 rMe(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Ft.isSelectable(r)?(Up(t,new Ft(n)),!0):!1}function iMe(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Ft&&(r=n.node);let a=t.state.doc.resolve(e);for(let s=a.depth+1;s>0;s--){let o=s>a.depth?a.nodeAfter:a.node(s);if(Ft.isSelectable(o)){r&&n.$from.depth>0&&s>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?i=a.before(n.$from.depth):i=a.before(s);break}}return i!=null?(Up(t,Ft.create(t.state.doc,i)),!0):!1}function aMe(t,e,n,r,i){return Fk(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?iMe(t,n):rMe(t,n))}function sMe(t,e,n,r){return Fk(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function oMe(t,e,n,r){return Fk(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||lMe(t,n,r)}function lMe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Up(t,Wt.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let a=i.depth+1;a>0;a--){let s=a>i.depth?i.nodeAfter:i.node(a),o=i.before(a);if(s.inlineContent)Up(t,Wt.create(r,o+1,o+1+s.content.size));else if(Ft.isSelectable(s))Up(t,Ft.create(r,o));else continue;return!0}}function zk(t){return g1(t)}const sq=Ls?"metaKey":"ctrlKey";ya.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=zk(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&nMe(n,t.input.lastClick)&&!n[sq]&&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(bw(n));s&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new cMe(t,s,n,!!r)):(a=="doubleClick"?sMe:oMe)(t,s.pos,s.inside,n)?n.preventDefault():ju(t,"pointer"))};class cMe{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[sq],this.allowDefault=r.shiftKey;let a,s;if(n.inside>-1)a=e.state.doc.nodeAt(n.inside),s=n.inside;else{let u=e.state.doc.resolve(n.pos);a=u.parent,s=u.depth?u.before():0}const o=i?null:r.target,l=o?e.docView.nearestDesc(o,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&a.type.spec.draggable&&a.type.spec.selectable!==!1||c instanceof Ft&&c.from<=s&&c.to>s)&&(this.mightDrag={node:a,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ws&&!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)),ju(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(()=>fc(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(bw(e))),this.updateAllowDefault(e),this.allowDefault||!n?ju(this.view,"pointer"):aMe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ba&&this.mightDrag&&!this.mightDrag.node.isAtom||ia&&!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)?(Up(this.view,on.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):ju(this.view,"pointer")}move(e){this.updateAllowDefault(e),ju(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)}}ya.touchstart=t=>{t.input.lastTouch=Date.now(),zk(t),ju(t,"pointer")};ya.touchmove=t=>{t.input.lastTouch=Date.now(),ju(t,"pointer")};ya.contextmenu=t=>zk(t);function oq(t,e){return t.composing?!0:ba&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const uMe=ic?5e3:-1;_a.compositionstart=_a.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Wt&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),g1(t,!0),t.markCursor=null;else if(g1(t,!e.selection.empty),Ws&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,a=r.focusOffset;i&&i.nodeType==1&&a!=0;){let s=a<0?i.lastChild:i.childNodes[a-1];if(!s)break;if(s.nodeType==3){let o=t.domSelection();o&&o.collapse(s,s.nodeValue.length);break}else i=s,a=-1}}t.input.composing=!0}lq(t,uMe)};_a.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++,lq(t,20))};function lq(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>g1(t),e))}function cq(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=fMe());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function dMe(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=rwe(e.focusNode,e.focusOffset),r=iwe(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 fMe(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function g1(t,e=!1){if(!(ic&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),cq(t),e||t.docView&&t.docView.dirty){let n=Lk(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 hMe(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 d0=Ba&&Vu<15||sm&&cwe<604;ya.copy=_a.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=d0?null:n.clipboardData,s=r.content(),{dom:o,text:l}=jk(t,s);a?(n.preventDefault(),a.clearData(),a.setData("text/html",o.innerHTML),a.setData("text/plain",l)):hMe(t,o),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function pMe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function mMe(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?f0(t,r.value,null,i,e):f0(t,r.textContent,r.innerHTML,i,e)},50)}function f0(t,e,n,r,i){let a=eq(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,i,a||Mt.empty)))return!0;if(!a)return!1;let s=pMe(a),o=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(a);return t.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function uq(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," "):""}_a.paste=(t,e)=>{let n=e;if(t.composing&&!ic)return;let r=d0?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&f0(t,uq(r),r.getData("text/html"),i,n)?n.preventDefault():mMe(t,n)};class dq{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const gMe=Ls?"altKey":"ctrlKey";function fq(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[gMe]}ya.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(bw(n)),s;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Ft?i.to-1:i.to))){if(r&&r.mightDrag)s=Ft.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let h=t.docView.nearestDesc(n.target,!0);h&&h.node.type.spec.draggable&&h!=t.docView&&(s=Ft.create(t.state.doc,h.posBefore))}}let o=(s||t.state.selection).content(),{dom:l,text:c,slice:u}=jk(t,o);(!n.dataTransfer.files.length||!ia||UW>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(d0?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",d0||n.dataTransfer.setData("text/plain",c),t.dragging=new dq(u,fq(t,n),s)};ya.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};_a.dragover=_a.dragenter=(t,e)=>e.preventDefault();_a.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(bw(n));if(!i)return;let a=t.state.doc.resolve(i.pos),s=r&&r.slice;s?t.someProp("transformPasted",b=>{s=b(s,t,!1)}):s=eq(t,uq(n.dataTransfer),d0?null:n.dataTransfer.getData("text/html"),!1,a);let o=!!(r&&fq(t,n));if(t.someProp("handleDrop",b=>b(t,n,s||Mt.empty,o))){n.preventDefault();return}if(!s)return;n.preventDefault();let l=s?xW(t.state.doc,a.pos,s):a.pos;l==null&&(l=a.pos);let c=t.state.tr;if(o){let{node:b}=r;b?b.replace(c):c.deleteSelection()}let u=c.mapping.map(l),h=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,g=c.doc;if(h?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(g))return;let m=c.doc.resolve(u);if(h&&Ft.isSelectable(s.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new Ft(m));else{let b=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((y,v,x,M)=>b=M),c.setSelection(Ik(t,m,c.doc.resolve(b)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))};ya.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())&&fc(t)},20))};ya.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)};ya.beforeinput=(t,e)=>{if(ia&&ic&&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,Zd(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 _a)ya[t]=_a[t];function h0(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 x1{constructor(e,n){this.toDOM=e,this.spec=n||hf,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 ga(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof x1&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&h0(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Wu{constructor(e,n){this.attrs=e,this.spec=n||hf}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 ga(a,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Wu&&h0(this.attrs,e.attrs)&&h0(this.spec,e.spec)}static is(e){return e.type instanceof Wu}destroy(){}}class Bk{constructor(e,n){this.attrs=e,this.spec=n||hf}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 ga(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 Bk&&h0(this.attrs,e.attrs)&&h0(this.spec,e.spec)}destroy(){}}class ga{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new ga(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 ga(e,e,new x1(n,r))}static inline(e,n,r,i){return new ga(e,n,new Wu(r,i))}static node(e,n,r,i){return new ga(e,n,new Bk(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Wu}get widget(){return this.type instanceof x1}}const bp=[],hf={};class mr{constructor(e,n){this.local=e.length?e:bp,this.children=n.length?n:bp}static create(e,n){return n.length?v1(n,e,0,hf):ea}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,a){for(let s=0;s<this.local.length;s++){let o=this.local[s];o.from<=n&&o.to>=e&&(!a||a(o.spec))&&r.push(o.copy(o.from+i,o.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let o=this.children[s]+1;this.children[s+2].findInner(e-o,n-o,r,i+o,a)}}map(e,n,r){return this==ea||e.maps.length==0?this:this.mapInner(e,n,0,0,r||hf)}mapInner(e,n,r,i,a){let s;for(let o=0;o<this.local.length;o++){let l=this.local[o].map(e,r,i);l&&l.type.valid(n,l)?(s||(s=[])).push(l):a.onRemove&&a.onRemove(this.local[o].spec)}return this.children.length?xMe(this.children,s||[],e,n,r,i,a):s?new mr(s.sort(pf),bp):ea}add(e,n){return n.length?this==ea?mr.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,a=0;e.forEach((o,l)=>{let c=l+r,u;if(u=pq(n,o,c)){for(i||(i=this.children.slice());a<i.length&&i[a]<l;)a+=3;i[a]==l?i[a+2]=i[a+2].addInner(o,u,c+1):i.splice(a,0,l,l+o.nodeSize,v1(u,o,c+1,hf)),a+=3}});let s=hq(a?mq(n):n,-r);for(let o=0;o<s.length;o++)s[o].type.valid(e,s[o])||s.splice(o--,1);return new mr(s.length?this.local.concat(s).sort(pf):this.local,i||this.children)}remove(e){return e.length==0||this==ea?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let a=0;a<r.length;a+=3){let s,o=r[a]+n,l=r[a+1]+n;for(let u=0,h;u<e.length;u++)(h=e[u])&&h.from>o&&h.to<l&&(e[u]=null,(s||(s=[])).push(h));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[a+2].removeInner(s,o+1);c!=ea?r[a+2]=c:(r.splice(a,3),a-=3)}if(i.length){for(let a=0,s;a<e.length;a++)if(s=e[a])for(let o=0;o<i.length;o++)i[o].eq(s,n)&&(i==this.local&&(i=this.local.slice()),i.splice(o--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new mr(i,r):ea}forChild(e,n){if(this==ea)return this;if(n.isLeaf)return mr.empty;let r,i;for(let o=0;o<this.children.length;o+=3)if(this.children[o]>=e){this.children[o]==e&&(r=this.children[o+2]);break}let a=e+1,s=a+n.content.size;for(let o=0;o<this.local.length;o++){let l=this.local[o];if(l.from<s&&l.to>a&&l.type instanceof Wu){let c=Math.max(a,l.from)-a,u=Math.min(s,l.to)-a;c<u&&(i||(i=[])).push(l.copy(c,u))}}if(i){let o=new mr(i.sort(pf),bp);return r?new Nu([o,r]):o}return r||ea}eq(e){if(this==e)return!0;if(!(e instanceof mr)||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 Hk(this.localsInner(e))}localsInner(e){if(this==ea)return bp;if(e.inlineContent||!this.local.some(Wu.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Wu||n.push(this.local[r]);return n}forEachSet(e){e(this)}}mr.empty=new mr([],[]);mr.removeOverlap=Hk;const ea=mr.empty;class Nu{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,hf));return Nu.from(r)}forChild(e,n){if(n.isLeaf)return mr.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=ea&&(a instanceof Nu?r=r.concat(a.members):r.push(a))}return Nu.from(r)}eq(e){if(!(e instanceof Nu)||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?Hk(r?n:n.sort(pf)):bp}static from(e){switch(e.length){case 0:return ea;case 1:return e[0];default:return new Nu(e.every(n=>n instanceof mr)?e:e.reduce((n,r)=>n.concat(r instanceof mr?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function xMe(t,e,n,r,i,a,s){let o=t.slice();for(let c=0,u=a;c<n.maps.length;c++){let h=0;n.maps[c].forEach((g,m,b,y)=>{let v=y-b-(m-g);for(let x=0;x<o.length;x+=3){let M=o[x+1];if(M<0||g>M+u-h)continue;let w=o[x]+u-h;m>=w?o[x+1]=g<=w?-2:-1:g>=u&&v&&(o[x]+=v,o[x+1]+=v)}h+=v}),u=n.maps[c].map(u,-1)}let l=!1;for(let c=0;c<o.length;c+=3)if(o[c+1]<0){if(o[c+1]==-2){l=!0,o[c+1]=-1;continue}let u=n.map(t[c]+a),h=u-i;if(h<0||h>=r.content.size){l=!0;continue}let g=n.map(t[c+1]+a,-1),m=g-i,{index:b,offset:y}=r.content.findIndex(h),v=r.maybeChild(b);if(v&&y==h&&y+v.nodeSize==m){let x=o[c+2].mapInner(n,v,u+1,t[c]+a+1,s);x!=ea?(o[c]=h,o[c+1]=m,o[c+2]=x):(o[c+1]=-2,l=!0)}else l=!0}if(l){let c=vMe(o,t,e,n,i,a,s),u=v1(c,r,0,s);e=u.local;for(let h=0;h<o.length;h+=3)o[h+1]<0&&(o.splice(h,3),h-=3);for(let h=0,g=0;h<u.children.length;h+=3){let m=u.children[h];for(;g<o.length&&o[g]<m;)g+=3;o.splice(g,0,u.children[h],u.children[h+1],u.children[h+2])}}return new mr(e.sort(pf),o)}function hq(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 ga(i.from+e,i.to+e,i.type))}return n}function vMe(t,e,n,r,i,a,s){function o(l,c){for(let u=0;u<l.local.length;u++){let h=l.local[u].map(r,i,c);h?n.push(h):s.onRemove&&s.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)o(l.children[u+2],l.children[u]+c+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&o(t[l+2],e[l]+a+1);return n}function pq(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 mq(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function v1(t,e,n,r){let i=[],a=!1;e.forEach((o,l)=>{let c=pq(t,o,l+n);if(c){a=!0;let u=v1(c,o,n+l+1,r);u!=ea&&i.push(l,l+o.nodeSize,u)}});let s=hq(a?mq(t):t,-n).sort(pf);for(let o=0;o<s.length;o++)s[o].type.valid(e,s[o])||(r.onRemove&&r.onRemove(s[o].spec),s.splice(o--,1));return s.length||i.length?new mr(s,i):ea}function pf(t,e){return t.from-e.from||t.to-e.to}function Hk(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),QB(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),QB(e,i,r.copy(a.from,r.to)));break}}}return e}function QB(t,e,n){for(;e<t.length&&pf(n,t[e])>0;)e++;t.splice(e,0,n)}function v2(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ea&&e.push(r)}),t.cursorWrapper&&e.push(mr.create(t.state.doc,[t.cursorWrapper.deco])),Nu.from(e)}const bMe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},yMe=Ba&&Vu<=11;class _Me{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 SMe{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new _Me,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]);Ba&&Vu<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),yMe&&(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,bMe)),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(VB(this.view)){if(this.suppressingSelectionUpdates)return fc(this.view);if(Ba&&Vu<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&If(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=am(a))n.add(a);for(let a=e.anchorNode;a;a=am(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)&&VB(e)&&!this.ignoreSelectionChange(r),a=-1,s=-1,o=!1,l=[];if(e.editable)for(let u=0;u<n.length;u++){let h=this.registerMutation(n[u],l);h&&(a=a<0?h.from:Math.min(h.from,a),s=s<0?h.to:Math.max(h.to,s),h.typeOver&&(o=!0))}if(Ws&&l.length){let u=l.filter(h=>h.nodeName=="BR");if(u.length==2){let[h,g]=u;h.parentNode&&h.parentNode.parentNode==g.parentNode?g.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let g of u){let m=g.parentNode;m&&m.nodeName=="LI"&&(!h||EMe(e,h)!=m)&&g.remove()}}}let c=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&xw(r)&&(c=Lk(e))&&c.eq(on.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,fc(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,s),wMe(e)),this.handleDOMChange(a,s,o,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||fc(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 u=0;u<e.addedNodes.length;u++){let h=e.addedNodes[u];n.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,a=e.nextSibling;if(Ba&&Vu<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:h,nextSibling:g}=e.addedNodes[u];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h),(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(a=g)}let s=i&&i.parentNode==e.target?Gi(i)+1:0,o=r.localPosFromDOM(e.target,s,-1),l=a&&a.parentNode==e.target?Gi(a):e.target.childNodes.length,c=r.localPosFromDOM(e.target,l,1);return{from:o,to:c}}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 JB=new WeakMap,e6=!1;function wMe(t){if(!JB.has(t)&&(JB.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Ws,e6)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."),e6=!0}}function t6(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return If(s.node,s.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function MMe(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return t6(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?t6(t,n):null}function EMe(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 AMe(t,e,n){let{node:r,fromOffset:i,toOffset:a,from:s,to:o}=t.docView.parseRange(e,n),l=t.domSelectionRange(),c,u=l.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:l.anchorOffset}],xw(l)||c.push({node:l.focusNode,offset:l.focusOffset})),ia&&t.input.lastKeyCode===8)for(let v=a;v>i;v--){let x=r.childNodes[v-1],M=x.pmViewDesc;if(x.nodeName=="BR"&&!M){a=v;break}if(!M||M.size)break}let h=t.state.doc,g=t.someProp("domParser")||Cx.fromSchema(t.state.schema),m=h.resolve(s),b=null,y=g.parse(r,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:i,to:a,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:TMe,context:m});if(c&&c[0].pos!=null){let v=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=v),b={anchor:v+s,head:x+s}}return{doc:y,sel:b,from:s,to:o}}function TMe(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ba&&/^(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||ba&&/^(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 CMe=/^(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 NMe(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let A=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,j=Lk(t,A);if(j&&!t.state.selection.eq(j)){if(ia&&ic&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",k=>k(t,Zd(13,"Enter"))))return;let N=t.state.tr.setSelection(j);A=="pointer"?N.setMeta("pointer",!0):A=="key"&&N.scrollIntoView(),a&&N.setMeta("composition",a),t.dispatch(N)}return}let s=t.state.doc.resolve(e),o=s.sharedDepth(n);e=s.before(o+1),n=t.state.doc.resolve(n).after(o+1);let l=t.state.selection,c=AMe(t,e,n),u=t.state.doc,h=u.slice(c.from,c.to),g,m;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(g=t.state.selection.to,m="end"):(g=t.state.selection.from,m="start"),t.input.lastKeyCode=null;let b=kMe(h.content,c.doc.content,c.from,g,m);if(b&&t.input.domChangeCount++,(sm&&t.input.lastIOSEnter>Date.now()-225||ic)&&i.some(A=>A.nodeType==1&&!CMe.test(A.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",A=>A(t,Zd(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(r&&l instanceof Wt&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))b={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let A=n6(t,t.state.doc,c.sel);if(A&&!A.eq(t.state.selection)){let j=t.state.tr.setSelection(A);a&&j.setMeta("composition",a),t.dispatch(j)}}return}t.state.selection.from<t.state.selection.to&&b.start==b.endB&&t.state.selection instanceof Wt&&(b.start>t.state.selection.from&&b.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?b.start=t.state.selection.from:b.endA<t.state.selection.to&&b.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(b.endB+=t.state.selection.to-b.endA,b.endA=t.state.selection.to)),Ba&&Vu<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>c.from&&c.doc.textBetween(b.start-c.from-1,b.start-c.from+1)=="  "&&(b.start--,b.endA--,b.endB--);let y=c.doc.resolveNoCache(b.start-c.from),v=c.doc.resolveNoCache(b.endB-c.from),x=u.resolve(b.start),M=y.sameParent(v)&&y.parent.inlineContent&&x.end()>=b.endA;if((sm&&t.input.lastIOSEnter>Date.now()-225&&(!M||i.some(A=>A.nodeName=="DIV"||A.nodeName=="P"))||!M&&y.pos<c.doc.content.size&&(!y.sameParent(v)||!y.parent.inlineContent)&&y.pos<v.pos&&!/\S/.test(c.doc.textBetween(y.pos,v.pos,"","")))&&t.someProp("handleKeyDown",A=>A(t,Zd(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&PMe(u,b.start,b.endA,y,v)&&t.someProp("handleKeyDown",A=>A(t,Zd(8,"Backspace")))){ic&&ia&&t.domObserver.suppressSelectionUpdates();return}ia&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),ic&&!M&&y.start()!=v.start()&&v.parentOffset==0&&y.depth==v.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==b.endA&&(b.endB-=2,v=c.doc.resolveNoCache(b.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(A){return A(t,Zd(13,"Enter"))})},20));let w=b.start,C=b.endA,T=A=>{let j=A||t.state.tr.replace(w,C,c.doc.slice(b.start-c.from,b.endB-c.from));if(c.sel){let N=n6(t,j.doc,c.sel);N&&!(ia&&t.composing&&N.empty&&(b.start!=b.endB||t.input.lastChromeDelete<Date.now()-100)&&(N.head==w||N.head==j.mapping.map(C)-1)||Ba&&N.empty&&N.head==w)&&j.setSelection(N)}return a&&j.setMeta("composition",a),j.scrollIntoView()},R;if(M)if(y.pos==v.pos){Ba&&Vu<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>fc(t),20));let A=T(t.state.tr.delete(w,C)),j=u.resolve(b.start).marksAcross(u.resolve(b.endA));j&&A.ensureMarks(j),t.dispatch(A)}else if(b.endA==b.endB&&(R=RMe(y.parent.content.cut(y.parentOffset,v.parentOffset),x.parent.content.cut(x.parentOffset,b.endA-x.start())))){let A=T(t.state.tr);R.type=="add"?A.addMark(w,C,R.mark):A.removeMark(w,C,R.mark),t.dispatch(A)}else if(y.parent.child(y.index()).isText&&y.index()==v.index()-(v.textOffset?0:1)){let A=y.parent.textBetween(y.parentOffset,v.parentOffset),j=()=>T(t.state.tr.insertText(A,w,C));t.someProp("handleTextInput",N=>N(t,w,C,A,j))||t.dispatch(j())}else t.dispatch(T());else t.dispatch(T())}function n6(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Ik(t,e.resolve(n.anchor),e.resolve(n.head))}function RMe(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,a=r,s,o,l;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<n.length;u++)a=n[u].removeFromSet(a);if(i.length==1&&a.length==0)o=i[0],s="add",l=u=>u.mark(o.addToSet(u.marks));else if(i.length==0&&a.length==1)o=a[0],s="remove",l=u=>u.mark(o.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(l(e.child(u)));if(pt.from(c).eq(t))return{mark:o,type:s}}function PMe(t,e,n,r,i){if(n-e<=i.pos-r.pos||b2(r,!0,!1)<i.pos)return!1;let a=t.resolve(e);if(!r.parent.isTextblock){let o=a.nodeAfter;return o!=null&&n==e+o.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let s=t.resolve(b2(a,!0,!0));return!s.parent.isTextblock||s.pos>n||b2(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function b2(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 kMe(t,e,n,r,i){let a=t.findDiffStart(e,n);if(a==null)return null;let{a:s,b:o}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let l=Math.max(0,a-Math.min(s,o));r-=s+l-a}if(s<a&&t.size<e.size){let l=r<=a&&r>=s?a-r:0;a-=l,a&&a<e.size&&r6(e.textBetween(a-1,a+1))&&(a+=l?1:-1),o=a+(o-s),s=a}else if(o<a){let l=r<=a&&r>=o?a-r:0;a-=l,a&&a<t.size&&r6(t.textBetween(a-1,a+1))&&(a+=l?1:-1),s=a+(s-o),o=a}return{start:a,endA:s,endB:o}}function r6(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 gq{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 Zwe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(l6),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=s6(this),a6(this),this.nodeViews=o6(this),this.docView=UB(this.state.doc,i6(this),v2(this),this.dom,this),this.domObserver=new SMe(this,(r,i,a,s)=>NMe(this,r,i,a,s)),this.domObserver.start(),Qwe(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&iR(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(l6),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&&(cq(this),s=!0),this.state=e;let o=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(o||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let m=o6(this);OMe(m,this.nodeViews)&&(this.nodeViews=m,a=!0)}(o||n.handleDOMEvents!=this._props.handleDOMEvents)&&iR(this),this.editable=s6(this),a6(this);let l=v2(this),c=i6(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=a||!this.docView.matchesNode(e.doc,c,l);(h||!e.selection.eq(i.selection))&&(s=!0);let g=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&fwe(this);if(s){this.domObserver.stop();let m=h&&(Ba||ia)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&DMe(i.selection,e.selection);if(h){let b=ia?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=dMe(this)),(a||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=UB(e.doc,c,l,this.dom,this)),b&&!this.trackWrites&&(m=!0)}m||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Iwe(this))?fc(this,m):(ZW(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),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():g&&hwe(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 Ft){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&kB(this,n.getBoundingClientRect(),e)}else kB(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 dq(e.slice,e.move,i<0?void 0:Ft.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let s=0;s<this.directPlugins.length;s++){let o=this.directPlugins[s].props[e];if(o!=null&&(i=n?n(o):o))return i}let a=this.state.plugins;if(a)for(let s=0;s<a.length;s++){let o=a[s].props[e];if(o!=null&&(i=n?n(o):o))return i}}hasFocus(){if(Ba){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&&pwe(this.dom),fc(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 bwe(this,e)}coordsAtPos(e,n=1){return $W(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 Mwe(this,n||this.state,e)}pasteHTML(e,n){return f0(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return f0(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return jk(this,e)}destroy(){this.docView&&(Jwe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],v2(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,twe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return tMe(this,e)}domSelectionRange(){let e=this.domSelection();return e?ba&&this.root.nodeType===11&&swe(this.dom.ownerDocument)==this.dom&&MMe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}gq.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function i6(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"),[ga.node(0,t.state.doc.content.size,e)]}function a6(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:ga.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function s6(t){return!t.someProp("editable",e=>e(t.state)===!1)}function DMe(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 o6(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 OMe(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 l6(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 ed={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:"'"},b1={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},LMe=typeof navigator<"u"&&/Mac/.test(navigator.platform),IMe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Wi=0;Wi<10;Wi++)ed[48+Wi]=ed[96+Wi]=String(Wi);for(var Wi=1;Wi<=24;Wi++)ed[Wi+111]="F"+Wi;for(var Wi=65;Wi<=90;Wi++)ed[Wi]=String.fromCharCode(Wi+32),b1[Wi]=String.fromCharCode(Wi);for(var y2 in ed)b1.hasOwnProperty(y2)||(b1[y2]=ed[y2]);function jMe(t){var e=LMe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||IMe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?b1:ed)[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 UMe=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),FMe=typeof navigator<"u"&&/Win/.test(navigator.platform);function zMe(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,a,s;for(let o=0;o<e.length-1;o++){let l=e[o];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))a=!0;else if(/^mod$/i.test(l))UMe?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),s&&(n="Meta-"+n),a&&(n="Shift-"+n),n}function BMe(t){let e=Object.create(null);for(let n in t)e[zMe(n)]=t[n];return e}function _2(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 HMe(t){return new vr({props:{handleKeyDown:xq(t)}})}function xq(t){let e=BMe(t);return function(n,r){let i=jMe(r),a,s=e[_2(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let o=e[_2(i,r,!1)];if(o&&o(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(FMe&&r.ctrlKey&&r.altKey)&&(a=ed[r.keyCode])&&a!=i){let o=e[_2(a,r)];if(o&&o(n.state,n.dispatch,n))return!0}}return!1}}var $Me=Object.defineProperty,$k=(t,e)=>{for(var n in e)$Me(t,n,{get:e[n],enumerable:!0})};function yw(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 _w=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([s,o])=>[s,(...c)=>{const u=o(...c)(a);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,s=[],o=!!t,l=t||i.tr,c=()=>(!o&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(l),s.every(h=>h===!0)),u={...Object.fromEntries(Object.entries(n).map(([h,g])=>[h,(...b)=>{const y=this.buildProps(l,e),v=g(...b)(y);return s.push(v),u}])),run:c};return u}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,a=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([o,l])=>[o,(...c)=>l(...c)({...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:yw({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([o,l])=>[o,(...c)=>l(...c)(s)]))}};return s}},vq={};$k(vq,{blur:()=>VMe,clearContent:()=>GMe,clearNodes:()=>WMe,command:()=>qMe,createParagraphNear:()=>XMe,cut:()=>KMe,deleteCurrentNode:()=>YMe,deleteNode:()=>ZMe,deleteRange:()=>QMe,deleteSelection:()=>JMe,enter:()=>eEe,exitCode:()=>tEe,extendMarkRange:()=>nEe,first:()=>rEe,focus:()=>aEe,forEach:()=>sEe,insertContent:()=>oEe,insertContentAt:()=>uEe,joinBackward:()=>hEe,joinDown:()=>fEe,joinForward:()=>pEe,joinItemBackward:()=>mEe,joinItemForward:()=>gEe,joinTextblockBackward:()=>xEe,joinTextblockForward:()=>vEe,joinUp:()=>dEe,keyboardShortcut:()=>yEe,lift:()=>_Ee,liftEmptyBlock:()=>SEe,liftListItem:()=>wEe,newlineInCode:()=>MEe,resetAttributes:()=>EEe,scrollIntoView:()=>AEe,selectAll:()=>TEe,selectNodeBackward:()=>CEe,selectNodeForward:()=>NEe,selectParentNode:()=>REe,selectTextblockEnd:()=>PEe,selectTextblockStart:()=>kEe,setContent:()=>DEe,setMark:()=>ZEe,setMeta:()=>QEe,setNode:()=>JEe,setNodeSelection:()=>eAe,setTextDirection:()=>tAe,setTextSelection:()=>nAe,sinkListItem:()=>rAe,splitBlock:()=>iAe,splitListItem:()=>aAe,toggleList:()=>sAe,toggleMark:()=>oAe,toggleNode:()=>lAe,toggleWrap:()=>cAe,undoInputRule:()=>uAe,unsetAllMarks:()=>dAe,unsetMark:()=>fAe,unsetTextDirection:()=>hAe,updateAttributes:()=>pAe,wrapIn:()=>mAe,wrapInList:()=>gAe});var VMe=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),GMe=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),WMe=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:a,$to:s})=>{t.doc.nodesBetween(a.pos,s.pos,(o,l)=>{if(o.type.isText)return;const{doc:c,mapping:u}=e,h=c.resolve(u.map(l)),g=c.resolve(u.map(l+o.nodeSize)),m=h.blockRange(g);if(!m)return;const b=Rm(m);if(o.type.isTextblock){const{defaultType:y}=h.parent.contentMatchAt(h.index());e.setNodeMarkup(m.start,y)}(b||b===0)&&e.lift(m,b)})}),!0},qMe=t=>e=>t(e),XMe=()=>({state:t,dispatch:e})=>DW(t,e),KMe=(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 Wt(r.doc.resolve(Math.max(s-1,0)))),!0},YMe=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===r.type){if(e){const o=i.before(a),l=i.after(a);t.delete(o,l).scrollIntoView()}return!0}return!1};function Yr(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 ZMe=t=>({tr:e,state:n,dispatch:r})=>{const i=Yr(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 l=a.before(s),c=a.after(s);e.delete(l,c).scrollIntoView()}return!0}return!1},QMe=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},JMe=()=>({state:t,dispatch:e})=>Nk(t,e),eEe=()=>({commands:t})=>t.keyboardShortcut("Enter"),tEe=()=>({state:t,dispatch:e})=>zSe(t,e);function Vk(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function y1(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:Vk(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function bq(t,e,n={}){return t.find(r=>r.type===e&&y1(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function c6(t,e,n={}){return!!bq(t,e,n)}function Gk(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(u=>u.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(u=>u.type===e)||(n=n||((r=i.node.marks[0])==null?void 0:r.attrs),!bq([...i.node.marks],e,n)))return;let s=i.index,o=t.start()+i.offset,l=s+1,c=o+i.node.nodeSize;for(;s>0&&c6([...t.parent.child(s-1).marks],e,n);)s-=1,o-=t.parent.child(s).nodeSize;for(;l<t.parent.childCount&&c6([...t.parent.child(l).marks],e,n);)c+=t.parent.child(l).nodeSize,l+=1;return{from:o,to:c}}function Tc(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 nEe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=Tc(t,r.schema),{doc:s,selection:o}=n,{$from:l,from:c,to:u}=o;if(i){const h=Gk(l,a,e);if(h&&h.from<=c&&h.to>=u){const g=Wt.create(s,h.from,h.to);n.setSelection(g)}}return!0},rEe=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 yq(t){return t instanceof Wt}function nf(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function _q(t,e=null){if(!e)return null;const n=on.atStart(t),r=on.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?Wt.create(t,nf(0,i,a),nf(t.content.size,i,a)):Wt.create(t,nf(e,i,a),nf(e,i,a))}function iEe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Wk(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var aEe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const s=()=>{(Wk()||iEe())&&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&&!yq(n.state.selection))return s(),!0;const o=_q(i.doc,t)||n.state.selection,l=n.state.selection.eq(o);return a&&(l||i.setSelection(o),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},sEe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),oEe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Sq=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&&Sq(r)}return t};function zy(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 Sq(n)}function p0(t,e,n){if(t instanceof $u||t instanceof pt)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return pt.fromArray(t.map(o=>e.nodeFromJSON(o)));const s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(a){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:a});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",a),p0("",e,n)}if(i){if(n.errorOnInvalidContent){let s=!1,o="";const l=new sW({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:c=>(s=!0,o=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?Cx.fromSchema(l).parseSlice(zy(t),n.parseOptions):Cx.fromSchema(l).parse(zy(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const a=Cx.fromSchema(e);return n.slice?a.parseSlice(zy(t),n.parseOptions).content:a.parse(zy(t),n.parseOptions)}return p0("",e,n)}function lEe(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Ei||i instanceof Ti))return;const a=t.mapping.maps[r];let s=0;a.forEach((o,l,c,u)=>{s===0&&(s=u)}),t.setSelection(on.near(t.doc.resolve(s),n))}var cEe=t=>!("type"in t),uEe=(t,e,n)=>({tr:r,dispatch:i,editor:a})=>{var s;if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let o;const l=v=>{a.emit("contentError",{editor:a,error:v,disableCollaboration:()=>{"collaboration"in a.storage&&typeof a.storage.collaboration=="object"&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{p0(e,a.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(v){l(v)}try{o=p0(e,a.schema,{parseOptions:c,errorOnInvalidContent:(s=n.errorOnInvalidContent)!=null?s:a.options.enableContentCheck})}catch(v){return l(v),!1}let{from:u,to:h}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,m=!0;if((cEe(o)?o:[o]).forEach(v=>{v.check(),g=g?v.isText&&v.marks.length===0:!1,m=m?v.isBlock:!1}),u===h&&m){const{parent:v}=r.doc.resolve(u);v.isTextblock&&!v.type.spec.code&&!v.childCount&&(u-=1,h+=1)}let y;if(g){if(Array.isArray(e))y=e.map(v=>v.text||"").join("");else if(e instanceof pt){let v="";e.forEach(x=>{x.text&&(v+=x.text)}),y=v}else typeof e=="object"&&e&&e.text?y=e.text:y=e;r.insertText(y,u,h)}else{y=o;const v=r.doc.resolve(u),x=v.node(),M=v.parentOffset===0,w=x.isText||x.isTextblock,C=x.content.size>0;M&&w&&C&&(u=Math.max(0,u-1)),r.replaceWith(u,h,y)}n.updateSelection&&lEe(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:y}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:y})}return!0},dEe=()=>({state:t,dispatch:e})=>jSe(t,e),fEe=()=>({state:t,dispatch:e})=>USe(t,e),hEe=()=>({state:t,dispatch:e})=>AW(t,e),pEe=()=>({state:t,dispatch:e})=>RW(t,e),mEe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=pw(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},gEe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=pw(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},xEe=()=>({state:t,dispatch:e})=>LSe(t,e),vEe=()=>({state:t,dispatch:e})=>ISe(t,e);function wq(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function bEe(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,a,s;for(let o=0;o<e.length-1;o+=1){const l=e[o];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))a=!0;else if(/^mod$/i.test(l))Wk()||wq()?s=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var yEe=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=bEe(t).split(/-(?!$)/),s=a.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),o=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,o))});return l?.steps.forEach(c=>{const u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function td(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,s=e?Yr(e,t.schema):null,o=[];t.doc.nodesBetween(r,i,(h,g)=>{if(h.isText)return;const m=Math.max(r,g),b=Math.min(i,g+h.nodeSize);o.push({node:h,from:m,to:b})});const l=i-r,c=o.filter(h=>s?s.name===h.node.type.name:!0).filter(h=>y1(h.node.attrs,n,{strict:!1}));return a?!!c.length:c.reduce((h,g)=>h+g.to-g.from,0)>=l}var _Ee=(t,e={})=>({state:n,dispatch:r})=>{const i=Yr(t,n.schema);return td(n,i,e)?FSe(n,r):!1},SEe=()=>({state:t,dispatch:e})=>OW(t,e),wEe=t=>({state:e,dispatch:n})=>{const r=Yr(t,e.schema);return ZSe(r)(e,n)},MEe=()=>({state:t,dispatch:e})=>kW(t,e);function Sw(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function u6(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 EEe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,s=null;const o=Sw(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(a=Yr(t,r.schema)),o==="mark"&&(s=Tc(t,r.schema));let l=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,h)=>{a&&a===u.type&&(l=!0,i&&n.setNodeMarkup(h,void 0,u6(u.attrs,e))),s&&u.marks.length&&u.marks.forEach(g=>{s===g.type&&(l=!0,i&&n.addMark(h,h+u.nodeSize,s.create(u6(g.attrs,e))))})})}),l},AEe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),TEe=()=>({tr:t,dispatch:e})=>{if(e){const n=new hs(t.doc);t.setSelection(n)}return!0},CEe=()=>({state:t,dispatch:e})=>CW(t,e),NEe=()=>({state:t,dispatch:e})=>PW(t,e),REe=()=>({state:t,dispatch:e})=>$Se(t,e),PEe=()=>({state:t,dispatch:e})=>WSe(t,e),kEe=()=>({state:t,dispatch:e})=>GSe(t,e);function aR(t,e,n={},r={}){return p0(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var DEe=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:s,commands:o})=>{const{doc:l}=a;if(r.preserveWhitespace!=="full"){const c=aR(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return s&&a.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!n),!0}return s&&a.setMeta("preventUpdate",!n),o.insertContentAt({from:0,to:l.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function Mq(t,e){const n=Tc(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,l=>{s.push(...l.marks)});const o=s.find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function Eq(t,e){const n=new SW(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function OEe(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 LEe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function IEe(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 ww(t){return e=>IEe(e.$from,t)}function Ut(t,e,n){return t.config[e]===void 0&&t.parent?Ut(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Ut(t.parent,e,n):null}):t.config[e]}function qk(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Ut(e,"addExtensions",n);return r?[e,...qk(r())]:e}).flat(10)}function Xk(t,e){const n=Kf.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function Aq(t){return typeof t=="function"}function On(t,e=void 0,...n){return Aq(t)?e?t.bind(e)(...n):t(...n):t}function jEe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function om(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 Tq(t){const e=[],{nodeExtensions:n,markExtensions:r}=om(t),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(s=>{const o={name:s.name,options:s.options,storage:s.storage,extensions:i},l=Ut(s,"addGlobalAttributes",o);if(!l)return;l().forEach(u=>{u.types.forEach(h=>{Object.entries(u.attributes).forEach(([g,m])=>{e.push({type:h,name:g,attribute:{...a,...m}})})})})}),i.forEach(s=>{const o={name:s.name,options:s.options,storage:s.storage},l=Ut(s,"addAttributes",o);if(!l)return;const c=l();Object.entries(c).forEach(([u,h])=>{const g={...a,...h};typeof g?.default=="function"&&(g.default=g.default()),g?.isRequired&&g?.default===void 0&&delete g.default,e.push({type:s.name,name:u,attribute:g})})}),e}function Ar(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,a])=>{if(!r[i]){r[i]=a;return}if(i==="class"){const o=a?String(a).split(" "):[],l=r[i]?r[i].split(" "):[],c=o.filter(u=>!l.includes(u));r[i]=[...l,...c].join(" ")}else if(i==="style"){const o=a?a.split(";").map(u=>u.trim()).filter(Boolean):[],l=r[i]?r[i].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;l.forEach(u=>{const[h,g]=u.split(":").map(m=>m.trim());c.set(h,g)}),o.forEach(u=>{const[h,g]=u.split(":").map(m=>m.trim());c.set(h,g)}),r[i]=Array.from(c.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else r[i]=a}),r},{})}function _1(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)=>Ar(n,r),{})}function UEe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function d6(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((a,s)=>{const o=s.attribute.parseHTML?s.attribute.parseHTML(n):UEe(n.getAttribute(s.name));return o==null?a:{...a,[s.name]:o}},{});return{...r,...i}}}}function f6(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&jEe(n)?!1:n!=null))}function h6(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 FEe(t,e){var n;const r=Tq(t),{nodeExtensions:i,markExtensions:a}=om(t),s=(n=i.find(c=>Ut(c,"topNode")))==null?void 0:n.name,o=Object.fromEntries(i.map(c=>{const u=r.filter(x=>x.type===c.name),h={name:c.name,options:c.options,storage:c.storage,editor:e},g=t.reduce((x,M)=>{const w=Ut(M,"extendNodeSchema",h);return{...x,...w?w(c):{}}},{}),m=f6({...g,content:On(Ut(c,"content",h)),marks:On(Ut(c,"marks",h)),group:On(Ut(c,"group",h)),inline:On(Ut(c,"inline",h)),atom:On(Ut(c,"atom",h)),selectable:On(Ut(c,"selectable",h)),draggable:On(Ut(c,"draggable",h)),code:On(Ut(c,"code",h)),whitespace:On(Ut(c,"whitespace",h)),linebreakReplacement:On(Ut(c,"linebreakReplacement",h)),defining:On(Ut(c,"defining",h)),isolating:On(Ut(c,"isolating",h)),attrs:Object.fromEntries(u.map(h6))}),b=On(Ut(c,"parseHTML",h));b&&(m.parseDOM=b.map(x=>d6(x,u)));const y=Ut(c,"renderHTML",h);y&&(m.toDOM=x=>y({node:x,HTMLAttributes:_1(x,u)}));const v=Ut(c,"renderText",h);return v&&(m.toText=v),[c.name,m]})),l=Object.fromEntries(a.map(c=>{const u=r.filter(v=>v.type===c.name),h={name:c.name,options:c.options,storage:c.storage,editor:e},g=t.reduce((v,x)=>{const M=Ut(x,"extendMarkSchema",h);return{...v,...M?M(c):{}}},{}),m=f6({...g,inclusive:On(Ut(c,"inclusive",h)),excludes:On(Ut(c,"excludes",h)),group:On(Ut(c,"group",h)),spanning:On(Ut(c,"spanning",h)),code:On(Ut(c,"code",h)),attrs:Object.fromEntries(u.map(h6))}),b=On(Ut(c,"parseHTML",h));b&&(m.parseDOM=b.map(v=>d6(v,u)));const y=Ut(c,"renderHTML",h);return y&&(m.toDOM=v=>y({mark:v,HTMLAttributes:_1(v,u)})),[c.name,m]}));return new sW({topNode:s,nodes:o,marks:l})}function zEe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Kk(t){return t.sort((n,r)=>{const i=Ut(n,"priority")||100,a=Ut(r,"priority")||100;return i>a?-1:i<a?1:0})}function Cq(t){const e=Kk(qk(t)),n=zEe(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 Nq(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
  8068. `,textSerializers:s={}}=n||{};let o="";return t.nodesBetween(r,i,(l,c,u,h)=>{var g;l.isBlock&&c>r&&(o+=a);const m=s?.[l.type.name];if(m)return u&&(o+=m({node:l,pos:c,parent:u,index:h,range:e})),!1;l.isText&&(o+=(g=l?.text)==null?void 0:g.slice(Math.max(r,c)-c,i-c))}),o}function BEe(t,e){const n={from:0,to:t.content.size};return Nq(t,n,e)}function Rq(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function HEe(t,e){const n=Yr(e,t.schema),{from:r,to:i}=t.selection,a=[];t.doc.nodesBetween(r,i,o=>{a.push(o)});const s=a.reverse().find(o=>o.type.name===n.name);return s?{...s.attrs}:{}}function Pq(t,e){const n=Sw(typeof e=="string"?e:e.name,t.schema);return n==="node"?HEe(t,e):n==="mark"?Mq(t,e):{}}function $Ee(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 VEe(t){const e=$Ee(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 kq(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,a)=>{const s=[];if(i.ranges.length)i.forEach((o,l)=>{s.push({from:o,to:l})});else{const{from:o,to:l}=n[a];if(o===void 0||l===void 0)return;s.push({from:o,to:l})}s.forEach(({from:o,to:l})=>{const c=e.slice(a).map(o,-1),u=e.slice(a).map(l),h=e.invert().map(c,-1),g=e.invert().map(u);r.push({oldRange:{from:h,to:g},newRange:{from:c,to:u}})})}),VEe(r)}function Yk(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),s=Gk(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 GEe=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let a=r,s=null;for(;a>0&&s===null;){const o=i.node(a);o?.type.name===e?s=o:a-=1}return[s,a]};function S2(t,e){return e.nodes[t]||e.marks[t]||null}function N_(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 WEe=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,a,s,o)=>{var l,c;const u=((c=(l=i.type.spec).toText)==null?void 0:c.call(l,{node:i,pos:a,parent:s,index:o}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,r-a))}),n};function sR(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?Tc(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(h=>a?a.name===h.type.name:!0).find(h=>y1(h.attrs,n,{strict:!1}));let s=0;const o=[];if(i.forEach(({$from:h,$to:g})=>{const m=h.pos,b=g.pos;t.doc.nodesBetween(m,b,(y,v)=>{if(!y.isText&&!y.marks.length)return;const x=Math.max(m,v),M=Math.min(b,v+y.nodeSize),w=M-x;s+=w,o.push(...y.marks.map(C=>({mark:C,from:x,to:M})))})}),s===0)return!1;const l=o.filter(h=>a?a.name===h.mark.type.name:!0).filter(h=>y1(h.mark.attrs,n,{strict:!1})).reduce((h,g)=>h+g.to-g.from,0),c=o.filter(h=>a?h.mark.type!==a&&h.mark.type.excludes(a):!0).reduce((h,g)=>h+g.to-g.from,0);return(l>0?l+c:l)>=s}function qEe(t,e,n={}){if(!e)return td(t,null,n)||sR(t,null,n);const r=Sw(e,t.schema);return r==="node"?td(t,e,n):r==="mark"?sR(t,e,n):!1}var XEe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=ww(o=>o.type.name===e)(t.selection);if(!a)return!1;const s=t.doc.resolve(a.pos+1);return i.pos+1===s.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},KEe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function p6(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function m6(t,e){const{nodeExtensions:n}=om(e),r=n.find(s=>s.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=On(Ut(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function Mw(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&&(Mw(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function Dq(t){return t instanceof Ft}function YEe(t,e,n){var r;const{selection:i}=e;let a=null;if(yq(i)&&(a=i.$cursor),a){const o=(r=t.storedMarks)!=null?r:a.marks();return a.parent.type.allowsMarkType(n)&&(!!n.isInSet(o)||!o.some(c=>c.type.excludes(n)))}const{ranges:s}=i;return s.some(({$from:o,$to:l})=>{let c=o.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(o.pos,l.pos,(u,h,g)=>{if(c)return!1;if(u.isInline){const m=!g||g.type.allowsMarkType(n),b=!!n.isInSet(u.marks)||!u.marks.some(y=>y.type.excludes(n));c=m&&b}return!c}),c})}var ZEe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:s,ranges:o}=a,l=Tc(t,r.schema);if(i)if(s){const c=Mq(r,l);n.addStoredMark(l.create({...c,...e}))}else o.forEach(c=>{const u=c.$from.pos,h=c.$to.pos;r.doc.nodesBetween(u,h,(g,m)=>{const b=Math.max(m,u),y=Math.min(m+g.nodeSize,h);g.marks.find(x=>x.type===l)?g.marks.forEach(x=>{l===x.type&&n.addMark(b,y,l.create({...x.attrs,...e}))}):n.addMark(b,y,l.create(e))})});return YEe(r,n,l)},QEe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),JEe=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=Yr(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:o})=>NB(a,{...s,...e})(n)?!0:o.clearNodes()).command(({state:o})=>NB(a,{...s,...e})(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},eAe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=nf(t,0,r.content.size),a=Ft.create(r,i);e.setSelection(a)}return!0},tAe=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=r;let s,o;return typeof e=="number"?(s=e,o=e):e&&"from"in e&&"to"in e?(s=e.from,o=e.to):(s=a.from,o=a.to),i&&n.doc.nodesBetween(s,o,(l,c)=>{l.isText||n.setNodeMarkup(c,void 0,{...l.attrs,dir:t})}),!0},nAe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,s=Wt.atStart(r).from,o=Wt.atEnd(r).to,l=nf(i,s,o),c=nf(a,s,o),u=Wt.create(r,l,c);e.setSelection(u)}return!0},rAe=t=>({state:e,dispatch:n})=>{const r=Yr(t,e.schema);return ewe(r)(e,n)};function g6(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 iAe=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:s}=e,{$from:o,$to:l}=a,c=i.extensionManager.attributes,u=N_(c,o.node().type.name,o.node().attrs);if(a instanceof Ft&&a.node.isBlock)return!o.parentOffset||!dc(s,o.pos)?!1:(r&&(t&&g6(n,i.extensionManager.splittableMarks),e.split(o.pos).scrollIntoView()),!0);if(!o.parent.isBlock)return!1;const h=l.parentOffset===l.parent.content.size,g=o.depth===0?void 0:OEe(o.node(-1).contentMatchAt(o.indexAfter(-1)));let m=h&&g?[{type:g,attrs:u}]:void 0,b=dc(e.doc,e.mapping.map(o.pos),1,m);if(!m&&!b&&dc(e.doc,e.mapping.map(o.pos),1,g?[{type:g}]:void 0)&&(b=!0,m=g?[{type:g,attrs:u}]:void 0),r){if(b&&(a instanceof Wt&&e.deleteSelection(),e.split(e.mapping.map(o.pos),1,m),g&&!h&&!o.parentOffset&&o.parent.type!==g)){const y=e.mapping.map(o.before()),v=e.doc.resolve(y);o.node(-1).canReplaceWith(v.index(),v.index()+1,g)&&e.setNodeMarkup(e.mapping.map(o.before()),g)}t&&g6(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return b},aAe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var s;const o=Yr(t,r.schema),{$from:l,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(c))return!1;const h=l.node(-1);if(h.type!==o)return!1;const g=a.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==o||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let x=pt.empty;const M=l.index(-1)?1:l.index(-2)?2:3;for(let j=l.depth-M;j>=l.depth-3;j-=1)x=pt.from(l.node(j).copy(x));const w=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,C={...N_(g,l.node().type.name,l.node().attrs),...e},T=((s=o.contentMatch.defaultType)==null?void 0:s.createAndFill(C))||void 0;x=x.append(pt.from(o.createAndFill(null,T)||void 0));const R=l.before(l.depth-(M-1));n.replace(R,l.after(-w),new Mt(x,4-M,0));let A=-1;n.doc.nodesBetween(R,n.doc.content.size,(j,N)=>{if(A>-1)return!1;j.isTextblock&&j.content.size===0&&(A=N+1)}),A>-1&&n.setSelection(Wt.near(n.doc.resolve(A))),n.scrollIntoView()}return!0}const m=c.pos===l.end()?h.contentMatchAt(0).defaultType:null,b={...N_(g,h.type.name,h.attrs),...e},y={...N_(g,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);const v=m?[{type:o,attrs:b},{type:m,attrs:y}]:[{type:o,attrs:b}];if(!dc(n.doc,l.pos,2))return!1;if(i){const{selection:x,storedMarks:M}=r,{splittableMarks:w}=a.extensionManager,C=M||x.$to.parentOffset&&x.$from.marks();if(n.split(l.pos,2,v).scrollIntoView(),!C||!i)return!0;const T=C.filter(R=>w.includes(R.type.name));n.ensureMarks(T)}return!0},w2=(t,e)=>{const n=ww(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&&ld(t.doc,n.pos)&&t.join(n.pos),!0},M2=(t,e)=>{const n=ww(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&&ld(t.doc,r)&&t.join(r),!0},sAe=(t,e,n,r={})=>({editor:i,tr:a,state:s,dispatch:o,chain:l,commands:c,can:u})=>{const{extensions:h,splittableMarks:g}=i.extensionManager,m=Yr(t,s.schema),b=Yr(e,s.schema),{selection:y,storedMarks:v}=s,{$from:x,$to:M}=y,w=x.blockRange(M),C=v||y.$to.parentOffset&&y.$from.marks();if(!w)return!1;const T=ww(R=>m6(R.type.name,h))(y);if(w.depth>=1&&T&&w.depth-T.depth<=1){if(T.node.type===m)return c.liftListItem(b);if(m6(T.node.type.name,h)&&m.validContent(T.node.content)&&o)return l().command(()=>(a.setNodeMarkup(T.pos,m),!0)).command(()=>w2(a,m)).command(()=>M2(a,m)).run()}return!n||!C||!o?l().command(()=>u().wrapInList(m,r)?!0:c.clearNodes()).wrapInList(m,r).command(()=>w2(a,m)).command(()=>M2(a,m)).run():l().command(()=>{const R=u().wrapInList(m,r),A=C.filter(j=>g.includes(j.type.name));return a.ensureMarks(A),R?!0:c.clearNodes()}).wrapInList(m,r).command(()=>w2(a,m)).command(()=>M2(a,m)).run()},oAe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,s=Tc(t,r.schema);return sR(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:a}):i.setMark(s,e)},lAe=(t,e,n={})=>({state:r,commands:i})=>{const a=Yr(t,r.schema),s=Yr(e,r.schema),o=td(r,a,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),o?i.setNode(s,l):i.setNode(a,{...l,...n})},cAe=(t,e={})=>({state:n,commands:r})=>{const i=Yr(t,n.schema);return td(n,i,e)?r.lift(i):r.wrapIn(i,e)},uAe=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let a;if(i.spec.isInputRules&&(a=i.getState(t))){if(e){const s=t.tr,o=a.transform;for(let l=o.steps.length-1;l>=0;l-=1)s.step(o.steps[l].invert(o.docs[l]));if(a.text){const l=s.doc.resolve(a.from).marks();s.replaceWith(a.from,a.to,t.schema.text(a.text,l))}else s.delete(a.from,a.to)}return!0}}return!1},dAe=()=>({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},fAe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:s=!1}=e,{selection:o}=n,l=Tc(t,r.schema),{$from:c,empty:u,ranges:h}=o;if(!i)return!0;if(u&&s){let{from:g,to:m}=o;const b=(a=c.marks().find(v=>v.type===l))==null?void 0:a.attrs,y=Gk(c,l,b);y&&(g=y.from,m=y.to),n.removeMark(g,m,l)}else h.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,l)});return n.removeStoredMark(l),!0},hAe=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let a,s;return typeof t=="number"?(a=t,s=t):t&&"from"in t&&"to"in t?(a=t.from,s=t.to):(a=i.from,s=i.to),r&&e.doc.nodesBetween(a,s,(o,l)=>{if(o.isText)return;const c={...o.attrs};delete c.dir,e.setNodeMarkup(l,void 0,c)}),!0},pAe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,s=null;const o=Sw(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(a=Yr(t,r.schema)),o==="mark"&&(s=Tc(t,r.schema));let l=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,h=c.$to.pos;let g,m,b,y;n.selection.empty?r.doc.nodesBetween(u,h,(v,x)=>{a&&a===v.type&&(l=!0,b=Math.max(x,u),y=Math.min(x+v.nodeSize,h),g=x,m=v)}):r.doc.nodesBetween(u,h,(v,x)=>{x<u&&a&&a===v.type&&(l=!0,b=Math.max(x,u),y=Math.min(x+v.nodeSize,h),g=x,m=v),x>=u&&x<=h&&(a&&a===v.type&&(l=!0,i&&n.setNodeMarkup(x,void 0,{...v.attrs,...e})),s&&v.marks.length&&v.marks.forEach(M=>{if(s===M.type&&(l=!0,i)){const w=Math.max(x,u),C=Math.min(x+v.nodeSize,h);n.addMark(w,C,s.create({...M.attrs,...e}))}}))}),m&&(g!==void 0&&i&&n.setNodeMarkup(g,void 0,{...m.attrs,...e}),s&&m.marks.length&&m.marks.forEach(v=>{s===v.type&&i&&n.addMark(b,y,s.create({...v.attrs,...e}))}))}),l},mAe=(t,e={})=>({state:n,dispatch:r})=>{const i=Yr(t,n.schema);return qSe(i,e)(n,r)},gAe=(t,e={})=>({state:n,dispatch:r})=>{const i=Yr(t,n.schema);return XSe(i,e)(n,r)},xAe=class{constructor(){this.callbacks={}}on(e,n){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(n),this}emit(e,...n){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,n)),this}off(e,n){const r=this.callbacks[e];return r&&(n?this.callbacks[e]=r.filter(i=>i!==n):delete this.callbacks[e]),this}once(e,n){const r=(...i)=>{this.off(e,r),n.apply(this,i)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}},Ew=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},vAe=(t,e)=>{if(Vk(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 By(t){var e;const{editor:n,from:r,to:i,text:a,rules:s,plugin:o}=t,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let u=!1;const h=WEe(c)+a;return s.forEach(g=>{if(u)return;const m=vAe(h,g.find);if(!m)return;const b=l.state.tr,y=yw({state:l.state,transaction:b}),v={from:r-(m[0].length-a.length),to:i},{commands:x,chain:M,can:w}=new _w({editor:n,state:y});g.handler({state:y,range:v,match:m,commands:x,chain:M,can:w})===null||!b.steps.length||(g.undoable&&b.setMeta(o,{transform:b,from:r,to:i,text:a}),l.dispatch(b),u=!0)}),u}function bAe(t){const{editor:e,rules:n}=t,r=new vr({state:{init(){return null},apply(i,a,s){const o=i.getMeta(r);if(o)return o;const l=i.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:u}=l;typeof u=="string"?u=u:u=Xk(pt.from(u),s.schema);const{from:h}=l,g=h+u.length;By({editor:e,from:h,to:g,text:u,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,s,o){return By({editor:e,from:a,to:s,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&By({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?By({editor:e,from:s.pos,to:s.pos,text:`
  8069. `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function yAe(t){return Object.prototype.toString.call(t).slice(8,-1)}function Hy(t){return yAe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Oq(t,e){const n={...t};return Hy(t)&&Hy(e)&&Object.keys(e).forEach(r=>{Hy(e[r])&&Hy(t[r])?n[r]=Oq(t[r],e[r]):n[r]=e[r]}),n}var Zk=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{...On(Ut(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...On(Ut(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Oq(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}},ud=class Lq extends Zk{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Lq(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(c=>c?.type.name===n.name))return!1;const l=s.find(c=>c?.type.name===n.name);return l&&r.removeStoredMark(l),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 _Ae(t){return typeof t=="number"}var SAe=class{constructor(t){this.find=t.find,this.handler=t.handler}},wAe=(t,e,n)=>{if(Vk(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 MAe(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:s,dropEvent:o}=t,{commands:l,chain:c,can:u}=new _w({editor:e,state:n}),h=[];return n.doc.nodesBetween(r,i,(m,b)=>{var y,v,x,M,w;if((v=(y=m.type)==null?void 0:y.spec)!=null&&v.code||!(m.isText||m.isTextblock||m.isInline))return;const C=(w=(M=(x=m.content)==null?void 0:x.size)!=null?M:m.nodeSize)!=null?w:0,T=Math.max(r,b),R=Math.min(i,b+C);if(T>=R)return;const A=m.isText?m.text||"":m.textBetween(T-b,R-b,void 0,"");wAe(A,a.find,s).forEach(N=>{if(N.index===void 0)return;const k=T+N.index+1,F=k+N[0].length,I={from:n.tr.mapping.map(k),to:n.tr.mapping.map(F)},W=a.handler({state:n,range:I,match:N,commands:l,chain:c,can:u,pasteEvent:s,dropEvent:o});h.push(W)})}),h.every(m=>m!==null)}var $y=null,EAe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function AAe(t){const{editor:e,rules:n}=t;let r=null,i=!1,a=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,o;try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}const l=({state:u,from:h,to:g,rule:m,pasteEvt:b})=>{const y=u.tr,v=yw({state:u,transaction:y});if(!(!MAe({editor:e,state:v,from:Math.max(h-1,0),to:g.b-1,rule:m,pasteEvent:b,dropEvent:o})||!y.steps.length)){try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,y}};return n.map(u=>new vr({view(h){const g=b=>{var y;r=(y=h.dom.parentElement)!=null&&y.contains(b.target)?h.dom.parentElement:null,r&&($y=e)},m=()=>{$y&&($y=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",m),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",m)}}},props:{handleDOMEvents:{drop:(h,g)=>{if(a=r===h.dom.parentElement,o=g,!a){const m=$y;m?.isEditable&&setTimeout(()=>{const b=m.state.selection;b&&m.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(h,g)=>{var m;const b=(m=g.clipboardData)==null?void 0:m.getData("text/html");return s=g,i=!!b?.includes("data-pm-slice"),!1}}},appendTransaction:(h,g,m)=>{const b=h[0],y=b.getMeta("uiEvent")==="paste"&&!i,v=b.getMeta("uiEvent")==="drop"&&!a,x=b.getMeta("applyPasteRules"),M=!!x;if(!y&&!v&&!M)return;if(M){let{text:T}=x;typeof T=="string"?T=T:T=Xk(pt.from(T),m.schema);const{from:R}=x,A=R+T.length,j=EAe(T);return l({rule:u,state:m,from:R,to:{b:A},pasteEvt:j})}const w=g.doc.content.findDiffStart(m.doc.content),C=g.doc.content.findDiffEnd(m.doc.content);if(!(!_Ae(w)||!C||w===C.b))return l({rule:u,state:m,from:w,to:C,pasteEvt:s})}}))}var Aw=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=Cq(t),this.schema=FEe(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:S2(e.name,this.schema)},r=Ut(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Kk([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:S2(r.name,this.schema)},a=[],s=Ut(r,"addKeyboardShortcuts",i);let o={};if(r.type==="mark"&&Ut(r,"exitable",i)&&(o.ArrowRight=()=>ud.handleExit({editor:t,mark:r})),s){const g=Object.fromEntries(Object.entries(s()).map(([m,b])=>[m,()=>b({editor:t})]));o={...o,...g}}const l=HMe(o);a.push(l);const c=Ut(r,"addInputRules",i);if(p6(r,t.options.enableInputRules)&&c){const g=c();if(g&&g.length){const m=bAe({editor:t,rules:g}),b=Array.isArray(m)?m:[m];a.push(...b)}}const u=Ut(r,"addPasteRules",i);if(p6(r,t.options.enablePasteRules)&&u){const g=u();if(g&&g.length){const m=AAe({editor:t,rules:g});a.push(...m)}}const h=Ut(r,"addProseMirrorPlugins",i);if(h){const g=h();a.push(...g)}return a})}get attributes(){return Tq(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=om(this.extensions);return Object.fromEntries(e.filter(n=>!!Ut(n,"addNodeView")).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:Yr(n.name,this.schema)},a=Ut(n,"addNodeView",i);if(!a)return[];const s=a();if(!s)return[];const o=(l,c,u,h,g)=>{const m=_1(l,r);return s({node:l,view:c,getPos:u,decorations:h,innerDecorations:g,editor:t,extension:n,HTMLAttributes:m})};return[n.name,o]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=om(this.extensions);return Object.fromEntries(e.filter(n=>!!Ut(n,"addMarkView")).map(n=>{const r=this.attributes.filter(o=>o.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Tc(n.name,this.schema)},a=Ut(n,"addMarkView",i);if(!a)return[];const s=(o,l,c)=>{const u=_1(o,r);return a()({mark:o,view:l,inline:c,editor:t,extension:n,HTMLAttributes:u,updateAttributes:h=>{BAe(o,t,h)}})};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:S2(e.name,this.schema)};e.type==="mark"&&((n=On(Ut(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Ut(e,"onBeforeCreate",r),a=Ut(e,"onCreate",r),s=Ut(e,"onUpdate",r),o=Ut(e,"onSelectionUpdate",r),l=Ut(e,"onTransaction",r),c=Ut(e,"onFocus",r),u=Ut(e,"onBlur",r),h=Ut(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),a&&this.editor.on("create",a),s&&this.editor.on("update",s),o&&this.editor.on("selectionUpdate",o),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),h&&this.editor.on("destroy",h)})}};Aw.resolve=Cq;Aw.sort=Kk;Aw.flatten=qk;var TAe={};$k(TAe,{ClipboardTextSerializer:()=>jq,Commands:()=>Uq,Delete:()=>Fq,Drop:()=>zq,Editable:()=>Bq,FocusEvents:()=>$q,Keymap:()=>Vq,Paste:()=>Gq,Tabindex:()=>Wq,TextDirection:()=>qq,focusEventsPluginKey:()=>Hq});var Wn=class Iq extends Zk{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Iq(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},jq=Wn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new vr({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(u=>u.$from.pos)),o=Math.max(...a.map(u=>u.$to.pos)),l=Rq(n);return Nq(r,{from:s,to:o},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),Uq=Wn.create({name:"commands",addCommands(){return{...vq}}}),Fq=Wn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const a=()=>{var s,o,l,c;if((c=(l=(o=(s=this.editor.options.coreExtensionOptions)==null?void 0:s.delete)==null?void 0:o.filterTransaction)==null?void 0:l.call(o,t))!=null?c:t.getMeta("y-sync$"))return;const u=Eq(t.before,[t,...e]);kq(u).forEach(m=>{u.mapping.mapResult(m.oldRange.from).deletedAfter&&u.mapping.mapResult(m.oldRange.to).deletedBefore&&u.before.nodesBetween(m.oldRange.from,m.oldRange.to,(b,y)=>{const v=y+b.nodeSize-2,x=m.oldRange.from<=y&&v<=m.oldRange.to;this.editor.emit("delete",{type:"node",node:b,from:y,to:v,newFrom:u.mapping.map(y),newTo:u.mapping.map(v),deletedRange:m.oldRange,newRange:m.newRange,partial:!x,editor:this.editor,transaction:t,combinedTransform:u})})});const g=u.mapping;u.steps.forEach((m,b)=>{var y,v;if(m instanceof bo){const x=g.slice(b).map(m.from,-1),M=g.slice(b).map(m.to),w=g.invert().map(x,-1),C=g.invert().map(M),T=(y=u.doc.nodeAt(x-1))==null?void 0:y.marks.some(A=>A.eq(m.mark)),R=(v=u.doc.nodeAt(M))==null?void 0:v.marks.some(A=>A.eq(m.mark));this.editor.emit("delete",{type:"mark",mark:m.mark,from:m.from,to:m.to,deletedRange:{from:w,to:C},newRange:{from:x,to:M},partial:!!(R||T),editor:this.editor,transaction:t,combinedTransform:u})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(a,0):a()}}),zq=Wn.create({name:"drop",addProseMirrorPlugins(){return[new vr({key:new ci("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Bq=Wn.create({name:"editable",addProseMirrorPlugins(){return[new vr({key:new ci("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Hq=new ci("focusEvents"),$q=Wn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new vr({key:Hq,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}}}})]}}),Vq=Wn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:o})=>{const{selection:l,doc:c}=o,{empty:u,$anchor:h}=l,{pos:g,parent:m}=h,b=h.parent.isTextblock&&g>0?o.doc.resolve(g-1):h,y=b.parent.type.spec.isolating,v=h.pos-h.parentOffset,x=y&&b.parent.childCount===1?v===h.pos:on.atStart(c).from===g;return!u||!m.type.isTextblock||m.textContent.length||!x||x&&h.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 Wk()||wq()?a:i},addProseMirrorPlugins(){return[new vr({key:new ci("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(y=>y.getMeta("composition")))return;const r=t.some(y=>y.docChanged)&&!e.doc.eq(n.doc),i=t.some(y=>y.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:s,to:o}=e.selection,l=on.atStart(e.doc).from,c=on.atEnd(e.doc).to;if(a||!(s===l&&o===c)||!Mw(n.doc))return;const g=n.tr,m=yw({state:n,transaction:g}),{commands:b}=new _w({editor:this.editor,state:m});if(b.clearNodes(),!!g.steps.length)return g}})]}}),Gq=Wn.create({name:"paste",addProseMirrorPlugins(){return[new vr({key:new ci("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Wq=Wn.create({name:"tabindex",addProseMirrorPlugins(){return[new vr({key:new ci("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),qq=Wn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=om(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 vr({key:new ci("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),CAe=class yp{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 yp(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 yp(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 yp(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,s=this.pos+r+(a?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;const o=this.resolvedPos.doc.resolve(s);if(!i&&o.depth<=this.depth)return;const l=new yp(o,this.editor,i,i?n:null);i&&(l.actualDepth=this.depth+1),e.push(new yp(o,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const a=i.node.attrs,s=Object.keys(n);for(let o=0;o<s.length;o+=1){const l=s[o];if(a[l]!==n[l])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(l=>n[l]===s.node.attrs[l])&&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)}},NAe=`.ProseMirror {
  8070. position: relative;
  8071. }
  8072. .ProseMirror {
  8073. word-wrap: break-word;
  8074. white-space: pre-wrap;
  8075. white-space: break-spaces;
  8076. -webkit-font-variant-ligatures: none;
  8077. font-variant-ligatures: none;
  8078. font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
  8079. }
  8080. .ProseMirror [contenteditable="false"] {
  8081. white-space: normal;
  8082. }
  8083. .ProseMirror [contenteditable="false"] [contenteditable="true"] {
  8084. white-space: pre-wrap;
  8085. }
  8086. .ProseMirror pre {
  8087. white-space: pre-wrap;
  8088. }
  8089. img.ProseMirror-separator {
  8090. display: inline !important;
  8091. border: none !important;
  8092. margin: 0 !important;
  8093. width: 0 !important;
  8094. height: 0 !important;
  8095. }
  8096. .ProseMirror-gapcursor {
  8097. display: none;
  8098. pointer-events: none;
  8099. position: absolute;
  8100. margin: 0;
  8101. }
  8102. .ProseMirror-gapcursor:after {
  8103. content: "";
  8104. display: block;
  8105. position: absolute;
  8106. top: -2px;
  8107. width: 20px;
  8108. border-top: 1px solid black;
  8109. animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
  8110. }
  8111. @keyframes ProseMirror-cursor-blink {
  8112. to {
  8113. visibility: hidden;
  8114. }
  8115. }
  8116. .ProseMirror-hideselection *::selection {
  8117. background: transparent;
  8118. }
  8119. .ProseMirror-hideselection *::-moz-selection {
  8120. background: transparent;
  8121. }
  8122. .ProseMirror-hideselection * {
  8123. caret-color: transparent;
  8124. }
  8125. .ProseMirror-focused .ProseMirror-gapcursor {
  8126. display: block;
  8127. }`;function RAe(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 PAe=class extends xAe{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=_q(e,this.options.autofocus);this.editorState=Ap.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=RAe(NAe,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=Aq(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?[Bq,jq.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Uq,$q,Vq,Wq,zq,Gq,Fq,qq.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 Aw(r,this)}createCommandManager(){this.commandManager=new _w({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=aR(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=aR(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new gq(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(c=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(c)});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(c=>c.getMeta("focus")||c.getMeta("blur")),o=s?.getMeta("focus"),l=s?.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:s}),l&&this.emit("blur",{editor:this,event:l.event,transaction:s}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||a.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Pq(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return qEe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Xk(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
  8128. `,textSerializers:n={}}=t||{};return BEe(this.state.doc,{blockSeparator:e,textSerializers:{...Rq(this.schema),...n}})}get isEmpty(){return Mw(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 CAe(e,this)}get $doc(){return this.$pos(0)}};function lm(t){return new Ew({find:t.find,handler:({state:e,range:n,match:r})=>{const i=On(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:a}=e,s=r[r.length-1],o=r[0];if(s){const l=o.search(/\S/),c=n.from+o.indexOf(s),u=c+s.length;if(Yk(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===t.type&&y!==m.mark.type)).filter(m=>m.to>c).length)return null;u<n.to&&a.delete(u,n.to),c>n.from&&a.delete(n.from+l,c);const g=n.from+l+s.length;a.addMark(n.from+l,g,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function Xq(t){return new Ew({find:t.find,handler:({state:e,range:n,match:r})=>{const i=On(t.getAttributes,void 0,r)||{},{tr:a}=e,s=n.from;let o=n.to;const l=t.type.create(i);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=s+c;u>o?u=o:o=u+r[1].length;const h=r[0][r[0].length-1];a.insertText(h,s+r[0].length-1),a.replaceWith(u,o,l)}else if(r[0]){const c=t.type.isInline?s:s-1;a.insert(c,t.type.create(i)).delete(a.mapping.map(s),a.mapping.map(o))}a.scrollIntoView()},undoable:t.undoable})}function oR(t){return new Ew({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=On(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 cm(t){return new Ew({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=On(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),c=l&&Tk(l,t.type,a);if(!c)return null;if(s.wrap(l,c),t.keepMarks&&t.editor){const{selection:h,storedMarks:g}=e,{splittableMarks:m}=t.editor.extensionManager,b=g||h.$to.parentOffset&&h.$from.marks();if(b){const y=b.filter(v=>m.includes(v.type.name));s.ensureMarks(y)}}if(t.keepAttributes){const h=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(h,a).run()}const u=s.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&ld(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&s.join(n.from-1)},undoable:t.undoable})}var kAe=t=>"touches"in t,DAe=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=s=>{if(!this.isResizing||!this.activeHandle)return;const o=s.clientX-this.startX,l=s.clientY-this.startY;this.handleResize(o,l)},this.handleTouchMove=s=>{if(!this.isResizing||!this.activeHandle)return;const o=s.touches[0];if(!o)return;const l=o.clientX-this.startX,c=o.clientY-this.startY;this.handleResize(l,c)},this.handleMouseUp=()=>{if(!this.isResizing)return;const s=this.element.offsetWidth,o=this.element.offsetHeight;this.onCommit(s,o),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=s=>{s.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=s=>{s.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,a;this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t?.options)!=null&&r.directions&&(this.directions=t.options.directions),(i=t.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(a=t.options)!=null&&a.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()}get dom(){return this.container}get contentDOM(){return this.contentElement}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",t.style.justifyContent="flex-start",t.style.alignItems="flex-start",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),a=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),a&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{const e=this.createHandle(t);this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.wrapper.appendChild(e)})}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,kAe(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,t,e),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const a=t.includes("right"),s=t.includes("left"),o=t.includes("bottom"),l=t.includes("top");return a?r=this.startWidth+e:s&&(r=this.startWidth-e),o?i=this.startHeight+n:l&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(a?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(o?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,a,s;if(!n){let c=Math.max(this.minSize.width,t),u=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(c=Math.min(this.maxSize.width,c)),(i=this.maxSize)!=null&&i.height&&(u=Math.min(this.maxSize.height,u)),{width:c,height:u}}let o=t,l=e;return o<this.minSize.width&&(o=this.minSize.width,l=o/this.aspectRatio),l<this.minSize.height&&(l=this.minSize.height,o=l*this.aspectRatio),(a=this.maxSize)!=null&&a.width&&o>this.maxSize.width&&(o=this.maxSize.width,l=o/this.aspectRatio),(s=this.maxSize)!=null&&s.height&&l>this.maxSize.height&&(l=this.maxSize.height,o=l*this.aspectRatio),{width:o,height:l}}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 OAe(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Ft){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 LAe={};$k(LAe,{createAtomBlockMarkdownSpec:()=>IAe,createBlockMarkdownSpec:()=>jAe,createInlineMarkdownSpec:()=>zAe,parseAttributes:()=>Qk,parseIndentedBlocks:()=>lR,renderNestedMarkdownContent:()=>eD,serializeAttributes:()=>Jk});function Qk(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const c=i.map(u=>u.trim().slice(1));e.class=c.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(([,c,u])=>{var h;const g=parseInt(((h=u.match(/__QUOTED_(\d+)__/))==null?void 0:h[1])||"0",10),m=n[g];m&&(e[c]=m.slice(1,-1))});const l=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 l&&l.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function Jk(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 IAe(t){const{nodeName:e,name:n,parseAttributes:r=Qk,serializeAttributes:i=Jk,defaultAttributes:a={},requiredAttributes:s=[],allowedAttributes:o}=t,l=n||e,c=u=>{if(!o)return u;const h={};return o.forEach(g=>{g in u&&(h[g]=u[g])}),h};return{parseMarkdown:(u,h)=>{const g={...a,...u.attributes};return h.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(u){var h;const g=new RegExp(`^:::${l}(?:\\s|$)`,"m"),m=(h=u.match(g))==null?void 0:h.index;return m!==void 0?m:-1},tokenize(u,h,g){const m=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),b=u.match(m);if(!b)return;const y=b[1]||"",v=r(y);if(!s.find(M=>!(M in v)))return{type:e,raw:b[0],attributes:v}}},renderMarkdown:u=>{const h=c(u.attrs||{}),g=i(h),m=g?` {${g}}`:"";return`:::${l}${m} :::`}}}function jAe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=Qk,serializeAttributes:a=Jk,defaultAttributes:s={},content:o="block",allowedAttributes:l}=t,c=n||e,u=h=>{if(!l)return h;const g={};return l.forEach(m=>{m in h&&(g[m]=h[m])}),g};return{parseMarkdown:(h,g)=>{let m;if(r){const y=r(h);m=typeof y=="string"?[{type:"text",text:y}]:y}else o==="block"?m=g.parseChildren(h.tokens||[]):m=g.parseInline(h.tokens||[]);const b={...s,...h.attributes};return g.createNode(e,b,m)},markdownTokenizer:{name:e,level:"block",start(h){var g;const m=new RegExp(`^:::${c}`,"m"),b=(g=h.match(m))==null?void 0:g.index;return b!==void 0?b:-1},tokenize(h,g,m){var b;const y=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),v=h.match(y);if(!v)return;const[x,M=""]=v,w=i(M);let C=1;const T=x.length;let R="";const A=/^:::([\w-]*)(\s.*)?/gm,j=h.slice(T);for(A.lastIndex=0;;){const N=A.exec(j);if(N===null)break;const k=N.index,F=N[1];if(!((b=N[2])!=null&&b.endsWith(":::"))){if(F)C+=1;else if(C-=1,C===0){const I=j.slice(0,k);R=I.trim();const W=h.slice(0,T+k+N[0].length);let D=[];if(R)if(o==="block")for(D=m.blockTokens(I),D.forEach(B=>{B.text&&(!B.tokens||B.tokens.length===0)&&(B.tokens=m.inlineTokens(B.text))});D.length>0;){const B=D[D.length-1];if(B.type==="paragraph"&&(!B.text||B.text.trim()===""))D.pop();else break}else D=m.inlineTokens(R);return{type:e,raw:W,attributes:w,content:R,tokens:D}}}}}},renderMarkdown:(h,g)=>{const m=u(h.attrs||{}),b=a(m),y=b?` {${b}}`:"",v=g.renderChildren(h.content||[],`
  8129. `);return`:::${c}${y}
  8130. ${v}
  8131. :::`}}}function UAe(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 FAe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function zAe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=UAe,serializeAttributes:a=FAe,defaultAttributes:s={},selfClosing:o=!1,allowedAttributes:l}=t,c=n||e,u=g=>{if(!l)return g;const m={};return l.forEach(b=>{b in g&&(m[b]=g[b])}),m},h=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,m)=>{const b={...s,...g.attributes};if(o)return m.createNode(e,b);const y=r?r(g):g.content||"";return y?m.createNode(e,b,[m.createTextNode(y)]):m.createNode(e,b,[])},markdownTokenizer:{name:e,level:"inline",start(g){const m=o?new RegExp(`\\[${h}\\s*[^\\]]*\\]`):new RegExp(`\\[${h}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${h}\\]`),b=g.match(m),y=b?.index;return y!==void 0?y:-1},tokenize(g,m,b){const y=o?new RegExp(`^\\[${h}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${h}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${h}\\]`),v=g.match(y);if(!v)return;let x="",M="";if(o){const[,C]=v;M=C}else{const[,C,T]=v;M=C,x=T||""}const w=i(M.trim());return{type:e,raw:v[0],content:x.trim(),attributes:w}}},renderMarkdown:g=>{let m="";r?m=r(g):g.content&&g.content.length>0&&(m=g.content.filter(x=>x.type==="text").map(x=>x.text).join(""));const b=u(g.attrs||{}),y=a(b),v=y?` ${y}`:"";return o?`[${c}${v}]`:`[${c}${v}]${m}[/${c}]`}}}function lR(t,e,n){var r,i,a,s;const o=t.split(`
  8132. `),l=[];let c="",u=0;const h=e.baseIndentSize||2;for(;u<o.length;){const g=o[u],m=g.match(e.itemPattern);if(!m){if(l.length>0)break;if(g.trim()===""){u+=1,c=`${c}${g}
  8133. `;continue}else return}const b=e.extractItemData(m),{indentLevel:y,mainContent:v}=b;c=`${c}${g}
  8134. `;const x=[v];for(u+=1;u<o.length;){const T=o[u];if(T.trim()===""){const A=o.slice(u+1).findIndex(k=>k.trim()!=="");if(A===-1)break;if((((i=(r=o[u+1+A].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>y){x.push(T),c=`${c}${T}
  8135. `,u+=1;continue}else break}if((((s=(a=T.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:s.length)||0)>y)x.push(T),c=`${c}${T}
  8136. `,u+=1;else break}let M;const w=x.slice(1);if(w.length>0){const T=w.map(R=>R.slice(y+h)).join(`
  8137. `);T.trim()&&(e.customNestedParser?M=e.customNestedParser(T):M=n.blockTokens(T))}const C=e.createToken(b,M);l.push(C)}if(l.length!==0)return{items:l,raw:c}}function eD(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...s]=t.content,o=e.renderChildren([a]),l=[`${i}${o}`];return s&&s.length>0&&s.forEach(c=>{const u=e.renderChildren([c]);if(u){const h=u.split(`
  8138. `).map(g=>g?e.indent(g):"").join(`
  8139. `);l.push(h)}}),l.join(`
  8140. `)}function BAe(t,e,n={}){const{state:r}=e,{doc:i,tr:a}=r,s=t;i.descendants((o,l)=>{const c=a.mapping.map(l),u=a.mapping.map(l)+o.nodeSize;let h=null;if(o.marks.forEach(m=>{if(m!==s)return!1;h=m}),!h)return;let g=!1;if(Object.keys(n).forEach(m=>{n[m]!==h.attrs[m]&&(g=!0)}),g){const m=t.type.create({...t.attrs,...n});a.removeMark(c,u,t.type),a.addMark(c,u,m)}}),a.docChanged&&e.view.dispatch(a)}var $a=class Kq extends Zk{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Kq(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Uf(t){return new SAe({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=On(t.getAttributes,void 0,r,i);if(a===!1||a===null)return null;const{tr:s}=e,o=r[r.length-1],l=r[0];let c=n.to;if(o){const u=l.search(/\S/),h=n.from+l.indexOf(o),g=h+o.length;if(Yk(n.from,n.to,e.doc).filter(b=>b.mark.type.excluded.find(v=>v===t.type&&v!==b.mark.type)).filter(b=>b.to>h).length)return null;g<n.to&&s.delete(g,n.to),h>n.from&&s.delete(n.from+u,h),c=n.from+u+o.length,s.addMark(n.from+u,c,t.type.create(a||{})),s.removeStoredMark(t.type)}}})}var E2,x6;function HAe(){return x6||(x6=1,E2=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}),E2}var $Ae=HAe();const VAe=Zs($Ae);var A2={exports:{}},T2={};var v6;function GAe(){if(v6)return T2;v6=1;var t=ym(),e=MG();function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,a=t.useRef,s=t.useEffect,o=t.useMemo,l=t.useDebugValue;return T2.useSyncExternalStoreWithSelector=function(c,u,h,g,m){var b=a(null);if(b.current===null){var y={hasValue:!1,value:null};b.current=y}else y=b.current;b=o(function(){function x(R){if(!M){if(M=!0,w=R,R=g(R),m!==void 0&&y.hasValue){var A=y.value;if(m(A,R))return C=A}return C=R}if(A=C,r(w,R))return A;var j=g(R);return m!==void 0&&m(A,j)?(w=R,A):(w=R,C=j)}var M=!1,w,C,T=h===void 0?null:h;return[function(){return x(u())},T===null?void 0:function(){return x(T())}]},[u,h,g,m]);var v=i(c,b[0],b[1]);return s(function(){y.hasValue=!0,y.value=v},[v]),l(v),v},T2}var b6;function WAe(){return b6||(b6=1,A2.exports=GAe()),A2.exports}var Yq=WAe(),qAe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},XAe=({contentComponent:t})=>{const e=kP.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return f.jsx(f.Fragment,{children:Object.values(e)})};function KAe(){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]:tae.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 YAe=class extends ur.Component{constructor(t){var e;super(t),this.editorContentRef=ur.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=KAe(),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 f.jsxs(f.Fragment,{children:[f.jsx("div",{ref:qAe(e,this.editorContentRef),...n}),t?.contentComponent&&f.jsx(XAe,{contentComponent:t.contentComponent})]})}},ZAe=E.forwardRef((t,e)=>{const n=ur.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ur.createElement(YAe,{key:n,innerRef:e,...t})}),QAe=ur.memo(ZAe),JAe=typeof window<"u"?E.useLayoutEffect:E.useEffect,eTe=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 tTe(t){var e;const[n]=E.useState(()=>new eTe(t.editor)),r=Yq.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:VAe);return JAe(()=>n.watch(t.editor),[t.editor,n]),E.useDebugValue(r),r}var nTe=!1,cR=typeof window>"u",rTe=cR||!!(typeof window<"u"&&window.next),iTe=class Zq{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?cR||rTe?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 PAe(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?Zq.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 aTe(t={},e=[]){const n=E.useRef(t);n.current=t;const[r]=E.useState(()=>new iTe(n)),i=kP.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return E.useDebugValue(i),E.useEffect(r.onRender(e)),tTe({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var sTe=E.createContext({editor:null});sTe.Consumer;var oTe=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),lTe=()=>E.useContext(oTe);ur.forwardRef((t,e)=>{const{onDragStart:n}=lTe(),r=t.as||"div";return f.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});ur.createContext({markViewContentRef:()=>{}});var S1=(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]},cTe=/^\s*>\s$/,uTe=$a.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return S1("blockquote",{...Ar(this.options.HTMLAttributes,t),children:S1("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const o=e.renderChildren([i]).split(`
  8141. `).map(l=>l.trim()===""?n:`${n} ${l}`);r.push(o.join(`
  8142. `))}),r.join(`
  8143. ${n}
  8144. `)},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[cm({find:cTe,type:this.type})]}}),dTe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,fTe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,hTe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,pTe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,mTe=ud.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 S1("strong",{...Ar(this.options.HTMLAttributes,t),children:S1("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[lm({find:dTe,type:this.type}),lm({find:hTe,type:this.type})]},addPasteRules(){return[Uf({find:fTe,type:this.type}),Uf({find:pTe,type:this.type})]}}),gTe=/(^|[^`])`([^`]+)`(?!`)$/,xTe=/(^|[^`])`([^`]+)`(?!`)/g,vTe=ud.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Ar(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[lm({find:gTe,type:this.type})]},addPasteRules(){return[Uf({find:xTe,type:this.type})]}}),C2=4,bTe=/^```([a-z]+)?[\s\n]$/,yTe=/^~~~([a-z]+)?[\s\n]$/,_Te=$a.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:C2,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",Ar(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(`
  8145. `):r=`\`\`\`${i}
  8146. \`\`\``,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:C2,{state:r}=t,{selection:i}=r,{$from:a,empty:s}=i;if(a.parent.type!==this.type)return!1;const o=" ".repeat(n);return s?t.commands.insertContent(o):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,m=r.doc.textBetween(c,u,`
  8147. `,`
  8148. `).split(`
  8149. `).map(b=>o+b).join(`
  8150. `);return l.replaceWith(c,u,r.schema.text(m)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:C2,{state:r}=t,{selection:i}=r,{$from:a,empty:s}=i;return a.parent.type!==this.type?!1:s?t.commands.command(({tr:o})=>{var l;const{pos:c}=a,u=a.start(),h=a.end(),m=r.doc.textBetween(u,h,`
  8151. `,`
  8152. `).split(`
  8153. `);let b=0,y=0;const v=c-u;for(let R=0;R<m.length;R+=1){if(y+m[R].length>=v){b=R;break}y+=m[R].length+1}const M=((l=m[b].match(/^ */))==null?void 0:l[0])||"",w=Math.min(M.length,n);if(w===0)return!0;let C=u;for(let R=0;R<b;R+=1)C+=m[R].length+1;return o.delete(C,C+w),c-C<=w&&o.setSelection(Wt.create(o.doc,C)),!0}):t.commands.command(({tr:o})=>{const{from:l,to:c}=i,g=r.doc.textBetween(l,c,`
  8154. `,`
  8155. `).split(`
  8156. `).map(m=>{var b;const y=((b=m.match(/^ */))==null?void 0:b[0])||"",v=Math.min(y.length,n);return m.slice(v)}).join(`
  8157. `);return o.replaceWith(l,c,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(`
  8158. `);return!a||!s?!1:t.chain().command(({tr:o})=>(o.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const o=i.after();return o===void 0?!1:r.nodeAt(o)?t.commands.command(({tr:c})=>(c.setSelection(on.near(r.resolve(o))),!0)):t.commands.exitCode()}}},addInputRules(){return[oR({find:bTe,type:this.type,getAttributes:t=>({language:t[1]})}),oR({find:yTe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new vr({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:o}=t.state,l=o.text(n.replace(/\r\n?/g,`
  8159. `));return s.replaceSelectionWith(this.type.create({language:a},l)),s.selection.$from.parent.type!==this.type&&s.setSelection(Wt.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),STe=$a.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8160. `):""}),wTe=$a.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",Ar(this.options.HTMLAttributes,t)]},renderText(){return`
  8161. `},renderMarkdown:()=>`
  8162. `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:a}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:s}=this.options,{splittableMarks:o}=r.extensionManager,l=a||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&l&&s){const h=l.filter(g=>o.includes(g.type.name));c.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),MTe=$a.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]}`,Ar(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,i="#".repeat(r);return t.content?`${i} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>oR({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),ETe=$a.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Ar(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!OAe(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return Dq(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:a,tr:s,dispatch:o})=>{if(o){const{$to:l}=s.selection,c=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?s.setSelection(Wt.create(s.doc,l.pos+1)):l.nodeAfter.isBlock?s.setSelection(Ft.create(s.doc,l.pos)):s.setSelection(Wt.create(s.doc,l.pos));else{const u=a.schema.nodes[this.options.nextNodeType]||l.parent.type.contentMatch.defaultType,h=u?.create();h&&(s.insert(c,h),s.setSelection(Wt.create(s.doc,c+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Xq({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),ATe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,TTe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,CTe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,NTe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,RTe=ud.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",Ar(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[lm({find:ATe,type:this.type}),lm({find:CTe,type:this.type})]},addPasteRules(){return[Uf({find:TTe,type:this.type}),Uf({find:NTe,type:this.type})]}});const PTe="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",kTe="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",uR="numeric",dR="ascii",fR="alpha",kx="asciinumeric",mx="alphanumeric",hR="domain",Qq="emoji",DTe="scheme",OTe="slashscheme",N2="whitespace";function LTe(t,e){return t in e||(e[t]=[]),e[t]}function rf(t,e,n){e[uR]&&(e[kx]=!0,e[mx]=!0),e[dR]&&(e[kx]=!0,e[fR]=!0),e[kx]&&(e[mx]=!0),e[fR]&&(e[mx]=!0),e[mx]&&(e[hR]=!0),e[Qq]&&(e[hR]=!0);for(const r in e){const i=LTe(r,n);i.indexOf(t)<0&&i.push(t)}}function ITe(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function La(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}La.groups={};La.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||La.groups;let i;return e&&e.j?i=e:(i=new La(e),n&&r&&rf(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||La.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const a=e;let s,o=i.go(t);if(o?(s=new La,Object.assign(s.j,o.j),s.jr.push.apply(s.jr,o.jr),s.jd=o.jd,s.t=o.t):s=new La,a){if(r)if(s.t&&typeof s.t=="string"){const l=Object.assign(ITe(s.t,r),n);rf(a,l,r)}else n&&rf(a,n,r);s.t=a}return i.j[t]=s,s}};const nn=(t,e,n,r,i)=>t.ta(e,n,r,i),wr=(t,e,n,r,i)=>t.tr(e,n,r,i),y6=(t,e,n,r,i)=>t.ts(e,n,r,i),gt=(t,e,n,r,i)=>t.tt(e,n,r,i),ql="WORD",pR="UWORD",Jq="ASCIINUMERICAL",eX="ALPHANUMERICAL",m0="LOCALHOST",mR="TLD",gR="UTLD",R_="SCHEME",_p="SLASH_SCHEME",tD="NUM",xR="WS",nD="NL",Dx="OPENBRACE",Ox="CLOSEBRACE",w1="OPENBRACKET",M1="CLOSEBRACKET",E1="OPENPAREN",A1="CLOSEPAREN",T1="OPENANGLEBRACKET",C1="CLOSEANGLEBRACKET",N1="FULLWIDTHLEFTPAREN",R1="FULLWIDTHRIGHTPAREN",P1="LEFTCORNERBRACKET",k1="RIGHTCORNERBRACKET",D1="LEFTWHITECORNERBRACKET",O1="RIGHTWHITECORNERBRACKET",L1="FULLWIDTHLESSTHAN",I1="FULLWIDTHGREATERTHAN",j1="AMPERSAND",U1="APOSTROPHE",F1="ASTERISK",wu="AT",z1="BACKSLASH",B1="BACKTICK",H1="CARET",Ru="COLON",rD="COMMA",$1="DOLLAR",zo="DOT",V1="EQUALS",iD="EXCLAMATION",Ps="HYPHEN",Lx="PERCENT",G1="PIPE",W1="PLUS",q1="POUND",Ix="QUERY",aD="QUOTE",tX="FULLWIDTHMIDDLEDOT",sD="SEMI",Bo="SLASH",jx="TILDE",X1="UNDERSCORE",nX="EMOJI",K1="SYM";var rX=Object.freeze({__proto__:null,ALPHANUMERICAL:eX,AMPERSAND:j1,APOSTROPHE:U1,ASCIINUMERICAL:Jq,ASTERISK:F1,AT:wu,BACKSLASH:z1,BACKTICK:B1,CARET:H1,CLOSEANGLEBRACKET:C1,CLOSEBRACE:Ox,CLOSEBRACKET:M1,CLOSEPAREN:A1,COLON:Ru,COMMA:rD,DOLLAR:$1,DOT:zo,EMOJI:nX,EQUALS:V1,EXCLAMATION:iD,FULLWIDTHGREATERTHAN:I1,FULLWIDTHLEFTPAREN:N1,FULLWIDTHLESSTHAN:L1,FULLWIDTHMIDDLEDOT:tX,FULLWIDTHRIGHTPAREN:R1,HYPHEN:Ps,LEFTCORNERBRACKET:P1,LEFTWHITECORNERBRACKET:D1,LOCALHOST:m0,NL:nD,NUM:tD,OPENANGLEBRACKET:T1,OPENBRACE:Dx,OPENBRACKET:w1,OPENPAREN:E1,PERCENT:Lx,PIPE:G1,PLUS:W1,POUND:q1,QUERY:Ix,QUOTE:aD,RIGHTCORNERBRACKET:k1,RIGHTWHITECORNERBRACKET:O1,SCHEME:R_,SEMI:sD,SLASH:Bo,SLASH_SCHEME:_p,SYM:K1,TILDE:jx,TLD:mR,UNDERSCORE:X1,UTLD:gR,UWORD:pR,WORD:ql,WS:xR});const $l=/[a-z]/,Qg=new RegExp("\\p{L}","u"),R2=new RegExp("\\p{Emoji}","u"),Vl=/\d/,P2=/\s/,_6="\r",k2=`
  8163. `,jTe="️",UTe="‍",D2="";let Vy=null,Gy=null;function FTe(t=[]){const e={};La.groups=e;const n=new La;Vy==null&&(Vy=S6(PTe)),Gy==null&&(Gy=S6(kTe)),gt(n,"'",U1),gt(n,"{",Dx),gt(n,"}",Ox),gt(n,"[",w1),gt(n,"]",M1),gt(n,"(",E1),gt(n,")",A1),gt(n,"<",T1),gt(n,">",C1),gt(n,"(",N1),gt(n,")",R1),gt(n,"「",P1),gt(n,"」",k1),gt(n,"『",D1),gt(n,"』",O1),gt(n,"<",L1),gt(n,">",I1),gt(n,"&",j1),gt(n,"*",F1),gt(n,"@",wu),gt(n,"`",B1),gt(n,"^",H1),gt(n,":",Ru),gt(n,",",rD),gt(n,"$",$1),gt(n,".",zo),gt(n,"=",V1),gt(n,"!",iD),gt(n,"-",Ps),gt(n,"%",Lx),gt(n,"|",G1),gt(n,"+",W1),gt(n,"#",q1),gt(n,"?",Ix),gt(n,'"',aD),gt(n,"/",Bo),gt(n,";",sD),gt(n,"~",jx),gt(n,"_",X1),gt(n,"\\",z1),gt(n,"・",tX);const r=wr(n,Vl,tD,{[uR]:!0});wr(r,Vl,r);const i=wr(r,$l,Jq,{[kx]:!0}),a=wr(r,Qg,eX,{[mx]:!0}),s=wr(n,$l,ql,{[dR]:!0});wr(s,Vl,i),wr(s,$l,s),wr(i,Vl,i),wr(i,$l,i);const o=wr(n,Qg,pR,{[fR]:!0});wr(o,$l),wr(o,Vl,a),wr(o,Qg,o),wr(a,Vl,a),wr(a,$l),wr(a,Qg,a);const l=gt(n,k2,nD,{[N2]:!0}),c=gt(n,_6,xR,{[N2]:!0}),u=wr(n,P2,xR,{[N2]:!0});gt(n,D2,u),gt(c,k2,l),gt(c,D2,u),wr(c,P2,u),gt(u,_6),gt(u,k2),wr(u,P2,u),gt(u,D2,u);const h=wr(n,R2,nX,{[Qq]:!0});gt(h,"#"),wr(h,R2,h),gt(h,jTe,h);const g=gt(h,UTe);gt(g,"#"),wr(g,R2,h);const m=[[$l,s],[Vl,i]],b=[[$l,null],[Qg,o],[Vl,a]];for(let y=0;y<Vy.length;y++)vu(n,Vy[y],mR,ql,m);for(let y=0;y<Gy.length;y++)vu(n,Gy[y],gR,pR,b);rf(mR,{tld:!0,ascii:!0},e),rf(gR,{utld:!0,alpha:!0},e),vu(n,"file",R_,ql,m),vu(n,"mailto",R_,ql,m),vu(n,"http",_p,ql,m),vu(n,"https",_p,ql,m),vu(n,"ftp",_p,ql,m),vu(n,"ftps",_p,ql,m),rf(R_,{scheme:!0,ascii:!0},e),rf(_p,{slashscheme:!0,ascii:!0},e),t=t.sort((y,v)=>y[0]>v[0]?1:-1);for(let y=0;y<t.length;y++){const v=t[y][0],M=t[y][1]?{[DTe]:!0}:{[OTe]:!0};v.indexOf("-")>=0?M[hR]=!0:$l.test(v)?Vl.test(v)?M[kx]=!0:M[dR]=!0:M[uR]=!0,y6(n,v,v,M)}return y6(n,"localhost",m0,{ascii:!0}),n.jd=new La(K1),{start:n,tokens:Object.assign({groups:e},rX)}}function iX(t,e){const n=zTe(e.replace(/[A-Z]/g,o=>o.toLowerCase())),r=n.length,i=[];let a=0,s=0;for(;s<r;){let o=t,l=null,c=0,u=null,h=-1,g=-1;for(;s<r&&(l=o.go(n[s]));)o=l,o.accepts()?(h=0,g=0,u=o):h>=0&&(h+=n[s].length,g++),c+=n[s].length,a+=n[s].length,s++;a-=h,s-=g,c-=h,i.push({t:u.t,v:e.slice(a-c,a),s:a-c,e:a})}return i}function zTe(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 vu(t,e,n,r,i){let a;const s=e.length;for(let o=0;o<s-1;o++){const l=e[o];t.j[l]?a=t.j[l]:(a=new La(r),a.jr=i.slice(),t.j[l]=a),t=a}return a=new La(n),a.jr=i.slice(),t.j[e[s-1]]=a,a}function S6(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 g0={defaultProtocol:"http",events:null,format:w6,formatHref:w6,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function oD(t,e=null){let n=Object.assign({},g0);t&&(n=Object.assign(n,t instanceof oD?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}oD.prototype={o:g0,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]:g0[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 w6(t){return t}function aX(t,e){this.t="token",this.v=t,this.tk=e}aX.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=g0.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),a=this.toFormattedString(t),s={},o=t.get("className",n,e),l=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),h=t.getObj("events",n,e);return s.href=r,o&&(s.class=o),l&&(s.target=l),c&&(s.rel=c),u&&Object.assign(s,u),{tagName:i,attributes:s,content:a,eventListeners:h}}};function Tw(t,e){class n extends aX{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 M6=Tw("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),E6=Tw("text"),BTe=Tw("nl"),Wy=Tw("url",{isLink:!0,toHref(t=g0.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==m0&&t[1].t===Ru}}),Ts=t=>new La(t);function HTe({groups:t}){const e=t.domain.concat([j1,F1,wu,z1,B1,H1,$1,V1,Ps,tD,Lx,G1,W1,q1,Bo,K1,jx,X1]),n=[U1,Ru,rD,zo,iD,Lx,Ix,aD,sD,T1,C1,Dx,Ox,M1,w1,E1,A1,N1,R1,P1,k1,D1,O1,L1,I1],r=[j1,U1,F1,z1,B1,H1,$1,V1,Ps,Dx,Ox,Lx,G1,W1,q1,Ix,Bo,K1,jx,X1],i=Ts(),a=gt(i,jx);nn(a,r,a),nn(a,t.domain,a);const s=Ts(),o=Ts(),l=Ts();nn(i,t.domain,s),nn(i,t.scheme,o),nn(i,t.slashscheme,l),nn(s,r,a),nn(s,t.domain,s);const c=gt(s,wu);gt(a,wu,c),gt(o,wu,c),gt(l,wu,c);const u=gt(a,zo);nn(u,r,a),nn(u,t.domain,a);const h=Ts();nn(c,t.domain,h),nn(h,t.domain,h);const g=gt(h,zo);nn(g,t.domain,h);const m=Ts(M6);nn(g,t.tld,m),nn(g,t.utld,m),gt(c,m0,m);const b=gt(h,Ps);gt(b,Ps,b),nn(b,t.domain,h),nn(m,t.domain,h),gt(m,zo,g),gt(m,Ps,b);const y=gt(m,Ru);nn(y,t.numeric,M6);const v=gt(s,Ps),x=gt(s,zo);gt(v,Ps,v),nn(v,t.domain,s),nn(x,r,a),nn(x,t.domain,s);const M=Ts(Wy);nn(x,t.tld,M),nn(x,t.utld,M),nn(M,t.domain,s),nn(M,r,a),gt(M,zo,x),gt(M,Ps,v),gt(M,wu,c);const w=gt(M,Ru),C=Ts(Wy);nn(w,t.numeric,C);const T=Ts(Wy),R=Ts();nn(T,e,T),nn(T,n,R),nn(R,e,T),nn(R,n,R),gt(M,Bo,T),gt(C,Bo,T);const A=gt(o,Ru),j=gt(l,Ru),N=gt(j,Bo),k=gt(N,Bo);nn(o,t.domain,s),gt(o,zo,x),gt(o,Ps,v),nn(l,t.domain,s),gt(l,zo,x),gt(l,Ps,v),nn(A,t.domain,T),gt(A,Bo,T),gt(A,Ix,T),nn(k,t.domain,T),nn(k,e,T),gt(k,Bo,T);const F=[[Dx,Ox],[w1,M1],[E1,A1],[T1,C1],[N1,R1],[P1,k1],[D1,O1],[L1,I1]];for(let I=0;I<F.length;I++){const[W,D]=F[I],B=gt(T,W);gt(R,W,B),gt(B,D,T);const G=Ts(Wy);nn(B,e,G);const V=Ts();nn(B,n),nn(G,e,G),nn(G,n,V),nn(V,e,G),nn(V,n,V),gt(G,D,T),gt(V,D,T)}return gt(i,m0,M),gt(i,nD,BTe),{start:i,tokens:rX}}function $Te(t,e,n){let r=n.length,i=0,a=[],s=[];for(;i<r;){let o=t,l=null,c=null,u=0,h=null,g=-1;for(;i<r&&!(l=o.go(n[i].t));)s.push(n[i++]);for(;i<r&&(c=l||o.go(n[i].t));)l=null,o=c,o.accepts()?(g=0,h=o):g>=0&&g++,i++,u++;if(g<0)i-=u,i<r&&(s.push(n[i]),i++);else{s.length>0&&(a.push(O2(E6,e,s)),s=[]),i-=g,u-=g;const m=h.t,b=n.slice(i-u,i);a.push(O2(m,e,b))}}return s.length>0&&a.push(O2(E6,e,s)),a}function O2(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 VTe=typeof console<"u"&&console&&console.warn||(()=>{}),GTe="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ir={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function WTe(){return La.groups={},ir.scanner=null,ir.parser=null,ir.tokenQueue=[],ir.pluginQueue=[],ir.customSchemes=[],ir.initialized=!1,ir}function A6(t,e=!1){if(ir.initialized&&VTe(`linkifyjs: already initialized - will not register custom scheme "${t}" ${GTe}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
  8164. 1. Must only contain digits, lowercase ASCII letters or "-"
  8165. 2. Cannot start or end with "-"
  8166. 3. "-" cannot repeat`);ir.customSchemes.push([t,e])}function qTe(){ir.scanner=FTe(ir.customSchemes);for(let t=0;t<ir.tokenQueue.length;t++)ir.tokenQueue[t][1]({scanner:ir.scanner});ir.parser=HTe(ir.scanner.tokens);for(let t=0;t<ir.pluginQueue.length;t++)ir.pluginQueue[t][1]({scanner:ir.scanner,parser:ir.parser});return ir.initialized=!0,ir}function lD(t){return ir.initialized||qTe(),$Te(ir.parser.start,t,iX(ir.scanner.start,t))}lD.scan=iX;function sX(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 oD(n),i=lD(t),a=[];for(let s=0;s<i.length;s++){const o=i[s];o.isLink&&(!e||o.t===e)&&r.check(o)&&a.push(o.toFormattedObject(r))}return a}var cD="[\0-   ᠎ -\u2029  ]",XTe=new RegExp(cD),KTe=new RegExp(`${cD}$`),YTe=new RegExp(cD,"g");function ZTe(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function QTe(t){return new vr({key:new ci("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),a=e.some(c=>c.getMeta("preventAutolink"));if(!i||a)return;const{tr:s}=r,o=Eq(n.doc,[...e]);if(kq(o).forEach(({newRange:c})=>{const u=LEe(r.doc,c,m=>m.isTextblock);let h,g;if(u.length>1)h=u[0],g=r.doc.textBetween(h.pos,h.pos+h.node.nodeSize,void 0," ");else if(u.length){const m=r.doc.textBetween(c.from,c.to," "," ");if(!KTe.test(m))return;h=u[0],g=r.doc.textBetween(h.pos,c.to,void 0," ")}if(h&&g){const m=g.split(XTe).filter(Boolean);if(m.length<=0)return!1;const b=m[m.length-1],y=h.pos+g.lastIndexOf(b);if(!b)return!1;const v=lD(b).map(x=>x.toObject(t.defaultProtocol));if(!ZTe(v))return!1;v.filter(x=>x.isLink).map(x=>({...x,from:y+x.start+1,to:y+x.end+1})).filter(x=>r.schema.marks.code?!r.doc.rangeHasMark(x.from,x.to,r.schema.marks.code):!0).filter(x=>t.validate(x.value)).filter(x=>t.shouldAutoLink(x.value)).forEach(x=>{Yk(x.from,x.to,r.doc).some(M=>M.mark.type===t.type)||s.addMark(x.from,x.to,t.type.create({href:x.href}))})}}),!!s.steps.length)return s}})}function JTe(t){return new vr({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 u=r.target;const h=[];for(;u.nodeName!=="DIV";)h.push(u),u=u.parentNode;s=h.find(g=>g.nodeName==="A")}if(!s)return!1;const o=Pq(e.state,t.type.name),l=(i=s?.href)!=null?i:o.href,c=(a=s?.target)!=null?a:o.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),s&&l?(window.open(l,c),!0):!1}}})}function e2e(t){return new vr({key:new ci("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:a}=e,{selection:s}=a,{empty:o}=s;if(o)return!1;let l="";r.content.forEach(u=>{l+=u.textContent});const c=sX(l,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===l);return!l||!c||i!==void 0&&!i(c.href)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function Bd(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(YTe,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var oX=ud.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"){A6(t);return}A6(t.scheme,t.optionalSlashes)})},onDestroy(){WTe()},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)=>!!Bd(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=>!!Bd(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=>!!Bd(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Ar(this.options.HTMLAttributes,t),0]:["a",Ar(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=>!!Bd(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=>!!Bd(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[Uf({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=sX(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:s=>!!Bd(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(QTe({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Bd(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(JTe({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(e2e({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),t2e=oX,n2e=Object.defineProperty,r2e=(t,e)=>{for(var n in e)n2e(t,n,{get:e[n],enumerable:!0})},i2e="listItem",T6="textStyle",C6=/^\s*([-+*])\s$/,lX=$a.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",Ar(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,`
  8167. `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(i2e,this.editor.getAttributes(T6)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=cm({find:C6,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=cm({find:C6,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(T6),editor:this.editor})),[t]}}),cX=$a.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Ar(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(i=>i.type==="paragraph"))n=e.parseChildren(t.tokens);else{const i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(i.tokens)}],t.tokens.length>1){const s=t.tokens.slice(1),o=e.parseChildren(s);n.push(...o)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>eD(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)}}}),a2e={};r2e(a2e,{findListItemPos:()=>X0,getNextListDepth:()=>uD,handleBackspace:()=>vR,handleDelete:()=>bR,hasListBefore:()=>uX,hasListItemAfter:()=>s2e,hasListItemBefore:()=>dX,listItemHasSubList:()=>fX,nextListIsDeeper:()=>hX,nextListIsHigher:()=>pX});var X0=(t,e)=>{const{$from:n}=e.selection,r=Yr(t,e.schema);let i=null,a=n.depth,s=n.pos,o=null;for(;a>0&&o===null;)i=n.node(a),i.type===r?o=a:(a-=1,s-=1);return o===null?null:{$pos:e.doc.resolve(s),depth:o}},uD=(t,e)=>{const n=X0(t,e);if(!n)return!1;const[,r]=GEe(e,t,n.$pos.pos+4);return r},uX=(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))},dX=(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)},fX=(t,e,n)=>{if(!n)return!1;const r=Yr(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},vR=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!td(t.state,e)&&uX(t.state,e,n)){const{$anchor:o}=t.state.selection,l=t.state.doc.resolve(o.before()-1),c=[];l.node().descendants((g,m)=>{g.type.name===e&&c.push({node:g,pos:m})});const u=c.at(-1);if(!u)return!1;const h=t.state.doc.resolve(l.start()+u.pos+1);return t.chain().cut({from:o.start()-1,to:o.end()+1},h.end()).joinForward().run()}if(!td(t.state,e)||!KEe(t.state))return!1;const r=X0(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),s=fX(e,t.state,a);return dX(e,t.state)&&!s?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},hX=(t,e)=>{const n=uD(t,e),r=X0(t,e);return!r||!n?!1:n>r.depth},pX=(t,e)=>{const n=uD(t,e),r=X0(t,e);return!r||!n?!1:n<r.depth},bR=(t,e)=>{if(!td(t.state,e)||!XEe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:hX(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():pX(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},s2e=(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)},mX=Wn.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&&bR(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&&bR(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&&vR(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&&vR(t,n,r)&&(e=!0)}),e}}}}),N6=/^(\s*)(\d+)\.\s+(.*)$/,o2e=/^\s/;function l2e(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(N6);if(!a)break;const[,s,o,l]=a,c=s.length;let u=l,h=n+1;const g=[i];for(;h<t.length;){const m=t[h];if(m.match(N6))break;if(m.trim()==="")g.push(m),u+=`
  8168. `,h+=1;else if(m.match(o2e))g.push(m),u+=`
  8169. ${m.slice(c+2)}`,h+=1;else break}e.push({indent:c,number:parseInt(o,10),content:u.trim(),raw:g.join(`
  8170. `)}),r=h,n=h}return[e,r]}function gX(t,e,n){var r;const i=[];let a=0;for(;a<t.length;){const s=t[a];if(s.indent===e){const o=s.content.split(`
  8171. `),l=((r=o[0])==null?void 0:r.trim())||"",c=[];l&&c.push({type:"paragraph",raw:l,tokens:n.inlineTokens(l)});const u=o.slice(1).join(`
  8172. `).trim();if(u){const m=n.blockTokens(u);c.push(...m)}let h=a+1;const g=[];for(;h<t.length&&t[h].indent>e;)g.push(t[h]),h+=1;if(g.length>0){const m=Math.min(...g.map(y=>y.indent)),b=gX(g,m,n);c.push({type:"list",ordered:!0,start:g[0].number,items:b,raw:g.map(y=>y.raw).join(`
  8173. `)})}i.push({type:"list_item",raw:s.raw,tokens:c}),a=h}else a+=1}return i}function c2e(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 u2e="listItem",R6="textStyle",P6=/^(\d+)\.\s$/,xX=$a.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",Ar(this.options.HTMLAttributes,n),0]:["ol",Ar(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?c2e(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,`
  8174. `):"",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(`
  8175. `),[a,s]=l2e(i);if(a.length===0)return;const o=gX(a,0,n);return o.length===0?void 0:{type:"list",ordered:!0,start:((r=a[0])==null?void 0:r.number)||1,items:o,raw:i.slice(0,s).join(`
  8176. `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(u2e,this.editor.getAttributes(R6)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=cm({find:P6,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=cm({find:P6,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(R6)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),d2e=/^\s*(\[([( |x])?\])\s$/,f2e=$a.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",Ar(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 eD(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),a=document.createElement("label"),s=document.createElement("span"),o=document.createElement("input"),l=document.createElement("div"),c=u=>{var h,g;o.ariaLabel=((g=(h=this.options.a11y)==null?void 0:h.checkboxLabel)==null?void 0:g.call(h,u,o.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};return c(t),a.contentEditable="false",o.type="checkbox",o.addEventListener("mousedown",u=>u.preventDefault()),o.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){o.checked=!o.checked;return}const{checked:h}=u.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:g})=>{const m=n();if(typeof m!="number")return!1;const b=g.doc.nodeAt(m);return g.setNodeMarkup(m,void 0,{...b?.attrs,checked:h}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,h)||(o.checked=!o.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,h])=>{i.setAttribute(u,h)}),i.dataset.checked=t.attrs.checked,o.checked=t.attrs.checked,a.append(o,s),i.append(a,l),Object.entries(e).forEach(([u,h])=>{i.setAttribute(u,h)}),{dom:i,contentDOM:l,update:u=>u.type!==this.type?!1:(i.dataset.checked=u.attrs.checked,o.checked=u.attrs.checked,c(u),!0)}}},addInputRules(){return[cm({find:d2e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),h2e=$a.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",Ar(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,`
  8177. `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=a=>{const s=lR(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,l)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:l}),customNestedParser:r},n);return s?[{type:"taskList",raw:s.raw,items:s.items}]:n.blockTokens(a)},i=lR(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,s)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:s}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Wn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(lX.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(cX.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(mX.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(xX.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(f2e.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(h2e.configure(this.options.taskList)),t}});var p2e=$a.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Ar(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()}}}),m2e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,g2e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,x2e=ud.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",Ar(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[lm({find:m2e,type:this.type})]},addPasteRules(){return[Uf({find:g2e,type:this.type})]}}),v2e=$a.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),vX=ud.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",Ar(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()}}}),b2e=vX;function y2e(t={}){return new vr({view(e){return new _2e(e,t)}})}class _2e{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let a=s=>{this[i](s)};return e.dom.addEventListener(i,a),{name:i,handler:a}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,a=i.getBoundingClientRect(),s=a.width/i.offsetWidth,o=a.height/i.offsetHeight;if(n){let h=e.nodeBefore,g=e.nodeAfter;if(h||g){let m=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(m){let b=m.getBoundingClientRect(),y=h?b.bottom:b.top;h&&g&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let v=this.width/2*o;r={left:b.left,right:b.right,top:y-v,bottom:y+v}}}}if(!r){let h=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*s;r={left:h.left-g,right:h.left+g,top:h.top,bottom:h.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.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 c,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,u=-pageYOffset;else{let h=l.getBoundingClientRect(),g=h.width/l.offsetWidth,m=h.height/l.offsetHeight;c=h.left-l.scrollLeft*g,u=h.top-l.scrollTop*m}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-u)/o+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/o+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,a=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!a){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let o=xW(this.editorView.state.doc,s,this.editorView.dragging.slice);o!=null&&(s=o)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Er extends on{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Er.valid(r)?new Er(r):on.near(r)}content(){return Mt.empty}eq(e){return e instanceof Er&&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 Er(e.resolve(n.pos))}getBookmark(){return new dD(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!S2e(e)||!w2e(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&&Er.valid(e))return e;let i=e.pos,a=null;for(let s=e.depth;;s--){let o=e.node(s);if(n>0?e.indexAfter(s)<o.childCount:e.index(s)>0){a=o.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=n;let l=e.doc.resolve(i);if(Er.valid(l))return l}for(;;){let s=n>0?a.firstChild:a.lastChild;if(!s){if(a.isAtom&&!a.isText&&!Ft.isSelectable(a)){e=e.doc.resolve(i+a.nodeSize*n),r=!1;continue e}break}a=s,i+=n;let o=e.doc.resolve(i);if(Er.valid(o))return o}return null}}}Er.prototype.visible=!1;Er.findFrom=Er.findGapCursorFrom;on.jsonID("gapcursor",Er);class dD{constructor(e){this.pos=e}map(e){return new dD(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Er.valid(n)?new Er(n):on.near(n)}}function bX(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function S2e(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||bX(i.type))return!0;if(i.inlineContent)return!1}}return!0}function w2e(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||bX(i.type))return!0;if(i.inlineContent)return!1}}return!0}function M2e(){return new vr({props:{decorations:C2e,createSelectionBetween(t,e,n){return e.pos==n.pos&&Er.valid(n)?new Er(n):null},handleClick:A2e,handleKeyDown:E2e,handleDOMEvents:{beforeinput:T2e}}})}const E2e=xq({ArrowLeft:qy("horiz",-1),ArrowRight:qy("horiz",1),ArrowUp:qy("vert",-1),ArrowDown:qy("vert",1)});function qy(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,a){let s=r.selection,o=e>0?s.$to:s.$from,l=s.empty;if(s instanceof Wt){if(!a.endOfTextblock(n)||o.depth==0)return!1;l=!1,o=r.doc.resolve(e>0?o.after():o.before())}let c=Er.findGapCursorFrom(o,e,l);return c?(i&&i(r.tr.setSelection(new Er(c))),!0):!1}}function A2e(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Er.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Ft.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Er(r))),!0)}function T2e(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Er))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 Mt(i,0,0));return a.setSelection(Wt.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function C2e(t){if(!(t.selection instanceof Er))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",mr.create(t.doc,[ga.widget(t.selection.head,e,{key:"gapcursor"})])}var Y1=200,Ci=function(){};Ci.prototype.append=function(e){return e.length?(e=Ci.from(e),!this.length&&e||e.length<Y1&&this.leafAppend(e)||this.length<Y1&&e.leafPrepend(this)||this.appendInner(e)):this};Ci.prototype.prepend=function(e){return e.length?Ci.from(e).append(this):this};Ci.prototype.appendInner=function(e){return new N2e(this,e)};Ci.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Ci.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Ci.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Ci.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)};Ci.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};Ci.from=function(e){return e instanceof Ci?e:e&&e.length?new yX(e):Ci.empty};var yX=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,a){return i==0&&a==this.length?this:new e(this.values.slice(i,a))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,a,s,o){for(var l=a;l<s;l++)if(i(this.values[l],o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,a,s,o){for(var l=a-1;l>=s;l--)if(i(this.values[l],o+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Y1)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Y1)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})(Ci);Ci.empty=new yX([]);var N2e=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,a,s){var o=this.left.length;if(i<o&&this.left.forEachInner(r,i,Math.min(a,o),s)===!1||a>o&&this.right.forEachInner(r,Math.max(i-o,0),Math.min(this.length,a)-o,s+o)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,s){var o=this.left.length;if(i>o&&this.right.forEachInvertedInner(r,i-o,Math.max(a,o)-o,s+o)===!1||a<o&&this.left.forEachInvertedInner(r,Math.min(i,o),a,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var a=this.left.length;return i<=a?this.left.slice(r,i):r>=a?this.right.slice(r-a,i-a):this.left.slice(r,a).append(this.right.slice(0,i-a))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Ci);const R2e=500;class ho{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let s=e.tr,o,l,c=[],u=[];return this.items.forEach((h,g)=>{if(!h.step){i||(i=this.remapping(r,g+1),a=i.maps.length),a--,u.push(h);return}if(i){u.push(new Ho(h.map));let m=h.step.map(i.slice(a)),b;m&&s.maybeStep(m).doc&&(b=s.mapping.maps[s.mapping.maps.length-1],c.push(new Ho(b,void 0,void 0,c.length+u.length))),a--,b&&i.appendMap(b,a)}else s.maybeStep(h.step);if(h.selection)return o=i?h.selection.map(i.slice(a)):h.selection,l=new ho(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:s,selection:o}}addTransform(e,n,r,i){let a=[],s=this.eventCount,o=this.items,l=!i&&o.length?o.get(o.length-1):null;for(let u=0;u<e.steps.length;u++){let h=e.steps[u].invert(e.docs[u]),g=new Ho(e.mapping.maps[u],h,n),m;(m=l&&l.merge(g))&&(g=m,u?a.pop():o=o.slice(0,o.length-1)),a.push(g),n&&(s++,n=void 0),i||(l=g)}let c=s-r.depth;return c>k2e&&(o=P2e(o,c),s-=c),new ho(o.append(a),s)}remapping(e,n){let r=new c0;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 ho(this.items.append(e.map(n=>new Ho(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=e.mapping,s=e.steps.length,o=this.eventCount;this.items.forEach(g=>{g.selection&&o--},i);let l=n;this.items.forEach(g=>{let m=a.getMirror(--l);if(m==null)return;s=Math.min(s,m);let b=a.maps[m];if(g.step){let y=e.steps[m].invert(e.docs[m]),v=g.selection&&g.selection.map(a.slice(l+1,m));v&&o++,r.push(new Ho(b,y,v))}else r.push(new Ho(b))},i);let c=[];for(let g=n;g<s;g++)c.push(new Ho(a.maps[g]));let u=this.items.slice(0,i).append(c).append(r),h=new ho(u,o);return h.emptyItemCount()>R2e&&(h=h.compress(this.items.length-r.length)),h}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],a=0;return this.items.forEach((s,o)=>{if(o>=e)i.push(s),s.selection&&a++;else if(s.step){let l=s.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let u=s.selection&&s.selection.map(n.slice(r));u&&a++;let h=new Ho(c.invert(),l,u),g,m=i.length-1;(g=i.length&&i[m].merge(h))?i[m]=g:i.push(h)}}else s.map&&r--},this.items.length,0),new ho(Ci.from(i.reverse()),a)}}ho.empty=new ho(Ci.empty,0);function P2e(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class Ho{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 Ho(n.getMap().invert(),n,this.selection)}}}class Mu{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const k2e=20;function D2e(t,e,n,r){let i=n.getMeta(mf),a;if(i)return i.historyState;n.getMeta(I2e)&&(t=new Mu(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(mf))return s.getMeta(mf).redo?new Mu(t.done.addTransform(n,void 0,r,P_(e)),t.undone,k6(n.mapping.maps),t.prevTime,t.prevComposition):new Mu(t.done,t.undone.addTransform(n,void 0,r,P_(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let o=n.getMeta("composition"),l=t.prevTime==0||!s&&t.prevComposition!=o&&(t.prevTime<(n.time||0)-r.newGroupDelay||!O2e(n,t.prevRanges)),c=s?L2(t.prevRanges,n.mapping):k6(n.mapping.maps);return new Mu(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,P_(e)),ho.empty,c,n.time,o??t.prevComposition)}else return(a=n.getMeta("rebased"))?new Mu(t.done.rebased(n,a),t.undone.rebased(n,a),L2(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Mu(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),L2(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function O2e(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 k6(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 L2(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 L2e(t,e,n){let r=P_(e),i=mf.get(e).spec.config,a=(n?t.undone:t.done).popEvent(e,r);if(!a)return null;let s=a.selection.resolve(a.transform.doc),o=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),i,r),l=new Mu(n?o:a.remaining,n?a.remaining:o,null,0,-1);return a.transform.setSelection(s).setMeta(mf,{redo:n,historyState:l})}let I2=!1,D6=null;function P_(t){let e=t.plugins;if(D6!=e){I2=!1,D6=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){I2=!0;break}}return I2}const mf=new ci("history"),I2e=new ci("closeHistory");function j2e(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new vr({key:mf,state:{init(){return new Mu(ho.empty,ho.empty,null,0,-1)},apply(e,n,r){return D2e(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?SX:r=="historyRedo"?wX:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function _X(t,e){return(n,r)=>{let i=mf.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=L2e(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const SX=_X(!1,!0),wX=_X(!0,!0);Wn.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 vr({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,o=0,l=s;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(o,l);return t=!0,c}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),a=this.storage.characters({node:e.doc});if(a<=r||i>r&&a>r&&a<=i)return!0;if(i>r&&a>r&&a>i||!e.getMeta("paste"))return!1;const o=e.selection.$head.pos,l=a-r,c=o-l,u=o;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var U2e=Wn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[y2e(this.options)]}});Wn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new vr({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 mr.create(t,[]);let s=0;this.options.mode==="deepest"&&t.descendants((l,c)=>{if(l.isText)return;if(!(i>=c&&i<=c+l.nodeSize-1))return!1;s+=1});let o=0;return t.descendants((l,c)=>{if(l.isText||!(i>=c&&i<=c+l.nodeSize-1))return!1;if(o+=1,this.options.mode==="deepest"&&s-o>0||this.options.mode==="shallowest"&&o>1)return this.options.mode==="deepest";a.push(ga.node(c,c+l.nodeSize,{class:this.options.className}))}),mr.create(t,a)}}})]}});var F2e=Wn.create({name:"gapCursor",addProseMirrorPlugins(){return[M2e()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=On(Ut(t,"allowGapCursor",n)))!=null?e:null}}});Wn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new vr({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,o)=>{const l=r>=o&&r<=o+s.nodeSize,c=!s.isLeaf&&Mw(s);if((l||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];a&&u.push(this.options.emptyEditorClass);const h=ga.node(o,o+s.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:o,hasAnchor:l}):this.options.placeholder});i.push(h)}return this.options.includeChildren}),mr.create(t,i)}}})]}});Wn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new vr({key:new ci("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Dq(n.selection)||t.view.dragging?null:mr.create(n.doc,[ga.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function O6({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var z2e=Wn.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 vr({key:e,appendTransaction:(i,a,s)=>{const{doc:o,tr:l,schema:c}=s,u=e.getState(s),h=o.content.size,g=c.nodes[n];if(u)return l.insert(h,g.create())},state:{init:(i,a)=>{const s=a.tr.doc.lastChild;return!O6({node:s,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const s=i.doc.lastChild;return!O6({node:s,types:r})}}})]}}),B2e=Wn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>SX(t,e),redo:()=>({state:t,dispatch:e})=>wX(t,e)}},addProseMirrorPlugins(){return[j2e(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()}}}),H2e=Wn.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(mTe.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(uTe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(lX.configure(this.options.bulletList)),this.options.code!==!1&&i.push(vTe.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(_Te.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(STe.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(U2e.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(F2e.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(wTe.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(MTe.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(B2e.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(ETe.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(RTe.configure(this.options.italic)),this.options.listItem!==!1&&i.push(cX.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(mX.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(oX.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(xX.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(p2e.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(x2e.configure(this.options.strike)),this.options.text!==!1&&i.push(v2e.configure(this.options.text)),this.options.underline!==!1&&i.push(vX.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(z2e.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),$2e=H2e,V2e=Wn.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")}}}),G2e=V2e,W2e=20,MX=(t,e=0)=>{const n=[];return!t.children.length||e>W2e||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...MX(r,e+1))}),n},q2e=t=>{if(!t.children.length)return;const e=MX(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}`)})},EX=ud.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&q2e(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Ar(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}}}}),X2e=Wn.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const a=r[i].split(":");if(a.length>=2){const s=a[0].trim().toLowerCase(),o=a.slice(1).join(":").trim();if(s==="background-color")return o.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),AX=Wn.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const a=r[i].split(":");if(a.length>=2){const s=a[0].trim().toLowerCase(),o=a.slice(1).join(":").trim();if(s==="color")return o.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),K2e=Wn.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()}}}),Y2e=Wn.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()}}}),Z2e=Wn.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()}}});Wn.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(X2e.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(AX.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(K2e.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(Y2e.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(Z2e.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(EX.configure(this.options.textStyle)),t}});var Q2e=AX,J2e=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,eCe=$a.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",Ar(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,i,a,s;const o=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",l=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",c=(s=(a=t.attrs)==null?void 0:a.title)!=null?s:"";return c?`![${l}](${o} "${c}")`:`![${l}](${o})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:s})=>{const o=document.createElement("img");Object.entries(s).forEach(([u,h])=>{if(h!=null)switch(u){case"width":case"height":break;default:o.setAttribute(u,h);break}}),o.src=s.src;const l=new DAe({element:o,node:i,getPos:a,onResize:(u,h)=>{o.style.width=`${u}px`,o.style.height=`${h}px`},onCommit:(u,h)=>{const g=a();g!==void 0&&this.editor.chain().setNodeSelection(g).updateAttributes(this.name,{width:u,height:h}).run()},onUpdate:(u,h,g)=>u.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),c=l.dom;return c.style.visibility="hidden",c.style.pointerEvents="none",o.onload=()=>{c.style.visibility="",c.style.pointerEvents=""},l}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[Xq({find:J2e,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),tCe=eCe;function L6({content:t,onChange:e,placeholder:n}){const r=aTe({extensions:[$2e.configure({heading:!1,codeBlock:!1,code:!1}),b2e,t2e.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),G2e.configure({types:["paragraph"]}),EX,Q2e,tCe.configure({HTMLAttributes:{style:"max-width: 100%; height: auto;"}})],content:t,onUpdate:({editor:s})=>{e(s.getHTML())},editorProps:{attributes:{class:"prose prose-invert prose-sm max-w-none focus:outline-none min-h-[120px] px-3 py-2",placeholder:n||""}}});if(!r)return null;const i=({onClick:s,isActive:o=!1,children:l,title:c})=>f.jsx("button",{type:"button",onClick:s,title:c,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${o?"bg-bambu-dark-tertiary text-bambu-green":"text-bambu-gray"}`,children:l}),a=()=>{const s=window.prompt("Enter URL:");s&&r.chain().focus().setLink({href:s}).run()};return f.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[f.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[f.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:f.jsx(Zae,{className:"w-4 h-4"})}),f.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:f.jsx(ooe,{className:"w-4 h-4"})}),f.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:f.jsx(Ile,{className:"w-4 h-4"})}),f.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),f.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:f.jsx(KP,{className:"w-4 h-4"})}),f.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:f.jsx(u9,{className:"w-4 h-4"})}),f.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),f.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("left").run(),isActive:r.isActive({textAlign:"left"}),title:"Align Left",children:f.jsx(Rle,{className:"w-4 h-4"})}),f.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:f.jsx(Ale,{className:"w-4 h-4"})}),f.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("right").run(),isActive:r.isActive({textAlign:"right"}),title:"Align Right",children:f.jsx(Cle,{className:"w-4 h-4"})}),f.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),f.jsx(i,{onClick:a,isActive:r.isActive("link"),title:"Add Link",children:f.jsx(c9,{className:"w-4 h-4"})}),r.isActive("link")&&f.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:f.jsx(x9,{className:"w-4 h-4"})})]}),f.jsx(QAe,{editor:r})]})}function nCe({archiveId:t,archiveName:e,onClose:n}){const r=In(),[i,a]=E.useState(!1),[s,o]=E.useState(null),[l,c]=E.useState({}),{data:u,isLoading:h,error:g}=Nt({queryKey:["archive-project-page",t],queryFn:()=>ze.getArchiveProjectPage(t)}),m=Rt({mutationFn:T=>ze.updateArchiveProjectPage(t,T),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),c({})}});E.useEffect(()=>{const T=R=>{R.key==="Escape"&&(s!==null?o(null):i?x():n())};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[s,i,n]);const b=[...u?.model_pictures||[],...u?.profile_pictures||[]],y=()=>{c({title:u?.title||"",description:u?.description||"",designer:u?.designer||"",license:u?.license||"",profile_title:u?.profile_title||"",profile_description:u?.profile_description||""}),a(!0)},v=()=>{m.mutate(l)},x=()=>{a(!1),c({})},M=T=>{const R=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],A=new DOMParser().parseFromString(T,"text/html"),j=N=>{if(N.nodeType===Node.TEXT_NODE)return N.textContent||"";if(N.nodeType===Node.ELEMENT_NODE){const k=N,F=k.tagName.toLowerCase();if(!R.includes(F))return Array.from(k.childNodes).map(j).join("");let I="";if(F==="a"&&k.getAttribute("href")){const D=k.getAttribute("href");D?.toLowerCase().startsWith("http")&&(I=` href="${D}" target="_blank" rel="noopener noreferrer"`)}if(F==="img"){const D=k.getAttribute("src");if(!D?.toLowerCase().startsWith("http"))return"";I=` src="${D}" style="max-width: 100%; height: auto;"`}const W=Array.from(k.childNodes).map(j).join("");return["br","img"].includes(F)?`<${F}${I} />`:`<${F}${I}>${W}</${F}>`}return""};return Array.from(A.body.childNodes).map(j).join("")},w=u&&(u.title||u.description||u.designer||u.profile_title||b.length>0),C=T=>{T.target===T.currentTarget&&n()};return f.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:C,children:[f.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(wp,{className:"w-5 h-5 text-bambu-green"}),f.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&f.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[!i&&w&&f.jsxs(qe,{variant:"ghost",size:"sm",onClick:y,children:[f.jsx(YP,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&f.jsxs(f.Fragment,{children:[f.jsx(qe,{variant:"ghost",size:"sm",onClick:x,children:"Cancel"}),f.jsxs(qe,{variant:"primary",size:"sm",onClick:v,disabled:m.isPending,children:[f.jsx(qo,{className:"w-4 h-4 mr-1"}),"Save"]})]}),f.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:f.jsx(ln,{className:"w-5 h-5 text-bambu-gray"})})]})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[h&&f.jsx("div",{className:"flex items-center justify-center py-12",children:f.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),g&&f.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),u&&!w&&f.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[f.jsx(wp,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),f.jsx("p",{children:"No project page data found in this 3MF file."}),f.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),u&&w&&f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{className:"space-y-4",children:[i?f.jsx("input",{type:"text",value:l.title||"",onChange:T=>c({...l,title:T.target.value}),placeholder:"Title",className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold"}):u.title&&f.jsx("h3",{className:"text-xl font-semibold text-white",children:u.title}),f.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(aF,{className:"w-4 h-4 text-bambu-gray"}),f.jsx("input",{type:"text",value:l.designer||"",onChange:T=>c({...l,designer:T.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):u.designer&&f.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[f.jsx(aF,{className:"w-4 h-4"}),f.jsx("span",{children:u.designer}),u.designer_user_id&&f.jsx("a",{href:`https://makerworld.com/en/@${u.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:f.jsx(xc,{className:"w-3 h-3"})})]}),u.creation_date&&f.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[f.jsx(el,{className:"w-4 h-4"}),f.jsx("span",{children:u.creation_date})]}),i?f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(wp,{className:"w-4 h-4 text-bambu-gray"}),f.jsx("input",{type:"text",value:l.license||"",onChange:T=>c({...l,license:T.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):u.license&&f.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[f.jsx(wp,{className:"w-4 h-4"}),f.jsx("span",{children:u.license})]}),u.origin&&f.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:u.origin})]})]}),(u.description||i)&&f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?f.jsx(L6,{content:l.description||"",onChange:T=>c({...l,description:T}),placeholder:"Enter description..."}):f.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:M(u.description||"")}})]}),(u.profile_title||u.profile_description||i)&&f.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[f.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?f.jsxs("div",{className:"space-y-2",children:[f.jsx("input",{type:"text",value:l.profile_title||"",onChange:T=>c({...l,profile_title:T.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),f.jsx(L6,{content:l.profile_description||"",onChange:T=>c({...l,profile_description:T}),placeholder:"Profile description..."})]}):f.jsxs(f.Fragment,{children:[u.profile_title&&f.jsx("p",{className:"text-white font-medium",children:u.profile_title}),u.profile_description&&f.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:M(u.profile_description)}}),u.profile_user_name&&f.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",u.profile_user_name]})]})]}),b.length>0&&f.jsxs("div",{className:"space-y-2",children:[f.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[f.jsx(JS,{className:"w-4 h-4"}),"Images (",b.length,")"]}),f.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:b.map((T,R)=>f.jsx("button",{onClick:()=>o(R),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:f.jsx("img",{src:T.url,alt:T.name,className:"w-full h-full object-cover"})},T.path))})]}),u.design_model_id&&f.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:f.jsxs("a",{href:`https://makerworld.com/en/models/${u.design_model_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-bambu-green hover:underline",children:[f.jsx(xc,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),s!==null&&b[s]&&f.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>o(null),children:[f.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.max(0,s-1))},disabled:s===0,className:"absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:f.jsx(Ef,{className:"w-6 h-6 text-white"})}),f.jsx("img",{src:b[s].url,alt:b[s].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:T=>T.stopPropagation()}),f.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.min(b.length-1,s+1))},disabled:s===b.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:f.jsx(Mm,{className:"w-6 h-6 text-white"})}),f.jsx("button",{onClick:()=>o(null),className:"absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary",children:f.jsx(ln,{className:"w-6 h-6 text-white"})}),f.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[s+1," / ",b.length]})]})]})}const rCe=[.25,.5,.75,1,1.5,2,3,4];function iCe({src:t,title:e,downloadFilename:n,onClose:r}){const i=E.useRef(null),[a,s]=E.useState(!0),[o,l]=E.useState(.5),[c,u]=E.useState(0),[h,g]=E.useState(0);E.useEffect(()=>{const w=i.current;w&&(w.playbackRate=o)},[o]),E.useEffect(()=>{const w=C=>{C.key==="Escape"&&r()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[r]),E.useEffect(()=>{const w=i.current;if(!w)return;const C=()=>u(w.currentTime),T=()=>g(w.duration),R=()=>s(!0),A=()=>s(!1);return w.addEventListener("timeupdate",C),w.addEventListener("durationchange",T),w.addEventListener("play",R),w.addEventListener("pause",A),()=>{w.removeEventListener("timeupdate",C),w.removeEventListener("durationchange",T),w.removeEventListener("play",R),w.removeEventListener("pause",A)}},[]);const m=()=>{const w=i.current;w&&(a?w.pause():w.play())},b=w=>{const C=i.current;C&&(C.currentTime=parseFloat(w.target.value))},y=()=>{const w=i.current;w&&(w.currentTime=Math.max(0,w.currentTime-5))},v=()=>{const w=i.current;w&&(w.currentTime=Math.min(h,w.currentTime+5))},x=w=>{const C=Math.floor(w/60),T=Math.floor(w%60);return`${C}:${T.toString().padStart(2,"0")}`},M=()=>{const w=document.createElement("a");w.href=t,w.download=n,w.click()};return f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:f.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[f.jsx(Rp,{className:"w-5 h-5 text-bambu-green"}),e]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(qe,{variant:"secondary",size:"sm",onClick:M,children:[f.jsx(tl,{className:"w-4 h-4"}),"Download"]}),f.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:f.jsx(ln,{className:"w-5 h-5 text-bambu-gray"})})]})]}),f.jsxs("div",{className:"p-4",children:[f.jsx("video",{ref:i,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:m}),f.jsxs("div",{className:"mt-4 space-y-3",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:x(c)}),f.jsx("input",{type:"range",min:0,max:h||100,value:c,onChange:b,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8178. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8179. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8180. [&::-webkit-slider-thumb]:cursor-pointer`}),f.jsx("span",{className:"text-xs text-bambu-gray w-12",children:x(h)})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:y,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:f.jsx(dle,{className:"w-5 h-5 text-bambu-gray"})}),f.jsx("button",{onClick:m,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:a?f.jsx(Uoe,{className:"w-5 h-5 text-white"}):f.jsx(ew,{className:"w-5 h-5 text-white"})}),f.jsx("button",{onClick:v,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:f.jsx(p9,{className:"w-5 h-5 text-bambu-gray"})})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),f.jsx("div",{className:"flex gap-1",children:rCe.map(w=>f.jsxs("button",{onClick:()=>l(w),className:`px-2 py-1 text-xs rounded transition-colors ${o===w?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[w,"x"]},w))})]})]})]})]})]})})}function aCe({archiveId:t,archiveName:e,onClose:n}){const r=In(),{showToast:i}=sa(),[a,s]=E.useState(null),[o,l]=E.useState("asap"),[c,u]=E.useState(""),[h,g]=E.useState(!1),[m,b]=E.useState(!1),{data:y}=Nt({queryKey:["printers"],queryFn:()=>ze.getPrinters()});E.useEffect(()=>{y?.length===1&&!a&&s(y[0].id)},[y,a]),E.useEffect(()=>{const w=C=>{C.key==="Escape"&&n()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[n]);const v=Rt({mutationFn:w=>ze.addToQueue(w),onSuccess:()=>{r.invalidateQueries({queryKey:["queue"]}),i("Added to print queue"),n()},onError:w=>{i(w.message||"Failed to add to queue","error")}}),x=w=>{if(w.preventDefault(),!a){i("Please select a printer","error");return}const C={printer_id:a,archive_id:t,require_previous_success:h,auto_off_after:m};o==="scheduled"&&c&&(C.scheduled_time=new Date(c).toISOString()),v.mutate(C)},M=()=>{const w=new Date;return w.setMinutes(w.getMinutes()+1),w.toISOString().slice(0,16)};return f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:f.jsx(Ht,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:f.jsxs(Gt,{className:"p-0",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(el,{className:"w-5 h-5 text-bambu-green"}),f.jsx("h2",{className:"text-xl font-semibold text-white",children:"Schedule Print"})]}),f.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(ln,{className:"w-5 h-5"})})]}),f.jsxs("form",{onSubmit:x,className:"p-4 space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),f.jsx("p",{className:"text-white font-medium truncate",children:e})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),y?.length===0?f.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[f.jsx(wo,{className:"w-4 h-4"}),"No printers configured"]}):f.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:[f.jsx("option",{value:"",children:"Select printer..."}),y?.map(w=>f.jsx("option",{value:w.id,children:w.name},w.id))]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>l("asap"),children:[f.jsx(Ni,{className:"w-4 h-4"}),"ASAP (when idle)"]}),f.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>l("scheduled"),children:[f.jsx(el,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),f.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:c,onChange:w=>u(w.target.value),min:M(),required:!0})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox",id:"requirePrevious",checked:h,onChange:w=>g(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),f.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:w=>b(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),f.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[f.jsx(Wf,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),f.jsx("p",{className:"text-xs text-bambu-gray",children:o==="asap"?"Print will start as soon as the printer is idle.":"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available."}),f.jsxs("div",{className:"flex gap-3 pt-2",children:[f.jsx(qe,{type:"button",variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),f.jsx(qe,{type:"submit",className:"flex-1",disabled:v.isPending||!a||y?.length===0,children:v.isPending?"Adding...":"Add to Queue"})]})]})]})})})}function yR(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Jg(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function I6(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function sCe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i}){const a=In(),{showToast:s}=sa(),[o,l]=E.useState(!1),[c,u]=E.useState(!1),[h,g]=E.useState(!1),[m,b]=E.useState(!1),[y,v]=E.useState(!1),[x,M]=E.useState(!1),[w,C]=E.useState([]),[T,R]=E.useState(!1),[A,j]=E.useState(!1),[N,k]=E.useState(!1),[F,I]=E.useState(!1),[W,D]=E.useState(!1),[B,G]=E.useState(null),V=E.useRef(null),Z=Rt({mutationFn:ie=>ze.uploadSource3mf(t.id,ie),onSuccess:ie=>{a.invalidateQueries({queryKey:["archives"]}),s(`Source 3MF attached: ${ie.filename}`)},onError:ie=>{s(ie.message||"Failed to upload source 3MF","error")}}),Y=Rt({mutationFn:()=>ze.deleteSource3mf(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["archives"]}),s("Source 3MF removed")},onError:ie=>{s(ie.message||"Failed to remove source 3MF","error")}}),ee=Rt({mutationFn:()=>ze.scanArchiveTimelapse(t.id),onSuccess:ie=>{ie.status==="attached"?(a.invalidateQueries({queryKey:["archives"]}),s(`Timelapse attached: ${ie.filename}`)):ie.status==="exists"?s("Timelapse already attached"):ie.status==="not_found"&&ie.available_files&&ie.available_files.length>0?(C(ie.available_files),M(!0)):s(ie.message||"No matching timelapse found","warning")},onError:ie=>{s(ie.message||"Failed to scan for timelapse","error")}}),H=Rt({mutationFn:ie=>ze.selectArchiveTimelapse(t.id,ie),onSuccess:ie=>{a.invalidateQueries({queryKey:["archives"]}),s(`Timelapse attached: ${ie.filename}`),M(!1),C([])},onError:ie=>{s(ie.message||"Failed to attach timelapse","error")}}),q=Rt({mutationFn:()=>ze.deleteArchive(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["archives"]}),s("Archive deleted")},onError:()=>{s("Failed to delete archive","error")}}),ae=Rt({mutationFn:()=>ze.toggleFavorite(t.id),onSuccess:ie=>{a.invalidateQueries({queryKey:["archives"]}),s(ie.is_favorite?"Added to favorites":"Removed from favorites")}}),ce=ie=>{ie.preventDefault(),G({x:ie.clientX,y:ie.clientY})},xe=[{label:"Print",icon:f.jsx(nl,{className:"w-4 h-4"}),onClick:()=>u(!0)},{label:"Schedule",icon:f.jsx(el,{className:"w-4 h-4"}),onClick:()=>I(!0)},{label:"Open in Bambu Studio",icon:f.jsx(xc,{className:"w-4 h-4"}),onClick:()=>{const ie=t.print_name||t.filename||"model",ve=`${window.location.origin}${ze.getArchiveForSlicer(t.id,ie)}`;window.location.href=`bambustudioopen://${encodeURIComponent(ve)}`}},{label:"View on MakerWorld",icon:f.jsx(q_,{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:f.jsx(qx,{className:"w-4 h-4"}),onClick:()=>l(!0)},{label:"View Timelapse",icon:f.jsx(Rp,{className:"w-4 h-4"}),onClick:()=>v(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:f.jsx(nle,{className:"w-4 h-4"}),onClick:()=>ee.mutate(),disabled:!t.printer_id||!!t.timelapse_path||ee.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:f.jsx(JU,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const ie=document.createElement("a");ie.href=ze.getSource3mfDownloadUrl(t.id),ie.download=`${t.print_name||t.filename}_source.3mf`,ie.click()}else V.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:f.jsx(Ku,{className:"w-4 h-4"}),onClick:()=>V.current?.click()},{label:"Remove Source 3MF",icon:f.jsx(fr,{className:"w-4 h-4"}),onClick:()=>D(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:f.jsx(tl,{className:"w-4 h-4"}),onClick:()=>{const ie=document.createElement("a");ie.href=ze.getArchiveDownload(t.id),ie.download=`${t.print_name||t.filename}.3mf`,ie.click()}},{label:"Copy Download Link",icon:f.jsx(Vp,{className:"w-4 h-4"}),onClick:()=>{const ie=`${window.location.origin}${ze.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(ie).then(()=>{s("Link copied to clipboard")}).catch(()=>{s("Failed to copy link","error")})}},{label:"QR Code",icon:f.jsx(Koe,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:f.jsx(G_,{className:"w-4 h-4"}),onClick:()=>j(!0),disabled:!t.photos?.length},{label:"Project Page",icon:f.jsx(wp,{className:"w-4 h-4"}),onClick:()=>k(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:f.jsx(Kx,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>ae.mutate()},{label:"Edit",icon:f.jsx(Af,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:n?"Deselect":"Select",icon:n?f.jsx(Tf,{className:"w-4 h-4"}):f.jsx(Wp,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:f.jsx(fr,{className:"w-4 h-4"}),onClick:()=>g(!0),danger:!0}];return f.jsxs(Ht,{className:`relative flex flex-col ${n?"ring-2 ring-bambu-green":""} ${i?"cursor-pointer":""}`,onContextMenu:ce,onClick:i?()=>r(t.id):void 0,children:[i&&f.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:ie=>{ie.stopPropagation(),r(t.id)},children:n?f.jsx(Tf,{className:"w-5 h-5 text-bambu-green"}):f.jsx(Wp,{className:"w-5 h-5 text-white"})}),f.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",children:[t.thumbnail_path?f.jsx("img",{src:ze.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):f.jsx("div",{className:"w-full h-full flex items-center justify-center",children:f.jsx(JS,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),f.jsx("button",{className:"absolute top-2 right-2 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:ie=>{ie.stopPropagation(),ae.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:f.jsx(Kx,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),t.status==="failed"&&f.jsx("div",{className:"absolute top-2 left-12 px-2 py-1 rounded text-xs bg-red-500/80 text-white",children:"failed"}),t.duplicate_count>0&&f.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:[f.jsx(Vp,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&f.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:ie=>{ie.stopPropagation();const ve=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",Pe=`${window.location.origin}${ze.getSource3mfForSlicer(t.id,ve)}`;window.location.href=`bambustudioopen://${encodeURIComponent(Pe)}`},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:f.jsx(JU,{className:"w-4 h-4 text-orange-400"})}),t.timelapse_path&&f.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:ie=>{ie.stopPropagation(),v(!0)},title:"View timelapse",children:f.jsx(Rp,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&f.jsxs("button",{className:`absolute bottom-2 ${t.timelapse_path?"right-12":"right-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:ie=>{ie.stopPropagation(),j(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[f.jsx(G_,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&f.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})]})]}),f.jsxs(Gt,{className:"p-4 flex-1 flex flex-col",children:[f.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),f.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:e}),f.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)&&f.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${Jg(t.print_time_seconds||0)}
  8181. Actual: ${Jg(t.actual_time_seconds||0)}
  8182. Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Jg(t.actual_time_seconds)}`:`Estimated: ${Jg(t.print_time_seconds||0)}`,children:[f.jsx(Ni,{className:"w-3 h-3"}),Jg(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&f.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&&f.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[f.jsx(K_,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&f.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[f.jsx(Gp,{className:"w-3 h-3"}),t.total_layers&&f.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&f.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&f.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.filament_type&&f.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[f.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&f.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((ie,ve)=>f.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:ie},title:ie},ve))})]})]}),(t.tags||t.notes)&&f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&f.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:f.jsx(m9,{className:"w-3 h-3"})}),t.tags?.split(",").map((ie,ve)=>f.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:ie.trim()},ve))]}),f.jsx("div",{className:"flex-1"}),f.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[f.jsx("span",{children:I6(t.created_at)}),f.jsx("span",{children:yR(t.file_size)})]}),f.jsxs("div",{className:"flex gap-1 mt-3",children:[f.jsxs(qe,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>u(!0),children:[f.jsx(nl,{className:"w-3 h-3 flex-shrink-0"}),f.jsx("span",{className:"hidden sm:inline",children:"Print"})]}),f.jsx(qe,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ie=t.print_name||t.filename||"model",ve=`${window.location.origin}${ze.getArchiveForSlicer(t.id,ie)}`;window.location.href=`bambustudioopen://${encodeURIComponent(ve)}`},title:"Open in Bambu Studio",children:f.jsx(xc,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),f.jsx(qe,{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:f.jsx(q_,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),f.jsx(qe,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>l(!0),title:"3D Preview",children:f.jsx(qx,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),f.jsx(qe,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ie=document.createElement("a");ie.href=ze.getArchiveDownload(t.id),ie.download=`${t.print_name||t.filename}.3mf`,ie.click()},title:"Download",children:f.jsx(tl,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),f.jsx(qe,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>b(!0),title:"Edit",children:f.jsx(Af,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),f.jsx(qe,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>g(!0),title:"Delete",children:f.jsx(fr,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),m&&f.jsx(R1e,{archive:t,onClose:()=>b(!1)}),o&&f.jsx(A1e,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>l(!1)}),c&&f.jsx(T1e,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>u(!1),onSuccess:()=>{}}),h&&f.jsx(ja,{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:()=>{q.mutate(),g(!1)},onCancel:()=>g(!1)}),W&&f.jsx(ja,{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:()=>{Y.mutate(),D(!1)},onCancel:()=>D(!1)}),B&&f.jsx(P1e,{x:B.x,y:B.y,items:xe,onClose:()=>G(null)}),y&&t.timelapse_path&&f.jsx(iCe,{src:ze.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,onClose:()=>v(!1)}),x&&w.length>0&&f.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:f.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[f.jsxs("div",{children:[f.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),f.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),f.jsx("button",{onClick:()=>{M(!1),C([])},className:"text-gray-400 hover:text-white p-1",children:f.jsx(ln,{className:"w-5 h-5"})})]}),f.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:w.map(ie=>f.jsxs("button",{onClick:()=>H.mutate(ie.name),disabled:H.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:[f.jsx(Rp,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("p",{className:"text-white font-medium truncate",children:ie.name}),f.jsxs("p",{className:"text-sm text-gray-400",children:[yR(ie.size),ie.mtime&&` • ${I6(ie.mtime)}`]})]})]},ie.name))}),f.jsx("div",{className:"p-4 border-t border-gray-700",children:f.jsx(qe,{variant:"secondary",onClick:()=>{M(!1),C([])},className:"w-full",children:"Cancel"})})]})}),T&&f.jsx(U1e,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),A&&t.photos&&t.photos.length>0&&f.jsx(F1e,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>j(!1),onDelete:async ie=>{try{await ze.deleteArchivePhoto(t.id,ie),a.invalidateQueries({queryKey:["archives"]}),s("Photo deleted")}catch{s("Failed to delete photo","error")}}}),N&&f.jsx(nCe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>k(!1)}),F&&f.jsx(aCe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>I(!1)}),f.jsx("input",{ref:V,type:"file",accept:".3mf",className:"hidden",onChange:ie=>{const ve=ie.target.files?.[0];ve&&Z.mutate(ve),ie.target.value=""}})]})}const oCe=[{id:"all",label:"All Archives",icon:f.jsx(Xse,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:f.jsx(Ni,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:f.jsx(el,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:f.jsx(el,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:f.jsx(Kx,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:f.jsx(wo,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:f.jsx(Vp,{className:"w-4 h-4"})}];function lCe(){const t=In(),{showToast:e}=sa(),n=E.useRef(null),[r,i]=E.useState(""),[a,s]=E.useState(null),[o,l]=E.useState(null),[c,u]=E.useState(new Set),[h,g]=E.useState("or"),[m,b]=E.useState(!1),[y,v]=E.useState(null),[x,M]=E.useState(!1),[w,C]=E.useState([]),[T,R]=E.useState(!1),[A,j]=E.useState(new Set),[N,k]=E.useState(!1),[F,I]=E.useState(!1),[W,D]=E.useState(!1),[B,G]=E.useState("grid"),[V,Z]=E.useState("date-desc"),[Y,ee]=E.useState("all"),{data:H,isLoading:q}=Nt({queryKey:["archives",a],queryFn:()=>ze.getArchives(a||void 0)}),{data:ae}=Nt({queryKey:["printers"],queryFn:ze.getPrinters}),ce=Rt({mutationFn:async re=>(await Promise.all(re.map(U=>ze.deleteArchive(U))),re.length),onSuccess:re=>{t.invalidateQueries({queryKey:["archives"]}),j(new Set),e(`${re} archive${re!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}}),xe=new Map(ae?.map(re=>[re.id,re.name])||[]),ie=[...new Set(H?.flatMap(re=>re.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),ve=[...new Set(H?.flatMap(re=>re.filament_color?.split(",")||[]).filter(Boolean)||[])],Pe=[...new Set(H?.flatMap(re=>re.tags?.split(",").map(U=>U.trim())||[]).filter(Boolean)||[])].sort(),he=H?.filter(re=>{const U=new Date,L=new Date(re.created_at);let J=!0;switch(Y){case"recent":J=U.getTime()-L.getTime()<1440*60*1e3;break;case"this-week":J=U.getTime()-L.getTime()<10080*60*1e3;break;case"this-month":J=L.getMonth()===U.getMonth()&&L.getFullYear()===U.getFullYear();break;case"favorites":J=re.is_favorite===!0;break;case"failed":J=re.status==="failed";break;case"duplicates":J=re.duplicate_count>0;break}const ge=(re.print_name||re.filename).toLowerCase().includes(r.toLowerCase()),ye=!o||re.filament_type?.split(", ").includes(o),me=re.filament_color?.split(",")||[],et=c.size===0||(h==="or"?me.some(je=>c.has(je)):[...c].every(je=>me.includes(je))),Ie=Y==="favorites"||!m||re.is_favorite,Ke=re.tags?.split(",").map(je=>je.trim())||[],st=!y||Ke.includes(y);return J&&ge&&ye&&et&&Ie&&st}).sort((re,U)=>{switch(V){case"date-desc":return new Date(U.created_at).getTime()-new Date(re.created_at).getTime();case"date-asc":return new Date(re.created_at).getTime()-new Date(U.created_at).getTime();case"name-asc":return(re.print_name||re.filename).localeCompare(U.print_name||U.filename);case"name-desc":return(U.print_name||U.filename).localeCompare(re.print_name||re.filename);case"size-desc":return U.file_size-re.file_size;case"size-asc":return re.file_size-U.file_size;default:return 0}}),we=N||A.size>0,Le=re=>{j(U=>{const L=new Set(U);return L.has(re)?L.delete(re):L.add(re),L})},de=()=>{he&&j(new Set(he.map(re=>re.id)))},lt=()=>{j(new Set),k(!1)},$=re=>{u(U=>{const L=new Set(U);return L.has(re)?L.delete(re):L.add(re),L})},z=()=>{u(new Set)},ne=()=>{i(""),s(null),l(null),b(!1),v(null)},K=r||a||o||m||y,Q=E.useCallback(re=>{re.preventDefault(),re.dataTransfer.types.includes("Files")&&R(!0)},[]),oe=E.useCallback(re=>{re.preventDefault(),re.currentTarget===re.target&&R(!1)},[]),Ne=E.useCallback(re=>{re.preventDefault(),R(!1);const U=Array.from(re.dataTransfer.files).filter(L=>L.name.endsWith(".3mf"));U.length>0?(C(U),M(!0)):re.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),Ee=E.useCallback(re=>{const U=re.target;if(U.tagName==="INPUT"||U.tagName==="TEXTAREA"||U.isContentEditable){re.key==="Escape"&&U.blur();return}switch(re.key){case"/":re.preventDefault(),n.current?.focus();break;case"u":case"U":!re.metaKey&&!re.ctrlKey&&(re.preventDefault(),M(!0));break;case"Escape":we&&lt();break}},[we]);return E.useEffect(()=>(document.addEventListener("keydown",Ee),()=>document.removeEventListener("keydown",Ee)),[Ee]),f.jsxs("div",{className:"p-8 relative min-h-full",onDragOver:Q,onDragLeave:oe,onDrop:Ne,children:[T&&f.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:f.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[f.jsx(Ku,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),f.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),f.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),we&&f.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:[f.jsxs(qe,{variant:"secondary",size:"sm",onClick:lt,children:[f.jsx(ln,{className:"w-4 h-4"}),"Close"]}),f.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),f.jsxs("span",{className:"text-white font-medium",children:[A.size," selected"]}),f.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),f.jsx(qe,{variant:"secondary",size:"sm",onClick:de,children:"Select All"}),f.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),f.jsxs(qe,{variant:"secondary",size:"sm",onClick:()=>D(!0),children:[f.jsx(Yx,{className:"w-4 h-4"}),"Tags"]}),f.jsxs(qe,{variant:"secondary",size:"sm",onClick:()=>{const re=Array.from(A);Promise.all(re.map(U=>ze.toggleFavorite(U))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${re.length} archive${re.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[f.jsx(Kx,{className:"w-4 h-4"}),"Favorite"]}),f.jsxs(qe,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>I(!0),children:[f.jsx(fr,{className:"w-4 h-4"}),"Delete"]})]}),f.jsxs("div",{className:"flex items-center justify-between mb-8",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),f.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:Y,onChange:re=>ee(re.target.value),children:oCe.map(re=>f.jsx("option",{value:re.id,children:re.label},re.id))})]}),f.jsxs("p",{className:"text-bambu-gray",children:[he?.length||0," of ",H?.length||0," prints"]})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[!we&&f.jsxs(qe,{variant:"secondary",onClick:()=>k(!0),children:[f.jsx(Tf,{className:"w-4 h-4"}),"Select"]}),f.jsxs(qe,{onClick:()=>M(!0),children:[f.jsx(Ku,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),f.jsx(Ht,{className:"mb-6",children:f.jsxs(Gt,{className:"py-4",children:[f.jsxs("div",{className:"flex gap-4 items-center flex-wrap",children:[f.jsxs("div",{className:"flex-1 relative min-w-[200px]",children:[f.jsx(Xu,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),f.jsx("input",{ref:n,type:"text",placeholder:"Search archives... (press /)",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r,onChange:re=>i(re.target.value)})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(a9,{className:"w-4 h-4 text-bambu-gray"}),f.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:re=>s(re.target.value?Number(re.target.value):null),children:[f.jsx("option",{value:"",children:"All Printers"}),ae?.map(re=>f.jsx("option",{value:re.id,children:re.name},re.id))]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(K_,{className:"w-4 h-4 text-bambu-gray"}),f.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:o||"",onChange:re=>l(re.target.value||null),children:[f.jsx("option",{value:"",children:"All Materials"}),ie.map(re=>f.jsx("option",{value:re,children:re},re))]})]}),f.jsxs("button",{onClick:()=>b(!m),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors ${m?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:m?"Show all":"Show favorites only",children:[f.jsx(Kx,{className:`w-4 h-4 ${m?"fill-yellow-400":""}`}),f.jsx("span",{className:"text-sm",children:"Favorites"})]}),Pe.length>0&&f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Yx,{className:"w-4 h-4 text-bambu-gray"}),f.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:y||"",onChange:re=>v(re.target.value||null),children:[f.jsx("option",{value:"",children:"All Tags"}),Pe.map(re=>f.jsx("option",{value:re,children:re},re))]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(qae,{className:"w-4 h-4 text-bambu-gray"}),f.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:V,onChange:re=>Z(re.target.value),children:[f.jsx("option",{value:"date-desc",children:"Newest first"}),f.jsx("option",{value:"date-asc",children:"Oldest first"}),f.jsx("option",{value:"name-asc",children:"Name A-Z"}),f.jsx("option",{value:"name-desc",children:"Name Z-A"}),f.jsx("option",{value:"size-desc",children:"Largest first"}),f.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),f.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[f.jsx("button",{className:`p-2 ${B==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>G("grid"),title:"Grid view",children:f.jsx(l9,{className:"w-4 h-4"})}),f.jsx("button",{className:`p-2 ${B==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>G("list"),title:"List view",children:f.jsx(KP,{className:"w-4 h-4"})}),f.jsx("button",{className:`p-2 ${B==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>G("calendar"),title:"Calendar view",children:f.jsx(nse,{className:"w-4 h-4"})})]}),K&&f.jsxs(qe,{variant:"ghost",size:"sm",onClick:ne,className:"text-bambu-gray hover:text-white",children:[f.jsx(ln,{className:"w-4 h-4"}),"Reset"]})]}),ve.length>0&&f.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[f.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),c.size>1&&f.jsx("button",{onClick:()=>g(re=>re==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${h==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:h==="or"?"Match ANY selected color":"Match ALL selected colors",children:h.toUpperCase()}),f.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:ve.map(re=>f.jsx("button",{onClick:()=>$(re),className:`w-6 h-6 rounded-full border-2 transition-all ${c.has(re)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:re},title:re},re))}),c.size>0&&f.jsxs("button",{onClick:z,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[f.jsx(ln,{className:"w-3 h-3"}),"Clear"]})]})]})}),q?f.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):he?.length===0?f.jsx(Ht,{children:f.jsxs(Gt,{className:"text-center py-12",children:[f.jsx("p",{className:"text-bambu-gray",children:r?"No archives match your search":"No archives yet"}),f.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):B==="calendar"?f.jsx(Ht,{className:"p-6",children:f.jsx(j1e,{archives:he||[],onArchiveClick:re=>{i(re.print_name||re.filename),G("grid")}})}):B==="grid"?f.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:he?.map(re=>f.jsx(sCe,{archive:re,printerName:re.printer_id?xe.get(re.printer_id)||"Unknown":"No Printer",isSelected:A.has(re.id),onSelect:Le,selectionMode:we},re.id))}):B==="list"?f.jsx(Ht,{children:f.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[f.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[f.jsx("div",{className:"col-span-1"}),f.jsx("div",{className:"col-span-4",children:"Name"}),f.jsx("div",{className:"col-span-2",children:"Printer"}),f.jsx("div",{className:"col-span-2",children:"Date"}),f.jsx("div",{className:"col-span-1",children:"Size"}),f.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),he?.map(re=>f.jsxs("div",{className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${A.has(re.id)?"bg-bambu-green/10":""}`,children:[f.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[we&&f.jsx("button",{onClick:()=>Le(re.id),children:A.has(re.id)?f.jsx(Tf,{className:"w-4 h-4 text-bambu-green"}):f.jsx(Wp,{className:"w-4 h-4 text-bambu-gray"})}),re.thumbnail_path?f.jsx("img",{src:ze.getArchiveThumbnail(re.id),alt:"",className:"w-10 h-10 object-cover rounded"}):f.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:f.jsx(JS,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),f.jsxs("div",{className:"col-span-4",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("p",{className:"text-white text-sm truncate",children:re.print_name||re.filename}),re.timelapse_path&&f.jsx("span",{title:"Has timelapse",children:f.jsx(Rp,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})})]}),re.filament_type&&f.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[f.jsx("span",{className:"text-xs text-bambu-gray",children:re.filament_type}),re.filament_color&&f.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:re.filament_color.split(",").map((U,L)=>f.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:U},title:U},L))})]})]}),f.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:re.printer_id?xe.get(re.printer_id)||"Unknown":"No Printer"}),f.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:new Date(re.created_at).toLocaleDateString()}),f.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:yR(re.file_size)}),f.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[f.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>{const U=re.print_name||re.filename||"model",L=`${window.location.origin}${ze.getArchiveForSlicer(re.id,U)}`;window.location.href=`bambustudioopen://${encodeURIComponent(L)}`},title:"Open in Slicer",children:f.jsx(xc,{className:"w-4 h-4"})}),re.makerworld_url&&f.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>window.open(re.makerworld_url,"_blank"),title:"MakerWorld",children:f.jsx(q_,{className:"w-4 h-4"})}),f.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>{const U=document.createElement("a");U.href=ze.getArchiveDownload(re.id),U.download=`${re.print_name||re.filename}.3mf`,U.click()},title:"Download",children:f.jsx(tl,{className:"w-4 h-4"})})]})]},re.id))]})}):null,x&&f.jsx(C1e,{onClose:()=>{M(!1),C([])},initialFiles:w}),F&&f.jsx(ja,{title:"Delete Archives",message:`Are you sure you want to delete ${A.size} archive${A.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${A.size}`,variant:"danger",onConfirm:()=>{ce.mutate(Array.from(A)),I(!1)},onCancel:()=>I(!1)}),W&&f.jsx(k1e,{selectedIds:Array.from(A),existingTags:Pe,onClose:()=>D(!1)})]})}function cCe(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return E.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const Cw=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Pm(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function fD(t){return"nodeType"in t}function Va(t){var e,n;return t?Pm(t)?t:fD(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function hD(t){const{Document:e}=Va(t);return t instanceof e}function K0(t){return Pm(t)?!1:t instanceof Va(t).HTMLElement}function TX(t){return t instanceof Va(t).SVGElement}function km(t){return t?Pm(t)?t.document:fD(t)?hD(t)?t:K0(t)||TX(t)?t.ownerDocument:document:document:document}const ol=Cw?E.useLayoutEffect:E.useEffect;function pD(t){const e=E.useRef(t);return ol(()=>{e.current=t}),E.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function uCe(){const t=E.useRef(null),e=E.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=E.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function x0(t,e){e===void 0&&(e=[t]);const n=E.useRef(t);return ol(()=>{n.current!==t&&(n.current=t)},e),n}function Y0(t,e){const n=E.useRef();return E.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function Z1(t){const e=pD(t),n=E.useRef(null),r=E.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function _R(t){const e=E.useRef();return E.useEffect(()=>{e.current=t},[t]),e.current}let j2={};function Z0(t,e){return E.useMemo(()=>{if(e)return e;const n=j2[t]==null?0:j2[t]+1;return j2[t]=n,t+"-"+n},[t,e])}function CX(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((a,s)=>{const o=Object.entries(s);for(const[l,c]of o){const u=a[l];u!=null&&(a[l]=u+t*c)}return a},{...e})}}const Fp=CX(1),v0=CX(-1);function dCe(t){return"clientX"in t&&"clientY"in t}function mD(t){if(!t)return!1;const{KeyboardEvent:e}=Va(t.target);return e&&t instanceof e}function fCe(t){if(!t)return!1;const{TouchEvent:e}=Va(t.target);return e&&t instanceof e}function SR(t){if(fCe(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 dCe(t)?{x:t.clientX,y:t.clientY}:null}const um=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[um.Translate.toString(t),um.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),j6="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function hCe(t){return t.matches(j6)?t:t.querySelector(j6)}const pCe={display:"none"};function mCe(t){let{id:e,value:n}=t;return ur.createElement("div",{id:e,style:pCe},n)}function gCe(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 ur.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function xCe(){const[t,e]=E.useState("");return{announce:E.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const NX=E.createContext(null);function vCe(t){const e=E.useContext(NX);E.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function bCe(){const[t]=E.useState(()=>new Set),e=E.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[E.useCallback(r=>{let{type:i,event:a}=r;t.forEach(s=>{var o;return(o=s[i])==null?void 0:o.call(s,a)})},[t]),e]}const yCe={draggable:`
  8183. To pick up a draggable item, press the space bar.
  8184. While dragging, use the arrow keys to move the item.
  8185. Press space again to drop the item in its new position, or press escape to cancel.
  8186. `},_Ce={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 SCe(t){let{announcements:e=_Ce,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=yCe}=t;const{announce:a,announcement:s}=xCe(),o=Z0("DndLiveRegion"),[l,c]=E.useState(!1);if(E.useEffect(()=>{c(!0)},[]),vCe(E.useMemo(()=>({onDragStart(h){let{active:g}=h;a(e.onDragStart({active:g}))},onDragMove(h){let{active:g,over:m}=h;e.onDragMove&&a(e.onDragMove({active:g,over:m}))},onDragOver(h){let{active:g,over:m}=h;a(e.onDragOver({active:g,over:m}))},onDragEnd(h){let{active:g,over:m}=h;a(e.onDragEnd({active:g,over:m}))},onDragCancel(h){let{active:g,over:m}=h;a(e.onDragCancel({active:g,over:m}))}}),[a,e])),!l)return null;const u=ur.createElement(ur.Fragment,null,ur.createElement(mCe,{id:r,value:i.draggable}),ur.createElement(gCe,{id:o,announcement:s}));return n?ec.createPortal(u,n):u}var ri;(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"})(ri||(ri={}));function Q1(){}function J1(t,e){return E.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function RX(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return E.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const Ao=Object.freeze({x:0,y:0});function PX(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function kX(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function wCe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function U6(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 DX(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function F6(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 OX=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=F6(e,e.left,e.top),a=[];for(const s of r){const{id:o}=s,l=n.get(o);if(l){const c=PX(F6(l),i);a.push({id:o,data:{droppableContainer:s,value:c}})}}return a.sort(kX)},MCe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=U6(e),a=[];for(const s of r){const{id:o}=s,l=n.get(o);if(l){const c=U6(l),u=i.reduce((g,m,b)=>g+PX(c[b],m),0),h=Number((u/4).toFixed(4));a.push({id:o,data:{droppableContainer:s,value:h}})}}return a.sort(kX)};function ECe(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),a=Math.min(e.top+e.height,t.top+t.height),s=i-r,o=a-n;if(r<i&&n<a){const l=e.width*e.height,c=t.width*t.height,u=s*o,h=u/(l+c-u);return Number(h.toFixed(4))}return 0}const ACe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const a of r){const{id:s}=a,o=n.get(s);if(o){const l=ECe(o,e);l>0&&i.push({id:s,data:{droppableContainer:a,value:l}})}}return i.sort(wCe)};function TCe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function LX(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Ao}function CCe(t){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return i.reduce((s,o)=>({...s,top:s.top+t*o.y,bottom:s.bottom+t*o.y,left:s.left+t*o.x,right:s.right+t*o.x}),{...n})}}const NCe=CCe(1);function RCe(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 PCe(t,e,n){const r=RCe(e);if(!r)return t;const{scaleX:i,scaleY:a,x:s,y:o}=r,l=t.left-s-(1-i)*parseFloat(n),c=t.top-o-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),u=i?t.width/i:t.width,h=a?t.height/a:t.height;return{width:u,height:h,top:c,right:l+u,bottom:c+h,left:l}}const kCe={ignoreTransform:!1};function Dm(t,e){e===void 0&&(e=kCe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:c,transformOrigin:u}=Va(t).getComputedStyle(t);c&&(n=PCe(n,c,u))}const{top:r,left:i,width:a,height:s,bottom:o,right:l}=n;return{top:r,left:i,width:a,height:s,bottom:o,right:l}}function z6(t){return Dm(t,{ignoreTransform:!0})}function DCe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function OCe(t,e){return e===void 0&&(e=Va(t).getComputedStyle(t)),e.position==="fixed"}function LCe(t,e){e===void 0&&(e=Va(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 Nw(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(hD(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!K0(i)||TX(i)||n.includes(i))return n;const a=Va(t).getComputedStyle(i);return i!==t&&LCe(i,a)&&n.push(i),OCe(i,a)?n:r(i.parentNode)}return t?r(t):n}function IX(t){const[e]=Nw(t,1);return e??null}function U2(t){return!Cw||!t?null:Pm(t)?t:fD(t)?hD(t)||t===km(t).scrollingElement?window:K0(t)?t:null:null}function jX(t){return Pm(t)?t.scrollX:t.scrollLeft}function UX(t){return Pm(t)?t.scrollY:t.scrollTop}function wR(t){return{x:jX(t),y:UX(t)}}var Mi;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Mi||(Mi={}));function FX(t){return!Cw||!t?!1:t===document.scrollingElement}function zX(t){const e={x:0,y:0},n=FX(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},i=t.scrollTop<=e.y,a=t.scrollLeft<=e.x,s=t.scrollTop>=r.y,o=t.scrollLeft>=r.x;return{isTop:i,isLeft:a,isBottom:s,isRight:o,maxScroll:r,minScroll:e}}const ICe={x:.2,y:.2};function jCe(t,e,n,r,i){let{top:a,left:s,right:o,bottom:l}=n;r===void 0&&(r=10),i===void 0&&(i=ICe);const{isTop:c,isBottom:u,isLeft:h,isRight:g}=zX(t),m={x:0,y:0},b={x:0,y:0},y={height:e.height*i.y,width:e.width*i.x};return!c&&a<=e.top+y.height?(m.y=Mi.Backward,b.y=r*Math.abs((e.top+y.height-a)/y.height)):!u&&l>=e.bottom-y.height&&(m.y=Mi.Forward,b.y=r*Math.abs((e.bottom-y.height-l)/y.height)),!g&&o>=e.right-y.width?(m.x=Mi.Forward,b.x=r*Math.abs((e.right-y.width-o)/y.width)):!h&&s<=e.left+y.width&&(m.x=Mi.Backward,b.x=r*Math.abs((e.left+y.width-s)/y.width)),{direction:m,speed:b}}function UCe(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 BX(t){return t.reduce((e,n)=>Fp(e,wR(n)),Ao)}function FCe(t){return t.reduce((e,n)=>e+jX(n),0)}function zCe(t){return t.reduce((e,n)=>e+UX(n),0)}function BCe(t,e){if(e===void 0&&(e=Dm),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);IX(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const HCe=[["x",["left","right"],FCe],["y",["top","bottom"],zCe]];class gD{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=Nw(n),i=BX(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,s,o]of HCe)for(const l of s)Object.defineProperty(this,l,{get:()=>{const c=o(r),u=i[a]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ux{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 $Ce(t){const{EventTarget:e}=Va(t);return t instanceof e?t:km(t)}function F2(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 Is;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Is||(Is={}));function B6(t){t.preventDefault()}function VCe(t){t.stopPropagation()}var _n;(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"})(_n||(_n={}));const HX={start:[_n.Space,_n.Enter],cancel:[_n.Esc],end:[_n.Space,_n.Enter,_n.Tab]},GCe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case _n.Right:return{...n,x:n.x+25};case _n.Left:return{...n,x:n.x-25};case _n.Down:return{...n,y:n.y+25};case _n.Up:return{...n,y:n.y-25}}};class Rw{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 Ux(km(n)),this.windowListeners=new Ux(Va(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Is.Resize,this.handleCancel),this.windowListeners.add(Is.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Is.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&BCe(r),n(Ao)}handleKeyDown(e){if(mD(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=HX,coordinateGetter:s=GCe,scrollBehavior:o="smooth"}=i,{code:l}=e;if(a.end.includes(l)){this.handleEnd(e);return}if(a.cancel.includes(l)){this.handleCancel(e);return}const{collisionRect:c}=r.current,u=c?{x:c.left,y:c.top}:Ao;this.referenceCoordinates||(this.referenceCoordinates=u);const h=s(e,{active:n,context:r.current,currentCoordinates:u});if(h){const g=v0(h,u),m={x:0,y:0},{scrollableAncestors:b}=r.current;for(const y of b){const v=e.code,{isTop:x,isRight:M,isLeft:w,isBottom:C,maxScroll:T,minScroll:R}=zX(y),A=UCe(y),j={x:Math.min(v===_n.Right?A.right-A.width/2:A.right,Math.max(v===_n.Right?A.left:A.left+A.width/2,h.x)),y:Math.min(v===_n.Down?A.bottom-A.height/2:A.bottom,Math.max(v===_n.Down?A.top:A.top+A.height/2,h.y))},N=v===_n.Right&&!M||v===_n.Left&&!w,k=v===_n.Down&&!C||v===_n.Up&&!x;if(N&&j.x!==h.x){const F=y.scrollLeft+g.x,I=v===_n.Right&&F<=T.x||v===_n.Left&&F>=R.x;if(I&&!g.y){y.scrollTo({left:F,behavior:o});return}I?m.x=y.scrollLeft-F:m.x=v===_n.Right?y.scrollLeft-T.x:y.scrollLeft-R.x,m.x&&y.scrollBy({left:-m.x,behavior:o});break}else if(k&&j.y!==h.y){const F=y.scrollTop+g.y,I=v===_n.Down&&F<=T.y||v===_n.Up&&F>=R.y;if(I&&!g.x){y.scrollTo({top:F,behavior:o});return}I?m.y=y.scrollTop-F:m.y=v===_n.Down?y.scrollTop-T.y:y.scrollTop-R.y,m.y&&y.scrollBy({top:-m.y,behavior:o});break}}this.handleMove(e,Fp(v0(h,this.referenceCoordinates),m))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Rw.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=HX,onActivation:i}=e,{active:a}=n;const{code:s}=t.nativeEvent;if(r.start.includes(s)){const o=a.activatorNode.current;return o&&t.target!==o?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function H6(t){return!!(t&&"distance"in t)}function $6(t){return!!(t&&"delay"in t)}class xD{constructor(e,n,r){var i;r===void 0&&(r=$Ce(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=km(s),this.documentListeners=new Ux(this.document),this.listeners=new Ux(r),this.windowListeners=new Ux(Va(s)),this.initialCoordinates=(i=SR(a))!=null?i:Ao,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(Is.Resize,this.handleCancel),this.windowListeners.add(Is.DragStart,B6),this.windowListeners.add(Is.VisibilityChange,this.handleCancel),this.windowListeners.add(Is.ContextMenu,B6),this.documentListeners.add(Is.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if($6(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(H6(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(Is.Click,VCe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Is.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:a}=this,{onMove:s,options:{activationConstraint:o}}=a;if(!i)return;const l=(n=SR(e))!=null?n:Ao,c=v0(i,l);if(!r&&o){if(H6(o)){if(o.tolerance!=null&&F2(c,o.tolerance))return this.handleCancel();if(F2(c,o.distance))return this.handleStart()}if($6(o)&&F2(c,o.tolerance))return this.handleCancel();this.handlePending(o,c);return}e.cancelable&&e.preventDefault(),s(l)}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===_n.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const WCe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Pw extends xD{constructor(e){const{event:n}=e,r=km(n.target);super(e,WCe,r)}}Pw.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 qCe={move:{name:"mousemove"},end:{name:"mouseup"}};var MR;(function(t){t[t.RightClick=2]="RightClick"})(MR||(MR={}));class XCe extends xD{constructor(e){super(e,qCe,km(e.event.target))}}XCe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===MR.RightClick?!1:(r?.({event:n}),!0)}}];const z2={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class KCe extends xD{constructor(e){super(e,z2)}static setup(){return window.addEventListener(z2.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(z2.move.name,e)};function e(){}}}KCe.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 Fx;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(Fx||(Fx={}));var eS;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(eS||(eS={}));function YCe(t){let{acceleration:e,activator:n=Fx.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:s=5,order:o=eS.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:h,threshold:g}=t;const m=QCe({delta:h,disabled:!a}),[b,y]=uCe(),v=E.useRef({x:0,y:0}),x=E.useRef({x:0,y:0}),M=E.useMemo(()=>{switch(n){case Fx.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Fx.DraggableRect:return i}},[n,i,l]),w=E.useRef(null),C=E.useCallback(()=>{const R=w.current;if(!R)return;const A=v.current.x*x.current.x,j=v.current.y*x.current.y;R.scrollBy(A,j)},[]),T=E.useMemo(()=>o===eS.TreeOrder?[...c].reverse():c,[o,c]);E.useEffect(()=>{if(!a||!c.length||!M){y();return}for(const R of T){if(r?.(R)===!1)continue;const A=c.indexOf(R),j=u[A];if(!j)continue;const{direction:N,speed:k}=jCe(R,j,M,e,g);for(const F of["x","y"])m[F][N[F]]||(k[F]=0,N[F]=0);if(k.x>0||k.y>0){y(),w.current=R,b(C,s),v.current=k,x.current=N;return}}v.current={x:0,y:0},x.current={x:0,y:0},y()},[e,C,r,y,a,s,JSON.stringify(M),JSON.stringify(m),b,c,T,u,JSON.stringify(g)])}const ZCe={x:{[Mi.Backward]:!1,[Mi.Forward]:!1},y:{[Mi.Backward]:!1,[Mi.Forward]:!1}};function QCe(t){let{delta:e,disabled:n}=t;const r=_R(e);return Y0(i=>{if(n||!r||!i)return ZCe;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Mi.Backward]:i.x[Mi.Backward]||a.x===-1,[Mi.Forward]:i.x[Mi.Forward]||a.x===1},y:{[Mi.Backward]:i.y[Mi.Backward]||a.y===-1,[Mi.Forward]:i.y[Mi.Forward]||a.y===1}}},[n,e,r])}function JCe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return Y0(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function eNe(t,e){return E.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,a=i.activators.map(s=>({eventName:s.eventName,handler:e(s.handler,r)}));return[...n,...a]},[]),[t,e])}var b0;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(b0||(b0={}));var ER;(function(t){t.Optimized="optimized"})(ER||(ER={}));const V6=new Map;function tNe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[a,s]=E.useState(null),{frequency:o,measure:l,strategy:c}=i,u=E.useRef(t),h=v(),g=x0(h),m=E.useCallback(function(x){x===void 0&&(x=[]),!g.current&&s(M=>M===null?x:M.concat(x.filter(w=>!M.includes(w))))},[g]),b=E.useRef(null),y=Y0(x=>{if(h&&!n)return V6;if(!x||x===V6||u.current!==t||a!=null){const M=new Map;for(let w of t){if(!w)continue;if(a&&a.length>0&&!a.includes(w.id)&&w.rect.current){M.set(w.id,w.rect.current);continue}const C=w.node.current,T=C?new gD(l(C),C):null;w.rect.current=T,T&&M.set(w.id,T)}return M}return x},[t,a,n,h,l]);return E.useEffect(()=>{u.current=t},[t]),E.useEffect(()=>{h||m()},[n,h]),E.useEffect(()=>{a&&a.length>0&&s(null)},[JSON.stringify(a)]),E.useEffect(()=>{h||typeof o!="number"||b.current!==null||(b.current=setTimeout(()=>{m(),b.current=null},o))},[o,h,m,...r]),{droppableRects:y,measureDroppableContainers:m,measuringScheduled:a!=null};function v(){switch(c){case b0.Always:return!1;case b0.BeforeDragging:return n;default:return!n}}}function $X(t,e){return Y0(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function nNe(t,e){return $X(t,e)}function rNe(t){let{callback:e,disabled:n}=t;const r=pD(e),i=E.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(r)},[r,n]);return E.useEffect(()=>()=>i?.disconnect(),[i]),i}function kw(t){let{callback:e,disabled:n}=t;const r=pD(e),i=E.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(r)},[n]);return E.useEffect(()=>()=>i?.disconnect(),[i]),i}function iNe(t){return new gD(Dm(t),t)}function G6(t,e,n){e===void 0&&(e=iNe);const[r,i]=E.useState(null);function a(){i(l=>{if(!t)return null;if(t.isConnected===!1){var c;return(c=l??n)!=null?c:null}const u=e(t);return JSON.stringify(l)===JSON.stringify(u)?l:u})}const s=rNe({callback(l){if(t)for(const c of l){const{type:u,target:h}=c;if(u==="childList"&&h instanceof HTMLElement&&h.contains(t)){a();break}}}}),o=kw({callback:a});return ol(()=>{a(),t?(o?.observe(t),s?.observe(document.body,{childList:!0,subtree:!0})):(o?.disconnect(),s?.disconnect())},[t]),r}function aNe(t){const e=$X(t);return LX(t,e)}const W6=[];function sNe(t){const e=E.useRef(t),n=Y0(r=>t?r&&r!==W6&&t&&e.current&&t.parentNode===e.current.parentNode?r:Nw(t):W6,[t]);return E.useEffect(()=>{e.current=t},[t]),n}function oNe(t){const[e,n]=E.useState(null),r=E.useRef(t),i=E.useCallback(a=>{const s=U2(a.target);s&&n(o=>o?(o.set(s,wR(s)),new Map(o)):null)},[]);return E.useEffect(()=>{const a=r.current;if(t!==a){s(a);const o=t.map(l=>{const c=U2(l);return c?(c.addEventListener("scroll",i,{passive:!0}),[c,wR(c)]):null}).filter(l=>l!=null);n(o.length?new Map(o):null),r.current=t}return()=>{s(t),s(a)};function s(o){o.forEach(l=>{const c=U2(l);c?.removeEventListener("scroll",i)})}},[i,t]),E.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,s)=>Fp(a,s),Ao):BX(t):Ao,[t,e])}function q6(t,e){e===void 0&&(e=[]);const n=E.useRef(null);return E.useEffect(()=>{n.current=null},e),E.useEffect(()=>{const r=t!==Ao;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?v0(t,n.current):Ao}function lNe(t){E.useEffect(()=>{if(!Cw)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 cNe(t,e){return E.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:a}=r;return n[i]=s=>{a(s,e)},n},{}),[t,e])}function VX(t){return E.useMemo(()=>t?DCe(t):null,[t])}const X6=[];function uNe(t,e){e===void 0&&(e=Dm);const[n]=t,r=VX(n?Va(n):null),[i,a]=E.useState(X6);function s(){a(()=>t.length?t.map(l=>FX(l)?r:new gD(e(l),l)):X6)}const o=kw({callback:s});return ol(()=>{o?.disconnect(),s(),t.forEach(l=>o?.observe(l))},[t]),i}function dNe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return K0(e)?e:t}function fNe(t){let{measure:e}=t;const[n,r]=E.useState(null),i=E.useCallback(c=>{for(const{target:u}of c)if(K0(u)){r(h=>{const g=e(u);return h?{...h,width:g.width,height:g.height}:g});break}},[e]),a=kw({callback:i}),s=E.useCallback(c=>{const u=dNe(c);a?.disconnect(),u&&a?.observe(u),r(u?e(u):null)},[e,a]),[o,l]=Z1(s);return E.useMemo(()=>({nodeRef:o,rect:n,setRef:l}),[n,o,l])}const hNe=[{sensor:Pw,options:{}},{sensor:Rw,options:{}}],pNe={current:{}},k_={draggable:{measure:z6},droppable:{measure:z6,strategy:b0.WhileDragging,frequency:ER.Optimized},dragOverlay:{measure:Dm}};class zx 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 mNe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new zx,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Q1},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:k_,measureDroppableContainers:Q1,windowRect:null,measuringScheduled:!1},gNe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Q1,draggableNodes:new Map,over:null,measureDroppableContainers:Q1},Dw=E.createContext(gNe),GX=E.createContext(mNe);function xNe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new zx}}}function vNe(t,e){switch(e.type){case ri.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case ri.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 ri.DragEnd:case ri.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ri.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new zx(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case ri.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 zx(t.droppable.containers);return s.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:s}}}case ri.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new zx(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function bNe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=E.useContext(Dw),a=_R(r),s=_R(n?.id);return E.useEffect(()=>{if(!e&&!r&&a&&s!=null){if(!mD(a)||document.activeElement===a.target)return;const o=i.get(s);if(!o)return;const{activatorNode:l,node:c}=o;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const u of[l.current,c.current]){if(!u)continue;const h=hCe(u);if(h){h.focus();break}}})}},[r,e,i,s,a]),null}function yNe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function _Ne(t){return E.useMemo(()=>({draggable:{...k_.draggable,...t?.draggable},droppable:{...k_.droppable,...t?.droppable},dragOverlay:{...k_.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function SNe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const a=E.useRef(!1),{x:s,y:o}=typeof i=="boolean"?{x:i,y:i}:i;ol(()=>{if(!s&&!o||!e){a.current=!1;return}if(a.current||!r)return;const c=e?.node.current;if(!c||c.isConnected===!1)return;const u=n(c),h=LX(u,r);if(s||(h.x=0),o||(h.y=0),a.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const g=IX(c);g&&g.scrollBy({top:h.y,left:h.x})}},[e,s,o,r,n])}const WX=E.createContext({...Ao,scaleX:1,scaleY:1});var Eu;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Eu||(Eu={}));const qX=E.memo(function(e){var n,r,i,a;let{id:s,accessibility:o,autoScroll:l=!0,children:c,sensors:u=hNe,collisionDetection:h=ACe,measuring:g,modifiers:m,...b}=e;const y=E.useReducer(vNe,void 0,xNe),[v,x]=y,[M,w]=bCe(),[C,T]=E.useState(Eu.Uninitialized),R=C===Eu.Initialized,{draggable:{active:A,nodes:j,translate:N},droppable:{containers:k}}=v,F=A!=null?j.get(A):null,I=E.useRef({initial:null,translated:null}),W=E.useMemo(()=>{var Oe;return A!=null?{id:A,data:(Oe=F?.data)!=null?Oe:pNe,rect:I}:null},[A,F]),D=E.useRef(null),[B,G]=E.useState(null),[V,Z]=E.useState(null),Y=x0(b,Object.values(b)),ee=Z0("DndDescribedBy",s),H=E.useMemo(()=>k.getEnabled(),[k]),q=_Ne(g),{droppableRects:ae,measureDroppableContainers:ce,measuringScheduled:xe}=tNe(H,{dragging:R,dependencies:[N.x,N.y],config:q.droppable}),ie=JCe(j,A),ve=E.useMemo(()=>V?SR(V):null,[V]),Pe=pe(),he=nNe(ie,q.draggable.measure);SNe({activeNode:A!=null?j.get(A):null,config:Pe.layoutShiftCompensation,initialRect:he,measure:q.draggable.measure});const we=G6(ie,q.draggable.measure,he),Le=G6(ie?ie.parentElement:null),de=E.useRef({activatorEvent:null,active:null,activeNode:ie,collisionRect:null,collisions:null,droppableRects:ae,draggableNodes:j,draggingNode:null,draggingNodeRect:null,droppableContainers:k,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),lt=k.getNodeFor((n=de.current.over)==null?void 0:n.id),$=fNe({measure:q.dragOverlay.measure}),z=(r=$.nodeRef.current)!=null?r:ie,ne=R?(i=$.rect)!=null?i:we:null,K=!!($.nodeRef.current&&$.rect),Q=aNe(K?null:we),oe=VX(z?Va(z):null),Ne=sNe(R?lt??ie:null),Ee=uNe(Ne),re=yNe(m,{transform:{x:N.x-Q.x,y:N.y-Q.y,scaleX:1,scaleY:1},activatorEvent:V,active:W,activeNodeRect:we,containerNodeRect:Le,draggingNodeRect:ne,over:de.current.over,overlayNodeRect:$.rect,scrollableAncestors:Ne,scrollableAncestorRects:Ee,windowRect:oe}),U=ve?Fp(ve,N):null,L=oNe(Ne),J=q6(L),ge=q6(L,[we]),ye=Fp(re,J),me=ne?NCe(ne,re):null,et=W&&me?h({active:W,collisionRect:me,droppableRects:ae,droppableContainers:H,pointerCoordinates:U}):null,Ie=DX(et,"id"),[Ke,st]=E.useState(null),je=K?re:Fp(re,ge),le=TCe(je,(a=Ke?.rect)!=null?a:null,we),Ze=E.useRef(null),Fe=E.useCallback((Oe,Ae)=>{let{sensor:be,options:$e}=Ae;if(D.current==null)return;const ft=j.get(D.current);if(!ft)return;const yt=Oe.nativeEvent,Pt=new be({active:D.current,activeNode:ft,event:yt,options:$e,context:de,onAbort(Ot){if(!j.get(Ot))return;const{onDragAbort:qn}=Y.current,pi={id:Ot};qn?.(pi),M({type:"onDragAbort",event:pi})},onPending(Ot,Rn,qn,pi){if(!j.get(Ot))return;const{onDragPending:mi}=Y.current,Pi={id:Ot,constraint:Rn,initialCoordinates:qn,offset:pi};mi?.(Pi),M({type:"onDragPending",event:Pi})},onStart(Ot){const Rn=D.current;if(Rn==null)return;const qn=j.get(Rn);if(!qn)return;const{onDragStart:pi}=Y.current,Qr={activatorEvent:yt,active:{id:Rn,data:qn.data,rect:I}};ec.unstable_batchedUpdates(()=>{pi?.(Qr),T(Eu.Initializing),x({type:ri.DragStart,initialCoordinates:Ot,active:Rn}),M({type:"onDragStart",event:Qr}),G(Ze.current),Z(yt)})},onMove(Ot){x({type:ri.DragMove,coordinates:Ot})},onEnd:cn(ri.DragEnd),onCancel:cn(ri.DragCancel)});Ze.current=Pt;function cn(Ot){return async function(){const{active:qn,collisions:pi,over:Qr,scrollAdjustedTranslate:mi}=de.current;let Pi=null;if(qn&&mi){const{cancelDrop:qi}=Y.current;Pi={activatorEvent:yt,active:qn,collisions:pi,delta:mi,over:Qr},Ot===ri.DragEnd&&typeof qi=="function"&&await Promise.resolve(qi(Pi))&&(Ot=ri.DragCancel)}D.current=null,ec.unstable_batchedUpdates(()=>{x({type:Ot}),T(Eu.Uninitialized),st(null),G(null),Z(null),Ze.current=null;const qi=Ot===ri.DragEnd?"onDragEnd":"onDragCancel";if(Pi){const Ir=Y.current[qi];Ir?.(Pi),M({type:qi,event:Pi})}})}}},[j]),Xe=E.useCallback((Oe,Ae)=>(be,$e)=>{const ft=be.nativeEvent,yt=j.get($e);if(D.current!==null||!yt||ft.dndKit||ft.defaultPrevented)return;const Pt={active:yt};Oe(be,Ae.options,Pt)===!0&&(ft.dndKit={capturedBy:Ae.sensor},D.current=$e,Fe(be,Ae))},[j,Fe]),ct=eNe(u,Xe);lNe(u),ol(()=>{we&&C===Eu.Initializing&&T(Eu.Initialized)},[we,C]),E.useEffect(()=>{const{onDragMove:Oe}=Y.current,{active:Ae,activatorEvent:be,collisions:$e,over:ft}=de.current;if(!Ae||!be)return;const yt={active:Ae,activatorEvent:be,collisions:$e,delta:{x:ye.x,y:ye.y},over:ft};ec.unstable_batchedUpdates(()=>{Oe?.(yt),M({type:"onDragMove",event:yt})})},[ye.x,ye.y]),E.useEffect(()=>{const{active:Oe,activatorEvent:Ae,collisions:be,droppableContainers:$e,scrollAdjustedTranslate:ft}=de.current;if(!Oe||D.current==null||!Ae||!ft)return;const{onDragOver:yt}=Y.current,Pt=$e.get(Ie),cn=Pt&&Pt.rect.current?{id:Pt.id,rect:Pt.rect.current,data:Pt.data,disabled:Pt.disabled}:null,Ot={active:Oe,activatorEvent:Ae,collisions:be,delta:{x:ft.x,y:ft.y},over:cn};ec.unstable_batchedUpdates(()=>{st(cn),yt?.(Ot),M({type:"onDragOver",event:Ot})})},[Ie]),ol(()=>{de.current={activatorEvent:V,active:W,activeNode:ie,collisionRect:me,collisions:et,droppableRects:ae,draggableNodes:j,draggingNode:z,draggingNodeRect:ne,droppableContainers:k,over:Ke,scrollableAncestors:Ne,scrollAdjustedTranslate:ye},I.current={initial:ne,translated:me}},[W,ie,et,me,j,z,ne,ae,k,Ke,Ne,ye]),YCe({...Pe,delta:N,draggingRect:me,pointerCoordinates:U,scrollableAncestors:Ne,scrollableAncestorRects:Ee});const ue=E.useMemo(()=>({active:W,activeNode:ie,activeNodeRect:we,activatorEvent:V,collisions:et,containerNodeRect:Le,dragOverlay:$,draggableNodes:j,droppableContainers:k,droppableRects:ae,over:Ke,measureDroppableContainers:ce,scrollableAncestors:Ne,scrollableAncestorRects:Ee,measuringConfiguration:q,measuringScheduled:xe,windowRect:oe}),[W,ie,we,V,et,Le,$,j,k,ae,Ke,ce,Ne,Ee,q,xe,oe]),Qe=E.useMemo(()=>({activatorEvent:V,activators:ct,active:W,activeNodeRect:we,ariaDescribedById:{draggable:ee},dispatch:x,draggableNodes:j,over:Ke,measureDroppableContainers:ce}),[V,ct,W,we,x,ee,j,Ke,ce]);return ur.createElement(NX.Provider,{value:w},ur.createElement(Dw.Provider,{value:Qe},ur.createElement(GX.Provider,{value:ue},ur.createElement(WX.Provider,{value:le},c)),ur.createElement(bNe,{disabled:o?.restoreFocus===!1})),ur.createElement(SCe,{...o,hiddenTextDescribedById:ee}));function pe(){const Oe=B?.autoScrollEnabled===!1,Ae=typeof l=="object"?l.enabled===!1:l===!1,be=R&&!Oe&&!Ae;return typeof l=="object"?{...l,enabled:be}:{enabled:be}}}),wNe=E.createContext(null),K6="button",MNe="Draggable";function ENe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=Z0(MNe),{activators:s,activatorEvent:o,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:h,over:g}=E.useContext(Dw),{role:m=K6,roleDescription:b="draggable",tabIndex:y=0}=i??{},v=l?.id===e,x=E.useContext(v?WX:wNe),[M,w]=Z1(),[C,T]=Z1(),R=cNe(s,e),A=x0(n);ol(()=>(h.set(e,{id:e,key:a,node:M,activatorNode:C,data:A}),()=>{const N=h.get(e);N&&N.key===a&&h.delete(e)}),[h,e]);const j=E.useMemo(()=>({role:m,tabIndex:y,"aria-disabled":r,"aria-pressed":v&&m===K6?!0:void 0,"aria-roledescription":b,"aria-describedby":u.draggable}),[r,m,y,v,b,u.draggable]);return{active:l,activatorEvent:o,activeNodeRect:c,attributes:j,isDragging:v,listeners:r?void 0:R,node:M,over:g,setNodeRef:w,setActivatorNodeRef:T,transform:x}}function ANe(){return E.useContext(GX)}const TNe="Droppable",CNe={timeout:25};function NNe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=Z0(TNe),{active:s,dispatch:o,over:l,measureDroppableContainers:c}=E.useContext(Dw),u=E.useRef({disabled:n}),h=E.useRef(!1),g=E.useRef(null),m=E.useRef(null),{disabled:b,updateMeasurementsFor:y,timeout:v}={...CNe,...i},x=x0(y??r),M=E.useCallback(()=>{if(!h.current){h.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{c(Array.isArray(x.current)?x.current:[x.current]),m.current=null},v)},[v]),w=kw({callback:M,disabled:b||!s}),C=E.useCallback((j,N)=>{w&&(N&&(w.unobserve(N),h.current=!1),j&&w.observe(j))},[w]),[T,R]=Z1(C),A=x0(e);return E.useEffect(()=>{!w||!T.current||(w.disconnect(),h.current=!1,w.observe(T.current))},[T,w]),E.useEffect(()=>(o({type:ri.RegisterDroppable,element:{id:r,key:a,disabled:n,node:T,rect:g,data:A}}),()=>o({type:ri.UnregisterDroppable,key:a,id:r})),[r]),E.useEffect(()=>{n!==u.current.disabled&&(o({type:ri.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,o]),{active:s,rect:g,isOver:l?.id===r,node:T,over:l,setNodeRef:R}}function Ow(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function RNe(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function Xy(t){return t!==null&&t>=0}function PNe(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 kNe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const vD=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=Ow(e,r,n),s=e[i],o=a[i];return!o||!s?null:{x:o.left-s.left,y:o.top-s.top,scaleX:o.width/s.width,scaleY:o.height/s.height}},Ky={scaleX:1,scaleY:1},DNe=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:a,overIndex:s}=t;const o=(e=a[n])!=null?e:r;if(!o)return null;if(i===n){const c=a[s];return c?{x:0,y:n<s?c.top+c.height-(o.top+o.height):c.top-o.top,...Ky}:null}const l=ONe(a,i,n);return i>n&&i<=s?{x:0,y:-o.height-l,...Ky}:i<n&&i>=s?{x:0,y:o.height+l,...Ky}:{x:0,y:0,...Ky}};function ONe(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 XX="Sortable",KX=ur.createContext({activeIndex:-1,containerId:XX,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:vD,disabled:{draggable:!1,droppable:!1}});function YX(t){let{children:e,id:n,items:r,strategy:i=vD,disabled:a=!1}=t;const{active:s,dragOverlay:o,droppableRects:l,over:c,measureDroppableContainers:u}=ANe(),h=Z0(XX,n),g=o.rect!==null,m=E.useMemo(()=>r.map(R=>typeof R=="object"&&"id"in R?R.id:R),[r]),b=s!=null,y=s?m.indexOf(s.id):-1,v=c?m.indexOf(c.id):-1,x=E.useRef(m),M=!PNe(m,x.current),w=v!==-1&&y===-1||M,C=kNe(a);ol(()=>{M&&b&&u(m)},[M,m,b,u]),E.useEffect(()=>{x.current=m},[m]);const T=E.useMemo(()=>({activeIndex:y,containerId:h,disabled:C,disableTransforms:w,items:m,overIndex:v,useDragOverlay:g,sortedRects:RNe(m,l),strategy:i}),[y,h,C.draggable,C.droppable,w,m,v,l,g,i]);return ur.createElement(KX.Provider,{value:T},e)}const LNe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return Ow(n,r,i).indexOf(e)},INe=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:a,newIndex:s,previousItems:o,previousContainerId:l,transition:c}=t;return!c||!r||o!==a&&i===s?!1:n?!0:s!==i&&e===l},jNe={duration:200,easing:"ease"},ZX="transform",UNe=um.Transition.toString({property:ZX,duration:0,easing:"linear"}),FNe={roleDescription:"sortable"};function zNe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,s]=E.useState(null),o=E.useRef(n);return ol(()=>{if(!e&&n!==o.current&&r.current){const l=i.current;if(l){const c=Dm(r.current,{ignoreTransform:!0}),u={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(u.x||u.y)&&s(u)}}n!==o.current&&(o.current=n)},[e,n,r,i]),E.useEffect(()=>{a&&s(null)},[a]),a}function QX(t){let{animateLayoutChanges:e=INe,attributes:n,disabled:r,data:i,getNewIndex:a=LNe,id:s,strategy:o,resizeObserverConfig:l,transition:c=jNe}=t;const{items:u,containerId:h,activeIndex:g,disabled:m,disableTransforms:b,sortedRects:y,overIndex:v,useDragOverlay:x,strategy:M}=E.useContext(KX),w=BNe(r,m),C=u.indexOf(s),T=E.useMemo(()=>({sortable:{containerId:h,index:C,items:u},...i}),[h,i,C,u]),R=E.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:A,node:j,isOver:N,setNodeRef:k}=NNe({id:s,data:T,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:R,...l}}),{active:F,activatorEvent:I,activeNodeRect:W,attributes:D,setNodeRef:B,listeners:G,isDragging:V,over:Z,setActivatorNodeRef:Y,transform:ee}=ENe({id:s,data:T,attributes:{...FNe,...n},disabled:w.draggable}),H=cCe(k,B),q=!!F,ae=q&&!b&&Xy(g)&&Xy(v),ce=!x&&V,xe=ce&&ae?ee:null,ve=ae?xe??(o??M)({rects:y,activeNodeRect:W,activeIndex:g,overIndex:v,index:C}):null,Pe=Xy(g)&&Xy(v)?a({id:s,items:u,activeIndex:g,overIndex:v}):C,he=F?.id,we=E.useRef({activeId:he,items:u,newIndex:Pe,containerId:h}),Le=u!==we.current.items,de=e({active:F,containerId:h,isDragging:V,isSorting:q,id:s,index:C,items:u,newIndex:we.current.newIndex,previousItems:we.current.items,previousContainerId:we.current.containerId,transition:c,wasDragging:we.current.activeId!=null}),lt=zNe({disabled:!de,index:C,node:j,rect:A});return E.useEffect(()=>{q&&we.current.newIndex!==Pe&&(we.current.newIndex=Pe),h!==we.current.containerId&&(we.current.containerId=h),u!==we.current.items&&(we.current.items=u)},[q,Pe,h,u]),E.useEffect(()=>{if(he===we.current.activeId)return;if(he!=null&&we.current.activeId==null){we.current.activeId=he;return}const z=setTimeout(()=>{we.current.activeId=he},50);return()=>clearTimeout(z)},[he]),{active:F,activeIndex:g,attributes:D,data:T,rect:A,index:C,newIndex:Pe,items:u,isOver:N,isSorting:q,isDragging:V,listeners:G,node:j,overIndex:v,over:Z,setNodeRef:H,setActivatorNodeRef:Y,setDroppableNodeRef:k,setDraggableNodeRef:B,transform:lt??ve,transition:$()};function $(){if(lt||Le&&we.current.newIndex===C)return UNe;if(!(ce&&!mD(I)||!c)&&(q||de))return um.Transition.toString({...c,property:ZX})}}function BNe(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 tS(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 HNe=[_n.Down,_n.Right,_n.Up,_n.Left],JX=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:s,scrollableAncestors:o}}=e;if(HNe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const l=[];a.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const g=i.get(h.id);if(g)switch(t.code){case _n.Down:r.top<g.top&&l.push(h);break;case _n.Up:r.top>g.top&&l.push(h);break;case _n.Left:r.left>g.left&&l.push(h);break;case _n.Right:r.left<g.left&&l.push(h);break}});const c=MCe({collisionRect:r,droppableRects:i,droppableContainers:l});let u=DX(c,"id");if(u===s?.id&&c.length>1&&(u=c[1].id),u!=null){const h=a.get(n.id),g=a.get(u),m=g?i.get(g.id):null,b=g?.node.current;if(b&&m&&h&&g){const v=Nw(b).some((R,A)=>o[A]!==R),x=eK(h,g),M=$Ne(h,g),w=v||!x?{x:0,y:0}:{x:M?r.width-m.width:0,y:M?r.height-m.height:0},C={x:m.left,y:m.top};return w.x&&w.y?C:v0(C,w)}}}};function eK(t,e){return!tS(t)||!tS(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function $Ne(t,e){return!tS(t)||!tS(e)||!eK(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function VNe({item:t,onClose:e}){const n=In(),{showToast:r}=sa(),[i,a]=E.useState(t.printer_id),s=t.scheduled_time&&new Date(t.scheduled_time).getTime()>Date.now()+4320*60*60*1e3,[o,l]=E.useState(t.scheduled_time&&!s?"scheduled":"asap"),[c,u]=E.useState(()=>t.scheduled_time&&!s?new Date(t.scheduled_time).toISOString().slice(0,16):""),[h,g]=E.useState(t.require_previous_success),[m,b]=E.useState(t.auto_off_after),{data:y}=Nt({queryKey:["printers"],queryFn:()=>ze.getPrinters()});E.useEffect(()=>{const w=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[e]);const v=Rt({mutationFn:w=>ze.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")}}),x=w=>{w.preventDefault();const C={printer_id:i,require_previous_success:h,auto_off_after:m};o==="scheduled"&&c?C.scheduled_time=new Date(c).toISOString():C.scheduled_time=null,v.mutate(C)},M=()=>{const w=new Date;return w.setMinutes(w.getMinutes()+1),w.toISOString().slice(0,16)};return f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:f.jsx(Ht,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:f.jsxs(Gt,{className:"p-0",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Af,{className:"w-5 h-5 text-bambu-green"}),f.jsx("h2",{className:"text-xl font-semibold text-white",children:"Edit Queue Item"})]}),f.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(ln,{className:"w-5 h-5"})})]}),f.jsxs("form",{onSubmit:x,className:"p-4 space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),f.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),y?.length===0?f.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[f.jsx(wo,{className:"w-4 h-4"}),"No printers configured"]}):f.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:y?.map(w=>f.jsx("option",{value:w.id,children:w.name},w.id))})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>l("asap"),children:[f.jsx(Ni,{className:"w-4 h-4"}),"ASAP (when idle)"]}),f.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>l("scheduled"),children:[f.jsx(el,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),f.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:c,onChange:w=>u(w.target.value),min:M(),required:!0})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox",id:"requirePrevious",checked:h,onChange:w=>g(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),f.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:w=>b(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),f.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[f.jsx(Wf,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),f.jsx("p",{className:"text-xs text-bambu-gray",children:o==="asap"?"Print will start as soon as the printer is idle.":"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available."}),f.jsxs("div",{className:"flex gap-3 pt-2",children:[f.jsx(qe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),f.jsx(qe,{type:"submit",className:"flex-1",disabled:v.isPending||y?.length===0,children:v.isPending?"Saving...":"Save Changes"})]})]})]})})})}function tK(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 GNe(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 WNe({status:t}){const e={pending:{icon:Ni,color:"text-yellow-400 bg-yellow-400/10 border-yellow-400/20",label:"Pending"},printing:{icon:ew,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:gc,color:"text-green-400 bg-green-400/10 border-green-400/20",label:"Completed"},failed:{icon:z0,color:"text-red-400 bg-red-400/10 border-red-400/20",label:"Failed"},skipped:{icon:p9,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:ln,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:"Cancelled"}},{icon:n,color:r,label:i}=e[t];return f.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${r}`,children:[f.jsx(n,{className:"w-3.5 h-3.5"}),i]})}function B2({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:a,onRequeue:s}){const{attributes:o,listeners:l,setNodeRef:c,transform:u,transition:h,isDragging:g}=QX({id:t.id,disabled:t.status!=="pending"}),m={transform:um.Transform.toString(u),transition:h},b=t.status==="printing",y=t.status==="pending",v=["completed","failed","skipped","cancelled"].includes(t.status);return f.jsx("div",{ref:c,style:m,className:`
  8187. group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
  8188. transition-all duration-200 hover:border-bambu-dark-tertiary/80
  8189. ${g?"opacity-50 scale-[1.02] shadow-xl z-50":""}
  8190. ${b?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
  8191. `,children:f.jsxs("div",{className:"flex items-center gap-4 p-4",children:[y?f.jsx("div",{...o,...l,className:"flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors",children:f.jsx(XP,{className:"w-4 h-4 text-bambu-gray"})}):e!==void 0?f.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]}):f.jsx("div",{className:"w-8"}),f.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?f.jsx("img",{src:ze.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):f.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:f.jsx(Gp,{className:"w-6 h-6"})})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`}),f.jsx(QS,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:f.jsx(xc,{className:"w-3.5 h-3.5"})})]}),f.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx(nl,{className:"w-3.5 h-3.5"}),t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx(g9,{className:"w-3.5 h-3.5"}),tK(t.print_time_seconds)]}),y&&f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx(Ni,{className:"w-3.5 h-3.5"}),GNe(t.scheduled_time)]})]}),f.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.require_previous_success&&f.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&&f.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:[f.jsx(Wf,{className:"w-3 h-3"}),"Auto power off"]})]}),b&&f.jsxs("div",{className:"mt-3",children:[f.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:f.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Printing in progress..."})]}),t.error_message&&f.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[f.jsx(wo,{className:"w-3 h-3"}),t.error_message]})]}),f.jsx(WNe,{status:t.status}),f.jsxs("div",{className:"flex items-center gap-1",children:[b&&f.jsx(qe,{variant:"ghost",size:"sm",onClick:a,title:"Stop Print",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:f.jsx(gse,{className:"w-4 h-4"})}),y&&f.jsxs(f.Fragment,{children:[f.jsx(qe,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:f.jsx(Af,{className:"w-4 h-4"})}),f.jsx(qe,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:f.jsx(ln,{className:"w-4 h-4"})})]}),v&&f.jsxs(f.Fragment,{children:[f.jsx(qe,{variant:"ghost",size:"sm",onClick:s,title:"Re-queue",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:f.jsx(Mo,{className:"w-4 h-4"})}),f.jsx(qe,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:f.jsx(fr,{className:"w-4 h-4"})})]})]})]})})}function qNe(){const t=In(),{showToast:e}=sa(),[n,r]=E.useState(null),[i,a]=E.useState(""),[s,o]=E.useState(!1),[l,c]=E.useState(null),[u,h]=E.useState(null),[g,m]=E.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[b,y]=E.useState(()=>{const Y=localStorage.getItem("queue.historySortAsc");return Y!==null?Y==="true":!1}),[v,x]=E.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[M,w]=E.useState(()=>{const Y=localStorage.getItem("queue.pendingSortAsc");return Y!==null?Y==="true":!0});E.useEffect(()=>{localStorage.setItem("queue.historySortBy",g)},[g]),E.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(b))},[b]),E.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",v)},[v]),E.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(M))},[M]);const C=RX(J1(Pw,{activationConstraint:{distance:8}}),J1(Rw,{coordinateGetter:JX})),{data:T,isLoading:R}=Nt({queryKey:["queue",n,i],queryFn:()=>ze.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:A}=Nt({queryKey:["printers"],queryFn:()=>ze.getPrinters()}),j=Rt({mutationFn:Y=>ze.cancelQueueItem(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),N=Rt({mutationFn:Y=>ze.removeFromQueue(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),k=Rt({mutationFn:Y=>ze.stopQueueItem(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),F=Rt({mutationFn:Y=>ze.reorderQueue(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),I=Rt({mutationFn:Y=>{const ee=new Date;return ee.setFullYear(ee.getFullYear()+1),ze.addToQueue({printer_id:Y.printer_id,archive_id:Y.archive_id,scheduled_time:ee.toISOString(),require_previous_success:!1,auto_off_after:!1})},onSuccess:Y=>{t.invalidateQueries({queryKey:["queue"]}),e("Added back to queue - please set schedule"),c(Y)},onError:Y=>e(Y.message||"Failed to re-queue item","error")}),W=Rt({mutationFn:async()=>{const Y=T?.filter(ee=>["completed","failed","skipped","cancelled"].includes(ee.status))||[];for(const ee of Y)await ze.removeFromQueue(ee.id);return Y.length},onSuccess:Y=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${Y} history item${Y!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),D=E.useMemo(()=>{const Y=T?.filter(H=>H.status==="pending")||[],ee=H=>{if(!H.scheduled_time)return 0;const q=new Date(H.scheduled_time).getTime(),ae=Date.now()+4320*60*60*1e3;return q>ae?0:q};return[...Y].sort((H,q)=>{let ae;return v==="name"?ae=(H.archive_name||"").localeCompare(q.archive_name||""):v==="printer"?ae=(H.printer_name||"").localeCompare(q.printer_name||""):v==="time"?ae=ee(H)-ee(q):ae=H.position-q.position,M?ae:-ae})},[T,v,M]),B=T?.filter(Y=>Y.status==="printing")||[],G=E.useMemo(()=>[...T?.filter(ee=>["completed","failed","skipped","cancelled"].includes(ee.status))||[]].sort((ee,H)=>{let q;return g==="name"?q=(ee.archive_name||"").localeCompare(H.archive_name||""):g==="printer"?q=(ee.printer_name||"").localeCompare(H.printer_name||""):q=new Date(H.completed_at||H.created_at).getTime()-new Date(ee.completed_at||ee.created_at).getTime(),b?-q:q}),[T,g,b]),V=E.useMemo(()=>D.reduce((Y,ee)=>Y+(ee.print_time_seconds||0),0),[D]),Z=Y=>{const{active:ee,over:H}=Y;if(!H||ee.id===H.id)return;const q=D.findIndex(ce=>ce.id===ee.id),ae=D.findIndex(ce=>ce.id===H.id);if(q!==-1&&ae!==-1){const xe=Ow(D,q,ae).map((ie,ve)=>({id:ie.id,position:ve+1}));F.mutate(xe)}};return f.jsxs("div",{className:"p-8",children:[f.jsx("div",{className:"flex items-center justify-between mb-8",children:f.jsxs("div",{children:[f.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[f.jsx(u9,{className:"w-7 h-7 text-bambu-green"}),"Print Queue"]}),f.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage your print jobs"})]})}),f.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[f.jsx(Ht,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:f.jsx(Gt,{className:"p-4",children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:f.jsx(ew,{className:"w-5 h-5 text-blue-400"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-2xl font-bold text-white",children:B.length}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),f.jsx(Ht,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:f.jsx(Gt,{className:"p-4",children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:f.jsx(Ni,{className:"w-5 h-5 text-yellow-400"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-2xl font-bold text-white",children:D.length}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),f.jsx(Ht,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:f.jsx(Gt,{className:"p-4",children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:f.jsx(g9,{className:"w-5 h-5 text-bambu-green"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-2xl font-bold text-white",children:tK(V)}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),f.jsx(Ht,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:f.jsx(Gt,{className:"p-4",children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:f.jsx(gc,{className:"w-5 h-5 text-gray-400"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-2xl font-bold text-white",children:G.length}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"History"})]})]})})})]}),f.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[f.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:Y=>r(Y.target.value?Number(Y.target.value):null),children:[f.jsx("option",{value:"",children:"All Printers"}),A?.map(Y=>f.jsx("option",{value:Y.id,children:Y.name},Y.id))]}),f.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:Y=>a(Y.target.value),children:[f.jsx("option",{value:"",children:"All Status"}),f.jsx("option",{value:"pending",children:"Pending"}),f.jsx("option",{value:"printing",children:"Printing"}),f.jsx("option",{value:"completed",children:"Completed"}),f.jsx("option",{value:"failed",children:"Failed"}),f.jsx("option",{value:"skipped",children:"Skipped"}),f.jsx("option",{value:"cancelled",children:"Cancelled"})]}),f.jsx("div",{className:"flex-1"}),G.length>0&&f.jsxs(qe,{variant:"secondary",size:"sm",onClick:()=>o(!0),children:[f.jsx(fr,{className:"w-4 h-4"}),"Clear History"]})]}),R?f.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):T?.length===0?f.jsxs(Ht,{className:"p-12 text-center border-dashed",children:[f.jsx(el,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),f.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:"No prints scheduled"}),f.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.'})]}):f.jsxs("div",{className:"space-y-8",children:[B.length>0&&f.jsxs("div",{children:[f.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[f.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),"Currently Printing"]}),f.jsx("div",{className:"space-y-3",children:B.map(Y=>f.jsx(B2,{item:Y,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>h({type:"stop",item:Y}),onRequeue:()=>{}},Y.id))})]}),D.length>0&&f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between mb-4",children:[f.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[f.jsx(Ni,{className:"w-5 h-5 text-yellow-400"}),"Queued",f.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",D.length," item",D.length!==1?"s":"",")"]}),f.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)"})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:v,onChange:Y=>x(Y.target.value),children:[f.jsx("option",{value:"position",children:"Sort by Position"}),f.jsx("option",{value:"name",children:"Sort by Name"}),f.jsx("option",{value:"printer",children:"Sort by Printer"}),f.jsx("option",{value:"time",children:"Sort by Schedule"})]}),f.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>w(!M),title:M?"Ascending":"Descending",className:"px-2",children:M?f.jsx($p,{className:"w-4 h-4"}):f.jsx(Wx,{className:"w-4 h-4"})})]})]}),f.jsx(qX,{sensors:C,collisionDetection:OX,onDragEnd:Z,children:f.jsx(YX,{items:D.map(Y=>Y.id),strategy:DNe,children:f.jsx("div",{className:"space-y-3",children:D.map((Y,ee)=>f.jsx(B2,{item:Y,position:ee+1,onEdit:()=>c(Y),onCancel:()=>h({type:"cancel",item:Y}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{}},Y.id))})})})]}),G.length>0&&f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between mb-4",children:[f.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[f.jsx(gc,{className:"w-5 h-5 text-bambu-gray"}),"History",f.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",G.length," item",G.length!==1?"s":"",")"]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:g,onChange:Y=>m(Y.target.value),children:[f.jsx("option",{value:"date",children:"Sort by Date"}),f.jsx("option",{value:"name",children:"Sort by Name"}),f.jsx("option",{value:"printer",children:"Sort by Printer"})]}),f.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>y(!b),title:b?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:b?f.jsx($p,{className:"w-4 h-4"}):f.jsx(Wx,{className:"w-4 h-4"})})]})]}),f.jsx("div",{className:"space-y-3",children:G.slice(0,20).map((Y,ee)=>f.jsx(B2,{item:Y,position:ee+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>h({type:"remove",item:Y}),onStop:()=>{},onRequeue:()=>I.mutate(Y)},Y.id))})]})]}),l&&f.jsx(VNe,{item:l,onClose:()=>c(null)}),u&&f.jsx(ja,{title:u.type==="cancel"?"Cancel Scheduled Print":u.type==="stop"?"Stop Print":"Remove from History",message:u.type==="cancel"?`Are you sure you want to cancel "${u.item.archive_name||"this print"}"?`:u.type==="stop"?`Are you sure you want to stop the current print "${u.item.archive_name||"this print"}"? This will cancel the print job on the printer.`:`Are you sure you want to remove "${u.item.archive_name||"this item"}" from the queue history?`,confirmText:u.type==="cancel"?"Cancel Print":u.type==="stop"?"Stop Print":"Remove",variant:"danger",onConfirm:()=>{u.type==="cancel"?j.mutate(u.item.id):u.type==="stop"?k.mutate(u.item.id):N.mutate(u.item.id),h(null)},onCancel:()=>h(null)}),s&&f.jsx(ja,{title:"Clear History",message:`Are you sure you want to remove all ${G.length} item${G.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{W.mutate(),o(!1)},onCancel:()=>o(!1)})]})}function XNe({printDates:t,months:e=3}){const{weeks:n,monthLabels:r,printCounts:i}=E.useMemo(()=>{const l={};t.forEach(x=>{const M=x.split("T")[0];l[M]=(l[M]||0)+1});const c=new Date,u=new Date(c);u.setMonth(u.getMonth()-e),u.setDate(u.getDate()-u.getDay());const h=[],g=[];let m=[],b=-1;const y=new Date(u);let v=0;for(;y<=c;)y.getDay()===0&&m.length>0&&(h.push(m),m=[],v++),y.getMonth()!==b&&(g.push({month:y.toLocaleDateString("en-US",{month:"short"}),weekIndex:v}),b=y.getMonth()),m.push(new Date(y)),y.setDate(y.getDate()+1);return m.length>0&&h.push(m),{weeks:h,monthLabels:g,printCounts:l}},[t,e]),a=Math.max(1,...Object.values(i)),s=l=>{if(l===0)return"bg-bambu-dark";const c=l/a;return c<=.25?"bg-bambu-green/30":c<=.5?"bg-bambu-green/50":c<=.75?"bg-bambu-green/75":"bg-bambu-green"},o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return f.jsxs("div",{className:"overflow-x-auto",children:[f.jsx("div",{className:"flex mb-1 ml-8",children:r.map(({month:l,weekIndex:c},u)=>f.jsx("div",{className:"text-xs text-bambu-gray",style:{marginLeft:u===0?0:`${(c-(r[u-1]?.weekIndex||0))*14-24}px`},children:l},u))}),f.jsxs("div",{className:"flex gap-0.5",children:[f.jsx("div",{className:"flex flex-col gap-0.5 mr-1",children:o.map((l,c)=>f.jsx("div",{className:"h-3 text-xs text-bambu-gray flex items-center",style:{visibility:c%2===1?"visible":"hidden"},children:l},l))}),n.map((l,c)=>f.jsx("div",{className:"flex flex-col gap-0.5",children:[0,1,2,3,4,5,6].map(u=>{const h=l.find(y=>y.getDay()===u);if(!h)return f.jsx("div",{className:"w-3 h-3"},u);const g=h.toISOString().split("T")[0],m=i[g]||0,b=g===new Date().toISOString().split("T")[0];return f.jsx("div",{className:`w-3 h-3 rounded-sm ${s(m)} ${b?"ring-1 ring-white":""}`,title:`${h.toLocaleDateString()}: ${m} print${m!==1?"s":""}`},u)})},c))]}),f.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-bambu-gray",children:[f.jsx("span",{children:"Less"}),f.jsxs("div",{className:"flex gap-0.5",children:[f.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-dark"}),f.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/30"}),f.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/50"}),f.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/75"}),f.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green"})]}),f.jsx("span",{children:"More"})]})]})}function nK(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=nK(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function An(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=nK(t))&&(r&&(r+=" "),r+=e);return r}var KNe=["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 bD(t){if(typeof t!="string")return!1;var e=KNe;return e.includes(t)}var YNe=["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"],ZNe=new Set(YNe);function rK(t){return typeof t!="string"?!1:ZNe.has(t)}function iK(t){return typeof t=="string"&&t.startsWith("data-")}function Ha(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(rK(n)||iK(n))&&(e[n]=t[n]);return e}function Ff(t){if(t==null)return null;if(E.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Ha(e)}return typeof t=="object"&&!Array.isArray(t)?Ha(t):null}function Sa(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(rK(n)||iK(n)||bD(n))&&(e[n]=t[n]);return e}function QNe(t){return t==null?null:E.isValidElement(t)?Sa(t.props):typeof t=="object"&&!Array.isArray(t)?Sa(t):null}var JNe=["children","width","height","viewBox","className","style","title","desc"];function AR(){return AR=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},AR.apply(null,arguments)}function e3e(t,e){if(t==null)return{};var n,r,i=t3e(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 t3e(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 yD=E.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:s,style:o,title:l,desc:c}=t,u=e3e(t,JNe),h=a||{width:r,height:i,x:0,y:0},g=An("recharts-surface",s);return E.createElement("svg",AR({},Sa(u),{className:g,width:r,height:i,style:o,viewBox:"".concat(h.x," ").concat(h.y," ").concat(h.width," ").concat(h.height),ref:e}),E.createElement("title",null,l),E.createElement("desc",null,c),n)}),n3e=["children","className"];function TR(){return TR=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},TR.apply(null,arguments)}function r3e(t,e){if(t==null)return{};var n,r,i=i3e(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 i3e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var Lr=E.forwardRef((t,e)=>{var{children:n,className:r}=t,i=r3e(t,n3e),a=An("recharts-layer",r);return E.createElement("g",TR({className:a},Sa(i),{ref:e}),n)}),aK=E.createContext(null),a3e=()=>E.useContext(aK);function Qn(t){return function(){return t}}const sK=Math.cos,nS=Math.sin,Ro=Math.sqrt,rS=Math.PI,Lw=2*rS,CR=Math.PI,NR=2*CR,$d=1e-6,s3e=NR-$d;function oK(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function o3e(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return oK;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 l3e{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?oK:o3e(e)}moveTo(e,n){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,n){this._append`L${this._x1=+e},${this._y1=+n}`}quadraticCurveTo(e,n,r,i){this._append`Q${+e},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(e,n,r,i,a,s){this._append`C${+e},${+n},${+r},${+i},${this._x1=+a},${this._y1=+s}`}arcTo(e,n,r,i,a){if(e=+e,n=+n,r=+r,i=+i,a=+a,a<0)throw new Error(`negative radius: ${a}`);let s=this._x1,o=this._y1,l=r-e,c=i-n,u=s-e,h=o-n,g=u*u+h*h;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(g>$d)if(!(Math.abs(h*l-c*u)>$d)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let m=r-s,b=i-o,y=l*l+c*c,v=m*m+b*b,x=Math.sqrt(y),M=Math.sqrt(g),w=a*Math.tan((CR-Math.acos((y+g-v)/(2*x*M)))/2),C=w/M,T=w/x;Math.abs(C-1)>$d&&this._append`L${e+C*u},${n+C*h}`,this._append`A${a},${a},0,0,${+(h*m>u*b)},${this._x1=e+T*l},${this._y1=n+T*c}`}}arc(e,n,r,i,a,s){if(e=+e,n=+n,r=+r,s=!!s,r<0)throw new Error(`negative radius: ${r}`);let o=r*Math.cos(i),l=r*Math.sin(i),c=e+o,u=n+l,h=1^s,g=s?i-a:a-i;this._x1===null?this._append`M${c},${u}`:(Math.abs(this._x1-c)>$d||Math.abs(this._y1-u)>$d)&&this._append`L${c},${u}`,r&&(g<0&&(g=g%NR+NR),g>s3e?this._append`A${r},${r},0,1,${h},${e-o},${n-l}A${r},${r},0,1,${h},${this._x1=c},${this._y1=u}`:g>$d&&this._append`A${r},${r},0,${+(g>=CR)},${h},${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 _D(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 l3e(e)}function SD(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function lK(t){this._context=t}lK.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 Iw(t){return new lK(t)}function cK(t){return t[0]}function uK(t){return t[1]}function dK(t,e){var n=Qn(!0),r=null,i=Iw,a=null,s=_D(o);t=typeof t=="function"?t:t===void 0?cK:Qn(t),e=typeof e=="function"?e:e===void 0?uK:Qn(e);function o(l){var c,u=(l=SD(l)).length,h,g=!1,m;for(r==null&&(a=i(m=s())),c=0;c<=u;++c)!(c<u&&n(h=l[c],c,l))===g&&((g=!g)?a.lineStart():a.lineEnd()),g&&a.point(+t(h,c,l),+e(h,c,l));if(m)return a=null,m+""||null}return o.x=function(l){return arguments.length?(t=typeof l=="function"?l:Qn(+l),o):t},o.y=function(l){return arguments.length?(e=typeof l=="function"?l:Qn(+l),o):e},o.defined=function(l){return arguments.length?(n=typeof l=="function"?l:Qn(!!l),o):n},o.curve=function(l){return arguments.length?(i=l,r!=null&&(a=i(r)),o):i},o.context=function(l){return arguments.length?(l==null?r=a=null:a=i(r=l),o):r},o}function Yy(t,e,n){var r=null,i=Qn(!0),a=null,s=Iw,o=null,l=_D(c);t=typeof t=="function"?t:t===void 0?cK:Qn(+t),e=typeof e=="function"?e:Qn(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?uK:Qn(+n);function c(h){var g,m,b,y=(h=SD(h)).length,v,x=!1,M,w=new Array(y),C=new Array(y);for(a==null&&(o=s(M=l())),g=0;g<=y;++g){if(!(g<y&&i(v=h[g],g,h))===x)if(x=!x)m=g,o.areaStart(),o.lineStart();else{for(o.lineEnd(),o.lineStart(),b=g-1;b>=m;--b)o.point(w[b],C[b]);o.lineEnd(),o.areaEnd()}x&&(w[g]=+t(v,g,h),C[g]=+e(v,g,h),o.point(r?+r(v,g,h):w[g],n?+n(v,g,h):C[g]))}if(M)return o=null,M+""||null}function u(){return dK().defined(i).curve(s).context(a)}return c.x=function(h){return arguments.length?(t=typeof h=="function"?h:Qn(+h),r=null,c):t},c.x0=function(h){return arguments.length?(t=typeof h=="function"?h:Qn(+h),c):t},c.x1=function(h){return arguments.length?(r=h==null?null:typeof h=="function"?h:Qn(+h),c):r},c.y=function(h){return arguments.length?(e=typeof h=="function"?h:Qn(+h),n=null,c):e},c.y0=function(h){return arguments.length?(e=typeof h=="function"?h:Qn(+h),c):e},c.y1=function(h){return arguments.length?(n=h==null?null:typeof h=="function"?h:Qn(+h),c):n},c.lineX0=c.lineY0=function(){return u().x(t).y(e)},c.lineY1=function(){return u().x(t).y(n)},c.lineX1=function(){return u().x(r).y(e)},c.defined=function(h){return arguments.length?(i=typeof h=="function"?h:Qn(!!h),c):i},c.curve=function(h){return arguments.length?(s=h,a!=null&&(o=s(a)),c):s},c.context=function(h){return arguments.length?(h==null?a=o=null:o=s(a=h),c):a},c}class fK{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 c3e(t){return new fK(t,!0)}function u3e(t){return new fK(t,!1)}const wD={draw(t,e){const n=Ro(e/rS);t.moveTo(n,0),t.arc(0,0,n,0,Lw)}},d3e={draw(t,e){const n=Ro(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()}},hK=Ro(1/3),f3e=hK*2,h3e={draw(t,e){const n=Ro(e/f3e),r=n*hK;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},p3e={draw(t,e){const n=Ro(e),r=-n/2;t.rect(r,r,n,n)}},m3e=.8908130915292852,pK=nS(rS/10)/nS(7*rS/10),g3e=nS(Lw/10)*pK,x3e=-sK(Lw/10)*pK,v3e={draw(t,e){const n=Ro(e*m3e),r=g3e*n,i=x3e*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const s=Lw*a/5,o=sK(s),l=nS(s);t.lineTo(l*n,-o*n),t.lineTo(o*r-l*i,l*r+o*i)}t.closePath()}},H2=Ro(3),b3e={draw(t,e){const n=-Ro(e/(H2*3));t.moveTo(0,n*2),t.lineTo(-H2*n,-n),t.lineTo(H2*n,-n),t.closePath()}},Cs=-.5,Ns=Ro(3)/2,RR=1/Ro(12),y3e=(RR/2+1)*3,_3e={draw(t,e){const n=Ro(e/y3e),r=n/2,i=n*RR,a=r,s=n*RR+n,o=-a,l=s;t.moveTo(r,i),t.lineTo(a,s),t.lineTo(o,l),t.lineTo(Cs*r-Ns*i,Ns*r+Cs*i),t.lineTo(Cs*a-Ns*s,Ns*a+Cs*s),t.lineTo(Cs*o-Ns*l,Ns*o+Cs*l),t.lineTo(Cs*r+Ns*i,Cs*i-Ns*r),t.lineTo(Cs*a+Ns*s,Cs*s-Ns*a),t.lineTo(Cs*o+Ns*l,Cs*l-Ns*o),t.closePath()}};function S3e(t,e){let n=null,r=_D(i);t=typeof t=="function"?t:Qn(t||wD),e=typeof e=="function"?e:Qn(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:Qn(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:Qn(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function iS(){}function aS(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 mK(t){this._context=t}mK.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:aS(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:aS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function w3e(t){return new mK(t)}function gK(t){this._context=t}gK.prototype={areaStart:iS,areaEnd:iS,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:aS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function M3e(t){return new gK(t)}function xK(t){this._context=t}xK.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:aS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function E3e(t){return new xK(t)}function vK(t){this._context=t}vK.prototype={areaStart:iS,areaEnd:iS,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 A3e(t){return new vK(t)}function Y6(t){return t<0?-1:1}function Z6(t,e,n){var r=t._x1-t._x0,i=e-t._x1,a=(t._y1-t._y0)/(r||i<0&&-0),s=(n-t._y1)/(i||r<0&&-0),o=(a*i+s*r)/(r+i);return(Y6(a)+Y6(s))*Math.min(Math.abs(a),Math.abs(s),.5*Math.abs(o))||0}function Q6(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function $2(t,e,n){var r=t._x0,i=t._y0,a=t._x1,s=t._y1,o=(a-r)/3;t._context.bezierCurveTo(r+o,i+o*e,a-o,s-o*n,a,s)}function sS(t){this._context=t}sS.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:$2(this,this._t0,Q6(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,$2(this,Q6(this,n=Z6(this,t,e)),n);break;default:$2(this,this._t0,n=Z6(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function bK(t){this._context=new yK(t)}(bK.prototype=Object.create(sS.prototype)).point=function(t,e){sS.prototype.point.call(this,e,t)};function yK(t){this._context=t}yK.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 T3e(t){return new sS(t)}function C3e(t){return new bK(t)}function _K(t){this._context=t}_K.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=J6(t),i=J6(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 J6(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 N3e(t){return new _K(t)}function jw(t,e){this._context=t,this._t=e}jw.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 R3e(t){return new jw(t,.5)}function P3e(t){return new jw(t,0)}function k3e(t){return new jw(t,1)}function dm(t,e){if((s=t.length)>1)for(var n=1,r,i,a=t[e[0]],s,o=a.length;n<s;++n)for(i=a,a=t[e[n]],r=0;r<o;++r)a[r][1]+=a[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function PR(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function D3e(t,e){return t[e]}function O3e(t){const e=[];return e.key=t,e}function L3e(){var t=Qn([]),e=PR,n=dm,r=D3e;function i(a){var s=Array.from(t.apply(this,arguments),O3e),o,l=s.length,c=-1,u;for(const h of a)for(o=0,++c;o<l;++o)(s[o][c]=[0,+r(h,s[o].key,c,a)]).data=h;for(o=0,u=SD(e(s));o<l;++o)s[u[o]].index=o;return n(s,u),s}return i.keys=function(a){return arguments.length?(t=typeof a=="function"?a:Qn(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:Qn(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?PR:typeof a=="function"?a:Qn(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??dm,i):n},i}function I3e(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}dm(t,e)}}function j3e(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,a=r.length;n<a;++n){for(var s=0,o=0;s<i;++s)o+=t[s][n][1]||0;r[n][1]+=r[n][0]=-o/2}dm(t,e)}}function U3e(t,e){if(!(!((s=t.length)>0)||!((a=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,a,s;r<a;++r){for(var o=0,l=0,c=0;o<s;++o){for(var u=t[e[o]],h=u[r][1]||0,g=u[r-1][1]||0,m=(h-g)/2,b=0;b<o;++b){var y=t[e[b]],v=y[r][1]||0,x=y[r-1][1]||0;m+=v-x}l+=h,c+=m*h}i[r-1][1]+=i[r-1][0]=n,l&&(n-=c/l)}i[r-1][1]+=i[r-1][0]=n,dm(t,e)}}var V2={},G2={},e8;function F3e(){return e8||(e8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(G2)),G2}var W2={},t8;function SK(){return t8||(t8=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})(W2)),W2}var q2={},n8;function MD(){return n8||(n8=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})(q2)),q2}var X2={},K2={},r8;function z3e(){return r8||(r8=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})(K2)),K2}var i8;function ED(){return i8||(i8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=z3e(),n=MD();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=e.toString(i);const a=[],s=i.length;if(s===0)return a;let o=0,l="",c="",u=!1;for(i.charCodeAt(0)===46&&(a.push(""),o++);o<s;){const h=i[o];c?h==="\\"&&o+1<s?(o++,l+=i[o]):h===c?c="":l+=h:u?h==='"'||h==="'"?c=h:h==="]"?(u=!1,a.push(l),l=""):l+=h:h==="["?(u=!0,l&&(a.push(l),l="")):h==="."?l&&(a.push(l),l=""):l+=h,o++}return l&&a.push(l),a}t.toPath=r})(X2)),X2}var a8;function AD(){return a8||(a8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=F3e(),n=SK(),r=MD(),i=ED();function a(o,l,c){if(o==null)return c;switch(typeof l){case"string":{if(e.isUnsafeProperty(l))return c;const u=o[l];return u===void 0?n.isDeepKey(l)?a(o,i.toPath(l),c):c:u}case"number":case"symbol":{typeof l=="number"&&(l=r.toKey(l));const u=o[l];return u===void 0?c:u}default:{if(Array.isArray(l))return s(o,l,c);if(Object.is(l?.valueOf(),-0)?l="-0":l=String(l),e.isUnsafeProperty(l))return c;const u=o[l];return u===void 0?c:u}}}function s(o,l,c){if(l.length===0)return c;let u=o;for(let h=0;h<l.length;h++){if(u==null||e.isUnsafeProperty(l[h]))return c;u=u[l[h]]}return u===void 0?c:u}t.get=a})(V2)),V2}var Y2,s8;function B3e(){return s8||(s8=1,Y2=AD().get),Y2}var H3e=B3e();const zf=Zs(H3e);var Ai=t=>t===0?0:t>0?1:-1,Xs=t=>typeof t=="number"&&t!=+t,yc=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Et=t=>(typeof t=="number"||t instanceof Number)&&!Xs(t),ll=t=>Et(t)||typeof t=="string",$3e=0,y0=t=>{var e=++$3e;return"".concat(t||"").concat(e)},aa=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(!Et(e)&&typeof e!="string")return r;var a;if(yc(e)){if(n==null)return r;var s=e.indexOf("%");a=n*parseFloat(e.slice(0,s))/100}else a=+e;return Xs(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},wK=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 sr(t,e,n){return Et(t)&&Et(e)?t+n*(e-t):e}function MK(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):zf(r,e))===n)}var xr=t=>t===null||typeof t>"u",Q0=t=>xr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function V3e(t){return t!=null}function J0(){}var G3e=["type","size","sizeType"];function kR(){return kR=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},kR.apply(null,arguments)}function o8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function l8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?o8(Object(n),!0).forEach(function(r){W3e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function W3e(t,e,n){return(e=q3e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function q3e(t){var e=X3e(t,"string");return typeof e=="symbol"?e:e+""}function X3e(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 K3e(t,e){if(t==null)return{};var n,r,i=Y3e(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 Y3e(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 EK={symbolCircle:wD,symbolCross:d3e,symbolDiamond:h3e,symbolSquare:p3e,symbolStar:v3e,symbolTriangle:b3e,symbolWye:_3e},Z3e=Math.PI/180,Q3e=t=>{var e="symbol".concat(Q0(t));return EK[e]||wD},J3e=(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*Z3e;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}},eRe=(t,e)=>{EK["symbol".concat(Q0(t))]=e},TD=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=K3e(t,G3e),a=l8(l8({},i),{},{type:e,size:n,sizeType:r}),s="circle";typeof e=="string"&&(s=e);var o=()=>{var g=Q3e(s),m=S3e().type(g).size(J3e(n,r,s)),b=m();if(b!==null)return b},{className:l,cx:c,cy:u}=a,h=Sa(a);return Et(c)&&Et(u)&&Et(n)?E.createElement("path",kR({},h,{className:An("recharts-symbols",l),transform:"translate(".concat(c,", ").concat(u,")"),d:o()})):null};TD.registerSymbol=eRe;var AK=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,CD=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(E.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{bD(i)&&(r[i]=(a=>n[i](n,a)))}),r},tRe=(t,e,n)=>r=>(t(e,n,r),null),ev=(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];bD(i)&&typeof a=="function"&&(r||(r={}),r[i]=tRe(a,e,n))}),r};function c8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function nRe(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){rRe(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 rRe(t,e,n){return(e=iRe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function iRe(t){var e=aRe(t,"string");return typeof e=="symbol"?e:e+""}function aRe(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 Zr(t,e){var n=nRe({},t),r=e,i=Object.keys(e),a=i.reduce((s,o)=>(s[o]===void 0&&r[o]!==void 0&&(s[o]=r[o]),s),n);return a}function oS(){return oS=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},oS.apply(null,arguments)}function u8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function sRe(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){oRe(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 oRe(t,e,n){return(e=lRe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lRe(t){var e=cRe(t,"string");return typeof e=="symbol"?e:e+""}function cRe(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,uRe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function dRe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=ks/2,a=ks/6,s=ks/3,o=e.inactive?r:e.color,l=n??e.type;if(l==="none")return null;if(l==="plainline"){var c;return E.createElement("line",{strokeWidth:4,fill:"none",stroke:o,strokeDasharray:(c=e.payload)===null||c===void 0?void 0:c.strokeDasharray,x1:0,y1:i,x2:ks,y2:i,className:"recharts-legend-icon"})}if(l==="line")return E.createElement("path",{strokeWidth:4,fill:"none",stroke:o,d:"M0,".concat(i,"h").concat(s,`
  8192. A`).concat(a,",").concat(a,",0,1,1,").concat(2*s,",").concat(i,`
  8193. H`).concat(ks,"M").concat(2*s,",").concat(i,`
  8194. A`).concat(a,",").concat(a,",0,1,1,").concat(s,",").concat(i),className:"recharts-legend-icon"});if(l==="rect")return E.createElement("path",{stroke:"none",fill:o,d:"M0,".concat(ks/8,"h").concat(ks,"v").concat(ks*3/4,"h").concat(-ks,"z"),className:"recharts-legend-icon"});if(E.isValidElement(e.legendIcon)){var u=sRe({},e);return delete u.legendIcon,E.cloneElement(e.legendIcon,u)}return E.createElement(TD,{fill:o,cx:i,cy:i,size:ks,sizeType:"diameter",type:l})}function fRe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:s}=t,o={x:0,y:0,width:ks,height:ks},l={display:r==="horizontal"?"inline-block":"block",marginRight:10},c={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((u,h)=>{var g=u.formatter||i,m=An({"recharts-legend-item":!0,["legend-item-".concat(h)]:!0,inactive:u.inactive});if(u.type==="none")return null;var b=u.inactive?a:u.color,y=g?g(u.value,u,h):u.value;return E.createElement("li",oS({className:m,style:l,key:"legend-item-".concat(h)},ev(t,u,h)),E.createElement(yD,{width:n,height:n,viewBox:o,style:c,"aria-label":"".concat(y," legend icon")},E.createElement(dRe,{data:u,iconType:s,inactiveColor:a})),E.createElement("span",{className:"recharts-legend-item-text",style:{color:b}},y))})}var hRe=t=>{var e=Zr(t,uRe),{payload:n,layout:r,align:i}=e;if(!n||!n.length)return null;var a={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return E.createElement("ul",{className:"recharts-default-legend",style:a},E.createElement(fRe,oS({},e,{payload:n})))},Z2={},Q2={},d8;function pRe(){return d8||(d8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){const i=new Map;for(let a=0;a<n.length;a++){const s=n[a],o=r(s);i.has(o)||i.set(o,s)}return Array.from(i.values())}t.uniqBy=e})(Q2)),Q2}var J2={},f8;function TK(){return f8||(f8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(J2)),J2}var eC={},tC={},nC={},h8;function mRe(){return h8||(h8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(nC)),nC}var p8;function ND(){return p8||(p8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mRe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(tC)),tC}var rC={},m8;function gRe(){return m8||(m8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(rC)),rC}var g8;function xRe(){return g8||(g8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ND(),n=gRe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(eC)),eC}var iC={},aC={},x8;function vRe(){return x8||(x8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=AD();function n(r){return function(i){return e.get(i,r)}}t.property=n})(aC)),aC}var sC={},oC={},lC={},cC={},v8;function CK(){return v8||(v8=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})(cC)),cC}var uC={},b8;function NK(){return b8||(b8=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})(uC)),uC}var dC={},y8;function RK(){return y8||(y8=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})(dC)),dC}var _8;function bRe(){return _8||(_8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=CK(),n=NK(),r=RK();function i(u,h,g){return typeof g!="function"?i(u,h,()=>{}):a(u,h,function m(b,y,v,x,M,w){const C=g(b,y,v,x,M,w);return C!==void 0?!!C:a(b,y,m,w)},new Map)}function a(u,h,g,m){if(h===u)return!0;switch(typeof h){case"object":return s(u,h,g,m);case"function":return Object.keys(h).length>0?a(u,{...h},g,m):r.eq(u,h);default:return e.isObject(u)?typeof h=="string"?h==="":!0:r.eq(u,h)}}function s(u,h,g,m){if(h==null)return!0;if(Array.isArray(h))return l(u,h,g,m);if(h instanceof Map)return o(u,h,g,m);if(h instanceof Set)return c(u,h,g,m);const b=Object.keys(h);if(u==null)return b.length===0;if(b.length===0)return!0;if(m?.has(h))return m.get(h)===u;m?.set(h,u);try{for(let y=0;y<b.length;y++){const v=b[y];if(!n.isPrimitive(u)&&!(v in u)||h[v]===void 0&&u[v]!==void 0||h[v]===null&&u[v]!==null||!g(u[v],h[v],v,u,h,m))return!1}return!0}finally{m?.delete(h)}}function o(u,h,g,m){if(h.size===0)return!0;if(!(u instanceof Map))return!1;for(const[b,y]of h.entries()){const v=u.get(b);if(g(v,y,b,u,h,m)===!1)return!1}return!0}function l(u,h,g,m){if(h.length===0)return!0;if(!Array.isArray(u))return!1;const b=new Set;for(let y=0;y<h.length;y++){const v=h[y];let x=!1;for(let M=0;M<u.length;M++){if(b.has(M))continue;const w=u[M];let C=!1;if(g(w,v,y,u,h,m)&&(C=!0),C){b.add(M),x=!0;break}}if(!x)return!1}return!0}function c(u,h,g,m){return h.size===0?!0:u instanceof Set?l([...u],[...h],g,m):!1}t.isMatchWith=i,t.isSetMatch=c})(lC)),lC}var S8;function PK(){return S8||(S8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=bRe();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(oC)),oC}var fC={},hC={},pC={},w8;function yRe(){return w8||(w8=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})(pC)),pC}var mC={},M8;function kK(){return M8||(M8=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})(mC)),mC}var gC={},E8;function DK(){return E8||(E8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",a="[object Arguments]",s="[object Symbol]",o="[object Date]",l="[object Map]",c="[object Set]",u="[object Array]",h="[object Function]",g="[object ArrayBuffer]",m="[object Object]",b="[object Error]",y="[object DataView]",v="[object Uint8Array]",x="[object Uint8ClampedArray]",M="[object Uint16Array]",w="[object Uint32Array]",C="[object BigUint64Array]",T="[object Int8Array]",R="[object Int16Array]",A="[object Int32Array]",j="[object BigInt64Array]",N="[object Float32Array]",k="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=g,t.arrayTag=u,t.bigInt64ArrayTag=j,t.bigUint64ArrayTag=C,t.booleanTag=i,t.dataViewTag=y,t.dateTag=o,t.errorTag=b,t.float32ArrayTag=N,t.float64ArrayTag=k,t.functionTag=h,t.int16ArrayTag=R,t.int32ArrayTag=A,t.int8ArrayTag=T,t.mapTag=l,t.numberTag=r,t.objectTag=m,t.regexpTag=e,t.setTag=c,t.stringTag=n,t.symbolTag=s,t.uint16ArrayTag=M,t.uint32ArrayTag=w,t.uint8ArrayTag=v,t.uint8ClampedArrayTag=x})(gC)),gC}var xC={},A8;function _Re(){return A8||(A8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(xC)),xC}var T8;function OK(){return T8||(T8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=yRe(),n=kK(),r=DK(),i=NK(),a=_Re();function s(u,h){return o(u,void 0,u,new Map,h)}function o(u,h,g,m=new Map,b=void 0){const y=b?.(u,h,g,m);if(y!==void 0)return y;if(i.isPrimitive(u))return u;if(m.has(u))return m.get(u);if(Array.isArray(u)){const v=new Array(u.length);m.set(u,v);for(let x=0;x<u.length;x++)v[x]=o(u[x],x,g,m,b);return Object.hasOwn(u,"index")&&(v.index=u.index),Object.hasOwn(u,"input")&&(v.input=u.input),v}if(u instanceof Date)return new Date(u.getTime());if(u instanceof RegExp){const v=new RegExp(u.source,u.flags);return v.lastIndex=u.lastIndex,v}if(u instanceof Map){const v=new Map;m.set(u,v);for(const[x,M]of u)v.set(x,o(M,x,g,m,b));return v}if(u instanceof Set){const v=new Set;m.set(u,v);for(const x of u)v.add(o(x,void 0,g,m,b));return v}if(typeof Buffer<"u"&&Buffer.isBuffer(u))return u.subarray();if(a.isTypedArray(u)){const v=new(Object.getPrototypeOf(u)).constructor(u.length);m.set(u,v);for(let x=0;x<u.length;x++)v[x]=o(u[x],x,g,m,b);return v}if(u instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&u instanceof SharedArrayBuffer)return u.slice(0);if(u instanceof DataView){const v=new DataView(u.buffer.slice(0),u.byteOffset,u.byteLength);return m.set(u,v),l(v,u,g,m,b),v}if(typeof File<"u"&&u instanceof File){const v=new File([u],u.name,{type:u.type});return m.set(u,v),l(v,u,g,m,b),v}if(typeof Blob<"u"&&u instanceof Blob){const v=new Blob([u],{type:u.type});return m.set(u,v),l(v,u,g,m,b),v}if(u instanceof Error){const v=new u.constructor;return m.set(u,v),v.message=u.message,v.name=u.name,v.stack=u.stack,v.cause=u.cause,l(v,u,g,m,b),v}if(u instanceof Boolean){const v=new Boolean(u.valueOf());return m.set(u,v),l(v,u,g,m,b),v}if(u instanceof Number){const v=new Number(u.valueOf());return m.set(u,v),l(v,u,g,m,b),v}if(u instanceof String){const v=new String(u.valueOf());return m.set(u,v),l(v,u,g,m,b),v}if(typeof u=="object"&&c(u)){const v=Object.create(Object.getPrototypeOf(u));return m.set(u,v),l(v,u,g,m,b),v}return u}function l(u,h,g=u,m,b){const y=[...Object.keys(h),...e.getSymbols(h)];for(let v=0;v<y.length;v++){const x=y[v],M=Object.getOwnPropertyDescriptor(u,x);(M==null||M.writable)&&(u[x]=o(h[x],x,g,m,b))}}function c(u){switch(n.getTag(u)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=s,t.cloneDeepWithImpl=o,t.copyProperties=l})(hC)),hC}var C8;function SRe(){return C8||(C8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=OK();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(fC)),fC}var N8;function wRe(){return N8||(N8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=PK(),n=SRe();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(sC)),sC}var vC={},bC={},yC={},R8;function MRe(){return R8||(R8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=OK(),n=DK();function r(i,a){return e.cloneDeepWith(i,(s,o,l,c)=>{const u=a?.(s,o,l,c);if(u!==void 0)return u;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const h=new i.constructor(i?.valueOf());return e.copyProperties(h,i),h}case n.argumentsTag:{const h={};return e.copyProperties(h,i),h.length=i.length,h[Symbol.iterator]=i[Symbol.iterator],h}default:return}})}t.cloneDeepWith=r})(yC)),yC}var P8;function ERe(){return P8||(P8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=MRe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(bC)),bC}var _C={},SC={},k8;function LK(){return k8||(k8=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})(SC)),SC}var wC={},D8;function ARe(){return D8||(D8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=kK();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(wC)),wC}var O8;function TRe(){return O8||(O8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=SK(),n=LK(),r=ARe(),i=ED();function a(s,o){let l;if(Array.isArray(o)?l=o:typeof o=="string"&&e.isDeepKey(o)&&s?.[o]==null?l=i.toPath(o):l=[o],l.length===0)return!1;let c=s;for(let u=0;u<l.length;u++){const h=l[u];if((c==null||!Object.hasOwn(c,h))&&!((Array.isArray(c)||r.isArguments(c))&&n.isIndex(h)&&h<c.length))return!1;c=c[h]}return!0}t.has=a})(_C)),_C}var L8;function CRe(){return L8||(L8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=PK(),n=MD(),r=ERe(),i=AD(),a=TRe();function s(o,l){switch(typeof o){case"object":{Object.is(o?.valueOf(),-0)&&(o="-0");break}case"number":{o=n.toKey(o);break}}return l=r.cloneDeep(l),function(c){const u=i.get(c,o);return u===void 0?a.has(c,o):l===void 0?u===void 0:e.isMatch(u,l)}}t.matchesProperty=s})(vC)),vC}var I8;function NRe(){return I8||(I8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=TK(),n=vRe(),r=wRe(),i=CRe();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})(iC)),iC}var j8;function RRe(){return j8||(j8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=pRe(),n=TK(),r=xRe(),i=NRe();function a(s,o=n.identity){return r.isArrayLikeObject(s)?e.uniqBy(Array.from(s),i.iteratee(o)):[]}t.uniqBy=a})(Z2)),Z2}var MC,U8;function PRe(){return U8||(U8=1,MC=RRe().uniqBy),MC}var kRe=PRe();const F8=Zs(kRe);function IK(t,e,n){return e===!0?F8(t,n):typeof e=="function"?F8(t,e):t}var RD=E.createContext(null),DRe=t=>t,er=()=>{var t=E.useContext(RD);return t?t.store.dispatch:DRe},D_=()=>{},ORe=()=>D_,LRe=(t,e)=>t===e;function At(t){var e=E.useContext(RD);return Yq.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:ORe,e?e.store.getState:D_,e?e.store.getState:D_,e?t:D_,LRe)}function IRe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function jRe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function URe(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 z8=t=>Array.isArray(t)?t:[t];function FRe(t){const e=Array.isArray(t[0])?t[0]:t;return URe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function zRe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var BRe=class{constructor(t){this.value=t}deref(){return this.value}},HRe=typeof WeakRef<"u"?WeakRef:BRe,$Re=0,B8=1;function Zy(){return{s:$Re,v:void 0,o:null,p:null}}function jK(t,e={}){let n=Zy();const{resultEqualityCheck:r}=e;let i,a=0;function s(){let o=n;const{length:l}=arguments;for(let h=0,g=l;h<g;h++){const m=arguments[h];if(typeof m=="function"||typeof m=="object"&&m!==null){let b=o.o;b===null&&(o.o=b=new WeakMap);const y=b.get(m);y===void 0?(o=Zy(),b.set(m,o)):o=y}else{let b=o.p;b===null&&(o.p=b=new Map);const y=b.get(m);y===void 0?(o=Zy(),b.set(m,o)):o=y}}const c=o;let u;if(o.s===B8)u=o.v;else if(u=t.apply(null,arguments),a++,r){const h=i?.deref?.()??i;h!=null&&r(h,u)&&(u=h,a!==0&&a--),i=typeof u=="object"&&u!==null||typeof u=="function"?new HRe(u):u}return c.s=B8,c.v=u,u}return s.clearCache=()=>{n=Zy(),s.resetResultsCount()},s.resultsCount=()=>a,s.resetResultsCount=()=>{a=0},s}function VRe(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let a=0,s=0,o,l={},c=i.pop();typeof c=="object"&&(l=c,c=i.pop()),IRe(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);const u={...n,...l},{memoize:h,memoizeOptions:g=[],argsMemoize:m=jK,argsMemoizeOptions:b=[]}=u,y=z8(g),v=z8(b),x=FRe(i),M=h(function(){return a++,c.apply(null,arguments)},...y),w=m(function(){s++;const T=zRe(x,arguments);return o=M.apply(null,T),o},...v);return Object.assign(w,{resultFunc:c,memoizedResultFunc:M,dependencies:x,dependencyRecomputations:()=>s,resetDependencyRecomputations:()=>{s=0},lastResult:()=>o,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:h,argsMemoize:m})};return Object.assign(r,{withTypes:()=>r}),r}var Ve=VRe(jK),GRe=Object.assign((t,e=Ve)=>{jRe(t,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof t}`);const n=Object.keys(t),r=n.map(a=>t[a]);return e(r,(...a)=>a.reduce((s,o,l)=>(s[n[l]]=o,s),{}))},{withTypes:()=>GRe}),EC={},AC={},TC={},H8;function WRe(){return H8||(H8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(r){return typeof r=="symbol"?1:r===null?2:r===void 0?3:r!==r?4:0}const n=(r,i,a)=>{if(r!==i){const s=e(r),o=e(i);if(s===o&&s===0){if(r<i)return a==="desc"?1:-1;if(r>i)return a==="desc"?-1:1}return a==="desc"?o-s:s-o}return 0};t.compareValues=n})(TC)),TC}var CC={},NC={},$8;function UK(){return $8||($8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(NC)),NC}var V8;function qRe(){return V8||(V8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=UK(),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})(CC)),CC}var G8;function XRe(){return G8||(G8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=WRe(),n=qRe(),r=ED();function i(a,s,o,l){if(a==null)return[];o=l?void 0:o,Array.isArray(a)||(a=Object.values(a)),Array.isArray(s)||(s=s==null?[null]:[s]),s.length===0&&(s=[null]),Array.isArray(o)||(o=o==null?[]:[o]),o=o.map(m=>String(m));const c=(m,b)=>{let y=m;for(let v=0;v<b.length&&y!=null;++v)y=y[b[v]];return y},u=(m,b)=>b==null||m==null?b:typeof m=="object"&&"key"in m?Object.hasOwn(b,m.key)?b[m.key]:c(b,m.path):typeof m=="function"?m(b):Array.isArray(m)?c(b,m):typeof b=="object"?b[m]:b,h=s.map(m=>(Array.isArray(m)&&m.length===1&&(m=m[0]),m==null||typeof m=="function"||Array.isArray(m)||n.isKey(m)?m:{key:m,path:r.toPath(m)}));return a.map(m=>({original:m,criteria:h.map(b=>u(b,m))})).slice().sort((m,b)=>{for(let y=0;y<h.length;y++){const v=e.compareValues(m.criteria[y],b.criteria[y],o[y]);if(v!==0)return v}return 0}).map(m=>m.original)}t.orderBy=i})(AC)),AC}var RC={},W8;function KRe(){return W8||(W8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],a=Math.floor(r),s=(o,l)=>{for(let c=0;c<o.length;c++){const u=o[c];Array.isArray(u)&&l<a?s(u,l+1):i.push(u)}};return s(n,0),i}t.flatten=e})(RC)),RC}var PC={},q8;function FK(){return q8||(q8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=LK(),n=ND(),r=CK(),i=RK();function a(s,o,l){return r.isObject(l)&&(typeof o=="number"&&n.isArrayLike(l)&&e.isIndex(o)&&o<l.length||typeof o=="string"&&o in l)?i.eq(l[o],s):!1}t.isIterateeCall=a})(PC)),PC}var X8;function YRe(){return X8||(X8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=XRe(),n=KRe(),r=FK();function i(a,...s){const o=s.length;return o>1&&r.isIterateeCall(a,s[0],s[1])?s=[]:o>2&&r.isIterateeCall(s[0],s[1],s[2])&&(s=[s[0]]),e.orderBy(a,n.flatten(s),["asc"])}t.sortBy=i})(EC)),EC}var kC,K8;function ZRe(){return K8||(K8=1,kC=YRe().sortBy),kC}var QRe=ZRe();const Uw=Zs(QRe);var zK=t=>t.legend.settings,JRe=t=>t.legend.size,ePe=t=>t.legend.payload,tPe=Ve([ePe,zK],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?Uw(r,n):r});function nPe(){return At(tPe)}var Qy=1;function BK(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=E.useState({height:0,left:0,top:0,width:0}),r=E.useCallback(i=>{if(i!=null){var a=i.getBoundingClientRect(),s={height:a.height,left:a.left,top:a.top,width:a.width};(Math.abs(s.height-e.height)>Qy||Math.abs(s.left-e.left)>Qy||Math.abs(s.top-e.top)>Qy||Math.abs(s.width-e.width)>Qy)&&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 zi(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 rPe=typeof Symbol=="function"&&Symbol.observable||"@@observable",Y8=rPe,DC=()=>Math.random().toString(36).substring(7).split("").join("."),iPe={INIT:`@@redux/INIT${DC()}`,REPLACE:`@@redux/REPLACE${DC()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${DC()}`},lS=iPe;function PD(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 HK(t,e,n){if(typeof t!="function")throw new Error(zi(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(zi(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(zi(1));return n(HK)(t,e)}let r=t,i=e,a=new Map,s=a,o=0,l=!1;function c(){s===a&&(s=new Map,a.forEach((v,x)=>{s.set(x,v)}))}function u(){if(l)throw new Error(zi(3));return i}function h(v){if(typeof v!="function")throw new Error(zi(4));if(l)throw new Error(zi(5));let x=!0;c();const M=o++;return s.set(M,v),function(){if(x){if(l)throw new Error(zi(6));x=!1,c(),s.delete(M),a=null}}}function g(v){if(!PD(v))throw new Error(zi(7));if(typeof v.type>"u")throw new Error(zi(8));if(typeof v.type!="string")throw new Error(zi(17));if(l)throw new Error(zi(9));try{l=!0,i=r(i,v)}finally{l=!1}return(a=s).forEach(M=>{M()}),v}function m(v){if(typeof v!="function")throw new Error(zi(10));r=v,g({type:lS.REPLACE})}function b(){const v=h;return{subscribe(x){if(typeof x!="object"||x===null)throw new Error(zi(11));function M(){const C=x;C.next&&C.next(u())}return M(),{unsubscribe:v(M)}},[Y8](){return this}}}return g({type:lS.INIT}),{dispatch:g,subscribe:h,getState:u,replaceReducer:m,[Y8]:b}}function aPe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:lS.INIT})>"u")throw new Error(zi(12));if(typeof n(void 0,{type:lS.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(zi(13))})}function $K(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{aPe(n)}catch(a){i=a}return function(s={},o){if(i)throw i;let l=!1;const c={};for(let u=0;u<r.length;u++){const h=r[u],g=n[h],m=s[h],b=g(m,o);if(typeof b>"u")throw o&&o.type,new Error(zi(14));c[h]=b,l=l||b!==m}return l=l||r.length!==Object.keys(s).length,l?c:s}}function cS(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function sPe(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(zi(15))};const s={getState:i.getState,dispatch:(l,...c)=>a(l,...c)},o=t.map(l=>l(s));return a=cS(...o)(i.dispatch),{...i,dispatch:a}}}function VK(t){return PD(t)&&"type"in t&&typeof t.type=="string"}var GK=Symbol.for("immer-nothing"),Z8=Symbol.for("immer-draftable"),wa=Symbol.for("immer-state");function po(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var us=Object,fm=us.getPrototypeOf,uS="constructor",Fw="prototype",DR="configurable",dS="enumerable",O_="writable",_0="value",_c=t=>!!t&&!!t[wa];function To(t){return t?WK(t)||zw(t)||!!t[Z8]||!!t[uS]?.[Z8]||Bw(t)||Hw(t):!1}var oPe=us[Fw][uS].toString(),Q8=new WeakMap;function WK(t){if(!t||!kD(t))return!1;const e=fm(t);if(e===null||e===us[Fw])return!0;const n=us.hasOwnProperty.call(e,uS)&&e[uS];if(n===Object)return!0;if(!Sp(n))return!1;let r=Q8.get(n);return r===void 0&&(r=Function.toString.call(n),Q8.set(n,r)),r===oPe}function tv(t,e,n=!0){nv(t)===0?(n?Reflect.ownKeys(t):us.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function nv(t){const e=t[wa];return e?e.type_:zw(t)?1:Bw(t)?2:Hw(t)?3:0}var J8=(t,e,n=nv(t))=>n===2?t.has(e):us[Fw].hasOwnProperty.call(t,e),OR=(t,e,n=nv(t))=>n===2?t.get(e):t[e],fS=(t,e,n,r=nv(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function lPe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var zw=Array.isArray,Bw=t=>t instanceof Map,Hw=t=>t instanceof Set,kD=t=>typeof t=="object",Sp=t=>typeof t=="function",OC=t=>typeof t=="boolean",Yl=t=>t.copy_||t.base_,DD=t=>t.modified_?t.copy_:t.base_;function LR(t,e){if(Bw(t))return new Map(t);if(Hw(t))return new Set(t);if(zw(t))return Array[Fw].slice.call(t);const n=WK(t);if(e===!0||e==="class_only"&&!n){const r=us.getOwnPropertyDescriptors(t);delete r[wa];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],o=r[s];o[O_]===!1&&(o[O_]=!0,o[DR]=!0),(o.get||o.set)&&(r[s]={[DR]:!0,[O_]:!0,[dS]:o[dS],[_0]:t[s]})}return us.create(fm(t),r)}else{const r=fm(t);if(r!==null&&n)return{...t};const i=us.create(r);return us.assign(i,t)}}function OD(t,e=!1){return $w(t)||_c(t)||!To(t)||(nv(t)>1&&us.defineProperties(t,{set:Jy,add:Jy,clear:Jy,delete:Jy}),us.freeze(t),e&&tv(t,(n,r)=>{OD(r,!0)},!1)),t}function cPe(){po(2)}var Jy={[_0]:cPe};function $w(t){return t===null||!kD(t)?!0:us.isFrozen(t)}var hS="MapSet",IR="Patches",qK={};function hm(t){const e=qK[t];return e||po(0,t),e}var uPe=t=>!!qK[t],S0,XK=()=>S0,dPe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:uPe(hS)?hm(hS):void 0});function eH(t,e){e&&(t.patchPlugin_=hm(IR),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function jR(t){UR(t),t.drafts_.forEach(fPe),t.drafts_=null}function UR(t){t===S0&&(S0=t.parent_)}var tH=t=>S0=dPe(S0,t);function fPe(t){const e=t[wa];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function nH(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[wa].modified_&&(jR(e),po(4)),To(t)&&(t=rH(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[wa].base_,t,e)}else t=rH(e,n);return hPe(e,t,!0),jR(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==GK?t:void 0}function rH(t,e){if($w(e))return e;const n=e[wa];if(!n)return LD(e,t.handledSet_,t);if(!Vw(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);ZK(n,t)}return n.copy_}function hPe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&OD(e,n)}function KK(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var Vw=(t,e)=>t.scope_===e,pPe=[];function YK(t,e,n,r){const i=Yl(t),a=t.type_;if(r!==void 0&&OR(i,r,a)===e){fS(i,r,n,a);return}if(!t.draftLocations_){const o=t.draftLocations_=new Map;tv(i,(l,c)=>{if(_c(c)){const u=o.get(c)||[];u.push(l),o.set(c,u)}})}const s=t.draftLocations_.get(e)??pPe;for(const o of s)fS(i,o,n,a)}function mPe(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!Vw(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const s=DD(a);YK(t,a.draft_??a,s,n),ZK(a,i)})}function ZK(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)}KK(t)}}function gPe(t,e,n){const{scope_:r}=t;if(_c(n)){const i=n[wa];Vw(i,r)&&i.callbacks_.push(function(){L_(t);const s=DD(i);YK(t,n,s,e)})}else To(n)&&t.callbacks_.push(function(){const a=Yl(t);OR(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&LD(OR(t.copy_,e,t.type_),r.handledSet_,r)})}function LD(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||_c(t)||e.has(t)||!To(t)||$w(t)||(e.add(t),tv(t,(r,i)=>{if(_c(i)){const a=i[wa];if(Vw(a,n)){const s=DD(a);fS(t,r,s,t.type_),KK(a)}}else To(i)&&LD(i,e,n)})),t}function xPe(t,e){const n=zw(t),r={type_:n?1:0,scope_:e?e.scope_:XK(),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=ID;n&&(i=[r],a=w0);const{revoke:s,proxy:o}=Proxy.revocable(i,a);return r.draft_=o,r.revoke_=s,[o,r]}var ID={get(t,e){if(e===wa)return t;const n=Yl(t);if(!J8(n,e,t.type_))return vPe(t,n,e);const r=n[e];if(t.finalized_||!To(r))return r;if(r===LC(t.base_,e)){L_(t);const i=t.type_===1?+e:e,a=zR(t.scope_,r,t,i);return t.copy_[i]=a}return r},has(t,e){return e in Yl(t)},ownKeys(t){return Reflect.ownKeys(Yl(t))},set(t,e,n){const r=QK(Yl(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=LC(Yl(t),e),a=i?.[wa];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(lPe(n,i)&&(n!==void 0||J8(t.base_,e,t.type_)))return!0;L_(t),FR(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),gPe(t,e,n)),!0},deleteProperty(t,e){return L_(t),LC(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),FR(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Yl(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[O_]:!0,[DR]:t.type_!==1||e!=="length",[dS]:r[dS],[_0]:n[e]}},defineProperty(){po(11)},getPrototypeOf(t){return fm(t.base_)},setPrototypeOf(){po(12)}},w0={};tv(ID,(t,e)=>{w0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});w0.deleteProperty=function(t,e){return w0.set.call(this,t,e,void 0)};w0.set=function(t,e,n){return ID.set.call(this,t[0],e,n,t[0])};function LC(t,e){const n=t[wa];return(n?Yl(n):t)[e]}function vPe(t,e,n){const r=QK(e,n);return r?_0 in r?r[_0]:r.get?.call(t.draft_):void 0}function QK(t,e){if(!(e in t))return;let n=fm(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=fm(n)}}function FR(t){t.modified_||(t.modified_=!0,t.parent_&&FR(t.parent_))}function L_(t){t.copy_||(t.assigned_=new Map,t.copy_=LR(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var bPe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(Sp(n)&&!Sp(r)){const s=r;r=n;const o=this;return function(c=s,...u){return o.produce(c,h=>r.call(this,h,...u))}}Sp(r)||po(6),i!==void 0&&!Sp(i)&&po(7);let a;if(To(n)){const s=tH(this),o=zR(s,n,void 0);let l=!0;try{a=r(o),l=!1}finally{l?jR(s):UR(s)}return eH(s,i),nH(a,s)}else if(!n||!kD(n)){if(a=r(n),a===void 0&&(a=n),a===GK&&(a=void 0),this.autoFreeze_&&OD(a,!0),i){const s=[],o=[];hm(IR).generateReplacementPatches_(n,a,{patches_:s,inversePatches_:o}),i(s,o)}return a}else po(1,n)},this.produceWithPatches=(n,r)=>{if(Sp(n))return(o,...l)=>this.produceWithPatches(o,c=>n(c,...l));let i,a;return[this.produce(n,r,(o,l)=>{i=o,a=l}),i,a]},OC(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),OC(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),OC(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){To(e)||po(8),_c(e)&&(e=_o(e));const n=tH(this),r=zR(n,e,void 0);return r[wa].isManual_=!0,UR(n),r}finishDraft(e,n){const r=e&&e[wa];(!r||!r.isManual_)&&po(9);const{scope_:i}=r;return eH(i,n),nH(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=hm(IR).applyPatches_;return _c(e)?i(e,n):this.produce(e,a=>i(a,n))}};function zR(t,e,n,r){const[i,a]=Bw(e)?hm(hS).proxyMap_(e,n):Hw(e)?hm(hS).proxySet_(e,n):xPe(e,n);return(n?.scope_??XK()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?mPe(n,a,r):a.callbacks_.push(function(l){l.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:c}=l;a.modified_&&c&&c.generatePatches_(a,[],l)}),i}function _o(t){return _c(t)||po(10,t),JK(t)}function JK(t){if(!To(t)||$w(t))return t;const e=t[wa];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=LR(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=LR(t,!0);return tv(n,(i,a)=>{fS(n,i,JK(a))},r),e&&(e.finalized_=!1),n}var yPe=new bPe,eY=yPe.produce;function tY(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var _Pe=tY(),SPe=tY,wPe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?cS:cS.apply(null,arguments)};function Ks(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(ps(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=>VK(r)&&r.type===t,n}var nY=class gx extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,gx.prototype)}static get[Symbol.species](){return gx}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new gx(...e[0].concat(this)):new gx(...e.concat(this))}};function iH(t){return To(t)?eY(t,()=>{}):t}function e_(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function MPe(t){return typeof t=="boolean"}var EPe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let s=new nY;return n&&(MPe(n)?s.push(_Pe):s.push(SPe(n.extraArgument))),s},rY="RTK_autoBatch",cr=()=>t=>({payload:t,meta:{[rY]:!0}}),aH=t=>e=>{setTimeout(e,t)},iY=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,a=!1,s=!1;const o=new Set,l=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:aH(10):t.type==="callback"?t.queueNotification:aH(t.timeout),c=()=>{s=!1,a&&(a=!1,o.forEach(u=>u()))};return Object.assign({},r,{subscribe(u){const h=()=>i&&u(),g=r.subscribe(h);return o.add(u),()=>{g(),o.delete(u)}},dispatch(u){try{return i=!u?.meta?.[rY],a=!i,a&&(s||(s=!0,l(c))),r.dispatch(u)}finally{i=!0}}})},APe=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new nY(t);return r&&i.push(iY(typeof r=="object"?r:void 0)),i};function TPe(t){const e=EPe(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:a=void 0,enhancers:s=void 0}=t||{};let o;if(typeof n=="function")o=n;else if(PD(n))o=$K(n);else throw new Error(ps(1));let l;typeof r=="function"?l=r(e):l=e();let c=cS;i&&(c=wPe({trace:!1,...typeof i=="object"&&i}));const u=sPe(...l),h=APe(u);let g=typeof s=="function"?s(h):h();const m=c(...g);return HK(o,a,m)}function aY(t){const e={},n=[];let r;const i={addCase(a,s){const o=typeof a=="string"?a:a.type;if(!o)throw new Error(ps(28));if(o in e)throw new Error(ps(29));return e[o]=s,i},addAsyncThunk(a,s){return s.pending&&(e[a.pending.type]=s.pending),s.rejected&&(e[a.rejected.type]=s.rejected),s.fulfilled&&(e[a.fulfilled.type]=s.fulfilled),s.settled&&n.push({matcher:a.settled,reducer:s.settled}),i},addMatcher(a,s){return n.push({matcher:a,reducer:s}),i},addDefaultCase(a){return r=a,i}};return t(i),[e,n,r]}function CPe(t){return typeof t=="function"}function NPe(t,e){let[n,r,i]=aY(e),a;if(CPe(t))a=()=>iH(t());else{const o=iH(t);a=()=>o}function s(o=a(),l){let c=[n[l.type],...r.filter(({matcher:u})=>u(l)).map(({reducer:u})=>u)];return c.filter(u=>!!u).length===0&&(c=[i]),c.reduce((u,h)=>{if(h)if(_c(u)){const m=h(u,l);return m===void 0?u:m}else{if(To(u))return eY(u,g=>h(g,l));{const g=h(u,l);if(g===void 0){if(u===null)return u;throw Error("A case reducer on a non-draftable value must not return undefined")}return g}}return u},o)}return s.getInitialState=a,s}var RPe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",PPe=(t=21)=>{let e="",n=t;for(;n--;)e+=RPe[Math.random()*64|0];return e},kPe=Symbol.for("rtk-slice-createasyncthunk");function DPe(t,e){return`${t}/${e}`}function OPe({creators:t}={}){const e=t?.asyncThunk?.[kPe];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(ps(11));const s=(typeof r.reducers=="function"?r.reducers(IPe()):r.reducers)||{},o=Object.keys(s),l={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},c={addCase(w,C){const T=typeof w=="string"?w:w.type;if(!T)throw new Error(ps(12));if(T in l.sliceCaseReducersByType)throw new Error(ps(13));return l.sliceCaseReducersByType[T]=C,c},addMatcher(w,C){return l.sliceMatchers.push({matcher:w,reducer:C}),c},exposeAction(w,C){return l.actionCreators[w]=C,c},exposeCaseReducer(w,C){return l.sliceCaseReducersByName[w]=C,c}};o.forEach(w=>{const C=s[w],T={reducerName:w,type:DPe(i,w),createNotation:typeof r.reducers=="function"};UPe(C)?zPe(T,C,c,e):jPe(T,C,c)});function u(){const[w={},C=[],T=void 0]=typeof r.extraReducers=="function"?aY(r.extraReducers):[r.extraReducers],R={...w,...l.sliceCaseReducersByType};return NPe(r.initialState,A=>{for(let j in R)A.addCase(j,R[j]);for(let j of l.sliceMatchers)A.addMatcher(j.matcher,j.reducer);for(let j of C)A.addMatcher(j.matcher,j.reducer);T&&A.addDefaultCase(T)})}const h=w=>w,g=new Map,m=new WeakMap;let b;function y(w,C){return b||(b=u()),b(w,C)}function v(){return b||(b=u()),b.getInitialState()}function x(w,C=!1){function T(A){let j=A[w];return typeof j>"u"&&C&&(j=e_(m,T,v)),j}function R(A=h){const j=e_(g,C,()=>new WeakMap);return e_(j,A,()=>{const N={};for(const[k,F]of Object.entries(r.selectors??{}))N[k]=LPe(F,A,()=>e_(m,A,v),C);return N})}return{reducerPath:w,getSelectors:R,get selectors(){return R(T)},selectSlice:T}}const M={name:i,reducer:y,actions:l.actionCreators,caseReducers:l.sliceCaseReducersByName,getInitialState:v,...x(a),injectInto(w,{reducerPath:C,...T}={}){const R=C??a;return w.inject({reducerPath:R,reducer:y},T),{...M,...x(R,!0)}}};return M}}function LPe(t,e,n,r){function i(a,...s){let o=e(a);return typeof o>"u"&&r&&(o=n()),t(o,...s)}return i.unwrapped=t,i}var Ga=OPe();function IPe(){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 jPe({type:t,reducerName:e,createNotation:n},r,i){let a,s;if("reducer"in r){if(n&&!FPe(r))throw new Error(ps(17));a=r.reducer,s=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,s?Ks(t,s):Ks(t))}function UPe(t){return t._reducerDefinitionType==="asyncThunk"}function FPe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function zPe({type:t,reducerName:e},n,r,i){if(!i)throw new Error(ps(18));const{payloadCreator:a,fulfilled:s,pending:o,rejected:l,settled:c,options:u}=n,h=i(t,a,u);r.exposeAction(e,h),s&&r.addCase(h.fulfilled,s),o&&r.addCase(h.pending,o),l&&r.addCase(h.rejected,l),c&&r.addMatcher(h.settled,c),r.exposeCaseReducer(e,{fulfilled:s||t_,pending:o||t_,rejected:l||t_,settled:c||t_})}function t_(){}var BPe="task",sY="listener",oY="completed",jD="cancelled",HPe=`task-${jD}`,$Pe=`task-${oY}`,BR=`${sY}-${jD}`,VPe=`${sY}-${oY}`,Gw=class{constructor(t){this.code=t,this.message=`${BPe} ${jD} (reason: ${t})`}name="TaskAbortError";message},UD=(t,e)=>{if(typeof t!="function")throw new TypeError(ps(32))},pS=()=>{},lY=(t,e=pS)=>(t.catch(e),t),cY=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),gf=(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))},xf=t=>{if(t.aborted){const{reason:e}=t;throw new Gw(e)}};function uY(t,e){let n=pS;return new Promise((r,i)=>{const a=()=>i(new Gw(t.reason));if(t.aborted){a();return}n=cY(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=pS})}var GPe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof Gw?"cancelled":"rejected",error:n}}finally{e?.()}},mS=t=>e=>lY(uY(t,e).then(n=>(xf(t),n))),dY=t=>{const e=mS(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:zp}=Object,sH={},Ww="listenerMiddleware",WPe=(t,e)=>{const n=r=>cY(t,()=>gf(r,t.reason));return(r,i)=>{UD(r);const a=new AbortController;n(a);const s=GPe(async()=>{xf(t),xf(a.signal);const o=await r({pause:mS(a.signal),delay:dY(a.signal),signal:a.signal});return xf(a.signal),o},()=>gf(a,$Pe));return i?.autoJoin&&e.push(s.catch(pS)),{result:mS(t)(s),cancel(){gf(a,HPe)}}}},qPe=(t,e)=>{const n=async(r,i)=>{xf(e);let a=()=>{};const o=[new Promise((l,c)=>{let u=t({predicate:r,effect:(h,g)=>{g.unsubscribe(),l([h,g.getState(),g.getOriginalState()])}});a=()=>{u(),c()}})];i!=null&&o.push(new Promise(l=>setTimeout(l,i,null)));try{const l=await uY(e,Promise.race(o));return xf(e),l}finally{a()}};return(r,i)=>lY(n(r,i))},fY=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=Ks(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(ps(21));return UD(a),{predicate:i,type:e,effect:a}},hY=zp(t=>{const{type:e,predicate:n,effect:r}=fY(t);return{id:PPe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(ps(22))}}},{withTypes:()=>hY}),oH=(t,e)=>{const{type:n,effect:r,predicate:i}=fY(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},HR=t=>{t.pending.forEach(e=>{gf(e,BR)})},XPe=(t,e)=>()=>{for(const n of e.keys())HR(n);t.clear()},lH=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},pY=zp(Ks(`${Ww}/add`),{withTypes:()=>pY}),KPe=Ks(`${Ww}/removeAll`),mY=zp(Ks(`${Ww}/remove`),{withTypes:()=>mY}),YPe=(...t)=>{console.error(`${Ww}/error`,...t)},rv=(t={})=>{const e=new Map,n=new Map,r=m=>{const b=n.get(m)??0;n.set(m,b+1)},i=m=>{const b=n.get(m)??1;b===1?n.delete(m):n.set(m,b-1)},{extra:a,onError:s=YPe}=t;UD(s);const o=m=>(m.unsubscribe=()=>e.delete(m.id),e.set(m.id,m),b=>{m.unsubscribe(),b?.cancelActive&&HR(m)}),l=m=>{const b=oH(e,m)??hY(m);return o(b)};zp(l,{withTypes:()=>l});const c=m=>{const b=oH(e,m);return b&&(b.unsubscribe(),m.cancelActive&&HR(b)),!!b};zp(c,{withTypes:()=>c});const u=async(m,b,y,v)=>{const x=new AbortController,M=qPe(l,x.signal),w=[];try{m.pending.add(x),r(m),await Promise.resolve(m.effect(b,zp({},y,{getOriginalState:v,condition:(C,T)=>M(C,T).then(Boolean),take:M,delay:dY(x.signal),pause:mS(x.signal),extra:a,signal:x.signal,fork:WPe(x.signal,w),unsubscribe:m.unsubscribe,subscribe:()=>{e.set(m.id,m)},cancelActiveListeners:()=>{m.pending.forEach((C,T,R)=>{C!==x&&(gf(C,BR),R.delete(C))})},cancel:()=>{gf(x,BR),m.pending.delete(x)},throwIfCancelled:()=>{xf(x.signal)}})))}catch(C){C instanceof Gw||lH(s,C,{raisedBy:"effect"})}finally{await Promise.all(w),gf(x,VPe),i(m),m.pending.delete(x)}},h=XPe(e,n);return{middleware:m=>b=>y=>{if(!VK(y))return b(y);if(pY.match(y))return l(y.payload);if(KPe.match(y)){h();return}if(mY.match(y))return c(y.payload);let v=m.getState();const x=()=>{if(v===sH)throw new Error(ps(23));return v};let M;try{if(M=b(y),e.size>0){const w=m.getState(),C=Array.from(e.values());for(const T of C){let R=!1;try{R=T.predicate(y,w,v)}catch(A){R=!1,lH(s,A,{raisedBy:"predicate"})}R&&u(T,y,m,x)}}}finally{v=sH}return M},startListening:l,stopListening:c,clearListeners:h}};function ps(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 ZPe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},gY=Ga({name:"chartLayout",initialState:ZPe,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:QPe,setLayout:JPe,setChartSize:eke,setScale:tke}=gY.actions,nke=gY.reducer;function xY(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function cH(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?cH(Object(n),!0).forEach(function(r){rke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):cH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rke(t,e,n){return(e=ike(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ike(t){var e=ake(t,"string");return typeof e=="symbol"?e:e+""}function ake(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 Yn(t,e,n){return xr(t)||xr(e)?n:ll(e)?zf(t,e,n):typeof e=="function"?e(t):n}var ske=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:a,verticalAlign:s,layout:o}=e;if((o==="vertical"||o==="horizontal"&&s==="middle")&&a!=="center"&&Et(t[a]))return Tp(Tp({},t),{},{[a]:t[a]+(r||0)});if((o==="horizontal"||o==="vertical"&&a==="center")&&s!=="middle"&&Et(t[s]))return Tp(Tp({},t),{},{[s]:t[s]+(i||0)})}return t},Cc=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",vY=(t,e,n,r)=>{if(r)return t.map(o=>o.coordinate);var i,a,s=t.map(o=>(o.coordinate===e&&(i=!0),o.coordinate===n&&(a=!0),o.coordinate));return i||s.push(e),a||s.push(n),s},bY=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:a,scale:s,realScaleType:o,isCategorical:l,categoricalDomain:c,tickCount:u,ticks:h,niceTicks:g,axisType:m}=t;if(!s)return null;var b=o==="scaleBand"&&s.bandwidth?s.bandwidth()/2:2,y=i==="category"&&s.bandwidth?s.bandwidth()/b:0;if(y=m==="angleAxis"&&a&&a.length>=2?Ai(a[0]-a[1])*2*y:y,h||g){var v=(h||g||[]).map((x,M)=>{var w=r?r.indexOf(x):x;return{coordinate:s(w)+y,value:x,offset:y,index:M}});return v.filter(x=>!Xs(x.coordinate))}return l&&c?c.map((x,M)=>({coordinate:s(x)+y,value:x,index:M,offset:y})):s.ticks&&u!=null?s.ticks(u).map((x,M)=>({coordinate:s(x)+y,value:x,offset:y,index:M})):s.domain().map((x,M)=>({coordinate:s(x)+y,value:r?r[x]:x,index:M,offset:y}))},uH=1e-4,oke=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-uH,a=Math.max(r[0],r[1])+uH,s=t(e[0]),o=t(e[n-1]);(s<i||s>a||o<i||o>a)&&t.domain([e[0],e[n-1]])}},lke=(t,e)=>{if(!e||e.length!==2||!Et(e[0])||!Et(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(!Et(t[0])||t[0]<n)&&(i[0]=n),(!Et(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},cke=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0,s=0;s<e;++s){var o=Xs(t[s][n][1])?t[s][n][0]:t[s][n][1];o>=0?(t[s][n][0]=i,t[s][n][1]=i+o,i=t[s][n][1]):(t[s][n][0]=a,t[s][n][1]=a+o,a=t[s][n][1])}},uke=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=Xs(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)}},dke={sign:cke,expand:I3e,none:dm,silhouette:j3e,wiggle:U3e,positive:uke},fke=(t,e,n)=>{var r=dke[n],i=L3e().keys(e).value((a,s)=>Number(Yn(a,s,0))).order(PR).offset(r);return i(t)};function yY(t){return t==null?void 0:String(t)}function dH(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 o=MK(n,"value",i[e.dataKey]);if(o)return o.coordinate+r/2}return n[a]?n[a].coordinate+r/2:null}var l=Yn(i,xr(s)?e.dataKey:s);return xr(l)?null:e.scale(l)}var fH=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:a,index:s}=t;if(e.type==="category")return n[s]?n[s].coordinate+r:null;var o=Yn(a,e.dataKey,e.scale.domain()[s]);return xr(o)?null:e.scale(o)-i/2+r},hke=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]},pke=t=>{var e=t.flat(2).filter(Et);return[Math.min(...e),Math.max(...e)]},mke=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],gke=(t,e,n)=>{if(t!=null)return mke(Object.keys(t).reduce((r,i)=>{var a=t[i],{stackedData:s}=a,o=s.reduce((l,c)=>{var u=xY(c,e,n),h=pke(u);return[Math.min(l[0],h[0]),Math.max(l[1],h[1])]},[1/0,-1/0]);return[Math.min(o[0],r[0]),Math.max(o[1],r[1])]},[1/0,-1/0]))},hH=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,pH=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,pm=(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=Uw(e,u=>u.coordinate),a=1/0,s=1,o=i.length;s<o;s++){var l=i[s],c=i[s-1];a=Math.min((l.coordinate||0)-(c.coordinate||0),a)}return a===1/0?0:a}return n?void 0:0};function mH(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 Om(t,e){if(t)return String(t);if(typeof e=="string")return e}var xke=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},vke=(t,e)=>e==="centric"?t.angle:t.radius,Nc=t=>t.layout.width,Rc=t=>t.layout.height,bke=t=>t.layout.scale,_Y=t=>t.layout.margin,qw=Ve(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),Xw=Ve(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),SY="data-recharts-item-index",wY="data-recharts-item-data-key",iv=60;function gH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function n_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?gH(Object(n),!0).forEach(function(r){yke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):gH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function yke(t,e,n){return(e=_ke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _ke(t){var e=Ske(t,"string");return typeof e=="symbol"?e:e+""}function Ske(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 wke=t=>t.brush.height;function Mke(t){var e=Xw(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:iv;return n+i}return n},0)}function Eke(t){var e=Xw(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:iv;return n+i}return n},0)}function Ake(t){var e=qw(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function Tke(t){var e=qw(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var ui=Ve([Nc,Rc,_Y,wke,Mke,Eke,Ake,Tke,zK,JRe],(t,e,n,r,i,a,s,o,l,c)=>{var u={left:(n.left||0)+i,right:(n.right||0)+a},h={top:(n.top||0)+s,bottom:(n.bottom||0)+o},g=n_(n_({},h),u),m=g.bottom;g.bottom+=r,g=ske(g,l,c);var b=t-g.left-g.right,y=e-g.top-g.bottom;return n_(n_({brushBottom:m},g),{},{width:Math.max(b,0),height:Math.max(y,0)})}),Cke=Ve(ui,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),FD=Ve(Nc,Rc,(t,e)=>({x:0,y:0,width:t,height:e})),Nke=E.createContext(null),ca=()=>E.useContext(Nke)!=null,Kw=t=>t.brush,Yw=Ve([Kw,ui,_Y],(t,e,n)=>({height:t.height,x:Et(t.x)?t.x:e.left,y:Et(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Et(t.width)?t.width:e.width})),IC={},jC={},UC={},xH;function Rke(){return xH||(xH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:a}={}){let s,o=null;const l=a!=null&&a.includes("leading"),c=a==null||a.includes("trailing"),u=()=>{o!==null&&(n.apply(s,o),s=void 0,o=null)},h=()=>{c&&u(),y()};let g=null;const m=()=>{g!=null&&clearTimeout(g),g=setTimeout(()=>{g=null,h()},r)},b=()=>{g!==null&&(clearTimeout(g),g=null)},y=()=>{b(),s=void 0,o=null},v=()=>{u()},x=function(...M){if(i?.aborted)return;s=this,o=M;const w=g==null;m(),l&&w&&u()};return x.schedule=m,x.cancel=y,x.flush=v,i?.addEventListener("abort",y,{once:!0}),x}t.debounce=e})(UC)),UC}var vH;function Pke(){return vH||(vH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Rke();function n(r,i=0,a={}){typeof a!="object"&&(a={});const{leading:s=!1,trailing:o=!0,maxWait:l}=a,c=Array(2);s&&(c[0]="leading"),o&&(c[1]="trailing");let u,h=null;const g=e.debounce(function(...y){u=r.apply(this,y),h=null},i,{edges:c}),m=function(...y){return l!=null&&(h===null&&(h=Date.now()),Date.now()-h>=l)?(u=r.apply(this,y),h=Date.now(),g.cancel(),g.schedule(),u):(g.apply(this,y),u)},b=()=>(g.flush(),u);return m.cancel=g.cancel,m.flush=b,m}t.debounce=n})(jC)),jC}var bH;function kke(){return bH||(bH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Pke();function n(r,i=0,a={}){const{leading:s=!0,trailing:o=!0}=a;return e.debounce(r,i,{leading:s,maxWait:i,trailing:o})}t.throttle=n})(IC)),IC}var FC,yH;function Dke(){return yH||(yH=1,FC=kke().throttle),FC}var Oke=Dke();const Lke=Zs(Oke);var gS=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++]))}},MY=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:a,maxHeight:s}=n,o=yc(r)?t:Number(r),l=yc(i)?e:Number(i);return a&&a>0&&(o?l=o/a:l&&(o=l*a),s&&l!=null&&l>s&&(l=s)),{calculatedWidth:o,calculatedHeight:l}},Ike={width:0,height:0,overflow:"visible"},jke={width:0,overflowX:"visible"},Uke={height:0,overflowY:"visible"},Fke={},zke=t=>{var{width:e,height:n}=t,r=yc(e),i=yc(n);return r&&i?Ike:r?jke:i?Uke:Fke};function Bke(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 or(t){return Number.isFinite(t)}function cl(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function $R(){return $R=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},$R.apply(null,arguments)}function _H(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 SH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?_H(Object(n),!0).forEach(function(r){Hke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_H(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Hke(t,e,n){return(e=$ke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $ke(t){var e=Vke(t,"string");return typeof e=="symbol"?e:e+""}function Vke(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 EY=E.createContext({width:-1,height:-1});function Gke(t){return cl(t.width)&&cl(t.height)}function AY(t){var{children:e,width:n,height:r}=t,i=E.useMemo(()=>({width:n,height:r}),[n,r]);return Gke(i)?E.createElement(EY.Provider,{value:i},e):null}var zD=()=>E.useContext(EY),Wke=E.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:a,minWidth:s=0,minHeight:o,maxHeight:l,children:c,debounce:u=0,id:h,className:g,onResize:m,style:b={}}=t,y=E.useRef(null),v=E.useRef();v.current=m,E.useImperativeHandle(e,()=>y.current);var[x,M]=E.useState({containerWidth:r.width,containerHeight:r.height}),w=E.useCallback((j,N)=>{M(k=>{var F=Math.round(j),I=Math.round(N);return k.containerWidth===F&&k.containerHeight===I?k:{containerWidth:F,containerHeight:I}})},[]);E.useEffect(()=>{if(y.current==null||typeof ResizeObserver>"u")return J0;var j=I=>{var W,{width:D,height:B}=I[0].contentRect;w(D,B),(W=v.current)===null||W===void 0||W.call(v,D,B)};u>0&&(j=Lke(j,u,{trailing:!0,leading:!1}));var N=new ResizeObserver(j),{width:k,height:F}=y.current.getBoundingClientRect();return w(k,F),N.observe(y.current),()=>{N.disconnect()}},[w,u]);var{containerWidth:C,containerHeight:T}=x;gS(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:R,calculatedHeight:A}=MY(C,T,{width:i,height:a,aspect:n,maxHeight:l});return gS(R!=null&&R>0||A!=null&&A>0,`The width(%s) and height(%s) of chart should be greater than 0,
  8195. please check the style of container, or the props width(%s) and height(%s),
  8196. or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
  8197. height and width.`,R,A,i,a,s,o,n),E.createElement("div",{id:h?"".concat(h):void 0,className:An("recharts-responsive-container",g),style:SH(SH({},b),{},{width:i,height:a,minWidth:s,minHeight:o,maxHeight:l}),ref:y},E.createElement("div",{style:zke({width:i,height:a})},E.createElement(AY,{width:R,height:A},c)))}),zC=E.forwardRef((t,e)=>{var n=zD();if(cl(n.width)&&cl(n.height))return t.children;var{width:r,height:i}=Bke({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:s}=MY(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Et(a)&&Et(s)?E.createElement(AY,{width:a,height:s},t.children):E.createElement(Wke,$R({},t,{width:r,height:i,ref:e}))});function TY(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 Zw=()=>{var t,e=ca(),n=At(Cke),r=At(Yw),i=(t=At(Kw))===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}},qke={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},CY=()=>{var t;return(t=At(ui))!==null&&t!==void 0?t:qke},BD=()=>At(Nc),HD=()=>At(Rc),Xke=()=>At(t=>t.layout.margin),Sn=t=>t.layout.layoutType,Lm=()=>At(Sn),Kke=()=>{var t=Lm();if(t==="horizontal"||t==="vertical")return t},Yke=()=>{var t=Lm();return t!==void 0},Qw=t=>{var e=er(),n=ca(),{width:r,height:i}=t,a=zD(),s=r,o=i;return a&&(s=a.width>0?a.width:r,o=a.height>0?a.height:i),E.useEffect(()=>{!n&&cl(s)&&cl(o)&&e(eke({width:s,height:o}))},[e,n,s,o]),null},NY=Symbol.for("immer-nothing"),wH=Symbol.for("immer-draftable"),gs=Symbol.for("immer-state");function mo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var M0=Object.getPrototypeOf;function mm(t){return!!t&&!!t[gs]}function Bf(t){return t?RY(t)||Array.isArray(t)||!!t[wH]||!!t.constructor?.[wH]||av(t)||eM(t):!1}var Zke=Object.prototype.constructor.toString(),MH=new WeakMap;function RY(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=MH.get(n);return r===void 0&&(r=Function.toString.call(n),MH.set(n,r)),r===Zke}function xS(t,e,n=!0){Jw(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 Jw(t){const e=t[gs];return e?e.type_:Array.isArray(t)?1:av(t)?2:eM(t)?3:0}function VR(t,e){return Jw(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function PY(t,e,n){const r=Jw(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function Qke(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function av(t){return t instanceof Map}function eM(t){return t instanceof Set}function Vd(t){return t.copy_||t.base_}function GR(t,e){if(av(t))return new Map(t);if(eM(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=RY(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[gs];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],o=r[s];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[s]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[s]})}return Object.create(M0(t),r)}else{const r=M0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function $D(t,e=!1){return tM(t)||mm(t)||!Bf(t)||(Jw(t)>1&&Object.defineProperties(t,{set:r_,add:r_,clear:r_,delete:r_}),Object.freeze(t),e&&Object.values(t).forEach(n=>$D(n,!0))),t}function Jke(){mo(2)}var r_={value:Jke};function tM(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var eDe={};function Hf(t){const e=eDe[t];return e||mo(0,t),e}var E0;function kY(){return E0}function tDe(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function EH(t,e){e&&(Hf("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function WR(t){qR(t),t.drafts_.forEach(nDe),t.drafts_=null}function qR(t){t===E0&&(E0=t.parent_)}function AH(t){return E0=tDe(E0,t)}function nDe(t){const e=t[gs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function TH(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[gs].modified_&&(WR(e),mo(4)),Bf(t)&&(t=vS(e,t),e.parent_||bS(e,t)),e.patches_&&Hf("Patches").generateReplacementPatches_(n[gs].base_,t,e.patches_,e.inversePatches_)):t=vS(e,n,[]),WR(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==NY?t:void 0}function vS(t,e,n){if(tM(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[gs];if(!i)return xS(e,(a,s)=>CH(t,i,e,a,s,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return bS(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const a=i.copy_;let s=a,o=!1;i.type_===3&&(s=new Set(a),a.clear(),o=!0),xS(s,(l,c)=>CH(t,i,a,l,c,n,o),r),bS(t,a,!1),n&&t.patches_&&Hf("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function CH(t,e,n,r,i,a,s){if(i==null||typeof i!="object"&&!s)return;const o=tM(i);if(!(o&&!s)){if(mm(i)){const l=a&&e&&e.type_!==3&&!VR(e.assigned_,r)?a.concat(r):void 0,c=vS(t,i,l);if(PY(n,r,c),mm(c))t.canAutoFreeze_=!1;else return}else s&&n.add(i);if(Bf(i)&&!o){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&o)return;vS(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(av(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&bS(t,i)}}}function bS(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&$D(e,n)}function rDe(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:kY(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=VD;n&&(i=[r],a=A0);const{revoke:s,proxy:o}=Proxy.revocable(i,a);return r.draft_=o,r.revoke_=s,o}var VD={get(t,e){if(e===gs)return t;const n=Vd(t);if(!VR(n,e))return iDe(t,n,e);const r=n[e];return t.finalized_||!Bf(r)?r:r===BC(t.base_,e)?(HC(t),t.copy_[e]=KR(r,t)):r},has(t,e){return e in Vd(t)},ownKeys(t){return Reflect.ownKeys(Vd(t))},set(t,e,n){const r=DY(Vd(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=BC(Vd(t),e),a=i?.[gs];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(Qke(n,i)&&(n!==void 0||VR(t.base_,e)))return!0;HC(t),XR(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 BC(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,HC(t),XR(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Vd(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){mo(11)},getPrototypeOf(t){return M0(t.base_)},setPrototypeOf(){mo(12)}},A0={};xS(VD,(t,e)=>{A0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});A0.deleteProperty=function(t,e){return A0.set.call(this,t,e,void 0)};A0.set=function(t,e,n){return VD.set.call(this,t[0],e,n,t[0])};function BC(t,e){const n=t[gs];return(n?Vd(n):t)[e]}function iDe(t,e,n){const r=DY(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function DY(t,e){if(!(e in t))return;let n=M0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=M0(n)}}function XR(t){t.modified_||(t.modified_=!0,t.parent_&&XR(t.parent_))}function HC(t){t.copy_||(t.copy_=GR(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var aDe=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(l=a,...c){return s.produce(l,u=>n.call(this,u,...c))}}typeof n!="function"&&mo(6),r!==void 0&&typeof r!="function"&&mo(7);let i;if(Bf(e)){const a=AH(this),s=KR(e,void 0);let o=!0;try{i=n(s),o=!1}finally{o?WR(a):qR(a)}return EH(a,r),TH(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===NY&&(i=void 0),this.autoFreeze_&&$D(i,!0),r){const a=[],s=[];Hf("Patches").generateReplacementPatches_(e,i,a,s),r(a,s)}return i}else mo(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(s,...o)=>this.produceWithPatches(s,l=>e(l,...o));let r,i;return[this.produce(e,n,(s,o)=>{r=s,i=o}),r,i]},typeof t?.autoFreeze=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof t?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),typeof t?.useStrictIteration=="boolean"&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){Bf(t)||mo(8),mm(t)&&(t=sDe(t));const e=AH(this),n=KR(t,void 0);return n[gs].isManual_=!0,qR(e),n}finishDraft(t,e){const n=t&&t[gs];(!n||!n.isManual_)&&mo(9);const{scope_:r}=n;return EH(r,e),TH(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=Hf("Patches").applyPatches_;return mm(t)?r(t,e):this.produce(t,i=>r(i,e))}};function KR(t,e){const n=av(t)?Hf("MapSet").proxyMap_(t,e):eM(t)?Hf("MapSet").proxySet_(t,e):rDe(t,e);return(e?e.scope_:kY()).drafts_.push(n),n}function sDe(t){return mm(t)||mo(10,t),OY(t)}function OY(t){if(!Bf(t)||tM(t))return t;const e=t[gs];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=GR(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=GR(t,!0);return xS(n,(i,a)=>{PY(n,i,OY(a))},r),e&&(e.finalized_=!1),n}var oDe=new aDe;oDe.produce;var lDe={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},LY=Ga({name:"legend",initialState:lDe,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:cr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=_o(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:cr()},removeLegendPayload:{reducer(t,e){var n=_o(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:cr()}}}),{setLegendSize:NH,setLegendSettings:cDe,addLegendPayload:IY,replaceLegendPayload:jY,removeLegendPayload:UY}=LY.actions,uDe=LY.reducer,dDe=["contextPayload"];function YR(){return YR=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},YR.apply(null,arguments)}function RH(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 gm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?RH(Object(n),!0).forEach(function(r){fDe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):RH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fDe(t,e,n){return(e=hDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hDe(t){var e=pDe(t,"string");return typeof e=="symbol"?e:e+""}function pDe(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 mDe(t,e){if(t==null)return{};var n,r,i=gDe(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 gDe(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 xDe(t){return t.value}function vDe(t){var{contextPayload:e}=t,n=mDe(t,dDe),r=IK(e,t.payloadUniqBy,xDe),i=gm(gm({},n),{},{payload:r});return E.isValidElement(t.content)?E.cloneElement(t.content,i):typeof t.content=="function"?E.createElement(t.content,i):E.createElement(hRe,i)}function bDe(t,e,n,r,i,a){var{layout:s,align:o,verticalAlign:l}=e,c,u;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(o==="center"&&s==="vertical"?c={left:((r||0)-a.width)/2}:c=o==="right"?{right:n&&n.right||0}:{left:n&&n.left||0}),(!t||(t.top===void 0||t.top===null)&&(t.bottom===void 0||t.bottom===null))&&(l==="middle"?u={top:((i||0)-a.height)/2}:u=l==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),gm(gm({},c),u)}function yDe(t){var e=er();return E.useEffect(()=>{e(cDe(t))},[e,t]),null}function _De(t){var e=er();return E.useEffect(()=>(e(NH(t)),()=>{e(NH({width:0,height:0}))}),[e,t]),null}function SDe(t,e,n,r){return t==="vertical"&&Et(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var wDe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function FY(t){var e=Zr(t,wDe),n=nPe(),r=a3e(),i=Xke(),{width:a,height:s,wrapperStyle:o,portal:l}=e,[c,u]=BK([n]),h=BD(),g=HD();if(h==null||g==null)return null;var m=h-(i?.left||0)-(i?.right||0),b=SDe(e.layout,s,a,m),y=l?o:gm(gm({position:"absolute",width:b?.width||a||"auto",height:b?.height||s||"auto"},bDe(o,e,i,h,g,c)),o),v=l??r;if(v==null||n==null)return null;var x=E.createElement("div",{className:"recharts-legend-wrapper",style:y,ref:u},E.createElement(yDe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!l&&E.createElement(_De,{width:c.width,height:c.height}),E.createElement(vDe,YR({},e,b,{margin:i,chartWidth:h,chartHeight:g,contextPayload:n})));return ec.createPortal(x,v)}FY.displayName="Legend";function ZR(){return ZR=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},ZR.apply(null,arguments)}function PH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function $C(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?PH(Object(n),!0).forEach(function(r){MDe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):PH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function MDe(t,e,n){return(e=EDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function EDe(t){var e=ADe(t,"string");return typeof e=="symbol"?e:e+""}function ADe(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 TDe(t){return Array.isArray(t)&&ll(t[0])&&ll(t[1])?t.join(" ~ "):t}var CDe=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:a,formatter:s,itemSorter:o,wrapperClassName:l,labelClassName:c,label:u,labelFormatter:h,accessibilityLayer:g=!1}=t,m=()=>{if(a&&a.length){var T={padding:0,margin:0},R=(o?Uw(a,o):a).map((A,j)=>{if(A.type==="none")return null;var N=A.formatter||s||TDe,{value:k,name:F}=A,I=k,W=F;if(N){var D=N(k,F,A,j,a);if(Array.isArray(D))[I,W]=D;else if(D!=null)I=D;else return null}var B=$C({display:"block",paddingTop:4,paddingBottom:4,color:A.color||"#000"},r);return E.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(j),style:B},ll(W)?E.createElement("span",{className:"recharts-tooltip-item-name"},W):null,ll(W)?E.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,E.createElement("span",{className:"recharts-tooltip-item-value"},I),E.createElement("span",{className:"recharts-tooltip-item-unit"},A.unit||""))});return E.createElement("ul",{className:"recharts-tooltip-item-list",style:T},R)}return null},b=$C({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),y=$C({margin:0},i),v=!xr(u),x=v?u:"",M=An("recharts-default-tooltip",l),w=An("recharts-tooltip-label",c);v&&h&&a!==void 0&&a!==null&&(x=h(u,a));var C=g?{role:"status","aria-live":"assertive"}:{};return E.createElement("div",ZR({className:M,style:b},C),E.createElement("p",{className:w,style:y},E.isValidElement(x)?x:"".concat(x)),m())},ex="recharts-tooltip-wrapper",NDe={visibility:"hidden"};function RDe(t){var{coordinate:e,translateX:n,translateY:r}=t;return An(ex,{["".concat(ex,"-right")]:Et(n)&&e&&Et(e.x)&&n>=e.x,["".concat(ex,"-left")]:Et(n)&&e&&Et(e.x)&&n<e.x,["".concat(ex,"-bottom")]:Et(r)&&e&&Et(e.y)&&r>=e.y,["".concat(ex,"-top")]:Et(r)&&e&&Et(e.y)&&r<e.y})}function kH(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:a,reverseDirection:s,tooltipDimension:o,viewBox:l,viewBoxDimension:c}=t;if(a&&Et(a[r]))return a[r];var u=n[r]-o-(i>0?i:0),h=n[r]+i;if(e[r])return s[r]?u:h;var g=l[r];if(g==null)return 0;if(s[r]){var m=u,b=g;return m<b?Math.max(h,g):Math.max(u,g)}if(c==null)return 0;var y=h+o,v=g+c;return y>v?Math.max(u,g):Math.max(h,g)}function PDe(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 kDe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:a,tooltipBox:s,useTranslate3d:o,viewBox:l}=t,c,u,h;return s.height>0&&s.width>0&&n?(u=kH({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:s.width,viewBox:l,viewBoxDimension:l.width}),h=kH({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:s.height,viewBox:l,viewBoxDimension:l.height}),c=PDe({translateX:u,translateY:h,useTranslate3d:o})):c=NDe,{cssProperties:c,cssClasses:RDe({translateX:u,translateY:h,coordinate:n})}}function DH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function i_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?DH(Object(n),!0).forEach(function(r){QR(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):DH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function QR(t,e,n){return(e=DDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DDe(t){var e=ODe(t,"string");return typeof e=="symbol"?e:e+""}function ODe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class LDe extends E.PureComponent{constructor(){super(...arguments),QR(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),QR(this,"handleKeyDown",e=>{if(e.key==="Escape"){var n,r,i,a;this.setState({dismissed:!0,dismissedAtCoordinate:{x:(n=(r=this.props.coordinate)===null||r===void 0?void 0:r.x)!==null&&n!==void 0?n:0,y:(i=(a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==null&&i!==void 0?i:0}})}})}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}componentDidUpdate(){var e,n;this.state.dismissed&&(((e=this.props.coordinate)===null||e===void 0?void 0:e.x)!==this.state.dismissedAtCoordinate.x||((n=this.props.coordinate)===null||n===void 0?void 0:n.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:e,allowEscapeViewBox:n,animationDuration:r,animationEasing:i,children:a,coordinate:s,hasPayload:o,isAnimationActive:l,offset:c,position:u,reverseDirection:h,useTranslate3d:g,viewBox:m,wrapperStyle:b,lastBoundingBox:y,innerRef:v,hasPortalFromProps:x}=this.props,{cssClasses:M,cssProperties:w}=kDe({allowEscapeViewBox:n,coordinate:s,offsetTopLeft:c,position:u,reverseDirection:h,tooltipBox:{height:y.height,width:y.width},useTranslate3d:g,viewBox:m}),C=x?{}:i_(i_({transition:l&&e?"transform ".concat(r,"ms ").concat(i):void 0},w),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&o?"visible":"hidden",position:"absolute",top:0,left:0}),T=i_(i_({},C),{},{visibility:!this.state.dismissed&&e&&o?"visible":"hidden"},b);return E.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:M,style:T,ref:v},a)}}var zY=()=>{var t;return(t=At(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function JR(){return JR=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},JR.apply(null,arguments)}function OH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function LH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?OH(Object(n),!0).forEach(function(r){IDe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):OH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function IDe(t,e,n){return(e=jDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function jDe(t){var e=UDe(t,"string");return typeof e=="symbol"?e:e+""}function UDe(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 IH={curveBasisClosed:M3e,curveBasisOpen:E3e,curveBasis:w3e,curveBumpX:c3e,curveBumpY:u3e,curveLinearClosed:A3e,curveLinear:Iw,curveMonotoneX:T3e,curveMonotoneY:C3e,curveNatural:N3e,curveStep:R3e,curveStepAfter:k3e,curveStepBefore:P3e},yS=t=>or(t.x)&&or(t.y),jH=t=>t.base!=null&&yS(t.base)&&yS(t),tx=t=>t.x,nx=t=>t.y,FDe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(Q0(t));return(n==="curveMonotone"||n==="curveBump")&&e?IH["".concat(n).concat(e==="vertical"?"Y":"X")]:IH[n]||Iw},zDe=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:a=!1}=t,s=FDe(e,i),o=a?n.filter(yS):n,l;if(Array.isArray(r)){var c=n.map((m,b)=>LH(LH({},m),{},{base:r[b]}));i==="vertical"?l=Yy().y(nx).x1(tx).x0(m=>m.base.x):l=Yy().x(tx).y1(nx).y0(m=>m.base.y);var u=l.defined(jH).curve(s),h=a?c.filter(jH):c;return u(h)}i==="vertical"&&Et(r)?l=Yy().y(nx).x1(tx).x0(r):Et(r)?l=Yy().x(tx).y1(nx).y0(r):l=dK().x(tx).y(nx);var g=l.defined(yS).curve(s);return g(o)},Bp=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var a=n&&n.length?zDe(t):r;return E.createElement("path",JR({},Ha(t),CD(t),{className:An("recharts-curve",e),d:a===null?void 0:a,ref:i}))},BDe=["x","y","top","left","width","height","className"];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 UH(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 HDe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?UH(Object(n),!0).forEach(function(r){$De(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):UH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $De(t,e,n){return(e=VDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function VDe(t){var e=GDe(t,"string");return typeof e=="symbol"?e:e+""}function GDe(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 WDe(t,e){if(t==null)return{};var n,r,i=qDe(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 qDe(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 XDe=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),KDe=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:s=0,className:o}=t,l=WDe(t,BDe),c=HDe({x:e,y:n,top:r,left:i,width:a,height:s},l);return!Et(e)||!Et(n)||!Et(a)||!Et(s)||!Et(r)||!Et(i)?null:E.createElement("path",eP({},Sa(c),{className:An("recharts-cross",o),d:XDe(e,n,a,s,r,i)}))};function YDe(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 FH(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 zH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?FH(Object(n),!0).forEach(function(r){ZDe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):FH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ZDe(t,e,n){return(e=QDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function QDe(t){var e=JDe(t,"string");return typeof e=="symbol"?e:e+""}function JDe(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 eOe=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),BY=(t,e,n)=>t.map(r=>"".concat(eOe(r)," ").concat(e,"ms ").concat(n)).join(","),tOe=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),T0=(t,e)=>Object.keys(e).reduce((n,r)=>zH(zH({},n),{},{[r]:t(r,e[r])}),{});function BH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ni(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?BH(Object(n),!0).forEach(function(r){nOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):BH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nOe(t,e,n){return(e=rOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rOe(t){var e=iOe(t,"string");return typeof e=="symbol"?e:e+""}function iOe(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 _S=(t,e,n)=>t+(e-t)*n,tP=t=>{var{from:e,to:n}=t;return e!==n},HY=(t,e,n)=>{var r=T0((i,a)=>{if(tP(a)){var[s,o]=t(a.from,a.to,a.velocity);return ni(ni({},a),{},{from:s,velocity:o})}return a},e);return n<1?T0((i,a)=>tP(a)?ni(ni({},a),{},{velocity:_S(a.velocity,r[i].velocity,n),from:_S(a.from,r[i].from,n)}):a,e):HY(t,r,n-1)};function aOe(t,e,n,r,i,a){var s,o=r.reduce((g,m)=>ni(ni({},g),{},{[m]:{from:t[m],velocity:0,to:e[m]}}),{}),l=()=>T0((g,m)=>m.from,o),c=()=>!Object.values(o).filter(tP).length,u=null,h=g=>{s||(s=g);var m=g-s,b=m/n.dt;o=HY(n,o,b),i(ni(ni(ni({},t),e),l())),s=g,c()||(u=a.setTimeout(h))};return()=>(u=a.setTimeout(h),()=>{var g;(g=u)===null||g===void 0||g()})}function sOe(t,e,n,r,i,a,s){var o=null,l=i.reduce((h,g)=>ni(ni({},h),{},{[g]:[t[g],e[g]]}),{}),c,u=h=>{c||(c=h);var g=(h-c)/r,m=T0((y,v)=>_S(...v,n(g)),l);if(a(ni(ni(ni({},t),e),m)),g<1)o=s.setTimeout(u);else{var b=T0((y,v)=>_S(...v,n(1)),l);a(ni(ni(ni({},t),e),b))}};return()=>(o=s.setTimeout(u),()=>{var h;(h=o)===null||h===void 0||h()})}const oOe=(t,e,n,r,i,a)=>{var s=tOe(t,e);return n==null?()=>(i(ni(ni({},t),e)),()=>{}):n.isStepper===!0?aOe(t,e,n,s,i,a):sOe(t,e,n,r,s,i,a)};var SS=1e-4,$Y=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],VY=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),HH=(t,e)=>n=>{var r=$Y(t,e);return VY(r,n)},lOe=(t,e)=>n=>{var r=$Y(t,e),i=[...r.map((a,s)=>a*s).slice(1),0];return VY(i,n)},cOe=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(n.length===1)switch(n[0]){case"linear":return[0,0,1,1];case"ease":return[.25,.1,.25,1];case"ease-in":return[.42,0,1,1];case"ease-out":return[.42,0,.58,1];case"ease-in-out":return[0,0,.58,1];default:{var i,a=n[0].split("(");if(a[0]==="cubic-bezier"&&((i=a[1])===null||i===void 0?void 0:i.split(")")[0].split(",").length)===4){var s=a[1].split(")")[0].split(",").map(o=>parseFloat(o));return[s[0],s[1],s[2],s[3]]}}}return n.length===4?n:[0,0,1,1]},uOe=(t,e,n,r)=>{var i=HH(t,n),a=HH(e,r),s=lOe(t,n),o=c=>c>1?1:c<0?0:c,l=c=>{for(var u=c>1?1:c,h=u,g=0;g<8;++g){var m=i(h)-u,b=s(h);if(Math.abs(m-u)<SS||b<SS)return a(h);h=o(h-m/b)}return a(h)};return l.isStepper=!1,l},$H=function(){return uOe(...cOe(...arguments))},dOe=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,a=(s,o,l)=>{var c=-(s-o)*n,u=l*r,h=l+(c-u)*i/1e3,g=l*i/1e3+s;return Math.abs(g-o)<SS&&Math.abs(h)<SS?[o,0]:[g,h]};return a.isStepper=!0,a.dt=i,a},fOe=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return $H(t);case"spring":return dOe();default:if(t.split("(")[0]==="cubic-bezier")return $H(t)}return typeof t=="function"?t:null};function hOe(t){var e,n=()=>null,r=!1,i=null,a=s=>{if(!r){if(Array.isArray(s)){if(!s.length)return;var o=s,[l,...c]=o;if(typeof l=="number"){i=t.setTimeout(a.bind(null,c),l);return}a(l),i=t.setTimeout(a.bind(null,c));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 pOe{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 mOe(){return hOe(new pOe)}var gOe=E.createContext(mOe);function xOe(t,e){var n=E.useContext(gOe);return E.useMemo(()=>e??n(t),[t,e,n])}var vOe=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Im={devToolsEnabled:!1,isSsr:vOe()},bOe={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},VH={t:0},VC={t:1};function sv(t){var e=Zr(t,bOe),{isActive:n,canBegin:r,duration:i,easing:a,begin:s,onAnimationEnd:o,onAnimationStart:l,children:c}=e,u=n==="auto"?!Im.isSsr:n,h=xOe(e.animationId,e.animationManager),[g,m]=E.useState(u?VH:VC),b=E.useRef(null);return E.useEffect(()=>{u||m(VC)},[u]),E.useEffect(()=>{if(!u||!r)return J0;var y=oOe(VH,VC,fOe(a),i,m,h.getTimeoutController()),v=()=>{b.current=y()};return h.start([l,s,v,i,o]),()=>{h.stop(),b.current&&b.current(),o()}},[u,r,i,a,s,l,o,h]),c(g.t)}function ov(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=E.useRef(y0(e)),r=E.useRef(t);return r.current!==t&&(n.current=y0(e),r.current=t),n.current}var yOe=["radius"],_Oe=["radius"];function GH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function WH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?GH(Object(n),!0).forEach(function(r){SOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):GH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function SOe(t,e,n){return(e=wOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wOe(t){var e=MOe(t,"string");return typeof e=="symbol"?e:e+""}function MOe(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 wS(){return wS=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},wS.apply(null,arguments)}function qH(t,e){if(t==null)return{};var n,r,i=EOe(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 EOe(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 XH=(t,e,n,r,i)=>{var a=Math.min(Math.abs(n)/2,Math.abs(r)/2),s=r>=0?1:-1,o=n>=0?1:-1,l=r>=0&&n>=0||r<0&&n<0?1:0,c;if(a>0&&i instanceof Array){for(var u=[0,0,0,0],h=0,g=4;h<g;h++)u[h]=i[h]>a?a:i[h];c="M".concat(t,",").concat(e+s*u[0]),u[0]>0&&(c+="A ".concat(u[0],",").concat(u[0],",0,0,").concat(l,",").concat(t+o*u[0],",").concat(e)),c+="L ".concat(t+n-o*u[1],",").concat(e),u[1]>0&&(c+="A ".concat(u[1],",").concat(u[1],",0,0,").concat(l,`,
  8198. `).concat(t+n,",").concat(e+s*u[1])),c+="L ".concat(t+n,",").concat(e+r-s*u[2]),u[2]>0&&(c+="A ".concat(u[2],",").concat(u[2],",0,0,").concat(l,`,
  8199. `).concat(t+n-o*u[2],",").concat(e+r)),c+="L ".concat(t+o*u[3],",").concat(e+r),u[3]>0&&(c+="A ".concat(u[3],",").concat(u[3],",0,0,").concat(l,`,
  8200. `).concat(t,",").concat(e+r-s*u[3])),c+="Z"}else if(a>0&&i===+i&&i>0){var m=Math.min(a,i);c="M ".concat(t,",").concat(e+s*m,`
  8201. A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t+o*m,",").concat(e,`
  8202. L `).concat(t+n-o*m,",").concat(e,`
  8203. A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t+n,",").concat(e+s*m,`
  8204. L `).concat(t+n,",").concat(e+r-s*m,`
  8205. A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t+n-o*m,",").concat(e+r,`
  8206. L `).concat(t+o*m,",").concat(e+r,`
  8207. A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t,",").concat(e+r-s*m," Z")}else c="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return c},KH={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},GY=t=>{var e=Zr(t,KH),n=E.useRef(null),[r,i]=E.useState(-1);E.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var V=n.current.getTotalLength();V&&i(V)}catch{}},[]);var{x:a,y:s,width:o,height:l,radius:c,className:u}=e,{animationEasing:h,animationDuration:g,animationBegin:m,isAnimationActive:b,isUpdateAnimationActive:y}=e,v=E.useRef(o),x=E.useRef(l),M=E.useRef(a),w=E.useRef(s),C=E.useMemo(()=>({x:a,y:s,width:o,height:l,radius:c}),[a,s,o,l,c]),T=ov(C,"rectangle-");if(a!==+a||s!==+s||o!==+o||l!==+l||o===0||l===0)return null;var R=An("recharts-rectangle",u);if(!y){var A=Sa(e),{radius:j}=A,N=qH(A,yOe);return E.createElement("path",wS({},N,{radius:typeof c=="number"?c:void 0,className:R,d:XH(a,s,o,l,c)}))}var k=v.current,F=x.current,I=M.current,W=w.current,D="0px ".concat(r===-1?1:r,"px"),B="".concat(r,"px 0px"),G=BY(["strokeDasharray"],g,typeof h=="string"?h:KH.animationEasing);return E.createElement(sv,{animationId:T,key:T,canBegin:r>0,duration:g,easing:h,isActive:y,begin:m},V=>{var Z=sr(k,o,V),Y=sr(F,l,V),ee=sr(I,a,V),H=sr(W,s,V);n.current&&(v.current=Z,x.current=Y,M.current=ee,w.current=H);var q;b?V>0?q={transition:G,strokeDasharray:B}:q={strokeDasharray:D}:q={strokeDasharray:B};var ae=Sa(e),{radius:ce}=ae,xe=qH(ae,_Oe);return E.createElement("path",wS({},xe,{radius:typeof c=="number"?c:void 0,className:R,d:XH(ee,H,Z,Y,c),ref:n,style:WH(WH({},q),e.style)}))})};function YH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ZH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?YH(Object(n),!0).forEach(function(r){AOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):YH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function AOe(t,e,n){return(e=TOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function TOe(t){var e=COe(t,"string");return typeof e=="symbol"?e:e+""}function COe(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 MS=Math.PI/180,NOe=t=>t*180/Math.PI,Wr=(t,e,n,r)=>({x:t+Math.cos(-MS*r)*n,y:e+Math.sin(-MS*r)*n}),WY=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},ROe=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},POe=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,s=ROe({x:n,y:r},{x:i,y:a});if(s<=0)return{radius:s,angle:0};var o=(n-i)/s,l=Math.acos(o);return r>a&&(l=2*Math.PI-l),{radius:s,angle:NOe(l),angleInRadian:l}},kOe=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}},DOe=(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},OOe=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=POe({x:n,y:r},e),{innerRadius:s,outerRadius:o}=e;if(i<s||i>o||i===0)return null;var{startAngle:l,endAngle:c}=kOe(e),u=a,h;if(l<=c){for(;u>c;)u-=360;for(;u<l;)u+=360;h=u>=l&&u<=c}else{for(;u>l;)u-=360;for(;u<c;)u+=360;h=u>=c&&u<=l}return h?ZH(ZH({},e),{},{radius:i,angle:DOe(u,e)}):null};function qY(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,s=Wr(e,n,r,i),o=Wr(e,n,r,a);return{points:[s,o],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}function nP(){return nP=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},nP.apply(null,arguments)}var LOe=(t,e)=>{var n=Ai(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},a_=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:a,isExternal:s,cornerRadius:o,cornerIsExternal:l}=t,c=o*(s?1:-1)+r,u=Math.asin(o/c)/MS,h=l?i:i+a*u,g=Wr(e,n,c,h),m=Wr(e,n,r,h),b=l?i-a*u:i,y=Wr(e,n,c*Math.cos(u*MS),b);return{center:g,circleTangency:m,lineTangency:y,theta:u}},XY=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:s}=t,o=LOe(a,s),l=a+o,c=Wr(e,n,i,a),u=Wr(e,n,i,l),h="M ".concat(c.x,",").concat(c.y,`
  8208. A `).concat(i,",").concat(i,`,0,
  8209. `).concat(+(Math.abs(o)>180),",").concat(+(a>l),`,
  8210. `).concat(u.x,",").concat(u.y,`
  8211. `);if(r>0){var g=Wr(e,n,r,a),m=Wr(e,n,r,l);h+="L ".concat(m.x,",").concat(m.y,`
  8212. A `).concat(r,",").concat(r,`,0,
  8213. `).concat(+(Math.abs(o)>180),",").concat(+(a<=l),`,
  8214. `).concat(g.x,",").concat(g.y," Z")}else h+="L ".concat(e,",").concat(n," Z");return h},IOe=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:s,cornerIsExternal:o,startAngle:l,endAngle:c}=t,u=Ai(c-l),{circleTangency:h,lineTangency:g,theta:m}=a_({cx:e,cy:n,radius:i,angle:l,sign:u,cornerRadius:a,cornerIsExternal:o}),{circleTangency:b,lineTangency:y,theta:v}=a_({cx:e,cy:n,radius:i,angle:c,sign:-u,cornerRadius:a,cornerIsExternal:o}),x=o?Math.abs(l-c):Math.abs(l-c)-m-v;if(x<0)return s?"M ".concat(g.x,",").concat(g.y,`
  8215. a`).concat(a,",").concat(a,",0,0,1,").concat(a*2,`,0
  8216. a`).concat(a,",").concat(a,",0,0,1,").concat(-a*2,`,0
  8217. `):XY({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:l,endAngle:c});var M="M ".concat(g.x,",").concat(g.y,`
  8218. A`).concat(a,",").concat(a,",0,0,").concat(+(u<0),",").concat(h.x,",").concat(h.y,`
  8219. A`).concat(i,",").concat(i,",0,").concat(+(x>180),",").concat(+(u<0),",").concat(b.x,",").concat(b.y,`
  8220. A`).concat(a,",").concat(a,",0,0,").concat(+(u<0),",").concat(y.x,",").concat(y.y,`
  8221. `);if(r>0){var{circleTangency:w,lineTangency:C,theta:T}=a_({cx:e,cy:n,radius:r,angle:l,sign:u,isExternal:!0,cornerRadius:a,cornerIsExternal:o}),{circleTangency:R,lineTangency:A,theta:j}=a_({cx:e,cy:n,radius:r,angle:c,sign:-u,isExternal:!0,cornerRadius:a,cornerIsExternal:o}),N=o?Math.abs(l-c):Math.abs(l-c)-T-j;if(N<0&&a===0)return"".concat(M,"L").concat(e,",").concat(n,"Z");M+="L".concat(A.x,",").concat(A.y,`
  8222. A`).concat(a,",").concat(a,",0,0,").concat(+(u<0),",").concat(R.x,",").concat(R.y,`
  8223. A`).concat(r,",").concat(r,",0,").concat(+(N>180),",").concat(+(u>0),",").concat(w.x,",").concat(w.y,`
  8224. A`).concat(a,",").concat(a,",0,0,").concat(+(u<0),",").concat(C.x,",").concat(C.y,"Z")}else M+="L".concat(e,",").concat(n,"Z");return M},jOe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},KY=t=>{var e=Zr(t,jOe),{cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:s,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u,className:h}=e;if(a<i||c===u)return null;var g=An("recharts-sector",h),m=a-i,b=aa(s,m,0,!0),y;return b>0&&Math.abs(c-u)<360?y=IOe({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(b,m/2),forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}):y=XY({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:c,endAngle:u}),E.createElement("path",nP({},Sa(e),{className:g,d:y}))};function UOe(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(AK(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:s,angle:o}=e,l=Wr(r,i,a,o),c=Wr(r,i,s,o);return[{x:l.x,y:l.y},{x:c.x,y:c.y}]}return qY(e)}}var GC={},WC={},qC={},QH;function FOe(){return QH||(QH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=UK();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(qC)),qC}var JH;function zOe(){return JH||(JH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=FOe();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})(WC)),WC}var e$;function BOe(){return e$||(e$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=FK(),n=zOe();function r(i,a,s){s&&typeof s!="number"&&e.isIterateeCall(i,a,s)&&(a=s=void 0),i=n.toFinite(i),a===void 0?(a=i,i=0):a=n.toFinite(a),s=s===void 0?i<a?1:-1:n.toFinite(s);const o=Math.max(Math.ceil((a-i)/(s||1)),0),l=new Array(o);for(let c=0;c<o;c++)l[c]=i,i+=s;return l}t.range=r})(GC)),GC}var XC,t$;function HOe(){return t$||(t$=1,XC=BOe().range),XC}var $Oe=HOe();const YY=Zs($Oe);function qu(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function VOe(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function GD(t){let e,n,r;t.length!==2?(e=qu,n=(o,l)=>qu(t(o),l),r=(o,l)=>t(o)-l):(e=t===qu||t===VOe?t:GOe,n=t,r=t);function i(o,l,c=0,u=o.length){if(c<u){if(e(l,l)!==0)return u;do{const h=c+u>>>1;n(o[h],l)<0?c=h+1:u=h}while(c<u)}return c}function a(o,l,c=0,u=o.length){if(c<u){if(e(l,l)!==0)return u;do{const h=c+u>>>1;n(o[h],l)<=0?c=h+1:u=h}while(c<u)}return c}function s(o,l,c=0,u=o.length){const h=i(o,l,c,u-1);return h>c&&r(o[h-1],l)>-r(o[h],l)?h-1:h}return{left:i,center:s,right:a}}function GOe(){return 0}function ZY(t){return t===null?NaN:+t}function*WOe(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const qOe=GD(qu),lv=qOe.right;GD(ZY).center;class n$ extends Map{constructor(e,n=YOe){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(r$(this,e))}has(e){return super.has(r$(this,e))}set(e,n){return super.set(XOe(this,e),n)}delete(e){return super.delete(KOe(this,e))}}function r$({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function XOe({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function KOe({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function YOe(t){return t!==null&&typeof t=="object"?t.valueOf():t}function ZOe(t=qu){if(t===qu)return QY;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 QY(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const QOe=Math.sqrt(50),JOe=Math.sqrt(10),eLe=Math.sqrt(2);function ES(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>=QOe?10:a>=JOe?5:a>=eLe?2:1;let o,l,c;return i<0?(c=Math.pow(10,-i)/s,o=Math.round(t*c),l=Math.round(e*c),o/c<t&&++o,l/c>e&&--l,c=-c):(c=Math.pow(10,i)*s,o=Math.round(t/c),l=Math.round(e/c),o*c<t&&++o,l*c>e&&--l),l<o&&.5<=n&&n<2?ES(t,e,n*2):[o,l,c]}function rP(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?ES(e,t,n):ES(t,e,n);if(!(a>=i))return[];const o=a-i+1,l=new Array(o);if(r)if(s<0)for(let c=0;c<o;++c)l[c]=(a-c)/-s;else for(let c=0;c<o;++c)l[c]=(a-c)*s;else if(s<0)for(let c=0;c<o;++c)l[c]=(i+c)/-s;else for(let c=0;c<o;++c)l[c]=(i+c)*s;return l}function iP(t,e,n){return e=+e,t=+t,n=+n,ES(t,e,n)[2]}function aP(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?iP(e,t,n):iP(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function i$(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function a$(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function JY(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?QY:ZOe(i);r>n;){if(r-n>600){const l=r-n+1,c=e-n+1,u=Math.log(l),h=.5*Math.exp(2*u/3),g=.5*Math.sqrt(u*h*(l-h)/l)*(c-l/2<0?-1:1),m=Math.max(n,Math.floor(e-c*h/l+g)),b=Math.min(r,Math.floor(e+(l-c)*h/l+g));JY(t,e,m,b,i)}const a=t[e];let s=n,o=r;for(rx(t,n,e),i(t[r],a)>0&&rx(t,n,r);s<o;){for(rx(t,s,o),++s,--o;i(t[s],a)<0;)++s;for(;i(t[o],a)>0;)--o}i(t[n],a)===0?rx(t,n,o):(++o,rx(t,o,r)),o<=e&&(n=o+1),e<=o&&(r=o-1)}return t}function rx(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function tLe(t,e,n){if(t=Float64Array.from(WOe(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return a$(t);if(e>=1)return i$(t);var r,i=(r-1)*e,a=Math.floor(i),s=i$(JY(t,a).subarray(0,a+1)),o=a$(t.subarray(a+1));return s+(o-s)*(i-a)}}function nLe(t,e,n=ZY){if(!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return+n(t[0],0,t);if(e>=1)return+n(t[r-1],r-1,t);var r,i=(r-1)*e,a=Math.floor(i),s=+n(t[a],a,t),o=+n(t[a+1],a+1,t);return s+(o-s)*(i-a)}}function rLe(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 Qs(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Pc(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 sP=Symbol("implicit");function WD(){var t=new n$,e=[],n=[],r=sP;function i(a){let s=t.get(a);if(s===void 0){if(r!==sP)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 n$;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 WD(e,n).unknown(r)},Qs.apply(i,arguments),i}function qD(){var t=WD().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,a,s,o=!1,l=0,c=0,u=.5;delete t.unknown;function h(){var g=e().length,m=i<r,b=m?i:r,y=m?r:i;a=(y-b)/Math.max(1,g-l+c*2),o&&(a=Math.floor(a)),b+=(y-b-a*(g-l))*u,s=a*(1-l),o&&(b=Math.round(b),s=Math.round(s));var v=rLe(g).map(function(x){return b+a*x});return n(m?v.reverse():v)}return t.domain=function(g){return arguments.length?(e(g),h()):e()},t.range=function(g){return arguments.length?([r,i]=g,r=+r,i=+i,h()):[r,i]},t.rangeRound=function(g){return[r,i]=g,r=+r,i=+i,o=!0,h()},t.bandwidth=function(){return s},t.step=function(){return a},t.round=function(g){return arguments.length?(o=!!g,h()):o},t.padding=function(g){return arguments.length?(l=Math.min(1,c=+g),h()):l},t.paddingInner=function(g){return arguments.length?(l=Math.min(1,g),h()):l},t.paddingOuter=function(g){return arguments.length?(c=+g,h()):c},t.align=function(g){return arguments.length?(u=Math.max(0,Math.min(1,g)),h()):u},t.copy=function(){return qD(e(),[r,i]).round(o).paddingInner(l).paddingOuter(c).align(u)},Qs.apply(h(),arguments)}function eZ(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return eZ(e())},t}function iLe(){return eZ(qD.apply(null,arguments).paddingInner(1))}function XD(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function tZ(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function cv(){}var C0=.7,AS=1/C0,Hp="\\s*([+-]?\\d+)\\s*",N0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Jo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",aLe=/^#([0-9a-f]{3,8})$/,sLe=new RegExp(`^rgb\\(${Hp},${Hp},${Hp}\\)$`),oLe=new RegExp(`^rgb\\(${Jo},${Jo},${Jo}\\)$`),lLe=new RegExp(`^rgba\\(${Hp},${Hp},${Hp},${N0}\\)$`),cLe=new RegExp(`^rgba\\(${Jo},${Jo},${Jo},${N0}\\)$`),uLe=new RegExp(`^hsl\\(${N0},${Jo},${Jo}\\)$`),dLe=new RegExp(`^hsla\\(${N0},${Jo},${Jo},${N0}\\)$`),s$={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};XD(cv,R0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:o$,formatHex:o$,formatHex8:fLe,formatHsl:hLe,formatRgb:l$,toString:l$});function o$(){return this.rgb().formatHex()}function fLe(){return this.rgb().formatHex8()}function hLe(){return nZ(this).formatHsl()}function l$(){return this.rgb().formatRgb()}function R0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=aLe.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?c$(e):n===3?new Ia(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?s_(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?s_(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=sLe.exec(t))?new Ia(e[1],e[2],e[3],1):(e=oLe.exec(t))?new Ia(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=lLe.exec(t))?s_(e[1],e[2],e[3],e[4]):(e=cLe.exec(t))?s_(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=uLe.exec(t))?f$(e[1],e[2]/100,e[3]/100,1):(e=dLe.exec(t))?f$(e[1],e[2]/100,e[3]/100,e[4]):s$.hasOwnProperty(t)?c$(s$[t]):t==="transparent"?new Ia(NaN,NaN,NaN,0):null}function c$(t){return new Ia(t>>16&255,t>>8&255,t&255,1)}function s_(t,e,n,r){return r<=0&&(t=e=n=NaN),new Ia(t,e,n,r)}function pLe(t){return t instanceof cv||(t=R0(t)),t?(t=t.rgb(),new Ia(t.r,t.g,t.b,t.opacity)):new Ia}function oP(t,e,n,r){return arguments.length===1?pLe(t):new Ia(t,e,n,r??1)}function Ia(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}XD(Ia,oP,tZ(cv,{brighter(t){return t=t==null?AS:Math.pow(AS,t),new Ia(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?C0:Math.pow(C0,t),new Ia(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Ia(vf(this.r),vf(this.g),vf(this.b),TS(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:u$,formatHex:u$,formatHex8:mLe,formatRgb:d$,toString:d$}));function u$(){return`#${af(this.r)}${af(this.g)}${af(this.b)}`}function mLe(){return`#${af(this.r)}${af(this.g)}${af(this.b)}${af((isNaN(this.opacity)?1:this.opacity)*255)}`}function d$(){const t=TS(this.opacity);return`${t===1?"rgb(":"rgba("}${vf(this.r)}, ${vf(this.g)}, ${vf(this.b)}${t===1?")":`, ${t})`}`}function TS(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function vf(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function af(t){return t=vf(t),(t<16?"0":"")+t.toString(16)}function f$(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new go(t,e,n,r)}function nZ(t){if(t instanceof go)return new go(t.h,t.s,t.l,t.opacity);if(t instanceof cv||(t=R0(t)),!t)return new go;if(t instanceof go)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),a=Math.max(e,n,r),s=NaN,o=a-i,l=(a+i)/2;return o?(e===a?s=(n-r)/o+(n<r)*6:n===a?s=(r-e)/o+2:s=(e-n)/o+4,o/=l<.5?a+i:2-a-i,s*=60):o=l>0&&l<1?0:s,new go(s,o,l,t.opacity)}function gLe(t,e,n,r){return arguments.length===1?nZ(t):new go(t,e,n,r??1)}function go(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}XD(go,gLe,tZ(cv,{brighter(t){return t=t==null?AS:Math.pow(AS,t),new go(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?C0:Math.pow(C0,t),new go(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 Ia(KC(t>=240?t-240:t+120,i,r),KC(t,i,r),KC(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new go(h$(this.h),o_(this.s),o_(this.l),TS(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=TS(this.opacity);return`${t===1?"hsl(":"hsla("}${h$(this.h)}, ${o_(this.s)*100}%, ${o_(this.l)*100}%${t===1?")":`, ${t})`}`}}));function h$(t){return t=(t||0)%360,t<0?t+360:t}function o_(t){return Math.max(0,Math.min(1,t||0))}function KC(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 KD=t=>()=>t;function xLe(t,e){return function(n){return t+n*e}}function vLe(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 bLe(t){return(t=+t)==1?rZ:function(e,n){return n-e?vLe(e,n,t):KD(isNaN(e)?n:e)}}function rZ(t,e){var n=e-t;return n?xLe(t,n):KD(isNaN(t)?e:t)}const p$=(function t(e){var n=bLe(e);function r(i,a){var s=n((i=oP(i)).r,(a=oP(a)).r),o=n(i.g,a.g),l=n(i.b,a.b),c=rZ(i.opacity,a.opacity);return function(u){return i.r=s(u),i.g=o(u),i.b=l(u),i.opacity=c(u),i+""}}return r.gamma=t,r})(1);function yLe(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 _Le(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function SLe(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]=jm(t[s],e[s]);for(;s<n;++s)a[s]=e[s];return function(o){for(s=0;s<r;++s)a[s]=i[s](o);return a}}function wLe(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function CS(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function MLe(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]=jm(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var lP=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,YC=new RegExp(lP.source,"g");function ELe(t){return function(){return t}}function ALe(t){return function(e){return t(e)+""}}function TLe(t,e){var n=lP.lastIndex=YC.lastIndex=0,r,i,a,s=-1,o=[],l=[];for(t=t+"",e=e+"";(r=lP.exec(t))&&(i=YC.exec(e));)(a=i.index)>n&&(a=e.slice(n,a),o[s]?o[s]+=a:o[++s]=a),(r=r[0])===(i=i[0])?o[s]?o[s]+=i:o[++s]=i:(o[++s]=null,l.push({i:s,x:CS(r,i)})),n=YC.lastIndex;return n<e.length&&(a=e.slice(n),o[s]?o[s]+=a:o[++s]=a),o.length<2?l[0]?ALe(l[0].x):ELe(e):(e=l.length,function(c){for(var u=0,h;u<e;++u)o[(h=l[u]).i]=h.x(c);return o.join("")})}function jm(t,e){var n=typeof e,r;return e==null||n==="boolean"?KD(e):(n==="number"?CS:n==="string"?(r=R0(e))?(e=r,p$):TLe:e instanceof R0?p$:e instanceof Date?wLe:_Le(e)?yLe:Array.isArray(e)?SLe:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?MLe:CS)(t,e)}function YD(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function CLe(t,e){e===void 0&&(e=t,t=jm);for(var n=0,r=e.length-1,i=e[0],a=new Array(r<0?0:r);n<r;)a[n]=t(i,i=e[++n]);return function(s){var o=Math.max(0,Math.min(r-1,Math.floor(s*=r)));return a[o](s-o)}}function NLe(t){return function(){return t}}function NS(t){return+t}var m$=[0,1];function xa(t){return t}function cP(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:NLe(isNaN(e)?NaN:.5)}function RLe(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function PLe(t,e,n){var r=t[0],i=t[1],a=e[0],s=e[1];return i<r?(r=cP(i,r),a=n(s,a)):(r=cP(r,i),a=n(a,s)),function(o){return a(r(o))}}function kLe(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]=cP(t[s],t[s+1]),a[s]=n(e[s],e[s+1]);return function(o){var l=lv(t,o,1,r)-1;return a[l](i[l](o))}}function uv(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function nM(){var t=m$,e=m$,n=jm,r,i,a,s=xa,o,l,c;function u(){var g=Math.min(t.length,e.length);return s!==xa&&(s=RLe(t[0],t[g-1])),o=g>2?kLe:PLe,l=c=null,h}function h(g){return g==null||isNaN(g=+g)?a:(l||(l=o(t.map(r),e,n)))(r(s(g)))}return h.invert=function(g){return s(i((c||(c=o(e,t.map(r),CS)))(g)))},h.domain=function(g){return arguments.length?(t=Array.from(g,NS),u()):t.slice()},h.range=function(g){return arguments.length?(e=Array.from(g),u()):e.slice()},h.rangeRound=function(g){return e=Array.from(g),n=YD,u()},h.clamp=function(g){return arguments.length?(s=g?!0:xa,u()):s!==xa},h.interpolate=function(g){return arguments.length?(n=g,u()):n},h.unknown=function(g){return arguments.length?(a=g,h):a},function(g,m){return r=g,i=m,u()}}function ZD(){return nM()(xa,xa)}function DLe(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function RS(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 xm(t){return t=RS(Math.abs(t)),t?t[1]:NaN}function OLe(t,e){return function(n,r){for(var i=n.length,a=[],s=0,o=t[0],l=0;i>0&&o>0&&(l+o+1>r&&(o=Math.max(1,r-l)),a.push(n.substring(i-=o,i+o)),!((l+=o+1)>r));)o=t[s=(s+1)%t.length];return a.reverse().join(e)}}function LLe(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var ILe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function P0(t){if(!(e=ILe.exec(t)))throw new Error("invalid format: "+t);var e;return new QD({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]})}P0.prototype=QD.prototype;function QD(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+""}QD.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 jLe(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 iZ;function ULe(t,e){var n=RS(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(iZ=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")+RS(t,Math.max(0,e+a-1))[0]}function g$(t,e){var n=RS(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 x$={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:DLe,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)=>g$(t*100,e),r:g$,s:ULe,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function v$(t){return t}var b$=Array.prototype.map,y$=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function FLe(t){var e=t.grouping===void 0||t.thousands===void 0?v$:OLe(b$.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?v$:LLe(b$.call(t.numerals,String)),s=t.percent===void 0?"%":t.percent+"",o=t.minus===void 0?"−":t.minus+"",l=t.nan===void 0?"NaN":t.nan+"";function c(h){h=P0(h);var g=h.fill,m=h.align,b=h.sign,y=h.symbol,v=h.zero,x=h.width,M=h.comma,w=h.precision,C=h.trim,T=h.type;T==="n"?(M=!0,T="g"):x$[T]||(w===void 0&&(w=12),C=!0,T="g"),(v||g==="0"&&m==="=")&&(v=!0,g="0",m="=");var R=y==="$"?n:y==="#"&&/[boxX]/.test(T)?"0"+T.toLowerCase():"",A=y==="$"?r:/[%p]/.test(T)?s:"",j=x$[T],N=/[defgprs%]/.test(T);w=w===void 0?6:/[gprs]/.test(T)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));function k(F){var I=R,W=A,D,B,G;if(T==="c")W=j(F)+W,F="";else{F=+F;var V=F<0||1/F<0;if(F=isNaN(F)?l:j(Math.abs(F),w),C&&(F=jLe(F)),V&&+F==0&&b!=="+"&&(V=!1),I=(V?b==="("?b:o:b==="-"||b==="("?"":b)+I,W=(T==="s"?y$[8+iZ/3]:"")+W+(V&&b==="("?")":""),N){for(D=-1,B=F.length;++D<B;)if(G=F.charCodeAt(D),48>G||G>57){W=(G===46?i+F.slice(D+1):F.slice(D))+W,F=F.slice(0,D);break}}}M&&!v&&(F=e(F,1/0));var Z=I.length+F.length+W.length,Y=Z<x?new Array(x-Z+1).join(g):"";switch(M&&v&&(F=e(Y+F,Y.length?x-W.length:1/0),Y=""),m){case"<":F=I+F+W+Y;break;case"=":F=I+Y+F+W;break;case"^":F=Y.slice(0,Z=Y.length>>1)+I+F+W+Y.slice(Z);break;default:F=Y+I+F+W;break}return a(F)}return k.toString=function(){return h+""},k}function u(h,g){var m=c((h=P0(h),h.type="f",h)),b=Math.max(-8,Math.min(8,Math.floor(xm(g)/3)))*3,y=Math.pow(10,-b),v=y$[8+b/3];return function(x){return m(y*x)+v}}return{format:c,formatPrefix:u}}var l_,JD,aZ;zLe({thousands:",",grouping:[3],currency:["$",""]});function zLe(t){return l_=FLe(t),JD=l_.format,aZ=l_.formatPrefix,l_}function BLe(t){return Math.max(0,-xm(Math.abs(t)))}function HLe(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(xm(e)/3)))*3-xm(Math.abs(t)))}function $Le(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,xm(e)-xm(t))+1}function sZ(t,e,n,r){var i=aP(t,e,n),a;switch(r=P0(r??",f"),r.type){case"s":{var s=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=HLe(i,s))&&(r.precision=a),aZ(r,s)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=$Le(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=BLe(i))&&(r.precision=a-(r.type==="%")*2);break}}return JD(r)}function dd(t){var e=t.domain;return t.ticks=function(n){var r=e();return rP(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return sZ(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,a=r.length-1,s=r[i],o=r[a],l,c,u=10;for(o<s&&(c=s,s=o,o=c,c=i,i=a,a=c);u-- >0;){if(c=iP(s,o,n),c===l)return r[i]=s,r[a]=o,e(r);if(c>0)s=Math.floor(s/c)*c,o=Math.ceil(o/c)*c;else if(c<0)s=Math.ceil(s*c)/c,o=Math.floor(o*c)/c;else break;l=c}return t},t}function oZ(){var t=ZD();return t.copy=function(){return uv(t,oZ())},Qs.apply(t,arguments),dd(t)}function lZ(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,NS),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return lZ(t).unknown(e)},t=arguments.length?Array.from(t,NS):[0,1],dd(n)}function cZ(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 _$(t){return Math.log(t)}function S$(t){return Math.exp(t)}function VLe(t){return-Math.log(-t)}function GLe(t){return-Math.exp(-t)}function WLe(t){return isFinite(t)?+("1e"+t):t<0?0:t}function qLe(t){return t===10?WLe:t===Math.E?Math.exp:e=>Math.pow(t,e)}function XLe(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 w$(t){return(e,n)=>-t(-e,n)}function eO(t){const e=t(_$,S$),n=e.domain;let r=10,i,a;function s(){return i=XLe(r),a=qLe(r),n()[0]<0?(i=w$(i),a=w$(a),t(VLe,GLe)):t(_$,S$),e}return e.base=function(o){return arguments.length?(r=+o,s()):r},e.domain=function(o){return arguments.length?(n(o),s()):n()},e.ticks=o=>{const l=n();let c=l[0],u=l[l.length-1];const h=u<c;h&&([c,u]=[u,c]);let g=i(c),m=i(u),b,y;const v=o==null?10:+o;let x=[];if(!(r%1)&&m-g<v){if(g=Math.floor(g),m=Math.ceil(m),c>0){for(;g<=m;++g)for(b=1;b<r;++b)if(y=g<0?b/a(-g):b*a(g),!(y<c)){if(y>u)break;x.push(y)}}else for(;g<=m;++g)for(b=r-1;b>=1;--b)if(y=g>0?b/a(-g):b*a(g),!(y<c)){if(y>u)break;x.push(y)}x.length*2<v&&(x=rP(c,u,v))}else x=rP(g,m,Math.min(m-g,v)).map(a);return h?x.reverse():x},e.tickFormat=(o,l)=>{if(o==null&&(o=10),l==null&&(l=r===10?"s":","),typeof l!="function"&&(!(r%1)&&(l=P0(l)).precision==null&&(l.trim=!0),l=JD(l)),o===1/0)return l;const c=Math.max(1,r*o/e.ticks().length);return u=>{let h=u/a(Math.round(i(u)));return h*r<r-.5&&(h*=r),h<=c?l(u):""}},e.nice=()=>n(cZ(n(),{floor:o=>a(Math.floor(i(o))),ceil:o=>a(Math.ceil(i(o)))})),e}function uZ(){const t=eO(nM()).domain([1,10]);return t.copy=()=>uv(t,uZ()).base(t.base()),Qs.apply(t,arguments),t}function M$(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function E$(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function tO(t){var e=1,n=t(M$(e),E$(e));return n.constant=function(r){return arguments.length?t(M$(e=+r),E$(e)):e},dd(n)}function dZ(){var t=tO(nM());return t.copy=function(){return uv(t,dZ()).constant(t.constant())},Qs.apply(t,arguments)}function A$(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function KLe(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function YLe(t){return t<0?-t*t:t*t}function nO(t){var e=t(xa,xa),n=1;function r(){return n===1?t(xa,xa):n===.5?t(KLe,YLe):t(A$(n),A$(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},dd(e)}function rO(){var t=nO(nM());return t.copy=function(){return uv(t,rO()).exponent(t.exponent())},Qs.apply(t,arguments),t}function ZLe(){return rO.apply(null,arguments).exponent(.5)}function T$(t){return Math.sign(t)*t*t}function QLe(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function fZ(){var t=ZD(),e=[0,1],n=!1,r;function i(a){var s=QLe(t(a));return isNaN(s)?r:n?Math.round(s):s}return i.invert=function(a){return t.invert(T$(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,NS)).map(T$)),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 fZ(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},Qs.apply(i,arguments),dd(i)}function hZ(){var t=[],e=[],n=[],r;function i(){var s=0,o=Math.max(1,e.length);for(n=new Array(o-1);++s<o;)n[s-1]=nLe(t,s/o);return a}function a(s){return s==null||isNaN(s=+s)?r:e[lv(n,s)]}return a.invertExtent=function(s){var o=e.indexOf(s);return o<0?[NaN,NaN]:[o>0?n[o-1]:t[0],o<n.length?n[o]:t[t.length-1]]},a.domain=function(s){if(!arguments.length)return t.slice();t=[];for(let o of s)o!=null&&!isNaN(o=+o)&&t.push(o);return t.sort(qu),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 hZ().domain(t).range(e).unknown(r)},Qs.apply(a,arguments)}function pZ(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function s(l){return l!=null&&l<=l?i[lv(r,l,0,n)]:a}function o(){var l=-1;for(r=new Array(n);++l<n;)r[l]=((l+1)*e-(l-n)*t)/(n+1);return s}return s.domain=function(l){return arguments.length?([t,e]=l,t=+t,e=+e,o()):[t,e]},s.range=function(l){return arguments.length?(n=(i=Array.from(l)).length-1,o()):i.slice()},s.invertExtent=function(l){var c=i.indexOf(l);return c<0?[NaN,NaN]:c<1?[t,r[0]]:c>=n?[r[n-1],e]:[r[c-1],r[c]]},s.unknown=function(l){return arguments.length&&(a=l),s},s.thresholds=function(){return r.slice()},s.copy=function(){return pZ().domain([t,e]).range(i).unknown(a)},Qs.apply(dd(s),arguments)}function mZ(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[lv(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 mZ().domain(t).range(e).unknown(n)},Qs.apply(i,arguments)}const ZC=new Date,QC=new Date;function di(t,e,n,r){function i(a){return t(a=arguments.length===0?new Date:new Date(+a)),a}return i.floor=a=>(t(a=new Date(+a)),a),i.ceil=a=>(t(a=new Date(a-1)),e(a,1),t(a),a),i.round=a=>{const s=i(a),o=i.ceil(a);return a-s<o-a?s:o},i.offset=(a,s)=>(e(a=new Date(+a),s==null?1:Math.floor(s)),a),i.range=(a,s,o)=>{const l=[];if(a=i.ceil(a),o=o==null?1:Math.floor(o),!(a<s)||!(o>0))return l;let c;do l.push(c=new Date(+a)),e(a,o),t(a);while(c<a&&a<s);return l},i.filter=a=>di(s=>{if(s>=s)for(;t(s),!a(s);)s.setTime(s-1)},(s,o)=>{if(s>=s)if(o<0)for(;++o<=0;)for(;e(s,-1),!a(s););else for(;--o>=0;)for(;e(s,1),!a(s););}),n&&(i.count=(a,s)=>(ZC.setTime(+a),QC.setTime(+s),t(ZC),t(QC),Math.floor(n(ZC,QC))),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 PS=di(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);PS.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?di(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):PS);PS.range;const ac=1e3,$s=ac*60,sc=$s*60,Sc=sc*24,iO=Sc*7,C$=Sc*30,JC=Sc*365,sf=di(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*ac)},(t,e)=>(e-t)/ac,t=>t.getUTCSeconds());sf.range;const aO=di(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*ac)},(t,e)=>{t.setTime(+t+e*$s)},(t,e)=>(e-t)/$s,t=>t.getMinutes());aO.range;const sO=di(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*$s)},(t,e)=>(e-t)/$s,t=>t.getUTCMinutes());sO.range;const oO=di(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*ac-t.getMinutes()*$s)},(t,e)=>{t.setTime(+t+e*sc)},(t,e)=>(e-t)/sc,t=>t.getHours());oO.range;const lO=di(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*sc)},(t,e)=>(e-t)/sc,t=>t.getUTCHours());lO.range;const dv=di(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*$s)/Sc,t=>t.getDate()-1);dv.range;const rM=di(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Sc,t=>t.getUTCDate()-1);rM.range;const gZ=di(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Sc,t=>Math.floor(t/Sc));gZ.range;function Yf(t){return di(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())*$s)/iO)}const iM=Yf(0),kS=Yf(1),JLe=Yf(2),eIe=Yf(3),vm=Yf(4),tIe=Yf(5),nIe=Yf(6);iM.range;kS.range;JLe.range;eIe.range;vm.range;tIe.range;nIe.range;function Zf(t){return di(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)/iO)}const aM=Zf(0),DS=Zf(1),rIe=Zf(2),iIe=Zf(3),bm=Zf(4),aIe=Zf(5),sIe=Zf(6);aM.range;DS.range;rIe.range;iIe.range;bm.range;aIe.range;sIe.range;const cO=di(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());cO.range;const uO=di(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());uO.range;const wc=di(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());wc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:di(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)});wc.range;const Mc=di(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());Mc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:di(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)});Mc.range;function xZ(t,e,n,r,i,a){const s=[[sf,1,ac],[sf,5,5*ac],[sf,15,15*ac],[sf,30,30*ac],[a,1,$s],[a,5,5*$s],[a,15,15*$s],[a,30,30*$s],[i,1,sc],[i,3,3*sc],[i,6,6*sc],[i,12,12*sc],[r,1,Sc],[r,2,2*Sc],[n,1,iO],[e,1,C$],[e,3,3*C$],[t,1,JC]];function o(c,u,h){const g=u<c;g&&([c,u]=[u,c]);const m=h&&typeof h.range=="function"?h:l(c,u,h),b=m?m.range(c,+u+1):[];return g?b.reverse():b}function l(c,u,h){const g=Math.abs(u-c)/h,m=GD(([,,v])=>v).right(s,g);if(m===s.length)return t.every(aP(c/JC,u/JC,h));if(m===0)return PS.every(Math.max(aP(c,u,h),1));const[b,y]=s[g/s[m-1][2]<s[m][2]/g?m-1:m];return b.every(y)}return[o,l]}const[oIe,lIe]=xZ(Mc,uO,aM,gZ,lO,sO),[cIe,uIe]=xZ(wc,cO,iM,dv,oO,aO);function eN(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 tN(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 ix(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function dIe(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,s=t.shortDays,o=t.months,l=t.shortMonths,c=ax(i),u=sx(i),h=ax(a),g=sx(a),m=ax(s),b=sx(s),y=ax(o),v=sx(o),x=ax(l),M=sx(l),w={a:V,A:Z,b:Y,B:ee,c:null,d:O$,e:O$,f:OIe,g:VIe,G:WIe,H:PIe,I:kIe,j:DIe,L:vZ,m:LIe,M:IIe,p:H,q,Q:j$,s:U$,S:jIe,u:UIe,U:FIe,V:zIe,w:BIe,W:HIe,x:null,X:null,y:$Ie,Y:GIe,Z:qIe,"%":I$},C={a:ae,A:ce,b:xe,B:ie,c:null,d:L$,e:L$,f:ZIe,g:oje,G:cje,H:XIe,I:KIe,j:YIe,L:yZ,m:QIe,M:JIe,p:ve,q:Pe,Q:j$,s:U$,S:eje,u:tje,U:nje,V:rje,w:ije,W:aje,x:null,X:null,y:sje,Y:lje,Z:uje,"%":I$},T={a:k,A:F,b:I,B:W,c:D,d:k$,e:k$,f:TIe,g:P$,G:R$,H:D$,I:D$,j:wIe,L:AIe,m:SIe,M:MIe,p:N,q:_Ie,Q:NIe,s:RIe,S:EIe,u:gIe,U:xIe,V:vIe,w:mIe,W:bIe,x:B,X:G,y:P$,Y:R$,Z:yIe,"%":CIe};w.x=R(n,w),w.X=R(r,w),w.c=R(e,w),C.x=R(n,C),C.X=R(r,C),C.c=R(e,C);function R(he,we){return function(Le){var de=[],lt=-1,$=0,z=he.length,ne,K,Q;for(Le instanceof Date||(Le=new Date(+Le));++lt<z;)he.charCodeAt(lt)===37&&(de.push(he.slice($,lt)),(K=N$[ne=he.charAt(++lt)])!=null?ne=he.charAt(++lt):K=ne==="e"?" ":"0",(Q=we[ne])&&(ne=Q(Le,K)),de.push(ne),$=lt+1);return de.push(he.slice($,lt)),de.join("")}}function A(he,we){return function(Le){var de=ix(1900,void 0,1),lt=j(de,he,Le+="",0),$,z;if(lt!=Le.length)return null;if("Q"in de)return new Date(de.Q);if("s"in de)return new Date(de.s*1e3+("L"in de?de.L:0));if(we&&!("Z"in de)&&(de.Z=0),"p"in de&&(de.H=de.H%12+de.p*12),de.m===void 0&&(de.m="q"in de?de.q:0),"V"in de){if(de.V<1||de.V>53)return null;"w"in de||(de.w=1),"Z"in de?($=tN(ix(de.y,0,1)),z=$.getUTCDay(),$=z>4||z===0?DS.ceil($):DS($),$=rM.offset($,(de.V-1)*7),de.y=$.getUTCFullYear(),de.m=$.getUTCMonth(),de.d=$.getUTCDate()+(de.w+6)%7):($=eN(ix(de.y,0,1)),z=$.getDay(),$=z>4||z===0?kS.ceil($):kS($),$=dv.offset($,(de.V-1)*7),de.y=$.getFullYear(),de.m=$.getMonth(),de.d=$.getDate()+(de.w+6)%7)}else("W"in de||"U"in de)&&("w"in de||(de.w="u"in de?de.u%7:"W"in de?1:0),z="Z"in de?tN(ix(de.y,0,1)).getUTCDay():eN(ix(de.y,0,1)).getDay(),de.m=0,de.d="W"in de?(de.w+6)%7+de.W*7-(z+5)%7:de.w+de.U*7-(z+6)%7);return"Z"in de?(de.H+=de.Z/100|0,de.M+=de.Z%100,tN(de)):eN(de)}}function j(he,we,Le,de){for(var lt=0,$=we.length,z=Le.length,ne,K;lt<$;){if(de>=z)return-1;if(ne=we.charCodeAt(lt++),ne===37){if(ne=we.charAt(lt++),K=T[ne in N$?we.charAt(lt++):ne],!K||(de=K(he,Le,de))<0)return-1}else if(ne!=Le.charCodeAt(de++))return-1}return de}function N(he,we,Le){var de=c.exec(we.slice(Le));return de?(he.p=u.get(de[0].toLowerCase()),Le+de[0].length):-1}function k(he,we,Le){var de=m.exec(we.slice(Le));return de?(he.w=b.get(de[0].toLowerCase()),Le+de[0].length):-1}function F(he,we,Le){var de=h.exec(we.slice(Le));return de?(he.w=g.get(de[0].toLowerCase()),Le+de[0].length):-1}function I(he,we,Le){var de=x.exec(we.slice(Le));return de?(he.m=M.get(de[0].toLowerCase()),Le+de[0].length):-1}function W(he,we,Le){var de=y.exec(we.slice(Le));return de?(he.m=v.get(de[0].toLowerCase()),Le+de[0].length):-1}function D(he,we,Le){return j(he,e,we,Le)}function B(he,we,Le){return j(he,n,we,Le)}function G(he,we,Le){return j(he,r,we,Le)}function V(he){return s[he.getDay()]}function Z(he){return a[he.getDay()]}function Y(he){return l[he.getMonth()]}function ee(he){return o[he.getMonth()]}function H(he){return i[+(he.getHours()>=12)]}function q(he){return 1+~~(he.getMonth()/3)}function ae(he){return s[he.getUTCDay()]}function ce(he){return a[he.getUTCDay()]}function xe(he){return l[he.getUTCMonth()]}function ie(he){return o[he.getUTCMonth()]}function ve(he){return i[+(he.getUTCHours()>=12)]}function Pe(he){return 1+~~(he.getUTCMonth()/3)}return{format:function(he){var we=R(he+="",w);return we.toString=function(){return he},we},parse:function(he){var we=A(he+="",!1);return we.toString=function(){return he},we},utcFormat:function(he){var we=R(he+="",C);return we.toString=function(){return he},we},utcParse:function(he){var we=A(he+="",!0);return we.toString=function(){return he},we}}}var N$={"-":"",_:" ",0:"0"},Ri=/^\s*\d+/,fIe=/^%/,hIe=/[\\^$*+?|[\]().{}]/g;function Tn(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 pIe(t){return t.replace(hIe,"\\$&")}function ax(t){return new RegExp("^(?:"+t.map(pIe).join("|")+")","i")}function sx(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function mIe(t,e,n){var r=Ri.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function gIe(t,e,n){var r=Ri.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function xIe(t,e,n){var r=Ri.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function vIe(t,e,n){var r=Ri.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function bIe(t,e,n){var r=Ri.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function R$(t,e,n){var r=Ri.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function P$(t,e,n){var r=Ri.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function yIe(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 _Ie(t,e,n){var r=Ri.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function SIe(t,e,n){var r=Ri.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function k$(t,e,n){var r=Ri.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function wIe(t,e,n){var r=Ri.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function D$(t,e,n){var r=Ri.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function MIe(t,e,n){var r=Ri.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function EIe(t,e,n){var r=Ri.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function AIe(t,e,n){var r=Ri.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function TIe(t,e,n){var r=Ri.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function CIe(t,e,n){var r=fIe.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function NIe(t,e,n){var r=Ri.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function RIe(t,e,n){var r=Ri.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function O$(t,e){return Tn(t.getDate(),e,2)}function PIe(t,e){return Tn(t.getHours(),e,2)}function kIe(t,e){return Tn(t.getHours()%12||12,e,2)}function DIe(t,e){return Tn(1+dv.count(wc(t),t),e,3)}function vZ(t,e){return Tn(t.getMilliseconds(),e,3)}function OIe(t,e){return vZ(t,e)+"000"}function LIe(t,e){return Tn(t.getMonth()+1,e,2)}function IIe(t,e){return Tn(t.getMinutes(),e,2)}function jIe(t,e){return Tn(t.getSeconds(),e,2)}function UIe(t){var e=t.getDay();return e===0?7:e}function FIe(t,e){return Tn(iM.count(wc(t)-1,t),e,2)}function bZ(t){var e=t.getDay();return e>=4||e===0?vm(t):vm.ceil(t)}function zIe(t,e){return t=bZ(t),Tn(vm.count(wc(t),t)+(wc(t).getDay()===4),e,2)}function BIe(t){return t.getDay()}function HIe(t,e){return Tn(kS.count(wc(t)-1,t),e,2)}function $Ie(t,e){return Tn(t.getFullYear()%100,e,2)}function VIe(t,e){return t=bZ(t),Tn(t.getFullYear()%100,e,2)}function GIe(t,e){return Tn(t.getFullYear()%1e4,e,4)}function WIe(t,e){var n=t.getDay();return t=n>=4||n===0?vm(t):vm.ceil(t),Tn(t.getFullYear()%1e4,e,4)}function qIe(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Tn(e/60|0,"0",2)+Tn(e%60,"0",2)}function L$(t,e){return Tn(t.getUTCDate(),e,2)}function XIe(t,e){return Tn(t.getUTCHours(),e,2)}function KIe(t,e){return Tn(t.getUTCHours()%12||12,e,2)}function YIe(t,e){return Tn(1+rM.count(Mc(t),t),e,3)}function yZ(t,e){return Tn(t.getUTCMilliseconds(),e,3)}function ZIe(t,e){return yZ(t,e)+"000"}function QIe(t,e){return Tn(t.getUTCMonth()+1,e,2)}function JIe(t,e){return Tn(t.getUTCMinutes(),e,2)}function eje(t,e){return Tn(t.getUTCSeconds(),e,2)}function tje(t){var e=t.getUTCDay();return e===0?7:e}function nje(t,e){return Tn(aM.count(Mc(t)-1,t),e,2)}function _Z(t){var e=t.getUTCDay();return e>=4||e===0?bm(t):bm.ceil(t)}function rje(t,e){return t=_Z(t),Tn(bm.count(Mc(t),t)+(Mc(t).getUTCDay()===4),e,2)}function ije(t){return t.getUTCDay()}function aje(t,e){return Tn(DS.count(Mc(t)-1,t),e,2)}function sje(t,e){return Tn(t.getUTCFullYear()%100,e,2)}function oje(t,e){return t=_Z(t),Tn(t.getUTCFullYear()%100,e,2)}function lje(t,e){return Tn(t.getUTCFullYear()%1e4,e,4)}function cje(t,e){var n=t.getUTCDay();return t=n>=4||n===0?bm(t):bm.ceil(t),Tn(t.getUTCFullYear()%1e4,e,4)}function uje(){return"+0000"}function I$(){return"%"}function j$(t){return+t}function U$(t){return Math.floor(+t/1e3)}var hp,SZ,wZ;dje({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 dje(t){return hp=dIe(t),SZ=hp.format,hp.parse,wZ=hp.utcFormat,hp.utcParse,hp}function fje(t){return new Date(t)}function hje(t){return t instanceof Date?+t:+new Date(+t)}function dO(t,e,n,r,i,a,s,o,l,c){var u=ZD(),h=u.invert,g=u.domain,m=c(".%L"),b=c(":%S"),y=c("%I:%M"),v=c("%I %p"),x=c("%a %d"),M=c("%b %d"),w=c("%B"),C=c("%Y");function T(R){return(l(R)<R?m:o(R)<R?b:s(R)<R?y:a(R)<R?v:r(R)<R?i(R)<R?x:M:n(R)<R?w:C)(R)}return u.invert=function(R){return new Date(h(R))},u.domain=function(R){return arguments.length?g(Array.from(R,hje)):g().map(fje)},u.ticks=function(R){var A=g();return t(A[0],A[A.length-1],R??10)},u.tickFormat=function(R,A){return A==null?T:c(A)},u.nice=function(R){var A=g();return(!R||typeof R.range!="function")&&(R=e(A[0],A[A.length-1],R??10)),R?g(cZ(A,R)):u},u.copy=function(){return uv(u,dO(t,e,n,r,i,a,s,o,l,c))},u}function pje(){return Qs.apply(dO(cIe,uIe,wc,cO,iM,dv,oO,aO,sf,SZ).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function mje(){return Qs.apply(dO(oIe,lIe,Mc,uO,aM,rM,lO,sO,sf,wZ).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function sM(){var t=0,e=1,n,r,i,a,s=xa,o=!1,l;function c(h){return h==null||isNaN(h=+h)?l:s(i===0?.5:(h=(a(h)-n)*i,o?Math.max(0,Math.min(1,h)):h))}c.domain=function(h){return arguments.length?([t,e]=h,n=a(t=+t),r=a(e=+e),i=n===r?0:1/(r-n),c):[t,e]},c.clamp=function(h){return arguments.length?(o=!!h,c):o},c.interpolator=function(h){return arguments.length?(s=h,c):s};function u(h){return function(g){var m,b;return arguments.length?([m,b]=g,s=h(m,b),c):[s(0),s(1)]}}return c.range=u(jm),c.rangeRound=u(YD),c.unknown=function(h){return arguments.length?(l=h,c):l},function(h){return a=h,n=h(t),r=h(e),i=n===r?0:1/(r-n),c}}function fd(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function MZ(){var t=dd(sM()(xa));return t.copy=function(){return fd(t,MZ())},Pc.apply(t,arguments)}function EZ(){var t=eO(sM()).domain([1,10]);return t.copy=function(){return fd(t,EZ()).base(t.base())},Pc.apply(t,arguments)}function AZ(){var t=tO(sM());return t.copy=function(){return fd(t,AZ()).constant(t.constant())},Pc.apply(t,arguments)}function fO(){var t=nO(sM());return t.copy=function(){return fd(t,fO()).exponent(t.exponent())},Pc.apply(t,arguments)}function gje(){return fO.apply(null,arguments).exponent(.5)}function TZ(){var t=[],e=xa;function n(r){if(r!=null&&!isNaN(r=+r))return e((lv(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(qu),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)=>tLe(t,a/r))},n.copy=function(){return TZ(e).domain(t)},Pc.apply(n,arguments)}function oM(){var t=0,e=.5,n=1,r=1,i,a,s,o,l,c=xa,u,h=!1,g;function m(y){return isNaN(y=+y)?g:(y=.5+((y=+u(y))-a)*(r*y<r*a?o:l),c(h?Math.max(0,Math.min(1,y)):y))}m.domain=function(y){return arguments.length?([t,e,n]=y,i=u(t=+t),a=u(e=+e),s=u(n=+n),o=i===a?0:.5/(a-i),l=a===s?0:.5/(s-a),r=a<i?-1:1,m):[t,e,n]},m.clamp=function(y){return arguments.length?(h=!!y,m):h},m.interpolator=function(y){return arguments.length?(c=y,m):c};function b(y){return function(v){var x,M,w;return arguments.length?([x,M,w]=v,c=CLe(y,[x,M,w]),m):[c(0),c(.5),c(1)]}}return m.range=b(jm),m.rangeRound=b(YD),m.unknown=function(y){return arguments.length?(g=y,m):g},function(y){return u=y,i=y(t),a=y(e),s=y(n),o=i===a?0:.5/(a-i),l=a===s?0:.5/(s-a),r=a<i?-1:1,m}}function CZ(){var t=dd(oM()(xa));return t.copy=function(){return fd(t,CZ())},Pc.apply(t,arguments)}function NZ(){var t=eO(oM()).domain([.1,1,10]);return t.copy=function(){return fd(t,NZ()).base(t.base())},Pc.apply(t,arguments)}function RZ(){var t=tO(oM());return t.copy=function(){return fd(t,RZ()).constant(t.constant())},Pc.apply(t,arguments)}function hO(){var t=nO(oM());return t.copy=function(){return fd(t,hO()).exponent(t.exponent())},Pc.apply(t,arguments)}function xje(){return hO.apply(null,arguments).exponent(.5)}const xx=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:qD,scaleDiverging:CZ,scaleDivergingLog:NZ,scaleDivergingPow:hO,scaleDivergingSqrt:xje,scaleDivergingSymlog:RZ,scaleIdentity:lZ,scaleImplicit:sP,scaleLinear:oZ,scaleLog:uZ,scaleOrdinal:WD,scalePoint:iLe,scalePow:rO,scaleQuantile:hZ,scaleQuantize:pZ,scaleRadial:fZ,scaleSequential:MZ,scaleSequentialLog:EZ,scaleSequentialPow:fO,scaleSequentialQuantile:TZ,scaleSequentialSqrt:gje,scaleSequentialSymlog:AZ,scaleSqrt:ZLe,scaleSymlog:dZ,scaleThreshold:mZ,scaleTime:pje,scaleUtc:mje,tickFormat:sZ},Symbol.toStringTag,{value:"Module"}));var hd=t=>t.chartData,pO=Ve([hd],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),lM=(t,e,n,r)=>r?pO(t):hd(t);function nd(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(or(e)&&or(n))return!0}return!1}function F$(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function PZ(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if(or(n))i=n;else if(typeof n=="function")return;if(or(r))a=r;else if(typeof r=="function")return;var s=[i,a];if(nd(s))return s}}function vje(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(nd(r))return F$(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,a]=t,s,o;if(i==="auto")e!=null&&(s=Math.min(...e));else if(Et(i))s=i;else if(typeof i=="function")try{e!=null&&(s=i(e?.[0]))}catch{}else if(typeof i=="string"&&hH.test(i)){var l=hH.exec(i);if(l==null||e==null)s=void 0;else{var c=+l[1];s=e[0]-c}}else s=e?.[0];if(a==="auto")e!=null&&(o=Math.max(...e));else if(Et(a))o=a;else if(typeof a=="function")try{e!=null&&(o=a(e?.[1]))}catch{}else if(typeof a=="string"&&pH.test(a)){var u=pH.exec(a);if(u==null||e==null)o=void 0;else{var h=+u[1];o=e[1]+h}}else o=e?.[1];var g=[s,o];if(nd(g))return e==null?g:F$(g,e,n)}}}var Um=1e9,bje={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},gO,dr=!0,Ys="[DecimalError] ",bf=Ys+"Invalid argument: ",mO=Ys+"Exponent out of range: ",Fm=Math.floor,Gd=Math.pow,yje=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,cs,wi=1e7,ar=7,kZ=9007199254740991,OS=Fm(kZ/ar),Tt={};Tt.absoluteValue=Tt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Tt.comparedTo=Tt.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};Tt.decimalPlaces=Tt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*ar;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Tt.dividedBy=Tt.div=function(t){return hc(this,new this.constructor(t))};Tt.dividedToIntegerBy=Tt.idiv=function(t){var e=this,n=e.constructor;return Zn(hc(e,new n(t),0,1),n.precision)};Tt.equals=Tt.eq=function(t){return!this.cmp(t)};Tt.exponent=function(){return Kr(this)};Tt.greaterThan=Tt.gt=function(t){return this.cmp(t)>0};Tt.greaterThanOrEqualTo=Tt.gte=function(t){return this.cmp(t)>=0};Tt.isInteger=Tt.isint=function(){return this.e>this.d.length-2};Tt.isNegative=Tt.isneg=function(){return this.s<0};Tt.isPositive=Tt.ispos=function(){return this.s>0};Tt.isZero=function(){return this.s===0};Tt.lessThan=Tt.lt=function(t){return this.cmp(t)<0};Tt.lessThanOrEqualTo=Tt.lte=function(t){return this.cmp(t)<1};Tt.logarithm=Tt.log=function(t){var e,n=this,r=n.constructor,i=r.precision,a=i+5;if(t===void 0)t=new r(10);else if(t=new r(t),t.s<1||t.eq(cs))throw Error(Ys+"NaN");if(n.s<1)throw Error(Ys+(n.s?"NaN":"-Infinity"));return n.eq(cs)?new r(0):(dr=!1,e=hc(k0(n,a),k0(t,a),a),dr=!0,Zn(e,i))};Tt.minus=Tt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?LZ(e,t):DZ(e,(t.s=-t.s,t))};Tt.modulo=Tt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(Ys+"NaN");return n.s?(dr=!1,e=hc(n,t,0,1).times(t),dr=!0,n.minus(e)):Zn(new r(n),i)};Tt.naturalExponential=Tt.exp=function(){return OZ(this)};Tt.naturalLogarithm=Tt.ln=function(){return k0(this)};Tt.negated=Tt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Tt.plus=Tt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?DZ(e,t):LZ(e,(t.s=-t.s,t))};Tt.precision=Tt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(bf+t);if(e=Kr(i)+1,r=i.d.length-1,n=r*ar+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};Tt.squareRoot=Tt.sqrt=function(){var t,e,n,r,i,a,s,o=this,l=o.constructor;if(o.s<1){if(!o.s)return new l(0);throw Error(Ys+"NaN")}for(t=Kr(o),dr=!1,i=Math.sqrt(+o),i==0||i==1/0?(e=Yo(o.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=Fm((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 l(e)):r=new l(i.toString()),n=l.precision,i=s=n+3;;)if(a=r,r=a.plus(hc(o,a,s+2)).times(.5),Yo(a.d).slice(0,s)===(e=Yo(r.d)).slice(0,s)){if(e=e.slice(s-3,s+1),i==s&&e=="4999"){if(Zn(a,n+1,0),a.times(a).eq(o)){r=a;break}}else if(e!="9999")break;s+=4}return dr=!0,Zn(r,n)};Tt.times=Tt.mul=function(t){var e,n,r,i,a,s,o,l,c,u=this,h=u.constructor,g=u.d,m=(t=new h(t)).d;if(!u.s||!t.s)return new h(0);for(t.s*=u.s,n=u.e+t.e,l=g.length,c=m.length,l<c&&(a=g,g=m,m=a,s=l,l=c,c=s),a=[],s=l+c,r=s;r--;)a.push(0);for(r=c;--r>=0;){for(e=0,i=l+r;i>r;)o=a[i]+m[r]*g[i-r-1]+e,a[i--]=o%wi|0,e=o/wi|0;a[i]=(a[i]+e)%wi|0}for(;!a[--s];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,dr?Zn(t,h.precision):t};Tt.toDecimalPlaces=Tt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(ul(t,0,Um),e===void 0?e=r.rounding:ul(e,0,8),Zn(n,t+Kr(n)+1,e))};Tt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=$f(r,!0):(ul(t,0,Um),e===void 0?e=i.rounding:ul(e,0,8),r=Zn(new i(r),t+1,e),n=$f(r,!0,t+1)),n};Tt.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?$f(i):(ul(t,0,Um),e===void 0?e=a.rounding:ul(e,0,8),r=Zn(new a(i),t+Kr(i)+1,e),n=$f(r.abs(),!1,t+Kr(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Tt.toInteger=Tt.toint=function(){var t=this,e=t.constructor;return Zn(new e(t),Kr(t)+1,e.rounding)};Tt.toNumber=function(){return+this};Tt.toPower=Tt.pow=function(t){var e,n,r,i,a,s,o=this,l=o.constructor,c=12,u=+(t=new l(t));if(!t.s)return new l(cs);if(o=new l(o),!o.s){if(t.s<1)throw Error(Ys+"Infinity");return o}if(o.eq(cs))return o;if(r=l.precision,t.eq(cs))return Zn(o,r);if(e=t.e,n=t.d.length-1,s=e>=n,a=o.s,s){if((n=u<0?-u:u)<=kZ){for(i=new l(cs),e=Math.ceil(r/ar+4),dr=!1;n%2&&(i=i.times(o),B$(i.d,e)),n=Fm(n/2),n!==0;)o=o.times(o),B$(o.d,e);return dr=!0,t.s<0?new l(cs).div(i):Zn(i,r)}}else if(a<0)throw Error(Ys+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,o.s=1,dr=!1,i=t.times(k0(o,r+c)),dr=!0,i=OZ(i),i.s=a,i};Tt.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=Kr(i),r=$f(i,n<=a.toExpNeg||n>=a.toExpPos)):(ul(t,1,Um),e===void 0?e=a.rounding:ul(e,0,8),i=Zn(new a(i),t,e),n=Kr(i),r=$f(i,t<=n||n<=a.toExpNeg,t)),r};Tt.toSignificantDigits=Tt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(ul(t,1,Um),e===void 0?e=r.rounding:ul(e,0,8)),Zn(new r(n),t,e)};Tt.toString=Tt.valueOf=Tt.val=Tt.toJSON=Tt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=Kr(t),n=t.constructor;return $f(t,e<=n.toExpNeg||e>=n.toExpPos)};function DZ(t,e){var n,r,i,a,s,o,l,c,u=t.constructor,h=u.precision;if(!t.s||!e.s)return e.s||(e=new u(t)),dr?Zn(e,h):e;if(l=t.d,c=e.d,s=t.e,i=e.e,l=l.slice(),a=s-i,a){for(a<0?(r=l,a=-a,o=c.length):(r=c,i=s,o=l.length),s=Math.ceil(h/ar),o=s>o?s+1:o+1,a>o&&(a=o,r.length=1),r.reverse();a--;)r.push(0);r.reverse()}for(o=l.length,a=c.length,o-a<0&&(a=o,r=c,c=l,l=r),n=0;a;)n=(l[--a]=l[a]+c[a]+n)/wi|0,l[a]%=wi;for(n&&(l.unshift(n),++i),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=i,dr?Zn(e,h):e}function ul(t,e,n){if(t!==~~t||t<e||t>n)throw Error(bf+t)}function Yo(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=ar-r.length,n&&(a+=Au(n)),a+=r;s=t[e],r=s+"",n=ar-r.length,n&&(a+=Au(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return a+s}var hc=(function(){function t(r,i){var a,s=0,o=r.length;for(r=r.slice();o--;)a=r[o]*i+s,r[o]=a%wi|0,s=a/wi|0;return s&&r.unshift(s),r}function e(r,i,a,s){var o,l;if(a!=s)l=a>s?1:-1;else for(o=l=0;o<a;o++)if(r[o]!=i[o]){l=r[o]>i[o]?1:-1;break}return l}function n(r,i,a){for(var s=0;a--;)r[a]-=s,s=r[a]<i[a]?1:0,r[a]=s*wi+r[a]-i[a];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,a,s){var o,l,c,u,h,g,m,b,y,v,x,M,w,C,T,R,A,j,N=r.constructor,k=r.s==i.s?1:-1,F=r.d,I=i.d;if(!r.s)return new N(r);if(!i.s)throw Error(Ys+"Division by zero");for(l=r.e-i.e,A=I.length,T=F.length,m=new N(k),b=m.d=[],c=0;I[c]==(F[c]||0);)++c;if(I[c]>(F[c]||0)&&--l,a==null?M=a=N.precision:s?M=a+(Kr(r)-Kr(i))+1:M=a,M<0)return new N(0);if(M=M/ar+2|0,c=0,A==1)for(u=0,I=I[0],M++;(c<T||u)&&M--;c++)w=u*wi+(F[c]||0),b[c]=w/I|0,u=w%I|0;else{for(u=wi/(I[0]+1)|0,u>1&&(I=t(I,u),F=t(F,u),A=I.length,T=F.length),C=A,y=F.slice(0,A),v=y.length;v<A;)y[v++]=0;j=I.slice(),j.unshift(0),R=I[0],I[1]>=wi/2&&++R;do u=0,o=e(I,y,A,v),o<0?(x=y[0],A!=v&&(x=x*wi+(y[1]||0)),u=x/R|0,u>1?(u>=wi&&(u=wi-1),h=t(I,u),g=h.length,v=y.length,o=e(h,y,g,v),o==1&&(u--,n(h,A<g?j:I,g))):(u==0&&(o=u=1),h=I.slice()),g=h.length,g<v&&h.unshift(0),n(y,h,v),o==-1&&(v=y.length,o=e(I,y,A,v),o<1&&(u++,n(y,A<v?j:I,v))),v=y.length):o===0&&(u++,y=[0]),b[c++]=u,o&&y[0]?y[v++]=F[C]||0:(y=[F[C]],v=1);while((C++<T||y[0]!==void 0)&&M--)}return b[0]||b.shift(),m.e=l,Zn(m,s?a+Kr(m)+1:a)}})();function OZ(t,e){var n,r,i,a,s,o,l=0,c=0,u=t.constructor,h=u.precision;if(Kr(t)>16)throw Error(mO+Kr(t));if(!t.s)return new u(cs);for(dr=!1,o=h,s=new u(.03125);t.abs().gte(.1);)t=t.times(s),c+=5;for(r=Math.log(Gd(2,c))/Math.LN10*2+5|0,o+=r,n=i=a=new u(cs),u.precision=o;;){if(i=Zn(i.times(t),o),n=n.times(++l),s=a.plus(hc(i,n,o)),Yo(s.d).slice(0,o)===Yo(a.d).slice(0,o)){for(;c--;)a=Zn(a.times(a),o);return u.precision=h,e==null?(dr=!0,Zn(a,h)):a}a=s}}function Kr(t){for(var e=t.e*ar,n=t.d[0];n>=10;n/=10)e++;return e}function nN(t,e,n){if(e>t.LN10.sd())throw dr=!0,n&&(t.precision=n),Error(Ys+"LN10 precision limit exceeded");return Zn(new t(t.LN10),e)}function Au(t){for(var e="";t--;)e+="0";return e}function k0(t,e){var n,r,i,a,s,o,l,c,u,h=1,g=10,m=t,b=m.d,y=m.constructor,v=y.precision;if(m.s<1)throw Error(Ys+(m.s?"NaN":"-Infinity"));if(m.eq(cs))return new y(0);if(e==null?(dr=!1,c=v):c=e,m.eq(10))return e==null&&(dr=!0),nN(y,c);if(c+=g,y.precision=c,n=Yo(b),r=n.charAt(0),a=Kr(m),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)m=m.times(t),n=Yo(m.d),r=n.charAt(0),h++;a=Kr(m),r>1?(m=new y("0."+n),a++):m=new y(r+"."+n.slice(1))}else return l=nN(y,c+2,v).times(a+""),m=k0(new y(r+"."+n.slice(1)),c-g).plus(l),y.precision=v,e==null?(dr=!0,Zn(m,v)):m;for(o=s=m=hc(m.minus(cs),m.plus(cs),c),u=Zn(m.times(m),c),i=3;;){if(s=Zn(s.times(u),c),l=o.plus(hc(s,new y(i),c)),Yo(l.d).slice(0,c)===Yo(o.d).slice(0,c))return o=o.times(2),a!==0&&(o=o.plus(nN(y,c+2,v).times(a+""))),o=hc(o,new y(h),c),y.precision=v,e==null?(dr=!0,Zn(o,v)):o;o=l,i+=2}}function z$(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=Fm(n/ar),t.d=[],r=(n+1)%ar,n<0&&(r+=ar),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=ar;r<i;)t.d.push(+e.slice(r,r+=ar));e=e.slice(r),r=ar-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),dr&&(t.e>OS||t.e<-OS))throw Error(mO+n)}else t.s=0,t.e=0,t.d=[0];return t}function Zn(t,e,n){var r,i,a,s,o,l,c,u,h=t.d;for(s=1,a=h[0];a>=10;a/=10)s++;if(r=e-s,r<0)r+=ar,i=e,c=h[u=0];else{if(u=Math.ceil((r+1)/ar),a=h.length,u>=a)return t;for(c=a=h[u],s=1;a>=10;a/=10)s++;r%=ar,i=r-ar+s}if(n!==void 0&&(a=Gd(10,s-i-1),o=c/a%10|0,l=e<0||h[u+1]!==void 0||c%a,l=n<4?(o||l)&&(n==0||n==(t.s<0?3:2)):o>5||o==5&&(n==4||l||n==6&&(r>0?i>0?c/Gd(10,s-i):0:h[u-1])%10&1||n==(t.s<0?8:7))),e<1||!h[0])return l?(a=Kr(t),h.length=1,e=e-a-1,h[0]=Gd(10,(ar-e%ar)%ar),t.e=Fm(-e/ar)||0):(h.length=1,h[0]=t.e=t.s=0),t;if(r==0?(h.length=u,a=1,u--):(h.length=u+1,a=Gd(10,ar-r),h[u]=i>0?(c/Gd(10,s-i)%Gd(10,i)|0)*a:0),l)for(;;)if(u==0){(h[0]+=a)==wi&&(h[0]=1,++t.e);break}else{if(h[u]+=a,h[u]!=wi)break;h[u--]=0,a=1}for(r=h.length;h[--r]===0;)h.pop();if(dr&&(t.e>OS||t.e<-OS))throw Error(mO+Kr(t));return t}function LZ(t,e){var n,r,i,a,s,o,l,c,u,h,g=t.constructor,m=g.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new g(t),dr?Zn(e,m):e;if(l=t.d,h=e.d,r=e.e,c=t.e,l=l.slice(),s=c-r,s){for(u=s<0,u?(n=l,s=-s,o=h.length):(n=h,r=c,o=l.length),i=Math.max(Math.ceil(m/ar),o)+2,s>i&&(s=i,n.length=1),n.reverse(),i=s;i--;)n.push(0);n.reverse()}else{for(i=l.length,o=h.length,u=i<o,u&&(o=i),i=0;i<o;i++)if(l[i]!=h[i]){u=l[i]<h[i];break}s=0}for(u&&(n=l,l=h,h=n,e.s=-e.s),o=l.length,i=h.length-o;i>0;--i)l[o++]=0;for(i=h.length;i>s;){if(l[--i]<h[i]){for(a=i;a&&l[--a]===0;)l[a]=wi-1;--l[a],l[i]+=wi}l[i]-=h[i]}for(;l[--o]===0;)l.pop();for(;l[0]===0;l.shift())--r;return l[0]?(e.d=l,e.e=r,dr?Zn(e,m):e):new g(0)}function $f(t,e,n){var r,i=Kr(t),a=Yo(t.d),s=a.length;return e?(n&&(r=n-s)>0?a=a.charAt(0)+"."+a.slice(1)+Au(r):s>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+Au(-i-1)+a,n&&(r=n-s)>0&&(a+=Au(r))):i>=s?(a+=Au(i+1-s),n&&(r=n-i-1)>0&&(a=a+"."+Au(r))):((r=i+1)<s&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-s)>0&&(i+1===s&&(a+="."),a+=Au(r))),t.s<0?"-"+a:a}function B$(t,e){if(t.length>e)return t.length=e,!0}function IZ(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(bf+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 z$(s,a.toString())}else if(typeof a!="string")throw Error(bf+a);if(a.charCodeAt(0)===45?(a=a.slice(1),s.s=-1):s.s=1,yje.test(a))z$(s,a);else throw Error(bf+a)}if(i.prototype=Tt,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=IZ,i.config=i.set=_je,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 _je(t){if(!t||typeof t!="object")throw Error(Ys+"Object expected");var e,n,r,i=["precision",1,Um,"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(Fm(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(bf+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(bf+n+": "+r);return this}var gO=IZ(bje);cs=new gO(1);const Ln=gO;var Sje=t=>t,jZ={},UZ=t=>t===jZ,H$=t=>function e(){return arguments.length===0||arguments.length===1&&UZ(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},FZ=(t,e)=>t===1?e:H$(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!==jZ).length;return a>=t?e(...r):FZ(t-a,H$(function(){for(var s=arguments.length,o=new Array(s),l=0;l<s;l++)o[l]=arguments[l];var c=r.map(u=>UZ(u)?o.shift():u);return e(...c,...o)}))}),wje=t=>FZ(t.length,t),uP=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},Mje=wje((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),Eje=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return Sje;var i=n.reverse(),a=i[0],s=i.slice(1);return function(){return s.reduce((o,l)=>l(o),a(...arguments))}},dP=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function zZ(t){var e;return t===0?e=1:e=Math.floor(new Ln(t).abs().log(10).toNumber())+1,e}function BZ(t,e,n){for(var r=new Ln(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var HZ=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},$Z=(t,e,n)=>{if(t.lte(0))return new Ln(0);var r=zZ(t.toNumber()),i=new Ln(10).pow(r),a=t.div(i),s=r!==1?.05:.1,o=new Ln(Math.ceil(a.div(s).toNumber())).add(n).mul(s),l=o.mul(i);return e?new Ln(l.toNumber()):new Ln(Math.ceil(l.toNumber()))},Aje=(t,e,n)=>{var r=new Ln(1),i=new Ln(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new Ln(10).pow(zZ(t)-1),i=new Ln(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new Ln(Math.floor(t)))}else t===0?i=new Ln(Math.floor((e-1)/2)):n||(i=new Ln(Math.floor(t)));var s=Math.floor((e-1)/2),o=Eje(Mje(l=>i.add(new Ln(l-s).mul(r)).toNumber()),uP);return o(0,e)},VZ=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 Ln(0),tickMin:new Ln(0),tickMax:new Ln(0)};var s=$Z(new Ln(n).sub(e).div(r-1),i,a),o;e<=0&&n>=0?o=new Ln(0):(o=new Ln(e).add(n).div(2),o=o.sub(new Ln(o).mod(s)));var l=Math.ceil(o.sub(e).div(s).toNumber()),c=Math.ceil(new Ln(n).sub(o).div(s).toNumber()),u=l+c+1;return u>r?VZ(e,n,r,i,a+1):(u<r&&(c=n>0?c+(r-u):c,l=n>0?l:l+(r-u)),{step:s,tickMin:o.sub(new Ln(l).mul(s)),tickMax:o.add(new Ln(c).mul(s))})},Tje=function(e){var[n,r]=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=Math.max(i,2),[o,l]=HZ([n,r]);if(o===-1/0||l===1/0){var c=l===1/0?[o,...uP(0,i-1).map(()=>1/0)]:[...uP(0,i-1).map(()=>-1/0),l];return n>r?dP(c):c}if(o===l)return Aje(o,i,a);var{step:u,tickMin:h,tickMax:g}=VZ(o,l,s,a,0),m=BZ(h,g.add(new Ln(.1).mul(u)),u);return n>r?dP(m):m},Cje=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[s,o]=HZ([r,i]);if(s===-1/0||o===1/0)return[r,i];if(s===o)return[s];var l=Math.max(n,2),c=$Z(new Ln(o).sub(s).div(l-1),a,0),u=[...BZ(new Ln(s),new Ln(o),c),o];return a===!1&&(u=u.map(h=>Math.round(h))),r>i?dP(u):u},GZ=t=>t.rootProps.maxBarSize,Nje=t=>t.rootProps.barGap,WZ=t=>t.rootProps.barCategoryGap,Rje=t=>t.rootProps.barSize,fv=t=>t.rootProps.stackOffset,qZ=t=>t.rootProps.reverseStackOrder,xO=t=>t.options.chartName,vO=t=>t.rootProps.syncId,XZ=t=>t.rootProps.syncMethod,bO=t=>t.options.eventEmitter,Pje=t=>t.rootProps.baseValue,qr={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Ql={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},as={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},cM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},kje={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Ql.angleAxisId,includeHidden:!1,name:void 0,reversed:Ql.reversed,scale:Ql.scale,tick:Ql.tick,tickCount:void 0,ticks:void 0,type:Ql.type,unit:void 0},Dje={allowDataOverflow:as.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:as.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:as.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:as.scale,tick:as.tick,tickCount:as.tickCount,ticks:void 0,type:as.type,unit:void 0},Oje={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:Ql.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Ql.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:Ql.scale,tick:Ql.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},Lje={allowDataOverflow:as.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:as.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:as.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:as.scale,tick:as.tick,tickCount:as.tickCount,ticks:void 0,type:"category",unit:void 0},yO=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?Oje:kje,_O=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?Lje:Dje,uM=t=>t.polarOptions,SO=Ve([Nc,Rc,ui],WY),KZ=Ve([uM,SO],(t,e)=>{if(t!=null)return aa(t.innerRadius,e,0)}),YZ=Ve([uM,SO],(t,e)=>{if(t!=null)return aa(t.outerRadius,e,e*.8)}),Ije=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},ZZ=Ve([uM],Ije);Ve([yO,ZZ],cM);var QZ=Ve([SO,KZ,YZ],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});Ve([_O,QZ],cM);var JZ=Ve([Sn,uM,KZ,YZ,Nc,Rc],(t,e,n,r,i,a)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:s,cy:o,startAngle:l,endAngle:c}=e;return{cx:aa(s,i,i/2),cy:aa(o,a,a/2),innerRadius:n,outerRadius:r,startAngle:l,endAngle:c,clockWise:!1}}}),hr=(t,e)=>e,hv=(t,e,n)=>n;function dM(t){return t?.id}function eQ(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:a}=n,s=new Map;return t.forEach(o=>{var l,c=(l=o.data)!==null&&l!==void 0?l:r;if(!(c==null||c.length===0)){var u=dM(o);c.forEach((h,g)=>{var m=a==null||i?g:String(Yn(h,a,null)),b=Yn(h,o.dataKey,0),y;s.has(m)?y=s.get(m):y={},Object.assign(y,{[u]:b}),s.set(m,y)})}}),Array.from(s.values())}function fM(t){return t.stackId!=null&&t.dataKey!=null}var hM=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function pM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function jje(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 fi=t=>{var e=Sn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},zm=t=>t.tooltip.settings.axisId;function $$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function LS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$$(Object(n),!0).forEach(function(r){Uje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Uje(t,e,n){return(e=Fje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Fje(t){var e=zje(t,"string");return typeof e=="symbol"?e:e+""}function zje(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 fP=[0,"auto"],_i={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},tQ=(t,e)=>t.cartesianAxis.xAxis[e],kc=(t,e)=>{var n=tQ(t,e);return n??_i},Si={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:fP,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:iv},nQ=(t,e)=>t.cartesianAxis.yAxis[e],Dc=(t,e)=>{var n=nQ(t,e);return n??Si},Bje={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:""},wO=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??Bje},br=(t,e,n)=>{switch(e){case"xAxis":return kc(t,n);case"yAxis":return Dc(t,n);case"zAxis":return wO(t,n);case"angleAxis":return yO(t,n);case"radiusAxis":return _O(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},Hje=(t,e,n)=>{switch(e){case"xAxis":return kc(t,n);case"yAxis":return Dc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},pv=(t,e,n)=>{switch(e){case"xAxis":return kc(t,n);case"yAxis":return Dc(t,n);case"angleAxis":return yO(t,n);case"radiusAxis":return _O(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},rQ=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function MO(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 mM=t=>t.graphicalItems.cartesianItems,$je=Ve([hr,hv],MO),EO=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),mv=Ve([mM,br,$je],EO,{memoizeOptions:{resultEqualityCheck:pM}}),iQ=Ve([mv],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(fM)),aQ=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),Vje=Ve([mv],aQ),AO=t=>t.map(e=>e.data).filter(Boolean).flat(1),Gje=Ve([mv],AO,{memoizeOptions:{resultEqualityCheck:pM}}),TO=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},CO=Ve([Gje,lM],TO),NO=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:Yn(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:Yn(i,r)}))):t.map(r=>({value:r})),gM=Ve([CO,br,mv],NO);function sQ(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function I_(t){if(ll(t)||t instanceof Date){var e=Number(t);if(or(e))return e}}function V$(t){if(Array.isArray(t)){var e=[I_(t[0]),I_(t[1])];return nd(e)?e:void 0}var n=I_(t);if(n!=null)return[n,n]}function Ec(t){return t.map(I_).filter(V3e)}function Wje(t,e,n){return!n||typeof e!="number"||Xs(e)?[]:n.length?Ec(n.flatMap(r=>{var i=Yn(t,r.dataKey),a,s;if(Array.isArray(i)?[a,s]=i:a=s=i,!(!or(a)||!or(s)))return[e-a,e+s]})):[]}var hi=t=>{var e=fi(t),n=zm(t);return pv(t,e,n)},gv=Ve([hi],t=>t?.dataKey),qje=Ve([iQ,lM,hi],eQ),oQ=(t,e,n,r)=>{var i={},a=e.reduce((s,o)=>(o.stackId==null||(s[o.stackId]==null&&(s[o.stackId]=[]),s[o.stackId].push(o)),s),i);return Object.fromEntries(Object.entries(a).map(s=>{var[o,l]=s,c=r?[...l].reverse():l,u=c.map(dM);return[o,{stackedData:fke(t,u,n),graphicalItems:c}]}))},D0=Ve([qje,iQ,fv,qZ],oQ),lQ=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var s=gke(t,i,a);if(!(s!=null&&s[0]===0&&s[1]===0))return s}},Xje=Ve([br],t=>t.allowDataOverflow),RO=t=>{var e;if(t==null||!("domain"in t))return fP;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=Ec(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:fP},PO=Ve([br],RO),kO=Ve([PO,Xje],PZ),Kje=Ve([D0,hd,hr,kO],lQ,{memoizeOptions:{resultEqualityCheck:hM}}),xM=t=>t.errorBars,Yje=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>sQ(n,r)),IS=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=n.filter(Boolean);if(i.length!==0){var a=i.flat(),s=Math.min(...a),o=Math.max(...a);return[s,o]}},DO=(t,e,n,r,i)=>{var a,s;if(n.length>0&&t.forEach(o=>{n.forEach(l=>{var c,u,h=(c=r[l.id])===null||c===void 0?void 0:c.filter(x=>sQ(i,x)),g=Yn(o,(u=e.dataKey)!==null&&u!==void 0?u:l.dataKey),m=Wje(o,g,h);if(m.length>=2){var b=Math.min(...m),y=Math.max(...m);(a==null||b<a)&&(a=b),(s==null||y>s)&&(s=y)}var v=V$(g);v!=null&&(a=a==null?v[0]:Math.min(a,v[0]),s=s==null?v[1]:Math.max(s,v[1]))})}),e?.dataKey!=null&&t.forEach(o=>{var l=V$(Yn(o,e.dataKey));l!=null&&(a=a==null?l[0]:Math.min(a,l[0]),s=s==null?l[1]:Math.max(s,l[1]))}),or(a)&&or(s))return[a,s]},Zje=Ve([CO,br,Vje,xM,hr],DO,{memoizeOptions:{resultEqualityCheck:hM}});function Qje(t){var{value:e}=t;if(ll(e)||e instanceof Date)return e}var Jje=(t,e,n)=>{var r=t.map(Qje).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&wK(r))?YY(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},cQ=t=>t.referenceElements.dots,Bm=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),e4e=Ve([cQ,hr,hv],Bm),uQ=t=>t.referenceElements.areas,t4e=Ve([uQ,hr,hv],Bm),dQ=t=>t.referenceElements.lines,n4e=Ve([dQ,hr,hv],Bm),fQ=(t,e)=>{var n=Ec(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},r4e=Ve(e4e,hr,fQ),hQ=(t,e)=>{var n=Ec(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)]},i4e=Ve([t4e,hr],hQ);function a4e(t){var e;if(t.x!=null)return Ec([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:Ec(n)}function s4e(t){var e;if(t.y!=null)return Ec([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:Ec(n)}var pQ=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?a4e(r):s4e(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},o4e=Ve([n4e,hr],pQ),l4e=Ve(r4e,o4e,i4e,(t,e,n)=>IS(t,n,e)),OO=(t,e,n,r,i,a,s,o)=>{if(n!=null)return n;var l=s==="vertical"&&o==="xAxis"||s==="horizontal"&&o==="yAxis",c=l?IS(r,a,i):IS(a,i);return vje(e,c,t.allowDataOverflow)},c4e=Ve([br,PO,kO,Kje,Zje,l4e,Sn,hr],OO,{memoizeOptions:{resultEqualityCheck:hM}}),u4e=[0,1],LO=(t,e,n,r,i,a,s)=>{if(!((t==null||n==null||n.length===0)&&s===void 0)){var{dataKey:o,type:l}=t,c=Cc(e,a);if(c&&o==null){var u;return YY(0,(u=n?.length)!==null&&u!==void 0?u:0)}return l==="category"?Jje(r,t,c):i==="expand"?u4e:s}},IO=Ve([br,Sn,CO,gM,fv,hr,c4e],LO),mQ=(t,e,n,r,i)=>{if(t!=null){var{scale:a,type:s}=t;if(a==="auto")return e==="radial"&&i==="radiusAxis"?"band":e==="radial"&&i==="angleAxis"?"linear":s==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":s==="category"?"band":"linear";if(typeof a=="string"){var o="scale".concat(Q0(a));return o in xx?o:"point"}}},Hm=Ve([br,Sn,rQ,xO,hr],mQ);function d4e(t){if(t!=null){if(t in xx)return xx[t]();var e="scale".concat(Q0(t));if(e in xx)return xx[e]()}}function jO(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=d4e(e);if(i!=null){var a=i.domain(n).range(r);return oke(a),a}}}var UO=(t,e,n)=>{var r=RO(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&nd(t))return Tje(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&nd(t))return Cje(t,e.tickCount,e.allowDecimals)}},FO=Ve([IO,pv,Hm],UO),zO=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&nd(e)&&Array.isArray(n)&&n.length>0){var i=e[0],a=n[0],s=e[1],o=n[n.length-1];return[Math.min(i,a),Math.max(s,o)]}return e},f4e=Ve([br,IO,FO,hr],zO),h4e=Ve(gM,br,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(Ec(t.map(o=>o.value))).sort((o,l)=>o-l);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}}),gQ=Ve(h4e,Sn,WZ,ui,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!or(t))return 0;var a=e==="vertical"?r.height:r.width;if(i==="gap")return t*a/2;if(i==="no-gap"){var s=aa(n,t*a),o=t*a/2;return o-s-(o-s)/a*s}return 0}),p4e=(t,e)=>{var n=kc(t,e);return n==null||typeof n.padding!="string"?0:gQ(t,"xAxis",e,n.padding)},m4e=(t,e)=>{var n=Dc(t,e);return n==null||typeof n.padding!="string"?0:gQ(t,"yAxis",e,n.padding)},g4e=Ve(kc,p4e,(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}}),x4e=Ve(Dc,m4e,(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}}),v4e=Ve([ui,g4e,Yw,Kw,(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]}),b4e=Ve([ui,Sn,x4e,Yw,Kw,(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]}),xv=(t,e,n,r)=>{var i;switch(e){case"xAxis":return v4e(t,n,r);case"yAxis":return b4e(t,n,r);case"zAxis":return(i=wO(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return ZZ(t);case"radiusAxis":return QZ(t,n);default:return}},xQ=Ve([br,xv],cM),$m=Ve([br,Hm,f4e,xQ],jO);Ve([mv,xM,hr],Yje);function vQ(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var vM=(t,e)=>e,bM=(t,e,n)=>n,y4e=Ve(qw,vM,bM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(vQ)),_4e=Ve(Xw,vM,bM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(vQ)),bQ=(t,e)=>({width:t.width,height:e.height}),S4e=(t,e)=>{var n=typeof e.width=="number"?e.width:iv;return{width:n,height:t.height}},yQ=Ve(ui,kc,bQ),w4e=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},M4e=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},E4e=Ve(Rc,ui,y4e,vM,bM,(t,e,n,r,i)=>{var a={},s;return n.forEach(o=>{var l=bQ(e,o);s==null&&(s=w4e(e,r,t));var c=r==="top"&&!i||r==="bottom"&&i;a[o.id]=s-Number(c)*l.height,s+=(c?-1:1)*l.height}),a}),A4e=Ve(Nc,ui,_4e,vM,bM,(t,e,n,r,i)=>{var a={},s;return n.forEach(o=>{var l=S4e(e,o);s==null&&(s=M4e(e,r,t));var c=r==="left"&&!i||r==="right"&&i;a[o.id]=s-Number(c)*l.width,s+=(c?-1:1)*l.width}),a}),T4e=(t,e)=>{var n=kc(t,e);if(n!=null)return E4e(t,n.orientation,n.mirror)},C4e=Ve([ui,kc,T4e,(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}}}),N4e=(t,e)=>{var n=Dc(t,e);if(n!=null)return A4e(t,n.orientation,n.mirror)},R4e=Ve([ui,Dc,N4e,(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}}}),_Q=Ve(ui,Dc,(t,e)=>{var n=typeof e.width=="number"?e.width:iv;return{width:n,height:t.height}}),G$=(t,e,n)=>{switch(e){case"xAxis":return yQ(t,n).width;case"yAxis":return _Q(t,n).height;default:return}},SQ=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:s}=n,o=Cc(t,r),l=e.map(c=>c.value);if(s&&o&&a==="category"&&i&&wK(l))return l}},BO=Ve([Sn,gM,br,hr],SQ),wQ=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,s=Cc(t,r);if(s&&(i==="number"||a!=="auto"))return e.map(o=>o.value)}},HO=Ve([Sn,gM,pv,hr],wQ),W$=Ve([Sn,Hje,Hm,$m,BO,HO,xv,FO,hr],(t,e,n,r,i,a,s,o,l)=>{if(e!=null){var c=Cc(t,l);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:l,categoricalDomain:a,duplicateDomain:i,isCategorical:c,niceTicks:o,range:s,realScaleType:n,scale:r}}}),P4e=(t,e,n,r,i,a,s,o,l)=>{if(!(e==null||r==null)){var c=Cc(t,l),{type:u,ticks:h,tickCount:g}=e,m=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,b=u==="category"&&r.bandwidth?r.bandwidth()/m:0;b=l==="angleAxis"&&a!=null&&a.length>=2?Ai(a[0]-a[1])*2*b:b;var y=h||i;if(y){var v=y.map((x,M)=>{var w=s?s.indexOf(x):x;return{index:M,coordinate:r(w)+b,value:x,offset:b}});return v.filter(x=>or(x.coordinate))}return c&&o?o.map((x,M)=>({coordinate:r(x)+b,value:x,index:M,offset:b})).filter(x=>or(x.coordinate)):r.ticks?r.ticks(g).map(x=>({coordinate:r(x)+b,value:x,offset:b})):r.domain().map((x,M)=>({coordinate:r(x)+b,value:s?s[x]:x,index:M,offset:b}))}},MQ=Ve([Sn,pv,Hm,$m,FO,xv,BO,HO,hr],P4e),k4e=(t,e,n,r,i,a,s)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var o=Cc(t,s),{tickCount:l}=e,c=0;return c=s==="angleAxis"&&r?.length>=2?Ai(r[0]-r[1])*2*c:c,o&&a?a.map((u,h)=>({coordinate:n(u)+c,value:u,index:h,offset:c})):n.ticks?n.ticks(l).map(u=>({coordinate:n(u)+c,value:u,offset:c})):n.domain().map((u,h)=>({coordinate:n(u)+c,value:i?i[u]:u,index:h,offset:c}))}},rd=Ve([Sn,pv,$m,xv,BO,HO,hr],k4e),id=Ve(br,$m,(t,e)=>{if(!(t==null||e==null))return LS(LS({},t),{},{scale:e})}),D4e=Ve([br,Hm,IO,xQ],jO);Ve((t,e,n)=>wO(t,n),D4e,(t,e)=>{if(!(t==null||e==null))return LS(LS({},t),{},{scale:e})});var O4e=Ve([Sn,qw,Xw],(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}}),EQ=t=>t.options.defaultTooltipEventType,AQ=t=>t.options.validateTooltipEventTypes;function TQ(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function $O(t,e){var n=EQ(t),r=AQ(t);return TQ(e,n,r)}function L4e(t){return At(e=>$O(e,t))}var CQ=(t,e)=>{var n,r=Number(e);if(!(Xs(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},I4e=t=>t.tooltip.settings,Pu={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},j4e={itemInteraction:{click:Pu,hover:Pu},axisInteraction:{click:Pu,hover:Pu},keyboardInteraction:Pu,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}},NQ=Ga({name:"tooltip",initialState:j4e,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:cr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=_o(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:cr()},removeTooltipEntrySettings:{reducer(t,e){var n=_o(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:cr()},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:U4e,replaceTooltipEntrySettings:F4e,removeTooltipEntrySettings:z4e,setTooltipSettingsState:B4e,setActiveMouseOverItemIndex:RQ,mouseLeaveItem:H4e,mouseLeaveChart:PQ,setActiveClickItemIndex:$4e,setMouseOverAxisIndex:kQ,setMouseClickAxisIndex:V4e,setSyncInteraction:hP,setKeyboardInteraction:pP}=NQ.actions,G4e=NQ.reducer;function q$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function c_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?q$(Object(n),!0).forEach(function(r){W4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):q$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function W4e(t,e,n){return(e=q4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function q4e(t){var e=X4e(t,"string");return typeof e=="symbol"?e:e+""}function X4e(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 K4e(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function Y4e(t){return t.index!=null}var DQ=(t,e,n,r)=>{if(e==null)return Pu;var i=K4e(t,e,n);if(i==null)return Pu;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(Y4e(i)){if(a)return c_(c_({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return c_(c_({},Pu),{},{coordinate:i.coordinate})};function Z4e(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 Q4e(t,e){var n=Z4e(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 J4e(t,e,n){if(n==null||e==null)return!0;var r=Yn(t,e);return r==null||!nd(n)?!0:Q4e(r,n)}var VO=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!or(a))return i;var s=0,o=1/0;e.length>0&&(o=e.length-1);var l=Math.max(s,Math.min(a,o)),c=e[l];return c==null||J4e(c,n,r)?String(l):null},OQ=(t,e,n,r,i,a,s,o)=>{if(!(a==null||o==null)){var l=s[0],c=l==null?void 0:o(l.positions,a);if(c!=null)return c;var u=i?.[Number(a)];if(u)switch(n){case"horizontal":return{x:u.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:u.coordinate}}}},LQ=(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})},vv=t=>t.options.tooltipPayloadSearcher,Vm=t=>t.tooltip;function X$(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 K$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?X$(Object(n),!0).forEach(function(r){eUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):X$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function eUe(t,e,n){return(e=tUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function tUe(t){var e=nUe(t,"string");return typeof e=="symbol"?e:e+""}function nUe(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 rUe(t,e){return t??e}var IQ=(t,e,n,r,i,a,s)=>{if(!(e==null||a==null)){var{chartData:o,computedData:l,dataStartIndex:c,dataEndIndex:u}=n,h=[];return t.reduce((g,m)=>{var b,{dataDefinedOnItem:y,settings:v}=m,x=rUe(y,o),M=Array.isArray(x)?xY(x,c,u):x,w=(b=v?.dataKey)!==null&&b!==void 0?b:r,C=v?.nameKey,T;if(r&&Array.isArray(M)&&!Array.isArray(M[0])&&s==="axis"?T=MK(M,r,i):T=a(M,e,l,C),Array.isArray(T))T.forEach(A=>{var j=K$(K$({},v),{},{name:A.name,unit:A.unit,color:void 0,fill:void 0});g.push(mH({tooltipEntrySettings:j,dataKey:A.dataKey,payload:A.payload,value:Yn(A.payload,A.dataKey),name:A.name}))});else{var R;g.push(mH({tooltipEntrySettings:v,dataKey:w,payload:T,value:Yn(T,w),name:(R=Yn(T,C))!==null&&R!==void 0?R:v?.name}))}return g},h)}},GO=Ve([hi,Sn,rQ,xO,fi],mQ),iUe=Ve([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),aUe=Ve([fi,zm],MO),bv=Ve([iUe,hi,aUe],EO,{memoizeOptions:{resultEqualityCheck:pM}}),sUe=Ve([bv],t=>t.filter(fM)),oUe=Ve([bv],AO,{memoizeOptions:{resultEqualityCheck:pM}}),Gm=Ve([oUe,hd],TO),lUe=Ve([sUe,hd,hi],eQ),WO=Ve([Gm,hi,bv],NO),jQ=Ve([hi],RO),cUe=Ve([hi],t=>t.allowDataOverflow),UQ=Ve([jQ,cUe],PZ),uUe=Ve([bv],t=>t.filter(fM)),dUe=Ve([lUe,uUe,fv,qZ],oQ),fUe=Ve([dUe,hd,fi,UQ],lQ),hUe=Ve([bv],aQ),pUe=Ve([Gm,hi,hUe,xM,fi],DO,{memoizeOptions:{resultEqualityCheck:hM}}),mUe=Ve([cQ,fi,zm],Bm),gUe=Ve([mUe,fi],fQ),xUe=Ve([uQ,fi,zm],Bm),vUe=Ve([xUe,fi],hQ),bUe=Ve([dQ,fi,zm],Bm),yUe=Ve([bUe,fi],pQ),_Ue=Ve([gUe,yUe,vUe],IS),SUe=Ve([hi,jQ,UQ,fUe,pUe,_Ue,Sn,fi],OO),yv=Ve([hi,Sn,Gm,WO,fv,fi,SUe],LO),wUe=Ve([yv,hi,GO],UO),MUe=Ve([hi,yv,wUe,fi],zO),FQ=t=>{var e=fi(t),n=zm(t),r=!1;return xv(t,e,n,r)},zQ=Ve([hi,FQ],cM),BQ=Ve([hi,GO,MUe,zQ],jO),EUe=Ve([Sn,WO,hi,fi],SQ),AUe=Ve([Sn,WO,hi,fi],wQ),TUe=(t,e,n,r,i,a,s,o)=>{if(e){var{type:l}=e,c=Cc(t,o);if(r){var u=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,h=l==="category"&&r.bandwidth?r.bandwidth()/u:0;return h=o==="angleAxis"&&i!=null&&i?.length>=2?Ai(i[0]-i[1])*2*h:h,c&&s?s.map((g,m)=>({coordinate:r(g)+h,value:g,index:m,offset:h})):r.domain().map((g,m)=>({coordinate:r(g)+h,value:a?a[g]:g,index:m,offset:h}))}}},Oc=Ve([Sn,hi,GO,BQ,FQ,EUe,AUe,fi],TUe),qO=Ve([EQ,AQ,I4e],(t,e,n)=>TQ(n.shared,t,e)),HQ=t=>t.tooltip.settings.trigger,XO=t=>t.tooltip.settings.defaultIndex,_v=Ve([Vm,qO,HQ,XO],DQ),ad=Ve([_v,Gm,gv,yv],VO),$Q=Ve([Oc,ad],CQ),KO=Ve([_v],t=>{if(t)return t.dataKey}),CUe=Ve([_v],t=>{if(t)return t.graphicalItemId}),VQ=Ve([Vm,qO,HQ,XO],LQ),NUe=Ve([Nc,Rc,Sn,ui,Oc,XO,VQ,vv],OQ),RUe=Ve([_v,NUe],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),PUe=Ve([_v],t=>t.active),kUe=Ve([VQ,ad,hd,gv,$Q,vv,qO],IQ),DUe=Ve([kUe],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function Y$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Z$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Y$(Object(n),!0).forEach(function(r){OUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Y$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function OUe(t,e,n){return(e=LUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LUe(t){var e=IUe(t,"string");return typeof e=="symbol"?e:e+""}function IUe(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 jUe=()=>At(hi),UUe=()=>{var t=jUe(),e=At(Oc),n=At(BQ);return pm(!t||!n?void 0:Z$(Z$({},t),{},{scale:n}),e)};function Q$(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 pp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Q$(Object(n),!0).forEach(function(r){FUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Q$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function FUe(t,e,n){return(e=zUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function zUe(t){var e=BUe(t,"string");return typeof e=="symbol"?e:e+""}function BUe(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 HUe=(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}},$Ue=(t,e,n,r)=>{var i=e.find(c=>c&&c.index===n);if(i){if(t==="centric"){var a=i.coordinate,{radius:s}=r;return pp(pp(pp({},r),Wr(r.cx,r.cy,s,a)),{},{angle:a,radius:s})}var o=i.coordinate,{angle:l}=r;return pp(pp(pp({},r),Wr(r.cx,r.cy,o,l)),{},{angle:l,radius:o})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function VUe(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 GQ=(t,e,n,r,i)=>{var a,s=-1,o=(a=e?.length)!==null&&a!==void 0?a:0;if(o<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var l=0;l<o;l++){var c=l>0?n[l-1].coordinate:n[o-1].coordinate,u=n[l].coordinate,h=l>=o-1?n[0].coordinate:n[l+1].coordinate,g=void 0;if(Ai(u-c)!==Ai(h-u)){var m=[];if(Ai(h-u)===Ai(i[1]-i[0])){g=h;var b=u+i[1]-i[0];m[0]=Math.min(b,(b+c)/2),m[1]=Math.max(b,(b+c)/2)}else{g=c;var y=h+i[1]-i[0];m[0]=Math.min(u,(y+u)/2),m[1]=Math.max(u,(y+u)/2)}var v=[Math.min(u,(g+u)/2),Math.max(u,(g+u)/2)];if(t>v[0]&&t<=v[1]||t>=m[0]&&t<=m[1]){({index:s}=n[l]);break}}else{var x=Math.min(c,h),M=Math.max(c,h);if(t>(x+u)/2&&t<=(M+u)/2){({index:s}=n[l]);break}}}else if(e){for(var w=0;w<o;w++)if(w===0&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w>0&&w<o-1&&t>(e[w].coordinate+e[w-1].coordinate)/2&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w===o-1&&t>(e[w].coordinate+e[w-1].coordinate)/2){({index:s}=e[w]);break}}return s},WQ=()=>At(xO),YO=(t,e)=>e,qQ=(t,e,n)=>n,ZO=(t,e,n,r)=>r,GUe=Ve(Oc,t=>Uw(t,e=>e.coordinate)),QO=Ve([Vm,YO,qQ,ZO],DQ),JO=Ve([QO,Gm,gv,yv],VO),WUe=(t,e,n)=>{if(e!=null){var r=Vm(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},XQ=Ve([Vm,YO,qQ,ZO],LQ),jS=Ve([Nc,Rc,Sn,ui,Oc,ZO,XQ,vv],OQ),qUe=Ve([QO,jS],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),KQ=Ve([Oc,JO],CQ),XUe=Ve([XQ,JO,hd,gv,KQ,vv,YO],IQ),KUe=Ve([QO,JO],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),YUe=(t,e,n,r,i,a,s)=>{if(!(!t||!n||!r||!i)&&VUe(t,s)){var o=xke(t,e),l=GQ(o,a,i,n,r),c=HUe(e,i,l,t);return{activeIndex:String(l),activeCoordinate:c}}},ZUe=(t,e,n,r,i,a,s)=>{if(!(!t||!r||!i||!a||!n)){var o=OOe(t,n);if(o){var l=vke(o,e),c=GQ(l,s,a,r,i),u=$Ue(e,a,c,o);return{activeIndex:String(c),activeCoordinate:u}}}},QUe=(t,e,n,r,i,a,s,o)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?YUe(t,e,r,i,a,s,o):ZUe(t,e,n,r,i,a,s)},JUe=Ve(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}}),eFe=Ve(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(qr)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:jje}});function J$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function eV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?J$(Object(n),!0).forEach(function(r){tFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):J$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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)}var iFe={},aFe={zIndexMap:Object.values(qr).reduce((t,e)=>eV(eV({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),iFe)},sFe=new Set(Object.values(qr));function oFe(t){return sFe.has(t)}var YQ=Ga({name:"zIndex",initialState:aFe,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:cr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!oFe(n)&&delete t.zIndexMap[n])},prepare:cr()},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:cr()},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:cr()}}}),{registerZIndexPortal:lFe,unregisterZIndexPortal:cFe,registerZIndexPortalId:uFe,unregisterZIndexPortalId:dFe}=YQ.actions,fFe=YQ.reducer;function Wa(t){var{zIndex:e,children:n}=t,r=Yke(),i=r&&e!==void 0&&e!==0,a=ca(),s=er();E.useLayoutEffect(()=>i?(s(lFe({zIndex:e})),()=>{s(cFe({zIndex:e}))}):J0,[s,e,i]);var o=At(c=>JUe(c,e,a));if(!i)return n;if(!o)return null;var l=document.getElementById(o);return l?ec.createPortal(n,l):null}function mP(){return mP=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},mP.apply(null,arguments)}function tV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function u_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?tV(Object(n),!0).forEach(function(r){hFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):tV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function hFe(t,e,n){return(e=pFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pFe(t){var e=mFe(t,"string");return typeof e=="symbol"?e:e+""}function mFe(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 gFe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return E.isValidElement(e)?E.cloneElement(e,r):E.createElement(n,r)}function xFe(t){var e,{coordinate:n,payload:r,index:i,offset:a,tooltipAxisBandSize:s,layout:o,cursor:l,tooltipEventType:c,chartName:u}=t,h=n,g=r,m=i;if(!l||!h||u!=="ScatterChart"&&c!=="axis")return null;var b,y,v;if(u==="ScatterChart")b=h,y=KDe,v=qr.cursorLine;else if(u==="BarChart")b=YDe(o,h,a,s),y=GY,v=qr.cursorRectangle;else if(o==="radial"&&AK(h)){var{cx:x,cy:M,radius:w,startAngle:C,endAngle:T}=qY(h);b={cx:x,cy:M,startAngle:C,endAngle:T,innerRadius:w,outerRadius:w},y=KY,v=qr.cursorLine}else b={points:UOe(o,h,a)},y=Bp,v=qr.cursorLine;var R=typeof l=="object"&&"className"in l?l.className:void 0,A=u_(u_(u_(u_({stroke:"#ccc",pointerEvents:"none"},a),b),Ff(l)),{},{payload:g,payloadIndex:m,className:An("recharts-tooltip-cursor",R)});return E.createElement(Wa,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:v},E.createElement(gFe,{cursor:l,cursorComp:y,cursorProps:A}))}function vFe(t){var e=UUe(),n=CY(),r=Lm(),i=WQ();return e==null||n==null||r==null||i==null?null:E.createElement(xFe,mP({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var ZQ=E.createContext(null),bFe=()=>E.useContext(ZQ),rN={exports:{}},nV;function yFe(){return nV||(nV=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(l,c,u){this.fn=l,this.context=c,this.once=u||!1}function a(l,c,u,h,g){if(typeof u!="function")throw new TypeError("The listener must be a function");var m=new i(u,h||l,g),b=n?n+c:c;return l._events[b]?l._events[b].fn?l._events[b]=[l._events[b],m]:l._events[b].push(m):(l._events[b]=m,l._eventsCount++),l}function s(l,c){--l._eventsCount===0?l._events=new r:delete l._events[c]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],u,h;if(this._eventsCount===0)return c;for(h in u=this._events)e.call(u,h)&&c.push(n?h.slice(1):h);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(u)):c},o.prototype.listeners=function(c){var u=n?n+c:c,h=this._events[u];if(!h)return[];if(h.fn)return[h.fn];for(var g=0,m=h.length,b=new Array(m);g<m;g++)b[g]=h[g].fn;return b},o.prototype.listenerCount=function(c){var u=n?n+c:c,h=this._events[u];return h?h.fn?1:h.length:0},o.prototype.emit=function(c,u,h,g,m,b){var y=n?n+c:c;if(!this._events[y])return!1;var v=this._events[y],x=arguments.length,M,w;if(v.fn){switch(v.once&&this.removeListener(c,v.fn,void 0,!0),x){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,u),!0;case 3:return v.fn.call(v.context,u,h),!0;case 4:return v.fn.call(v.context,u,h,g),!0;case 5:return v.fn.call(v.context,u,h,g,m),!0;case 6:return v.fn.call(v.context,u,h,g,m,b),!0}for(w=1,M=new Array(x-1);w<x;w++)M[w-1]=arguments[w];v.fn.apply(v.context,M)}else{var C=v.length,T;for(w=0;w<C;w++)switch(v[w].once&&this.removeListener(c,v[w].fn,void 0,!0),x){case 1:v[w].fn.call(v[w].context);break;case 2:v[w].fn.call(v[w].context,u);break;case 3:v[w].fn.call(v[w].context,u,h);break;case 4:v[w].fn.call(v[w].context,u,h,g);break;default:if(!M)for(T=1,M=new Array(x-1);T<x;T++)M[T-1]=arguments[T];v[w].fn.apply(v[w].context,M)}}return!0},o.prototype.on=function(c,u,h){return a(this,c,u,h,!1)},o.prototype.once=function(c,u,h){return a(this,c,u,h,!0)},o.prototype.removeListener=function(c,u,h,g){var m=n?n+c:c;if(!this._events[m])return this;if(!u)return s(this,m),this;var b=this._events[m];if(b.fn)b.fn===u&&(!g||b.once)&&(!h||b.context===h)&&s(this,m);else{for(var y=0,v=[],x=b.length;y<x;y++)(b[y].fn!==u||g&&!b[y].once||h&&b[y].context!==h)&&v.push(b[y]);v.length?this._events[m]=v.length===1?v[0]:v:s(this,m)}return this},o.prototype.removeAllListeners=function(c){var u;return c?(u=n?n+c:c,this._events[u]&&s(this,u)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=n,o.EventEmitter=o,t.exports=o})(rN)),rN.exports}var _Fe=yFe();const SFe=Zs(_Fe);var O0=new SFe,gP="recharts.syncEvent.tooltip",rV="recharts.syncEvent.brush";function eL(t,e){if(e){var n=Number.parseInt(e,10);if(!Xs(n))return t?.[n]}}var wFe={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},QQ=Ga({name:"options",initialState:wFe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),MFe=QQ.reducer,{createEventEmitter:EFe}=QQ.actions;function AFe(t){return t.tooltip.syncInteraction}var TFe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},JQ=Ga({name:"chartData",initialState:TFe,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:iV,setDataStartEndIndexes:CFe,setComputedData:qGe}=JQ.actions,NFe=JQ.reducer,RFe=["x","y"];function aV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function mp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?aV(Object(n),!0).forEach(function(r){PFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):aV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function PFe(t,e,n){return(e=kFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function kFe(t){var e=DFe(t,"string");return typeof e=="symbol"?e:e+""}function DFe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function OFe(t,e){if(t==null)return{};var n,r,i=LFe(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 LFe(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 IFe(){var t=At(vO),e=At(bO),n=er(),r=At(XZ),i=At(Oc),a=Lm(),s=Zw(),o=At(l=>l.rootProps.className);E.useEffect(()=>{if(t==null)return J0;var l=(c,u,h)=>{if(e!==h&&t===c){if(r==="index"){var g;if(s&&u!==null&&u!==void 0&&(g=u.payload)!==null&&g!==void 0&&g.coordinate&&u.payload.sourceViewBox){var m=u.payload.coordinate,{x:b,y}=m,v=OFe(m,RFe),{x,y:M,width:w,height:C}=u.payload.sourceViewBox,T=mp(mp({},v),{},{x:s.x+(w?(b-x)/w:0)*s.width,y:s.y+(C?(y-M)/C:0)*s.height});n(mp(mp({},u),{},{payload:mp(mp({},u.payload),{},{coordinate:T})}))}else n(u);return}if(i!=null){var R;if(typeof r=="function"){var A={activeTooltipIndex:u.payload.index==null?void 0:Number(u.payload.index),isTooltipActive:u.payload.active,activeIndex:u.payload.index==null?void 0:Number(u.payload.index),activeLabel:u.payload.label,activeDataKey:u.payload.dataKey,activeCoordinate:u.payload.coordinate},j=r(i,A);R=i[j]}else r==="value"&&(R=i.find(G=>String(G.value)===u.payload.label));var{coordinate:N}=u.payload;if(R==null||u.payload.active===!1||N==null||s==null){n(hP({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:k,y:F}=N,I=Math.min(k,s.x+s.width),W=Math.min(F,s.y+s.height),D={x:a==="horizontal"?R.coordinate:I,y:a==="horizontal"?W:R.coordinate},B=hP({active:u.payload.active,coordinate:D,dataKey:u.payload.dataKey,index:String(R.index),label:u.payload.label,sourceViewBox:u.payload.sourceViewBox,graphicalItemId:u.payload.graphicalItemId});n(B)}}};return O0.on(gP,l),()=>{O0.off(gP,l)}},[o,n,e,t,r,i,a,s])}function jFe(){var t=At(vO),e=At(bO),n=er();E.useEffect(()=>{if(t==null)return J0;var r=(i,a,s)=>{e!==s&&t===i&&n(CFe(a))};return O0.on(rV,r),()=>{O0.off(rV,r)}},[n,e,t])}function UFe(){var t=er();E.useEffect(()=>{t(EFe())},[t]),IFe(),jFe()}function FFe(t,e,n,r,i,a){var s=At(m=>WUe(m,t,e)),o=At(bO),l=At(vO),c=At(XZ),u=At(AFe),h=u?.active,g=Zw();E.useEffect(()=>{if(!h&&l!=null&&o!=null){var m=hP({active:a,coordinate:n,dataKey:s,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:g,graphicalItemId:void 0});O0.emit(gP,l,m,o)}},[h,n,s,i,r,o,l,c,a,g])}function sV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function oV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?sV(Object(n),!0).forEach(function(r){zFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):sV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zFe(t,e,n){return(e=BFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function BFe(t){var e=HFe(t,"string");return typeof e=="symbol"?e:e+""}function HFe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function $Fe(t){return t.dataKey}function VFe(t,e){return E.isValidElement(t)?E.cloneElement(t,e):typeof t=="function"?E.createElement(t,e):E.createElement(CDe,e)}var lV=[],GFe={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 iN(t){var e,n,r=Zr(t,GFe),{active:i,allowEscapeViewBox:a,animationDuration:s,animationEasing:o,content:l,filterNull:c,isAnimationActive:u,offset:h,payloadUniqBy:g,position:m,reverseDirection:b,useTranslate3d:y,wrapperStyle:v,cursor:x,shared:M,trigger:w,defaultIndex:C,portal:T,axisId:R}=r,A=er(),j=typeof C=="number"?String(C):C;E.useEffect(()=>{A(B4e({shared:M,trigger:w,axisId:R,active:i,defaultIndex:j}))},[A,M,w,R,i,j]);var N=Zw(),k=zY(),F=L4e(M),{activeIndex:I,isActive:W}=(e=At(ve=>KUe(ve,F,w,j)))!==null&&e!==void 0?e:{},D=At(ve=>XUe(ve,F,w,j)),B=At(ve=>KQ(ve,F,w,j)),G=At(ve=>qUe(ve,F,w,j)),V=D,Z=bFe(),Y=(n=i??W)!==null&&n!==void 0?n:!1,[ee,H]=BK([V,Y]),q=F==="axis"?B:void 0;FFe(F,w,G,q,I,Y);var ae=T??Z;if(ae==null||N==null||F==null)return null;var ce=V??lV;Y||(ce=lV),c&&ce.length&&(ce=IK(ce.filter(ve=>ve.value!=null&&(ve.hide!==!0||r.includeHidden)),g,$Fe));var xe=ce.length>0,ie=E.createElement(LDe,{allowEscapeViewBox:a,animationDuration:s,animationEasing:o,isAnimationActive:u,active:Y,coordinate:G,hasPayload:xe,offset:h,position:m,reverseDirection:b,useTranslate3d:y,viewBox:N,wrapperStyle:v,lastBoundingBox:ee,innerRef:H,hasPortalFromProps:!!T},VFe(l,oV(oV({},r),{},{payload:ce,label:q,active:Y,activeIndex:I,coordinate:G,accessibilityLayer:k})));return E.createElement(E.Fragment,null,ec.createPortal(ie,ae),Y&&E.createElement(vFe,{cursor:x,tooltipEventType:F,coordinate:G,payload:ce,index:I}))}var Sv=t=>null;Sv.displayName="Cell";function WFe(t,e,n){return(e=qFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qFe(t){var e=XFe(t,"string");return typeof e=="symbol"?e:e+""}function XFe(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 KFe{constructor(e){WFe(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 cV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function YFe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?cV(Object(n),!0).forEach(function(r){ZFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):cV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ZFe(t,e,n){return(e=QFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function QFe(t){var e=JFe(t,"string");return typeof e=="symbol"?e:e+""}function JFe(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 eze={cacheSize:2e3,enableCache:!0},eJ=YFe({},eze),uV=new KFe(eJ.cacheSize),tze={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},dV="recharts_measurement_span";function nze(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",a=e.fontStyle||"",s=e.letterSpacing||"",o=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(a,"|").concat(s,"|").concat(o)}var fV=(t,e)=>{try{var n=document.getElementById(dV);n||(n=document.createElement("span"),n.setAttribute("id",dV),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,tze,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},Bx=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Im.isSsr)return{width:0,height:0};if(!eJ.enableCache)return fV(e,n);var r=nze(e,n),i=uV.get(r);if(i)return i;var a=fV(e,n);return uV.set(r,a),a},hV=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,pV=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,rze=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,ize=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,tJ={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},aze=Object.keys(tJ),Cp="NaN";function sze(t,e){return t*tJ[e]}class Da{static parse(e){var n,[,r,i]=(n=ize.exec(e))!==null&&n!==void 0?n:[];return new Da(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,Xs(e)&&(this.unit=""),n!==""&&!rze.test(n)&&(this.num=NaN,this.unit=""),aze.includes(n)&&(this.num=sze(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new Da(NaN,""):new Da(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new Da(NaN,""):new Da(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Da(NaN,""):new Da(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Da(NaN,""):new Da(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return Xs(this.num)}}function nJ(t){if(t.includes(Cp))return Cp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=hV.exec(e))!==null&&n!==void 0?n:[],s=Da.parse(r??""),o=Da.parse(a??""),l=i==="*"?s.multiply(o):s.divide(o);if(l.isNaN())return Cp;e=e.replace(hV,l.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var c,[,u,h,g]=(c=pV.exec(e))!==null&&c!==void 0?c:[],m=Da.parse(u??""),b=Da.parse(g??""),y=h==="+"?m.add(b):m.subtract(b);if(y.isNaN())return Cp;e=e.replace(pV,y.toString())}return e}var mV=/\(([^()]*)\)/;function oze(t){for(var e=t,n;(n=mV.exec(e))!=null;){var[,r]=n;e=e.replace(mV,nJ(r))}return e}function lze(t){var e=t.replace(/\s+/g,"");return e=oze(e),e=nJ(e),e}function cze(t){try{return lze(t)}catch{return Cp}}function aN(t){var e=cze(t.slice(5,-1));return e===Cp?"":e}var uze=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],dze=["dx","dy","angle","className","breakAll"];function xP(){return xP=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},xP.apply(null,arguments)}function gV(t,e){if(t==null)return{};var n,r,i=fze(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 fze(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 rJ=/[ \f\n\r\t\v\u2028\u2029]+/,iJ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];xr(e)||(n?i=e.toString().split(""):i=e.toString().split(rJ));var a=i.map(o=>({word:o,width:Bx(o,r).width})),s=n?0:Bx(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:s}}catch{return null}};function hze(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var aJ=(t,e,n,r)=>t.reduce((i,a)=>{var{word:s,width:o}=a,l=i[i.length-1];if(l&&o!=null&&(e==null||r||l.width+o+n<Number(e)))l.words.push(s),l.width+=o+n;else{var c={words:[s],width:o};i.push(c)}return i},[]),sJ=t=>t.reduce((e,n)=>e.width>n.width?e:n),pze="…",xV=(t,e,n,r,i,a,s,o)=>{var l=t.slice(0,e),c=iJ({breakAll:n,style:r,children:l+pze});if(!c)return[!1,[]];var u=aJ(c.wordsWithComputedWidth,a,s,o),h=u.length>i||sJ(u).width>Number(a);return[h,u]},mze=(t,e,n,r,i)=>{var{maxLines:a,children:s,style:o,breakAll:l}=t,c=Et(a),u=String(s),h=aJ(e,r,n,i);if(!c||i)return h;var g=h.length>a||sJ(h).width>Number(r);if(!g)return h;for(var m=0,b=u.length-1,y=0,v;m<=b&&y<=u.length-1;){var x=Math.floor((m+b)/2),M=x-1,[w,C]=xV(u,M,l,o,a,r,n,i),[T]=xV(u,x,l,o,a,r,n,i);if(!w&&!T&&(m=x+1),w&&T&&(b=x-1),!w&&T){v=C;break}y++}return v||h},vV=t=>{var e=xr(t)?[]:t.toString().split(rJ);return[{words:e,width:void 0}]},gze=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:s}=t;if((e||n)&&!Im.isSsr){var o,l,c=iJ({breakAll:a,children:r,style:i});if(c){var{wordsWithComputedWidth:u,spaceWidth:h}=c;o=u,l=h}else return vV(r);return mze({breakAll:a,children:r,maxLines:s,style:i},o,l,e,!!n)}return vV(r)},oJ="#808080",xze={angle:0,breakAll:!1,capHeight:"0.71em",fill:oJ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},yM=E.forwardRef((t,e)=>{var n=Zr(t,xze),{x:r,y:i,lineHeight:a,capHeight:s,fill:o,scaleToFit:l,textAnchor:c,verticalAnchor:u}=n,h=gV(n,uze),g=E.useMemo(()=>gze({breakAll:h.breakAll,children:h.children,maxLines:h.maxLines,scaleToFit:l,style:h.style,width:h.width}),[h.breakAll,h.children,h.maxLines,l,h.style,h.width]),{dx:m,dy:b,angle:y,className:v,breakAll:x}=h,M=gV(h,dze);if(!ll(r)||!ll(i)||g.length===0)return null;var w=Number(r)+(Et(m)?m:0),C=Number(i)+(Et(b)?b:0);if(!or(w)||!or(C))return null;var T;switch(u){case"start":T=aN("calc(".concat(s,")"));break;case"middle":T=aN("calc(".concat((g.length-1)/2," * -").concat(a," + (").concat(s," / 2))"));break;default:T=aN("calc(".concat(g.length-1," * -").concat(a,")"));break}var R=[];if(l){var A=g[0].width,{width:j}=h;R.push("scale(".concat(Et(j)&&Et(A)?j/A:1,")"))}return y&&R.push("rotate(".concat(y,", ").concat(w,", ").concat(C,")")),R.length&&(M.transform=R.join(" ")),E.createElement("text",xP({},Sa(M),{ref:e,x:w,y:C,className:An("recharts-text",v),textAnchor:c,fill:o.includes("url")?oJ:o}),g.map((N,k)=>{var F=N.words.join(x?"":" ");return E.createElement("tspan",{x:w,dy:k===0?T:a,key:"".concat(F,"-").concat(k)},F)}))});yM.displayName="Text";var vze=["labelRef"];function bze(t,e){if(t==null)return{};var n,r,i=yze(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 yze(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 bV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function kr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?bV(Object(n),!0).forEach(function(r){_ze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):bV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _ze(t,e,n){return(e=Sze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Sze(t){var e=wze(t,"string");return typeof e=="symbol"?e:e+""}function wze(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 Jl(){return Jl=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},Jl.apply(null,arguments)}var lJ=E.createContext(null),Mze=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:s,children:o}=t,l=E.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:s}),[e,n,r,i,a,s]);return E.createElement(lJ.Provider,{value:l},o)},cJ=()=>{var t=E.useContext(lJ),e=Zw();return t||TY(e)},Eze=E.createContext(null),Aze=()=>{var t=E.useContext(Eze),e=At(JZ);return t||e},Tze=t=>{var{value:e,formatter:n}=t,r=xr(t.children)?e:t.children;return typeof n=="function"?n(r):r},tL=t=>t!=null&&typeof t=="function",Cze=(t,e)=>{var n=Ai(e-t),r=Math.min(Math.abs(e-t),360);return n*r},Nze=(t,e,n,r,i)=>{var{offset:a,className:s}=t,{cx:o,cy:l,innerRadius:c,outerRadius:u,startAngle:h,endAngle:g,clockWise:m}=i,b=(c+u)/2,y=Cze(h,g),v=y>=0?1:-1,x,M;switch(e){case"insideStart":x=h+v*a,M=m;break;case"insideEnd":x=g-v*a,M=!m;break;case"end":x=g+v*a,M=m;break;default:throw new Error("Unsupported position ".concat(e))}M=y<=0?M:!M;var w=Wr(o,l,b,x),C=Wr(o,l,b,x+(M?1:-1)*359),T="M".concat(w.x,",").concat(w.y,`
  8225. A`).concat(b,",").concat(b,",0,1,").concat(M?0:1,`,
  8226. `).concat(C.x,",").concat(C.y),R=xr(t.id)?y0("recharts-radial-line-"):t.id;return E.createElement("text",Jl({},r,{dominantBaseline:"central",className:An("recharts-radial-bar-label",s)}),E.createElement("defs",null,E.createElement("path",{id:R,d:T})),E.createElement("textPath",{xlinkHref:"#".concat(R)},n))},Rze=(t,e,n)=>{var{cx:r,cy:i,innerRadius:a,outerRadius:s,startAngle:o,endAngle:l}=t,c=(o+l)/2;if(n==="outside"){var{x:u,y:h}=Wr(r,i,s+e,c);return{x:u,y:h,textAnchor:u>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var g=(a+s)/2,{x:m,y:b}=Wr(r,i,g,c);return{x:m,y:b,textAnchor:"middle",verticalAnchor:"middle"}},vP=t=>"cx"in t&&Et(t.cx),Pze=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,a;n!=null&&!vP(n)&&(a=n);var{x:s,y:o,upperWidth:l,lowerWidth:c,height:u}=e,h=s,g=s+(l-c)/2,m=(h+g)/2,b=(l+c)/2,y=h+l/2,v=u>=0?1:-1,x=v*r,M=v>0?"end":"start",w=v>0?"start":"end",C=l>=0?1:-1,T=C*r,R=C>0?"end":"start",A=C>0?"start":"end";if(i==="top"){var j={x:h+l/2,y:o-x,textAnchor:"middle",verticalAnchor:M};return kr(kr({},j),a?{height:Math.max(o-a.y,0),width:l}:{})}if(i==="bottom"){var N={x:g+c/2,y:o+u+x,textAnchor:"middle",verticalAnchor:w};return kr(kr({},N),a?{height:Math.max(a.y+a.height-(o+u),0),width:c}:{})}if(i==="left"){var k={x:m-T,y:o+u/2,textAnchor:R,verticalAnchor:"middle"};return kr(kr({},k),a?{width:Math.max(k.x-a.x,0),height:u}:{})}if(i==="right"){var F={x:m+b+T,y:o+u/2,textAnchor:A,verticalAnchor:"middle"};return kr(kr({},F),a?{width:Math.max(a.x+a.width-F.x,0),height:u}:{})}var I=a?{width:b,height:u}:{};return i==="insideLeft"?kr({x:m+T,y:o+u/2,textAnchor:A,verticalAnchor:"middle"},I):i==="insideRight"?kr({x:m+b-T,y:o+u/2,textAnchor:R,verticalAnchor:"middle"},I):i==="insideTop"?kr({x:h+l/2,y:o+x,textAnchor:"middle",verticalAnchor:w},I):i==="insideBottom"?kr({x:g+c/2,y:o+u-x,textAnchor:"middle",verticalAnchor:M},I):i==="insideTopLeft"?kr({x:h+T,y:o+x,textAnchor:A,verticalAnchor:w},I):i==="insideTopRight"?kr({x:h+l-T,y:o+x,textAnchor:R,verticalAnchor:w},I):i==="insideBottomLeft"?kr({x:g+T,y:o+u-x,textAnchor:A,verticalAnchor:M},I):i==="insideBottomRight"?kr({x:g+c-T,y:o+u-x,textAnchor:R,verticalAnchor:M},I):i&&typeof i=="object"&&(Et(i.x)||yc(i.x))&&(Et(i.y)||yc(i.y))?kr({x:s+aa(i.x,b),y:o+aa(i.y,u),textAnchor:"end",verticalAnchor:"end"},I):kr({x:y,y:o+u/2,textAnchor:"middle",verticalAnchor:"middle"},I)},kze={angle:0,offset:5,zIndex:qr.label,position:"middle",textBreakAll:!1};function Tu(t){var e=Zr(t,kze),{viewBox:n,position:r,value:i,children:a,content:s,className:o="",textBreakAll:l,labelRef:c}=e,u=Aze(),h=cJ(),g=r==="center"?h:u??h,m,b,y;if(n==null?m=g:vP(n)?m=n:m=TY(n),!m||xr(i)&&xr(a)&&!E.isValidElement(s)&&typeof s!="function")return null;var v=kr(kr({},e),{},{viewBox:m});if(E.isValidElement(s)){var{labelRef:x}=v,M=bze(v,vze);return E.cloneElement(s,M)}if(typeof s=="function"){if(b=E.createElement(s,v),E.isValidElement(b))return b}else b=Tze(e);var w=Sa(e);if(vP(m)){if(r==="insideStart"||r==="insideEnd"||r==="end")return Nze(e,r,b,w,m);y=Rze(m,e.offset,e.position)}else y=Pze(e,m);return E.createElement(Wa,{zIndex:e.zIndex},E.createElement(yM,Jl({ref:c,className:An("recharts-label",o)},w,y,{textAnchor:hze(w.textAnchor)?w.textAnchor:y.textAnchor,breakAll:l}),b))}Tu.displayName="Label";var Dze=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?E.createElement(Tu,Jl({key:"label-implicit"},r)):ll(t)?E.createElement(Tu,Jl({key:"label-implicit",value:t},r)):E.isValidElement(t)?t.type===Tu?E.cloneElement(t,kr({key:"label-implicit"},r)):E.createElement(Tu,Jl({key:"label-implicit",content:t},r)):tL(t)?E.createElement(Tu,Jl({key:"label-implicit",content:t},r)):t&&typeof t=="object"?E.createElement(Tu,Jl({},t,{key:"label-implicit"},r)):null};function Oze(t){var{label:e,labelRef:n}=t,r=cJ();return Dze(e,r,n)||null}var sN={},oN={},yV;function Lze(){return yV||(yV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(oN)),oN}var lN={},_V;function Ize(){return _V||(_V=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(lN)),lN}var SV;function jze(){return SV||(SV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Lze(),n=Ize(),r=ND();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(sN)),sN}var cN,wV;function Uze(){return wV||(wV=1,cN=jze().last),cN}var Fze=Uze();const zze=Zs(Fze);var Bze=["valueAccessor"],Hze=["dataKey","clockWise","id","textBreakAll","zIndex"];function US(){return US=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},US.apply(null,arguments)}function MV(t,e){if(t==null)return{};var n,r,i=$ze(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 $ze(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 Vze=t=>Array.isArray(t.value)?zze(t.value):t.value,uJ=E.createContext(void 0),dJ=uJ.Provider,fJ=E.createContext(void 0),Gze=fJ.Provider;function Wze(){return E.useContext(uJ)}function qze(){return E.useContext(fJ)}function j_(t){var{valueAccessor:e=Vze}=t,n=MV(t,Bze),{dataKey:r,clockWise:i,id:a,textBreakAll:s,zIndex:o}=n,l=MV(n,Hze),c=Wze(),u=qze(),h=c||u;return!h||!h.length?null:E.createElement(Wa,{zIndex:o??qr.label},E.createElement(Lr,{className:"recharts-label-list"},h.map((g,m)=>{var b,y=xr(r)?e(g,m):Yn(g&&g.payload,r),v=xr(a)?{}:{id:"".concat(a,"-").concat(m)};return E.createElement(Tu,US({key:"label-".concat(m)},Sa(g),l,v,{fill:(b=n.fill)!==null&&b!==void 0?b:g.fill,parentViewBox:g.parentViewBox,value:y,textBreakAll:s,viewBox:g.viewBox,index:m,zIndex:0}))})))}j_.displayName="LabelList";function nL(t){var{label:e}=t;return e?e===!0?E.createElement(j_,{key:"labelList-implicit"}):E.isValidElement(e)||tL(e)?E.createElement(j_,{key:"labelList-implicit",content:e}):typeof e=="object"?E.createElement(j_,US({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function bP(){return bP=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},bP.apply(null,arguments)}var hJ=t=>{var{cx:e,cy:n,r,className:i}=t,a=An("recharts-dot",i);return Et(e)&&Et(n)&&Et(r)?E.createElement("circle",bP({},Ha(t),CD(t),{className:a,cx:e,cy:n,r})):null},pJ=t=>t.graphicalItems.polarItems,Xze=Ve([hr,hv],MO),_M=Ve([pJ,br,Xze],EO),Kze=Ve([_M],AO),SM=Ve([Kze,pO],TO),Yze=Ve([SM,br,_M],NO);Ve([SM,br,_M],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,s=Yn(r,(a=e.dataKey)!==null&&a!==void 0?a:i.dataKey);return{value:s,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:Yn(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var EV=()=>{},Zze=Ve([SM,br,_M,xM,hr],DO),Qze=Ve([br,PO,kO,EV,Zze,EV,Sn,hr],OO),mJ=Ve([br,Sn,SM,Yze,fv,hr,Qze],LO),Jze=Ve([mJ,br,Hm],UO);Ve([br,mJ,Jze,hr],zO);var e5e={radiusAxis:{},angleAxis:{}},gJ=Ga({name:"polarAxis",initialState:e5e,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:XGe,removeRadiusAxis:KGe,addAngleAxis:YGe,removeAngleAxis:ZGe}=gJ.actions,t5e=gJ.reducer;function AV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function TV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?AV(Object(n),!0).forEach(function(r){n5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):AV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function n5e(t,e,n){return(e=r5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function r5e(t){var e=i5e(t,"string");return typeof e=="symbol"?e:e+""}function i5e(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 a5e=(t,e)=>e,rL=Ve([pJ,a5e],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),s5e=[],iL=(t,e,n)=>n?.length===0?s5e:n,xJ=Ve([pO,rL,iL],(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=>TV(TV({},e.presentationProps),a.props))),i!=null)return i}}),o5e=Ve([xJ,rL,iL],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,s=Yn(r,e.nameKey,e.name),o;return n!=null&&(a=n[i])!==null&&a!==void 0&&(a=a.props)!==null&&a!==void 0&&a.fill?o=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?o=r.fill:o=e.fill,{value:Om(s,e.dataKey),color:o,payload:r,type:e.legendType}})}),l5e=Ve([xJ,rL,iL,ui],(t,e,n,r)=>{if(!(e==null||t==null))return cBe({offset:r,pieSettings:e,displayedData:t,cells:n})}),uN={exports:{}},zn={};var CV;function c5e(){if(CV)return zn;CV=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),s=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),u=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),g=Symbol.for("react.view_transition"),m=Symbol.for("react.client.reference");function b(y){if(typeof y=="object"&&y!==null){var v=y.$$typeof;switch(v){case t:switch(y=y.type,y){case n:case i:case r:case l:case c:case g:return y;default:switch(y=y&&y.$$typeof,y){case s:case o:case h:case u:return y;case a:return y;default:return v}}case e:return v}}}return zn.ContextConsumer=a,zn.ContextProvider=s,zn.Element=t,zn.ForwardRef=o,zn.Fragment=n,zn.Lazy=h,zn.Memo=u,zn.Portal=e,zn.Profiler=i,zn.StrictMode=r,zn.Suspense=l,zn.SuspenseList=c,zn.isContextConsumer=function(y){return b(y)===a},zn.isContextProvider=function(y){return b(y)===s},zn.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},zn.isForwardRef=function(y){return b(y)===o},zn.isFragment=function(y){return b(y)===n},zn.isLazy=function(y){return b(y)===h},zn.isMemo=function(y){return b(y)===u},zn.isPortal=function(y){return b(y)===e},zn.isProfiler=function(y){return b(y)===i},zn.isStrictMode=function(y){return b(y)===r},zn.isSuspense=function(y){return b(y)===l},zn.isSuspenseList=function(y){return b(y)===c},zn.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===n||y===i||y===r||y===l||y===c||typeof y=="object"&&y!==null&&(y.$$typeof===h||y.$$typeof===u||y.$$typeof===s||y.$$typeof===a||y.$$typeof===o||y.$$typeof===m||y.getModuleId!==void 0)},zn.typeOf=b,zn}var NV;function u5e(){return NV||(NV=1,uN.exports=c5e()),uN.exports}var d5e=u5e(),RV=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",PV=null,dN=null,vJ=t=>{if(t===PV&&Array.isArray(dN))return dN;var e=[];return E.Children.forEach(t,n=>{xr(n)||(d5e.isFragment(n)?e=e.concat(vJ(n.props.children)):e.push(n))}),dN=e,PV=t,e};function aL(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>RV(i)):r=[RV(e)],vJ(t).forEach(i=>{var a=zf(i,"type.displayName")||zf(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var bJ=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,fN={},kV;function f5e(){return kV||(kV=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})(fN)),fN}var hN,DV;function h5e(){return DV||(DV=1,hN=f5e().isPlainObject),hN}var p5e=h5e();const m5e=Zs(p5e);function OV(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 LV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?OV(Object(n),!0).forEach(function(r){g5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):OV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function g5e(t,e,n){return(e=x5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function x5e(t){var e=v5e(t,"string");return typeof e=="symbol"?e:e+""}function v5e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function FS(){return FS=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},FS.apply(null,arguments)}var IV=(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},b5e={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},y5e=t=>{var e=Zr(t,b5e),{x:n,y:r,upperWidth:i,lowerWidth:a,height:s,className:o}=e,{animationEasing:l,animationDuration:c,animationBegin:u,isUpdateAnimationActive:h}=e,g=E.useRef(null),[m,b]=E.useState(-1),y=E.useRef(i),v=E.useRef(a),x=E.useRef(s),M=E.useRef(n),w=E.useRef(r),C=ov(t,"trapezoid-");if(E.useEffect(()=>{if(g.current&&g.current.getTotalLength)try{var D=g.current.getTotalLength();D&&b(D)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||s!==+s||i===0&&a===0||s===0)return null;var T=An("recharts-trapezoid",o);if(!h)return E.createElement("g",null,E.createElement("path",FS({},Sa(e),{className:T,d:IV(n,r,i,a,s)})));var R=y.current,A=v.current,j=x.current,N=M.current,k=w.current,F="0px ".concat(m===-1?1:m,"px"),I="".concat(m,"px 0px"),W=BY(["strokeDasharray"],c,l);return E.createElement(sv,{animationId:C,key:C,canBegin:m>0,duration:c,easing:l,isActive:h,begin:u},D=>{var B=sr(R,i,D),G=sr(A,a,D),V=sr(j,s,D),Z=sr(N,n,D),Y=sr(k,r,D);g.current&&(y.current=B,v.current=G,x.current=V,M.current=Z,w.current=Y);var ee=D>0?{transition:W,strokeDasharray:I}:{strokeDasharray:F};return E.createElement("path",FS({},Sa(e),{className:T,d:IV(Z,Y,B,G,V),ref:g,style:LV(LV({},ee),e.style)}))})},_5e=["option","shapeType","propTransformer","activeClassName"];function S5e(t,e){if(t==null)return{};var n,r,i=w5e(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 w5e(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 jV(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 zS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?jV(Object(n),!0).forEach(function(r){M5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):jV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function M5e(t,e,n){return(e=E5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function E5e(t){var e=A5e(t,"string");return typeof e=="symbol"?e:e+""}function A5e(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 T5e(t,e){return zS(zS({},e),t)}function C5e(t,e){return t==="symbols"}function UV(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return E.createElement(GY,n);case"trapezoid":return E.createElement(y5e,n);case"sector":return E.createElement(KY,n);case"symbols":if(C5e(e))return E.createElement(TD,n);break;case"curve":return E.createElement(Bp,n);default:return null}}function N5e(t){return E.isValidElement(t)?t.props:t}function yJ(t){var{option:e,shapeType:n,propTransformer:r=T5e,activeClassName:i="recharts-active-shape"}=t,a=S5e(t,_5e),s;if(E.isValidElement(e))s=E.cloneElement(e,zS(zS({},a),N5e(e)));else if(typeof e=="function")s=e(a,a.index);else if(m5e(e)&&typeof e!="boolean"){var o=r(e,a);s=E.createElement(UV,{shapeType:n,elementProps:o})}else{var l=a;s=E.createElement(UV,{shapeType:n,elementProps:l})}return a.isActive?E.createElement(Lr,{className:i},s):s}var sL=(t,e,n)=>{var r=er();return(i,a)=>s=>{t?.(i,a,s),r(RQ({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},oL=t=>{var e=er();return(n,r)=>i=>{t?.(n,r,i),e(H4e())}},lL=(t,e,n)=>{var r=er();return(i,a)=>s=>{t?.(i,a,s),r($4e({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function cL(t){var{tooltipEntrySettings:e}=t,n=er(),r=ca(),i=E.useRef(null);return E.useLayoutEffect(()=>{r||(i.current===null?n(U4e(e)):i.current!==e&&n(F4e({prev:i.current,next:e})),i.current=e)},[e,n,r]),E.useLayoutEffect(()=>()=>{i.current&&(n(z4e(i.current)),i.current=null)},[n]),null}function _J(t){var{legendPayload:e}=t,n=er(),r=ca(),i=E.useRef(null);return E.useLayoutEffect(()=>{r||(i.current===null?n(IY(e)):i.current!==e&&n(jY({prev:i.current,next:e})),i.current=e)},[n,r,e]),E.useLayoutEffect(()=>()=>{i.current&&(n(UY(i.current)),i.current=null)},[n]),null}function R5e(t){var{legendPayload:e}=t,n=er(),r=At(Sn),i=E.useRef(null);return E.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(IY(e)):i.current!==e&&n(jY({prev:i.current,next:e})),i.current=e)},[n,r,e]),E.useLayoutEffect(()=>()=>{i.current&&(n(UY(i.current)),i.current=null)},[n]),null}var pN,P5e=()=>{var[t]=E.useState(()=>y0("uid-"));return t},k5e=(pN=yne.useId)!==null&&pN!==void 0?pN:P5e;function SJ(t,e){var n=k5e();return e||(t?"".concat(t,"-").concat(n):n)}var D5e=E.createContext(void 0),uL=t=>{var{id:e,type:n,children:r}=t,i=SJ("recharts-".concat(n),e);return E.createElement(D5e.Provider,{value:i},r(i))},O5e={cartesianItems:[],polarItems:[]},wJ=Ga({name:"graphicalItems",initialState:O5e,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:cr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=_o(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:cr()},removeCartesianGraphicalItem:{reducer(t,e){var n=_o(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:cr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:cr()},removePolarGraphicalItem:{reducer(t,e){var n=_o(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:cr()}}}),{addCartesianGraphicalItem:L5e,replaceCartesianGraphicalItem:I5e,removeCartesianGraphicalItem:j5e,addPolarGraphicalItem:U5e,removePolarGraphicalItem:F5e}=wJ.actions,z5e=wJ.reducer,B5e=t=>{var e=er(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(L5e(t)):n.current!==t&&e(I5e({prev:n.current,next:t})),n.current=t},[e,t]),E.useLayoutEffect(()=>()=>{n.current&&(e(j5e(n.current)),n.current=null)},[e]),null},MJ=E.memo(B5e);function H5e(t){var e=er();return E.useLayoutEffect(()=>(e(U5e(t)),()=>{e(F5e(t))}),[e,t]),null}var $5e=["key"],V5e=["onMouseEnter","onClick","onMouseLeave"],G5e=["id"],W5e=["id"];function FV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Mr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?FV(Object(n),!0).forEach(function(r){q5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):FV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function q5e(t,e,n){return(e=X5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function X5e(t){var e=K5e(t,"string");return typeof e=="symbol"?e:e+""}function K5e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function sd(){return sd=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},sd.apply(null,arguments)}function wM(t,e){if(t==null)return{};var n,r,i=Y5e(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 Y5e(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 Z5e(t){var e=E.useMemo(()=>aL(t.children,Sv),[t.children]),n=At(r=>o5e(r,t.id,e));return n==null?null:E.createElement(R5e,{legendPayload:n})}var Q5e=E.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:s,name:o,hide:l,tooltipType:c}=t,u={dataDefinedOnItem:r.map(h=>h.tooltipPayload),positions:r.map(h=>h.tooltipPosition),settings:{stroke:i,strokeWidth:a,fill:s,dataKey:e,nameKey:n,name:Om(o,e),hide:l,type:c,color:s,unit:""}};return E.createElement(cL,{tooltipEntrySettings:u})}),J5e=(t,e)=>t>e?"start":t<e?"end":"middle",eBe=(t,e,n)=>aa(typeof e=="function"?e(t):e,n,n*.8),tBe=(t,e,n)=>{var{top:r,left:i,width:a,height:s}=e,o=WY(a,s),l=i+aa(t.cx,a,a/2),c=r+aa(t.cy,s,s/2),u=aa(t.innerRadius,o,0),h=eBe(n,t.outerRadius,o),g=t.maxRadius||Math.sqrt(a*a+s*s)/2;return{cx:l,cy:c,innerRadius:u,outerRadius:h,maxRadius:g}},nBe=(t,e)=>{var n=Ai(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function rBe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var iBe=(t,e)=>{if(E.isValidElement(t))return E.cloneElement(t,e);if(typeof t=="function")return t(e);var n=An("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=wM(e,$5e);return E.createElement(Bp,sd({},i,{type:"linear",className:n}))},aBe=(t,e,n)=>{if(E.isValidElement(t))return E.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),E.isValidElement(r)))return r;var i=An("recharts-pie-label-text",rBe(t));return E.createElement(yM,sd({},e,{alignmentBaseline:"middle",className:i}),r)};function sBe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:s}=n;if(!r||!i||!e)return null;var o=Ha(n),l=Ff(i),c=Ff(a),u=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,h=e.map((g,m)=>{var b=(g.startAngle+g.endAngle)/2,y=Wr(g.cx,g.cy,g.outerRadius+u,b),v=Mr(Mr(Mr(Mr({},o),g),{},{stroke:"none"},l),{},{index:m,textAnchor:J5e(y.x,g.cx)},y),x=Mr(Mr(Mr(Mr({},o),g),{},{fill:"none",stroke:g.fill},c),{},{index:m,points:[Wr(g.cx,g.cy,g.outerRadius,b),y],key:"line"});return E.createElement(Wa,{zIndex:qr.label,key:"label-".concat(g.startAngle,"-").concat(g.endAngle,"-").concat(g.midAngle,"-").concat(m)},E.createElement(Lr,null,a&&iBe(a,x),aBe(i,v,Yn(g,s))))});return E.createElement(Lr,{className:"recharts-pie-labels"},h)}function oBe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?E.createElement(nL,{label:i}):E.createElement(sBe,{sectors:e,props:n,showLabels:r})}function lBe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:s}=t,o=At(ad),l=At(KO),c=At(CUe),{onMouseEnter:u,onClick:h,onMouseLeave:g}=i,m=wM(i,V5e),b=sL(u,i.dataKey,s),y=oL(g),v=lL(h,i.dataKey,s);return e==null||e.length===0?null:E.createElement(E.Fragment,null,e.map((x,M)=>{if(x?.startAngle===0&&x?.endAngle===0&&e.length!==1)return null;var w=c==null||c===s,C=String(M)===o&&(l==null||i.dataKey===l)&&w,T=o?r:null,R=n&&C?n:T,A=Mr(Mr({},x),{},{stroke:x.stroke,tabIndex:-1,[SY]:M,[wY]:i.dataKey});return E.createElement(Lr,sd({key:"sector-".concat(x?.startAngle,"-").concat(x?.endAngle,"-").concat(x.midAngle,"-").concat(M),tabIndex:-1,className:"recharts-pie-sector"},ev(m,x,M),{onMouseEnter:b(x,M),onMouseLeave:y(x,M),onClick:v(x,M)}),E.createElement(yJ,sd({option:a??R,index:M,shapeType:"sector",isActive:C},A)))}))}function cBe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:a}=t,{cornerRadius:s,startAngle:o,endAngle:l,dataKey:c,nameKey:u,tooltipType:h}=n,g=Math.abs(n.minAngle),m=nBe(o,l),b=Math.abs(m),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,v=r.filter(R=>Yn(R,c,0)!==0).length,x=(b>=360?v:v-1)*y,M=b-v*g-x,w=r.reduce((R,A)=>{var j=Yn(A,c,0);return R+(Et(j)?j:0)},0),C;if(w>0){var T;C=r.map((R,A)=>{var j=Yn(R,c,0),N=Yn(R,u,A),k=tBe(n,a,R),F=(Et(j)?j:0)/w,I,W=Mr(Mr({},R),i&&i[A]&&i[A].props);A?I=T.endAngle+Ai(m)*y*(j!==0?1:0):I=o;var D=I+Ai(m)*((j!==0?g:0)+F*M),B=(I+D)/2,G=(k.innerRadius+k.outerRadius)/2,V=[{name:N,value:j,payload:W,dataKey:c,type:h}],Z=Wr(k.cx,k.cy,G,B);return T=Mr(Mr(Mr(Mr({},n.presentationProps),{},{percent:F,cornerRadius:typeof s=="string"?parseFloat(s):s,name:N,tooltipPayload:V,midAngle:B,middleRadius:G,tooltipPosition:Z},W),k),{},{value:j,dataKey:c,startAngle:I,endAngle:D,payload:W,paddingAngle:Ai(m)*y}),T})}return C}function uBe(t){var{showLabels:e,sectors:n,children:r}=t,i=E.useMemo(()=>!e||!n?[]:n.map(a=>({value:a.value,payload:a.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:a.cx,cy:a.cy,innerRadius:a.innerRadius,outerRadius:a.outerRadius,startAngle:a.startAngle,endAngle:a.endAngle,clockWise:!1},fill:a.fill})),[n,e]);return E.createElement(Gze,{value:e?i:void 0},r)}function dBe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:a,animationBegin:s,animationDuration:o,animationEasing:l,activeShape:c,inactiveShape:u,onAnimationStart:h,onAnimationEnd:g}=e,m=ov(e,"recharts-pie-"),b=n.current,[y,v]=E.useState(!1),x=E.useCallback(()=>{typeof g=="function"&&g(),v(!1)},[g]),M=E.useCallback(()=>{typeof h=="function"&&h(),v(!0)},[h]);return E.createElement(uBe,{showLabels:!y,sectors:i},E.createElement(sv,{animationId:m,begin:s,duration:o,isActive:a,easing:l,onAnimationStart:M,onAnimationEnd:x,key:m},w=>{var C=[],T=i&&i[0],R=T?.startAngle;return i?.forEach((A,j)=>{var N=b&&b[j],k=j>0?zf(A,"paddingAngle",0):0;if(N){var F=sr(N.endAngle-N.startAngle,A.endAngle-A.startAngle,w),I=Mr(Mr({},A),{},{startAngle:R+k,endAngle:R+F+k});C.push(I),R=I.endAngle}else{var{endAngle:W,startAngle:D}=A,B=sr(0,W-D,w),G=Mr(Mr({},A),{},{startAngle:R+k,endAngle:R+B+k});C.push(G),R=G.endAngle}}),n.current=C,E.createElement(Lr,null,E.createElement(lBe,{sectors:C,activeShape:c,inactiveShape:u,allOtherPieProps:e,shape:e.shape,id:r}))}),E.createElement(oBe,{showLabels:!y,sectors:i,props:e}),e.children)}var fBe={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:qr.area};function hBe(t){var{id:e}=t,n=wM(t,G5e),{hide:r,className:i,rootTabIndex:a}=t,s=E.useMemo(()=>aL(t.children,Sv),[t.children]),o=At(u=>l5e(u,e,s)),l=E.useRef(null),c=An("recharts-pie",i);return r||o==null?(l.current=null,E.createElement(Lr,{tabIndex:a,className:c})):E.createElement(Wa,{zIndex:t.zIndex},E.createElement(Q5e,{dataKey:t.dataKey,nameKey:t.nameKey,sectors:o,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,tooltipType:t.tooltipType}),E.createElement(Lr,{tabIndex:a,className:c},E.createElement(dBe,{props:Mr(Mr({},n),{},{sectors:o}),previousSectorsRef:l,id:e})))}function EJ(t){var e=Zr(t,fBe),{id:n}=e,r=wM(e,W5e),i=Ha(r);return E.createElement(uL,{id:n,type:"pie"},a=>E.createElement(E.Fragment,null,E.createElement(H5e,{type:"pie",id:a,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:e.maxRadius}),E.createElement(Z5e,sd({},r,{id:a})),E.createElement(hBe,sd({},r,{id:a}))))}EJ.displayName="Pie";var pBe=["points"];function zV(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 mN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?zV(Object(n),!0).forEach(function(r){mBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):zV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function mBe(t,e,n){return(e=gBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gBe(t){var e=xBe(t,"string");return typeof e=="symbol"?e:e+""}function xBe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function BS(){return BS=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},BS.apply(null,arguments)}function vBe(t,e){if(t==null)return{};var n,r,i=bBe(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 bBe(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 yBe(t){var{option:e,dotProps:n,className:r}=t;if(E.isValidElement(e))return E.cloneElement(e,n);if(typeof e=="function")return e(n);var i=An(r,typeof e!="boolean"?e.className:""),a=n??{},{points:s}=a,o=vBe(a,pBe);return E.createElement(hJ,BS({},o,{className:i}))}function _Be(t,e){return t==null?!1:e?!0:t.length===1}function SBe(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:s,needClip:o,clipPathId:l,zIndex:c=qr.scatter}=t;if(!_Be(e,n))return null;var u=bJ(n),h=QNe(n),g=e.map((b,y)=>{var v,x,M=mN(mN(mN({r:3},s),h),{},{index:y,cx:(v=b.x)!==null&&v!==void 0?v:void 0,cy:(x=b.y)!==null&&x!==void 0?x:void 0,dataKey:a,value:b.value,payload:b.payload,points:e});return E.createElement(yBe,{key:"dot-".concat(y),option:n,dotProps:M,className:i})}),m={};return o&&l!=null&&(m.clipPath="url(#clipPath-".concat(u?"":"dots-").concat(l,")")),E.createElement(Wa,{zIndex:c},E.createElement(Lr,BS({className:r},m),g))}function BV(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?BV(Object(n),!0).forEach(function(r){wBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):BV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function wBe(t,e,n){return(e=MBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function MBe(t){var e=EBe(t,"string");return typeof e=="symbol"?e:e+""}function EBe(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 ABe={xAxis:{},yAxis:{},zAxis:{}},AJ=Ga({name:"cartesianAxis",initialState:ABe,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:cr()},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:cr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:cr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:cr()},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:cr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:cr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:cr()},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:cr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:cr()},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]=HV(HV({},t.yAxis[n]),{},{width:r,widthHistory:s})}}}}),{addXAxis:TBe,replaceXAxis:CBe,removeXAxis:NBe,addYAxis:RBe,replaceYAxis:PBe,removeYAxis:kBe,addZAxis:QGe,replaceZAxis:JGe,removeZAxis:e9e,updateYAxisWidth:DBe}=AJ.actions,OBe=AJ.reducer,LBe=Ve([ui],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),IBe=Ve([LBe,Nc,Rc],(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)}}),dL=()=>At(IBe),jBe=()=>At(DUe);function $V(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function gN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$V(Object(n),!0).forEach(function(r){UBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$V(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function UBe(t,e,n){return(e=FBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function FBe(t){var e=zBe(t,"string");return typeof e=="symbol"?e:e+""}function zBe(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 BBe=t=>{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:s}=t;if(i===!1||e.x==null||e.y==null)return null;var o={index:n,dataKey:a,cx:e.x,cy:e.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},l=gN(gN(gN({},o),Ff(i)),CD(i)),c;return E.isValidElement(i)?c=E.cloneElement(i,l):typeof i=="function"?c=i(l):c=E.createElement(hJ,l),E.createElement(Lr,{className:"recharts-active-dot",clipPath:s},c)};function VV(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:s=qr.activeDot}=t,o=At(ad),l=jBe();if(e==null||l==null)return null;var c=e.find(u=>l.includes(u.payload));return xr(c)?null:E.createElement(Wa,{zIndex:s},E.createElement(BBe,{point:c,childIndex:Number(o),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var HBe="Invariant failed";function $Be(t,e){throw new Error(HBe)}var VBe=["x","y"];function yP(){return yP=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},yP.apply(null,arguments)}function GV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ox(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?GV(Object(n),!0).forEach(function(r){GBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):GV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function GBe(t,e,n){return(e=WBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function WBe(t){var e=qBe(t,"string");return typeof e=="symbol"?e:e+""}function qBe(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 XBe(t,e){if(t==null)return{};var n,r,i=KBe(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 KBe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function YBe(t,e){var{x:n,y:r}=t,i=XBe(t,VBe),a="".concat(n),s=parseInt(a,10),o="".concat(r),l=parseInt(o,10),c="".concat(e.height||i.height),u=parseInt(c,10),h="".concat(e.width||i.width),g=parseInt(h,10);return ox(ox(ox(ox(ox({},e),i),s?{x:s}:{}),l?{y:l}:{}),{},{height:u,width:g,name:e.name,radius:e.radius})}function HS(t){return E.createElement(yJ,yP({shapeType:"rectangle",propTransformer:YBe,activeClassName:"recharts-active-bar"},t))}var ZBe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Et(e))return e;var a=Et(r)||xr(r);return a?e(r,i):(a||$Be(),n)}},QBe={},TJ=Ga({name:"errorBars",initialState:QBe,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:t9e,replaceErrorBar:n9e,removeErrorBar:r9e}=TJ.actions,JBe=TJ.reducer,e6e=["children"];function t6e(t,e){if(t==null)return{};var n,r,i=n6e(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 n6e(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 r6e={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},i6e=E.createContext(r6e);function a6e(t){var{children:e}=t,n=t6e(t,e6e);return E.createElement(i6e.Provider,{value:n},e)}function fL(t,e){var n,r,i=At(c=>kc(c,t)),a=At(c=>Dc(c,e)),s=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:_i.allowDataOverflow,o=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:Si.allowDataOverflow,l=s||o;return{needClip:l,needClipX:s,needClipY:o}}function CJ(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=dL(),{needClipX:a,needClipY:s,needClip:o}=fL(e,n);if(!o||!i)return null;var{x:l,y:c,width:u,height:h}=i;return E.createElement("clipPath",{id:"clipPath-".concat(r)},E.createElement("rect",{x:a?l:l-u/2,y:s?c:c-h/2,width:a?u:u*2,height:s?h:h*2}))}function s6e(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&or(t.zIndex)?t.zIndex:e}var xN={exports:{}},vN={};var WV;function o6e(){if(WV)return vN;WV=1;var t=ym();function e(l,c){return l===c&&(l!==0||1/l===1/c)||l!==l&&c!==c}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,a=t.useEffect,s=t.useMemo,o=t.useDebugValue;return vN.useSyncExternalStoreWithSelector=function(l,c,u,h,g){var m=i(null);if(m.current===null){var b={hasValue:!1,value:null};m.current=b}else b=m.current;m=s(function(){function v(T){if(!x){if(x=!0,M=T,T=h(T),g!==void 0&&b.hasValue){var R=b.value;if(g(R,T))return w=R}return w=T}if(R=w,n(M,T))return R;var A=h(T);return g!==void 0&&g(R,A)?(M=T,R):(M=T,w=A)}var x=!1,M,w,C=u===void 0?null:u;return[function(){return v(c())},C===null?void 0:function(){return v(C())}]},[c,u,h,g]);var y=r(l,m[0],m[1]);return a(function(){b.hasValue=!0,b.value=y},[y]),o(y),y},vN}var qV;function l6e(){return qV||(qV=1,xN.exports=o6e()),xN.exports}l6e();function c6e(t){t()}function u6e(){let t=null,e=null;return{clear(){t=null,e=null},notify(){c6e(()=>{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 XV={notify(){},get:()=>[]};function d6e(t,e){let n,r=XV,i=0,a=!1;function s(y){u();const v=r.subscribe(y);let x=!1;return()=>{x||(x=!0,v(),h())}}function o(){r.notify()}function l(){b.onStateChange&&b.onStateChange()}function c(){return a}function u(){i++,n||(n=t.subscribe(l),r=u6e())}function h(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=XV)}function g(){a||(a=!0,u())}function m(){a&&(a=!1,h())}const b={addNestedSub:s,notifyNestedSubs:o,handleChangeWrapper:l,isSubscribed:c,trySubscribe:g,tryUnsubscribe:m,getListeners:()=>r};return b}var f6e=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",h6e=f6e(),p6e=()=>typeof navigator<"u"&&navigator.product==="ReactNative",m6e=p6e(),g6e=()=>h6e||m6e?E.useLayoutEffect:E.useEffect,x6e=g6e();function KV(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function v6e(t,e){if(KV(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])||!KV(t[n[i]],e[n[i]]))return!1;return!0}var b6e=Symbol.for("react-redux-context"),y6e=typeof globalThis<"u"?globalThis:{};function _6e(){if(!E.createContext)return{};const t=y6e[b6e]??=new Map;let e=t.get(E.createContext);return e||(e=E.createContext(null),t.set(E.createContext,e)),e}var S6e=_6e();function w6e(t){const{children:e,context:n,serverState:r,store:i}=t,a=E.useMemo(()=>{const l=d6e(i);return{store:i,subscription:l,getServerState:r?()=>r:void 0}},[i,r]),s=E.useMemo(()=>i.getState(),[i]);x6e(()=>{const{subscription:l}=a;return l.onStateChange=l.notifyNestedSubs,l.trySubscribe(),s!==i.getState()&&l.notifyNestedSubs(),()=>{l.tryUnsubscribe(),l.onStateChange=void 0}},[a,s]);const o=n||S6e;return E.createElement(o.Provider,{value:a},e)}var M6e=w6e,E6e=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function A6e(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function MM(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(E6e.has(r)){if(t[r]==null&&e[r]==null)continue;if(!v6e(t[r],e[r]))return!1}else if(!A6e(t[r],e[r]))return!1;return!0}var T6e=["onMouseEnter","onMouseLeave","onClick"],C6e=["value","background","tooltipPosition"],N6e=["id"],R6e=["onMouseEnter","onClick","onMouseLeave"];function Ac(){return Ac=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},Ac.apply(null,arguments)}function YV(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 ma(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?YV(Object(n),!0).forEach(function(r){P6e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):YV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function P6e(t,e,n){return(e=k6e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function k6e(t){var e=D6e(t,"string");return typeof e=="symbol"?e:e+""}function D6e(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 $S(t,e){if(t==null)return{};var n,r,i=O6e(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 O6e(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 L6e=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Om(n,e),payload:t}]},I6e=E.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:a,hide:s,unit:o,tooltipType:l}=t,c={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:Om(a,e),hide:s,type:l,color:i,unit:o}};return E.createElement(cL,{tooltipEntrySettings:c})});function j6e(t){var e=At(ad),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:s,onMouseLeave:o,onClick:l}=a,c=$S(a,T6e),u=sL(s,r),h=oL(o),g=lL(l,r);if(!i||n==null)return null;var m=Ff(i);return E.createElement(Wa,{zIndex:s6e(i,qr.barBackground)},n.map((b,y)=>{var{value:v,background:x,tooltipPosition:M}=b,w=$S(b,C6e);if(!x)return null;var C=u(b,y),T=h(b,y),R=g(b,y),A=ma(ma(ma(ma(ma({option:i,isActive:String(y)===e},w),{},{fill:"#eee"},x),m),ev(c,b,y)),{},{onMouseEnter:C,onMouseLeave:T,onClick:R,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return E.createElement(HS,Ac({key:"background-bar-".concat(y)},A))}))}function U6e(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 ma(ma({},s),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:s,fill:a.fill})});return E.createElement(dJ,{value:e?i:void 0},n)}function F6e(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:s}=t,o=At(ad),l=At(KO),c=n&&String(a)===o&&(l==null||s===l),u=c?n:e;return c?E.createElement(Wa,{zIndex:qr.activeBar},E.createElement(HS,Ac({},r,{name:String(r.name)},i,{isActive:c,option:u,index:a,dataKey:s}))):E.createElement(HS,Ac({},r,{name:String(r.name)},i,{isActive:c,option:u,index:a,dataKey:s}))}function z6e(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return E.createElement(HS,Ac({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function B6e(t){var e,{data:n,props:r}=t,i=(e=Ha(r))!==null&&e!==void 0?e:{},{id:a}=i,s=$S(i,N6e),{shape:o,dataKey:l,activeBar:c}=r,{onMouseEnter:u,onClick:h,onMouseLeave:g}=r,m=$S(r,R6e),b=sL(u,l),y=oL(g),v=lL(h,l);return n?E.createElement(E.Fragment,null,n.map((x,M)=>E.createElement(Lr,Ac({key:"rectangle-".concat(x?.x,"-").concat(x?.y,"-").concat(x?.value,"-").concat(M),className:"recharts-bar-rectangle"},ev(m,x,M),{onMouseEnter:b(x,M),onMouseLeave:y(x,M),onClick:v(x,M)}),c?E.createElement(F6e,{shape:o,activeBar:c,baseProps:s,entry:x,index:M,dataKey:l}):E.createElement(z6e,{shape:o,baseProps:s,entry:x,index:M,dataKey:l})))):null}function H6e(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:a,animationBegin:s,animationDuration:o,animationEasing:l,onAnimationEnd:c,onAnimationStart:u}=e,h=n.current,g=ov(e,"recharts-bar-"),[m,b]=E.useState(!1),y=!m,v=E.useCallback(()=>{typeof c=="function"&&c(),b(!1)},[c]),x=E.useCallback(()=>{typeof u=="function"&&u(),b(!0)},[u]);return E.createElement(U6e,{showLabels:y,rects:r},E.createElement(sv,{animationId:g,begin:s,duration:o,isActive:a,easing:l,onAnimationEnd:v,onAnimationStart:x,key:g},M=>{var w=M===1?r:r?.map((C,T)=>{var R=h&&h[T];if(R)return ma(ma({},C),{},{x:sr(R.x,C.x,M),y:sr(R.y,C.y,M),width:sr(R.width,C.width,M),height:sr(R.height,C.height,M)});if(i==="horizontal"){var A=sr(0,C.height,M),j=sr(C.stackedBarStart,C.y,M);return ma(ma({},C),{},{y:j,height:A})}var N=sr(0,C.width,M),k=sr(C.stackedBarStart,C.x,M);return ma(ma({},C),{},{width:N,x:k})});return M>0&&(n.current=w??null),w==null?null:E.createElement(Lr,null,E.createElement(B6e,{props:e,data:w}))}),E.createElement(nL,{label:e.label}),e.children)}function $6e(t){var e=E.useRef(null);return E.createElement(H6e,{previousRectanglesRef:e,props:t})}var NJ=0,V6e=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:Yn(t,e)}};class G6e extends E.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:a,yAxisId:s,needClip:o,background:l,id:c}=this.props;if(e||n==null)return null;var u=An("recharts-bar",i),h=c;return E.createElement(Lr,{className:u,id:c},o&&E.createElement("defs",null,E.createElement(CJ,{clipPathId:h,xAxisId:a,yAxisId:s})),E.createElement(Lr,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(h,")"):void 0},E.createElement(j6e,{data:n,dataKey:r,background:l,allOtherBarProps:this.props}),E.createElement($6e,this.props)))}}var W6e={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:NJ,xAxisId:0,yAxisId:0,zIndex:qr.bar};function q6e(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:s,animationBegin:o,animationDuration:l,animationEasing:c,isAnimationActive:u}=t,{needClip:h}=fL(e,n),g=Lm(),m=ca(),b=aL(t.children,Sv),y=At(M=>_8e(M,e,n,m,t.id,b));if(g!=="vertical"&&g!=="horizontal")return null;var v,x=y?.[0];return x==null||x.height==null||x.width==null?v=0:v=g==="vertical"?x.height/2:x.width/2,E.createElement(a6e,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:V6e,errorBarOffset:v},E.createElement(G6e,Ac({},t,{layout:g,needClip:h,data:y,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:s,animationBegin:o,animationDuration:l,animationEasing:c,isAnimationActive:u})))}function X6e(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:a,xAxis:s,yAxis:o,xAxisTicks:l,yAxisTicks:c,stackedData:u,displayedData:h,offset:g,cells:m,parentViewBox:b,dataStartIndex:y}=t,v=e==="horizontal"?o:s,x=u?v.scale.domain():null,M=hke({numericAxis:v}),w=v.scale(M);return h.map((C,T)=>{var R,A,j,N,k,F;u?R=lke(u[T+y],x):(R=Yn(C,n),Array.isArray(R)||(R=[M,R]));var I=ZBe(r,NJ)(R[1],T);if(e==="horizontal"){var W,[D,B]=[o.scale(R[0]),o.scale(R[1])];A=fH({axis:s,ticks:l,bandSize:a,offset:i.offset,entry:C,index:T}),j=(W=B??D)!==null&&W!==void 0?W:void 0,N=i.size;var G=D-B;if(k=Xs(G)?0:G,F={x:A,y:g.top,width:N,height:g.height},Math.abs(I)>0&&Math.abs(k)<Math.abs(I)){var V=Ai(k||I)*(Math.abs(I)-Math.abs(k));j-=V,k+=V}}else{var[Z,Y]=[s.scale(R[0]),s.scale(R[1])];if(A=Z,j=fH({axis:o,ticks:c,bandSize:a,offset:i.offset,entry:C,index:T}),N=Y-Z,k=i.size,F={x:g.left,y:j,width:g.width,height:k},Math.abs(I)>0&&Math.abs(N)<Math.abs(I)){var ee=Ai(N||I)*(Math.abs(I)-Math.abs(N));N+=ee}}if(A==null||j==null||N==null||k==null)return null;var H=ma(ma({},C),{},{stackedBarStart:w,x:A,y:j,width:N,height:k,value:u?R:R[1],payload:C,background:F,tooltipPosition:{x:A+N/2,y:j+k/2},parentViewBox:b},m&&m[T]&&m[T].props);return H}).filter(Boolean)}function K6e(t){var e=Zr(t,W6e),n=ca();return E.createElement(uL,{id:e.id,type:"bar"},r=>E.createElement(E.Fragment,null,E.createElement(_J,{legendPayload:L6e(e)}),E.createElement(I6e,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),E.createElement(MJ,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:yY(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),E.createElement(Wa,{zIndex:e.zIndex},E.createElement(q6e,Ac({},e,{id:r})))))}var RJ=E.memo(K6e,MM);RJ.displayName="Bar";function ZV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function d_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ZV(Object(n),!0).forEach(function(r){Y6e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ZV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Y6e(t,e,n){return(e=Z6e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Z6e(t){var e=Q6e(t,"string");return typeof e=="symbol"?e:e+""}function Q6e(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 J6e=(t,e)=>e,e8e=(t,e,n)=>n,t8e=(t,e,n,r)=>r,n8e=(t,e,n,r,i)=>i,wv=Ve([mM,n8e],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),r8e=Ve([wv],t=>t?.maxBarSize),i8e=(t,e,n,r,i,a)=>a,QV=(t,e,n)=>{var r=n??t;if(!xr(r))return aa(r,e,0)},a8e=Ve([Sn,mM,J6e,e8e,t8e],(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")),s8e=(t,e,n,r)=>{var i=Sn(t);return i==="horizontal"?D0(t,"yAxis",n,r):D0(t,"xAxis",e,r)},o8e=(t,e,n)=>{var r=Sn(t);return r==="horizontal"?G$(t,"xAxis",e):G$(t,"yAxis",n)},l8e=(t,e,n)=>{var r={},i=t.filter(fM),a=t.filter(c=>c.stackId==null),s=i.reduce((c,u)=>(c[u.stackId]||(c[u.stackId]=[]),c[u.stackId].push(u),c),r),o=Object.entries(s).map(c=>{var[u,h]=c,g=h.map(b=>b.dataKey),m=QV(e,n,h[0].barSize);return{stackId:u,dataKeys:g,barSize:m}}),l=a.map(c=>{var u=[c.dataKey].filter(g=>g!=null),h=QV(e,n,c.barSize);return{stackId:void 0,dataKeys:u,barSize:h}});return[...o,...l]},c8e=Ve([a8e,Rje,o8e],l8e),u8e=(t,e,n,r,i)=>{var a,s,o=wv(t,e,n,r,i);if(o!=null){var l=Sn(t),c=GZ(t),{maxBarSize:u}=o,h=xr(u)?c:u,g,m;return l==="horizontal"?(g=id(t,"xAxis",e,r),m=rd(t,"xAxis",e,r)):(g=id(t,"yAxis",n,r),m=rd(t,"yAxis",n,r)),(a=(s=pm(g,m,!0))!==null&&s!==void 0?s:h)!==null&&a!==void 0?a:0}},PJ=(t,e,n,r)=>{var i=Sn(t),a,s;return i==="horizontal"?(a=id(t,"xAxis",e,r),s=rd(t,"xAxis",e,r)):(a=id(t,"yAxis",n,r),s=rd(t,"yAxis",n,r)),pm(a,s)};function d8e(t,e,n,r,i){var a=r.length;if(!(a<1)){var s=aa(t,n,0,!0),o,l=[];if(or(r[0].barSize)){var c=!1,u=n/a,h=r.reduce((x,M)=>x+(M.barSize||0),0);h+=(a-1)*s,h>=n&&(h-=(a-1)*s,s=0),h>=n&&u>0&&(c=!0,u*=.9,h=a*u);var g=(n-h)/2>>0,m={offset:g-s,size:0};o=r.reduce((x,M)=>{var w,C={stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:m.offset+m.size+s,size:c?u:(w=M.barSize)!==null&&w!==void 0?w:0}},T=[...x,C];return m=T[T.length-1].position,T},l)}else{var b=aa(e,n,0,!0);n-2*b-(a-1)*s<=0&&(s=0);var y=(n-2*b-(a-1)*s)/a;y>1&&(y>>=0);var v=or(i)?Math.min(y,i):y;o=r.reduce((x,M,w)=>[...x,{stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:b+(y+s)*w+(y-v)/2,size:v}}],l)}return o}}var f8e=(t,e,n,r,i,a,s)=>{var o=xr(s)?e:s,l=d8e(n,r,i!==a?i:a,t,o);return i!==a&&l!=null&&(l=l.map(c=>d_(d_({},c),{},{position:d_(d_({},c.position),{},{offset:c.position.offset-i/2})}))),l},h8e=Ve([c8e,GZ,Nje,WZ,u8e,PJ,r8e],f8e),p8e=(t,e,n,r)=>id(t,"xAxis",e,r),m8e=(t,e,n,r)=>id(t,"yAxis",n,r),g8e=(t,e,n,r)=>rd(t,"xAxis",e,r),x8e=(t,e,n,r)=>rd(t,"yAxis",n,r),v8e=Ve([h8e,wv],(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}}),b8e=(t,e)=>{var n=dM(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)}}}},y8e=Ve([s8e,wv],b8e),_8e=Ve([ui,FD,p8e,m8e,g8e,x8e,v8e,Sn,lM,PJ,y8e,wv,i8e],(t,e,n,r,i,a,s,o,l,c,u,h,g)=>{var{chartData:m,dataStartIndex:b,dataEndIndex:y}=l;if(!(h==null||s==null||e==null||o!=="horizontal"&&o!=="vertical"||n==null||r==null||i==null||a==null||c==null)){var{data:v}=h,x;if(v!=null&&v.length>0?x=v:x=m?.slice(b,y+1),x!=null)return X6e({layout:o,barSettings:h,pos:s,parentViewBox:e,bandSize:c,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:u,displayedData:x,offset:t,cells:g,dataStartIndex:b})}}),kJ=t=>{var{chartData:e}=t,n=er(),r=ca();return E.useEffect(()=>r?()=>{}:(n(iV(e)),()=>{n(iV(void 0))}),[e,n,r]),null},JV={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},DJ=Ga({name:"brush",initialState:JV,reducers:{setBrushSettings(t,e){return e.payload==null?JV:e.payload}}}),{setBrushSettings:i9e}=DJ.actions,S8e=DJ.reducer;function w8e(t,e,n){return(e=M8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function M8e(t){var e=E8e(t,"string");return typeof e=="symbol"?e:e+""}function E8e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class hL{static create(e){return new hL(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}}w8e(hL,"EPS",1e-4);function A8e(t){return(t%180+180)%180}var T8e=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=A8e(i),s=a*Math.PI/180,o=Math.atan(r/n),l=s>o&&s<Math.PI-o?r/Math.sin(s):n/Math.cos(s);return Math.abs(l)},C8e={dots:[],areas:[],lines:[]},OJ=Ga({name:"referenceElements",initialState:C8e,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=_o(t).dots.findIndex(r=>r===e.payload);n!==-1&&t.dots.splice(n,1)},addArea:(t,e)=>{t.areas.push(e.payload)},removeArea:(t,e)=>{var n=_o(t).areas.findIndex(r=>r===e.payload);n!==-1&&t.areas.splice(n,1)},addLine:(t,e)=>{t.lines.push(e.payload)},removeLine:(t,e)=>{var n=_o(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:a9e,removeDot:s9e,addArea:o9e,removeArea:l9e,addLine:c9e,removeLine:u9e}=OJ.actions,N8e=OJ.reducer,R8e=E.createContext(void 0),P8e=t=>{var{children:e}=t,[n]=E.useState("".concat(y0("recharts"),"-clip")),r=dL();if(r==null)return null;var{x:i,y:a,width:s,height:o}=r;return E.createElement(R8e.Provider,{value:n},E.createElement("defs",null,E.createElement("clipPath",{id:n},E.createElement("rect",{x:i,y:a,height:o,width:s}))),e)};function LJ(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 k8e(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return T8e(r,n)}function D8e(t,e,n){var r=n==="width",{x:i,y:a,width:s,height:o}=t;return e===1?{start:r?i:a,end:r?i+s:a+o}:{start:r?i+s:a+o,end:r?i:a}}function VS(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 O8e(t,e){return LJ(t,e+1)}function L8e(t,e,n,r,i){for(var a=(r||[]).slice(),{start:s,end:o}=e,l=0,c=1,u=s,h=function(){var b=r?.[l];if(b===void 0)return{v:LJ(r,c)};var y=l,v,x=()=>(v===void 0&&(v=n(b,y)),v),M=b.coordinate,w=l===0||VS(t,M,x,u,o);w||(l=0,u=s,c+=1),w&&(u=M+t*(x()/2+i),l+=c)},g;c<=a.length;)if(g=h(),g)return g.v;return[]}function eG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ta(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?eG(Object(n),!0).forEach(function(r){I8e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):eG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function I8e(t,e,n){return(e=j8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function j8e(t){var e=U8e(t,"string");return typeof e=="symbol"?e:e+""}function U8e(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 F8e(t,e,n,r,i){for(var a=(r||[]).slice(),s=a.length,{start:o}=e,{end:l}=e,c=function(g){var m=a[g],b,y=()=>(b===void 0&&(b=n(m,g)),b);if(g===s-1){var v=t*(m.coordinate+t*y()/2-l);a[g]=m=ta(ta({},m),{},{tickCoord:v>0?m.coordinate-v*t:m.coordinate})}else a[g]=m=ta(ta({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var x=VS(t,m.tickCoord,y,o,l);x&&(l=m.tickCoord-t*(y()/2+i),a[g]=ta(ta({},m),{},{isShow:!0}))}},u=s-1;u>=0;u--)c(u);return a}function z8e(t,e,n,r,i,a){var s=(r||[]).slice(),o=s.length,{start:l,end:c}=e;if(a){var u=r[o-1],h=n(u,o-1),g=t*(u.coordinate+t*h/2-c);if(s[o-1]=u=ta(ta({},u),{},{tickCoord:g>0?u.coordinate-g*t:u.coordinate}),u.tickCoord!=null){var m=VS(t,u.tickCoord,()=>h,l,c);m&&(c=u.tickCoord-t*(h/2+i),s[o-1]=ta(ta({},u),{},{isShow:!0}))}}for(var b=a?o-1:o,y=function(M){var w=s[M],C,T=()=>(C===void 0&&(C=n(w,M)),C);if(M===0){var R=t*(w.coordinate-t*T()/2-l);s[M]=w=ta(ta({},w),{},{tickCoord:R<0?w.coordinate-R*t:w.coordinate})}else s[M]=w=ta(ta({},w),{},{tickCoord:w.coordinate});if(w.tickCoord!=null){var A=VS(t,w.tickCoord,T,l,c);A&&(l=w.tickCoord+t*(T()/2+i),s[M]=ta(ta({},w),{},{isShow:!0}))}},v=0;v<b;v++)y(v);return s}function pL(t,e,n){var{tick:r,ticks:i,viewBox:a,minTickGap:s,orientation:o,interval:l,tickFormatter:c,unit:u,angle:h}=t;if(!i||!i.length||!r)return[];if(Et(l)||Im.isSsr){var g;return(g=O8e(i,Et(l)?l:0))!==null&&g!==void 0?g:[]}var m=[],b=o==="top"||o==="bottom"?"width":"height",y=u&&b==="width"?Bx(u,{fontSize:e,letterSpacing:n}):{width:0,height:0},v=(w,C)=>{var T=typeof c=="function"?c(w.value,C):w.value;return b==="width"?k8e(Bx(T,{fontSize:e,letterSpacing:n}),y,h):Bx(T,{fontSize:e,letterSpacing:n})[b]},x=i.length>=2?Ai(i[1].coordinate-i[0].coordinate):1,M=D8e(a,x,b);return l==="equidistantPreserveStart"?L8e(x,M,v,i,s):(l==="preserveStart"||l==="preserveStartEnd"?m=z8e(x,M,v,i,s,l==="preserveStartEnd"):m=F8e(x,M,v,i,s),m.filter(w=>w.isShow))}var B8e=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:a=0}=t,s=0;if(e){Array.from(e).forEach(u=>{if(u){var h=u.getBoundingClientRect();h.width>s&&(s=h.width)}});var o=n?n.getBoundingClientRect().width:0,l=i+a,c=s+l+o+(n?r:0);return Math.round(c)}return 0},H8e=["axisLine","width","height","className","hide","ticks","axisType"];function $8e(t,e){if(t==null)return{};var n,r,i=V8e(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 V8e(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 Vf(){return Vf=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},Vf.apply(null,arguments)}function tG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function $r(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?tG(Object(n),!0).forEach(function(r){G8e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):tG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function G8e(t,e,n){return(e=W8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function W8e(t){var e=q8e(t,"string");return typeof e=="symbol"?e:e+""}function q8e(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:qr.axis};function X8e(t){var{x:e,y:n,width:r,height:i,orientation:a,mirror:s,axisLine:o,otherSvgProps:l}=t;if(!o)return null;var c=$r($r($r({},l),Ha(o)),{},{fill:"none"});if(a==="top"||a==="bottom"){var u=+(a==="top"&&!s||a==="bottom"&&s);c=$r($r({},c),{},{x1:e,y1:n+u*i,x2:e+r,y2:n+u*i})}else{var h=+(a==="left"&&!s||a==="right"&&s);c=$r($r({},c),{},{x1:e+h*r,y1:n,x2:e+h*r,y2:n+i})}return E.createElement("line",Vf({},c,{className:An("recharts-cartesian-axis-line",zf(o,"className"))}))}function K8e(t,e,n,r,i,a,s,o,l){var c,u,h,g,m,b,y=o?-1:1,v=t.tickSize||s,x=Et(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":c=u=t.coordinate,g=n+ +!o*i,h=g-y*v,b=h-y*l,m=x;break;case"left":h=g=t.coordinate,u=e+ +!o*r,c=u-y*v,m=c-y*l,b=x;break;case"right":h=g=t.coordinate,u=e+ +o*r,c=u+y*v,m=c+y*l,b=x;break;default:c=u=t.coordinate,g=n+ +o*i,h=g+y*v,b=h+y*l,m=x;break}return{line:{x1:c,y1:h,x2:u,y2:g},tick:{x:m,y:b}}}function Y8e(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function Z8e(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function Q8e(t){var{option:e,tickProps:n,value:r}=t,i,a=An(n.className,"recharts-cartesian-axis-tick-value");if(E.isValidElement(e))i=E.cloneElement(e,$r($r({},n),{},{className:a}));else if(typeof e=="function")i=e($r($r({},n),{},{className:a}));else{var s="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(s=An(s,e?.className)),i=E.createElement(yM,Vf({},n,{className:s}),r)}return i}var J8e=E.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:s,unit:o,padding:l,tickTextProps:c,orientation:u,mirror:h,x:g,y:m,width:b,height:y,tickSize:v,tickMargin:x,fontSize:M,letterSpacing:w,getTicksConfig:C,events:T,axisType:R}=t,A=pL($r($r({},C),{},{ticks:n}),M,w),j=Y8e(u,h),N=Z8e(u,h),k=Ha(C),F=Ff(r),I={};typeof i=="object"&&(I=i);var W=$r($r({},k),{},{fill:"none"},I),D=A.map(V=>$r({entry:V},K8e(V,g,m,b,y,u,v,h,x))),B=D.map(V=>{var{entry:Z,line:Y}=V;return E.createElement(Lr,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(Z.value,"-").concat(Z.coordinate,"-").concat(Z.tickCoord)},i&&E.createElement("line",Vf({},W,Y,{className:An("recharts-cartesian-axis-tick-line",zf(i,"className"))})))}),G=D.map((V,Z)=>{var{entry:Y,tick:ee}=V,H=$r($r($r($r({textAnchor:j,verticalAnchor:N},k),{},{stroke:"none",fill:a},F),ee),{},{index:Z,payload:Y,visibleTicksCount:A.length,tickFormatter:s,padding:l},c);return E.createElement(Lr,Vf({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Y.value,"-").concat(Y.coordinate,"-").concat(Y.tickCoord)},ev(T,Y,Z)),r&&E.createElement(Q8e,{option:r,tickProps:H,value:"".concat(typeof s=="function"?s(Y.value,Z):Y.value).concat(o||"")}))});return E.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(R,"-ticks")},G.length>0&&E.createElement(Wa,{zIndex:qr.label},E.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(R,"-tick-labels"),ref:e},G)),B.length>0&&E.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(R,"-tick-lines")},B))}),eHe=E.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:s,ticks:o,axisType:l}=t,c=$8e(t,H8e),[u,h]=E.useState(""),[g,m]=E.useState(""),b=E.useRef(null);E.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var v;return B8e({ticks:b.current,label:(v=t.labelRef)===null||v===void 0?void 0:v.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var y=E.useCallback(v=>{if(v){var x=v.getElementsByClassName("recharts-cartesian-axis-tick-value");b.current=x;var M=x[0];if(M){var w=window.getComputedStyle(M),C=w.fontSize,T=w.letterSpacing;(C!==u||T!==g)&&(h(C),m(T))}}},[u,g]);return s||r!=null&&r<=0||i!=null&&i<=0?null:E.createElement(Wa,{zIndex:t.zIndex},E.createElement(Lr,{className:An("recharts-cartesian-axis",a)},E.createElement(X8e,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Ha(t)}),E.createElement(J8e,{ref:y,axisType:l,events:c,fontSize:u,getTicksConfig:t,height:t.height,letterSpacing:g,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:o,unit:t.unit,width:t.width,x:t.x,y:t.y}),E.createElement(Mze,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},E.createElement(Oze,{label:t.label,labelRef:t.labelRef}),t.children)))}),mL=E.forwardRef((t,e)=>{var n=Zr(t,pc);return E.createElement(eHe,Vf({},n,{ref:e}))});mL.displayName="CartesianAxis";var tHe=["x1","y1","x2","y2","key"],nHe=["offset"],rHe=["xAxisId","yAxisId"],iHe=["xAxisId","yAxisId"];function nG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function na(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?nG(Object(n),!0).forEach(function(r){aHe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function aHe(t,e,n){return(e=sHe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sHe(t){var e=oHe(t,"string");return typeof e=="symbol"?e:e+""}function oHe(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 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 GS(t,e){if(t==null)return{};var n,r,i=lHe(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 lHe(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 cHe=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:a,height:s,ry:o}=t;return E.createElement("rect",{x:r,y:i,ry:o,width:a,height:s,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function IJ(t){var{option:e,lineItemProps:n}=t,r;if(E.isValidElement(e))r=E.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:a,y1:s,x2:o,y2:l,key:c}=n,u=GS(n,tHe),h=(i=Ha(u))!==null&&i!==void 0?i:{},{offset:g}=h,m=GS(h,nHe);r=E.createElement("line",of({},m,{x1:a,y1:s,x2:o,y2:l,fill:"none",key:c}))}return r}function uHe(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:s}=t,o=GS(t,rHe),l=i.map((c,u)=>{var h=na(na({},o),{},{x1:e,y1:c,x2:e+n,y2:c,key:"line-".concat(u),index:u});return E.createElement(IJ,{key:"line-".concat(u),option:r,lineItemProps:h})});return E.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function dHe(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:s}=t,o=GS(t,iHe),l=i.map((c,u)=>{var h=na(na({},o),{},{x1:c,y1:e,x2:c,y2:e+n,key:"line-".concat(u),index:u});return E.createElement(IJ,{option:r,lineItemProps:h,key:"line-".concat(u)})});return E.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function fHe(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:a,height:s,horizontalPoints:o,horizontal:l=!0}=t;if(!l||!e||!e.length||o==null)return null;var c=o.map(h=>Math.round(h+i-i)).sort((h,g)=>h-g);i!==c[0]&&c.unshift(0);var u=c.map((h,g)=>{var m=!c[g+1],b=m?i+s-h:c[g+1]-h;if(b<=0)return null;var y=g%e.length;return E.createElement("rect",{key:"react-".concat(g),y:h,x:r,height:b,width:a,stroke:"none",fill:e[y],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},u)}function hHe(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:s,height:o,verticalPoints:l}=t;if(!e||!n||!n.length)return null;var c=l.map(h=>Math.round(h+i-i)).sort((h,g)=>h-g);i!==c[0]&&c.unshift(0);var u=c.map((h,g)=>{var m=!c[g+1],b=m?i+s-h:c[g+1]-h;if(b<=0)return null;var y=g%n.length;return E.createElement("rect",{key:"react-".concat(g),x:h,y:a,width:b,height:o,stroke:"none",fill:n[y],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},u)}var pHe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return vY(pL(na(na(na({},pc),n),{},{ticks:bY(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},mHe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return vY(pL(na(na(na({},pc),n),{},{ticks:bY(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},gHe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:qr.grid};function _P(t){var e=BD(),n=HD(),r=CY(),i=na(na({},Zr(t,gHe)),{},{x:Et(t.x)?t.x:r.left,y:Et(t.y)?t.y:r.top,width:Et(t.width)?t.width:r.width,height:Et(t.height)?t.height:r.height}),{xAxisId:a,yAxisId:s,x:o,y:l,width:c,height:u,syncWithTicks:h,horizontalValues:g,verticalValues:m}=i,b=ca(),y=At(N=>W$(N,"xAxis",a,b)),v=At(N=>W$(N,"yAxis",s,b));if(!cl(c)||!cl(u)||!Et(o)||!Et(l))return null;var x=i.verticalCoordinatesGenerator||pHe,M=i.horizontalCoordinatesGenerator||mHe,{horizontalPoints:w,verticalPoints:C}=i;if((!w||!w.length)&&typeof M=="function"){var T=g&&g.length,R=M({yAxis:v?na(na({},v),{},{ticks:T?g:v.ticks}):void 0,width:e??c,height:n??u,offset:r},T?!0:h);gS(Array.isArray(R),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof R,"]")),Array.isArray(R)&&(w=R)}if((!C||!C.length)&&typeof x=="function"){var A=m&&m.length,j=x({xAxis:y?na(na({},y),{},{ticks:A?m:y.ticks}):void 0,width:e??c,height:n??u,offset:r},A?!0:h);gS(Array.isArray(j),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof j,"]")),Array.isArray(j)&&(C=j)}return E.createElement(Wa,{zIndex:i.zIndex},E.createElement("g",{className:"recharts-cartesian-grid"},E.createElement(cHe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),E.createElement(fHe,of({},i,{horizontalPoints:w})),E.createElement(hHe,of({},i,{verticalPoints:C})),E.createElement(uHe,of({},i,{offset:r,horizontalPoints:w,xAxis:y,yAxis:v})),E.createElement(dHe,of({},i,{offset:r,verticalPoints:C,xAxis:y,yAxis:v}))))}_P.displayName="CartesianGrid";function xHe(t){var e=Ff(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:a}=e,s=Number(i),o=Number(a);return(Number.isNaN(s)||s<0)&&(s=n),(Number.isNaN(o)||o<0)&&(o=r),{r:s,strokeWidth:o}}return{r:n,strokeWidth:r}}var jJ=(t,e,n,r)=>id(t,"xAxis",e,r),UJ=(t,e,n,r)=>rd(t,"xAxis",e,r),FJ=(t,e,n,r)=>id(t,"yAxis",n,r),zJ=(t,e,n,r)=>rd(t,"yAxis",n,r),vHe=Ve([Sn,jJ,FJ,UJ,zJ],(t,e,n,r,i)=>Cc(t,"xAxis")?pm(e,r,!1):pm(n,i,!1)),bHe=(t,e,n,r,i)=>i,BJ=Ve([mM,bHe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),yHe=(t,e,n,r,i)=>{var a,s=BJ(t,e,n,r,i);if(s!=null){var o=Sn(t),l=Cc(o,"xAxis"),c;if(l?c=D0(t,"yAxis",n,r):c=D0(t,"xAxis",e,r),c!=null){var{stackId:u}=s,h=dM(s);if(!(u==null||h==null)){var g=(a=c[u])===null||a===void 0?void 0:a.stackedData;return g?.find(m=>m.key===h)}}}},_He=Ve([Sn,jJ,FJ,UJ,zJ,yHe,lM,vHe,BJ,Pje],(t,e,n,r,i,a,s,o,l,c)=>{var{chartData:u,dataStartIndex:h,dataEndIndex:g}=s;if(!(l==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null)){var{data:m}=l,b;if(m&&m.length>0?b=m:b=u?.slice(h,g+1),b!=null)return zHe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:h,areaSettings:l,stackedData:a,displayedData:b,chartBaseValue:c,bandSize:o})}}),SHe=["id"],wHe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function yf(){return yf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},yf.apply(null,arguments)}function HJ(t,e){if(t==null)return{};var n,r,i=MHe(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 MHe(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 rG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Np(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?rG(Object(n),!0).forEach(function(r){EHe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):rG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function EHe(t,e,n){return(e=AHe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function AHe(t){var e=THe(t,"string");return typeof e=="symbol"?e:e+""}function THe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function WS(t,e){return t&&t!=="none"?t:e}var CHe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:s}=t;return[{inactive:s,dataKey:e,type:a,color:WS(r,i),value:Om(n,e),payload:t}]},NHe=E.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:s,hide:o,unit:l,tooltipType:c}=t,u={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Om(s,e),hide:o,type:c,color:WS(r,a),unit:l}};return E.createElement(cL,{tooltipEntrySettings:u})});function RHe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:s}=r,o=Ha(r);return E.createElement(SBe,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:s,baseProps:o,needClip:i,clipPathId:e})}function PHe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(a=>{var s,o,l={x:(s=a.x)!==null&&s!==void 0?s:0,y:(o=a.y)!==null&&o!==void 0?o:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Np(Np({},l),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:l,fill:void 0})});return E.createElement(dJ,{value:e?i:void 0},n)}function iG(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:a}=t,{layout:s,type:o,stroke:l,connectNulls:c,isRange:u}=a,{id:h}=a,g=HJ(a,SHe),m=Ha(g),b=Sa(g);return E.createElement(E.Fragment,null,e?.length>1&&E.createElement(Lr,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},E.createElement(Bp,yf({},b,{id:h,points:e,connectNulls:c,type:o,baseLine:n,layout:s,stroke:"none",className:"recharts-area-area"})),l!=="none"&&E.createElement(Bp,yf({},m,{className:"recharts-area-curve",layout:s,type:o,connectNulls:c,fill:"none",points:e})),l!=="none"&&u&&E.createElement(Bp,yf({},m,{className:"recharts-area-curve",layout:s,type:o,connectNulls:c,fill:"none",points:n}))),E.createElement(RHe,{points:e,props:g,clipPathId:i}))}function kHe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].y,s=r[r.length-1].y;if(!or(a)||!or(s))return null;var o=e*Math.abs(a-s),l=Math.max(...r.map(c=>c.x||0));return Et(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(c=>c.x||0),l)),Et(l)?E.createElement("rect",{x:0,y:a<s?a:a-o,width:l+(i?parseInt("".concat(i),10):1),height:Math.floor(o)}):null}function DHe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].x,s=r[r.length-1].x;if(!or(a)||!or(s))return null;var o=e*Math.abs(a-s),l=Math.max(...r.map(c=>c.y||0));return Et(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(c=>c.y||0),l)),Et(l)?E.createElement("rect",{x:a<s?a:a-o,y:0,width:o,height:Math.floor(l+(i?parseInt("".concat(i),10):1))}):null}function OHe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?E.createElement(kHe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):E.createElement(DHe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function LHe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a}=t,{points:s,baseLine:o,isAnimationActive:l,animationBegin:c,animationDuration:u,animationEasing:h,onAnimationStart:g,onAnimationEnd:m}=r,b=E.useMemo(()=>({points:s,baseLine:o}),[s,o]),y=ov(b,"recharts-area-"),v=Kke(),[x,M]=E.useState(!1),w=!x,C=E.useCallback(()=>{typeof m=="function"&&m(),M(!1)},[m]),T=E.useCallback(()=>{typeof g=="function"&&g(),M(!0)},[g]);if(v==null)return null;var R=i.current,A=a.current;return E.createElement(PHe,{showLabels:w,points:s},r.children,E.createElement(sv,{animationId:y,begin:c,duration:u,isActive:l,easing:h,onAnimationEnd:C,onAnimationStart:T,key:y},j=>{if(R){var N=R.length/s.length,k=j===1?s:s.map((I,W)=>{var D=Math.floor(W*N);if(R[D]){var B=R[D];return Np(Np({},I),{},{x:sr(B.x,I.x,j),y:sr(B.y,I.y,j)})}return I}),F;return Et(o)?F=sr(A,o,j):xr(o)||Xs(o)?F=sr(A,0,j):F=o.map((I,W)=>{var D=Math.floor(W*N);if(Array.isArray(A)&&A[D]){var B=A[D];return Np(Np({},I),{},{x:sr(B.x,I.x,j),y:sr(B.y,I.y,j)})}return I}),j>0&&(i.current=k,a.current=F),E.createElement(iG,{points:k,baseLine:F,needClip:e,clipPathId:n,props:r})}return j>0&&(i.current=s,a.current=o),E.createElement(Lr,null,l&&E.createElement("defs",null,E.createElement("clipPath",{id:"animationClipPath-".concat(n)},E.createElement(OHe,{alpha:j,points:s,baseLine:o,layout:v,strokeWidth:r.strokeWidth}))),E.createElement(Lr,{clipPath:"url(#animationClipPath-".concat(n,")")},E.createElement(iG,{points:s,baseLine:o,needClip:e,clipPathId:n,props:r})))}),E.createElement(nL,{label:r.label}))}function IHe(t){var{needClip:e,clipPathId:n,props:r}=t,i=E.useRef(null),a=E.useRef();return E.createElement(LHe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class jHe extends E.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:a,left:s,needClip:o,xAxisId:l,yAxisId:c,width:u,height:h,id:g,baseLine:m,zIndex:b}=this.props;if(e)return null;var y=An("recharts-area",i),v=g,{r:x,strokeWidth:M}=xHe(n),w=bJ(n),C=x*2+M,T=o?"url(#clipPath-".concat(w?"":"dots-").concat(v,")"):void 0;return E.createElement(Wa,{zIndex:b},E.createElement(Lr,{className:y},o&&E.createElement("defs",null,E.createElement(CJ,{clipPathId:v,xAxisId:l,yAxisId:c}),!w&&E.createElement("clipPath",{id:"clipPath-dots-".concat(v)},E.createElement("rect",{x:s-C/2,y:a-C/2,width:u+C,height:h+C}))),E.createElement(IHe,{needClip:o,clipPathId:v,props:this.props})),E.createElement(VV,{points:r,mainColor:WS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}),this.props.isRange&&Array.isArray(m)&&E.createElement(VV,{points:m,mainColor:WS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}))}}var $J={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:qr.area};function UHe(t){var e,n=Zr(t,$J),{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:s,connectNulls:o,dot:l,fill:c,fillOpacity:u,hide:h,isAnimationActive:g,legendType:m,stroke:b,xAxisId:y,yAxisId:v}=n,x=HJ(n,wHe),M=Lm(),w=WQ(),{needClip:C}=fL(y,v),T=ca(),{points:R,isRange:A,baseLine:j}=(e=At(D=>_He(D,y,v,T,t.id)))!==null&&e!==void 0?e:{},N=dL();if(M!=="horizontal"&&M!=="vertical"||N==null||w!=="AreaChart"&&w!=="ComposedChart")return null;var{height:k,width:F,x:I,y:W}=N;return!R||!R.length?null:E.createElement(jHe,yf({},x,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:s,baseLine:j,connectNulls:o,dot:l,fill:c,fillOpacity:u,height:k,hide:h,layout:M,isAnimationActive:g==="auto"?!Im.isSsr:g,isRange:A,legendType:m,needClip:C,points:R,stroke:b,width:F,left:I,top:W,xAxisId:y,yAxisId:v}))}var FHe=(t,e,n,r,i)=>{var a=n??e;if(Et(a))return a;var s=t==="horizontal"?i:r,o=s.scale.domain();if(s.type==="number"){var l=Math.max(o[0],o[1]),c=Math.min(o[0],o[1]);return a==="dataMin"?c:a==="dataMax"||l<0?l:Math.max(Math.min(o[0],o[1]),0)}return a==="dataMin"?o[0]:a==="dataMax"?o[1]:o[0]};function zHe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:s,xAxis:o,yAxis:l,displayedData:c,dataStartIndex:u,xAxisTicks:h,yAxisTicks:g,bandSize:m}=t,b=i&&i.length,y=FHe(a,s,n,o,l),v=a==="horizontal",x=!1,M=c.map((C,T)=>{var R;b?R=i[u+T]:(R=Yn(C,r),Array.isArray(R)?x=!0:R=[y,R]);var A=R[1]==null||b&&!e&&Yn(C,r)==null;return v?{x:dH({axis:o,ticks:h,bandSize:m,entry:C,index:T}),y:A?null:l.scale(R[1]),value:R,payload:C}:{x:A?null:o.scale(R[1]),y:dH({axis:l,ticks:g,bandSize:m,entry:C,index:T}),value:R,payload:C}}),w;return b||x?w=M.map(C=>{var T=Array.isArray(C.value)?C.value[0]:null;return v?{x:C.x,y:T!=null&&C.y!=null?l.scale(T):null,payload:C.payload}:{x:T!=null?o.scale(T):null,y:C.y,payload:C.payload}}):w=v?l.scale(y):o.scale(y),{points:M,baseLine:w,isRange:x}}function BHe(t){var e=Zr(t,$J),n=ca();return E.createElement(uL,{id:e.id,type:"area"},r=>E.createElement(E.Fragment,null,E.createElement(_J,{legendPayload:CHe(e)}),E.createElement(NHe,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),E.createElement(MJ,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:yY(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),E.createElement(UHe,yf({},e,{id:r}))))}var VJ=E.memo(BHe,MM);VJ.displayName="Area";var HHe=["domain","range"],$He=["domain","range"];function aG(t,e){if(t==null)return{};var n,r,i=VHe(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 VHe(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 sG(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 GJ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=aG(t,HHe),{domain:a,range:s}=e,o=aG(e,$He);return!sG(n,a)||!sG(r,s)?!1:MM(i,o)}var GHe=["dangerouslySetInnerHTML","ticks"],WHe=["id"];function SP(){return SP=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},SP.apply(null,arguments)}function oG(t,e){if(t==null)return{};var n,r,i=qHe(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 qHe(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 XHe(t){var e=er(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(TBe(t)):n.current!==t&&e(CBe({prev:n.current,next:t})),n.current=t},[t,e]),E.useLayoutEffect(()=>()=>{n.current&&(e(NBe(n.current)),n.current=null)},[e]),null}var KHe=t=>{var{xAxisId:e,className:n}=t,r=At(FD),i=ca(),a="xAxis",s=At(v=>$m(v,a,e,i)),o=At(v=>MQ(v,a,e,i)),l=At(v=>yQ(v,e)),c=At(v=>C4e(v,e)),u=At(v=>tQ(v,e));if(l==null||c==null||u==null)return null;var{dangerouslySetInnerHTML:h,ticks:g}=t,m=oG(t,GHe),{id:b}=u,y=oG(u,WHe);return E.createElement(mL,SP({},m,y,{scale:s,x:c.x,y:c.y,width:l.width,height:l.height,className:An("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:o,axisType:a}))},YHe={allowDataOverflow:_i.allowDataOverflow,allowDecimals:_i.allowDecimals,allowDuplicatedCategory:_i.allowDuplicatedCategory,angle:_i.angle,axisLine:pc.axisLine,height:_i.height,hide:!1,includeHidden:_i.includeHidden,interval:_i.interval,minTickGap:_i.minTickGap,mirror:_i.mirror,orientation:_i.orientation,padding:_i.padding,reversed:_i.reversed,scale:_i.scale,tick:_i.tick,tickCount:_i.tickCount,tickLine:pc.tickLine,tickSize:pc.tickSize,type:_i.type,xAxisId:0},ZHe=t=>{var e=Zr(t,YHe);return E.createElement(E.Fragment,null,E.createElement(XHe,{allowDataOverflow:e.allowDataOverflow,allowDecimals:e.allowDecimals,allowDuplicatedCategory:e.allowDuplicatedCategory,angle:e.angle,dataKey:e.dataKey,domain:e.domain,height:e.height,hide:e.hide,id:e.xAxisId,includeHidden:e.includeHidden,interval:e.interval,minTickGap:e.minTickGap,mirror:e.mirror,name:e.name,orientation:e.orientation,padding:e.padding,reversed:e.reversed,scale:e.scale,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit}),E.createElement(KHe,e))},wP=E.memo(ZHe,GJ);wP.displayName="XAxis";var QHe=["dangerouslySetInnerHTML","ticks"],JHe=["id"];function MP(){return MP=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},MP.apply(null,arguments)}function lG(t,e){if(t==null)return{};var n,r,i=e$e(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 e$e(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 t$e(t){var e=er(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(RBe(t)):n.current!==t&&e(PBe({prev:n.current,next:t})),n.current=t},[t,e]),E.useLayoutEffect(()=>()=>{n.current&&(e(kBe(n.current)),n.current=null)},[e]),null}var n$e=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,a=E.useRef(null),s=E.useRef(null),o=At(FD),l=ca(),c=er(),u="yAxis",h=At(T=>$m(T,u,e,l)),g=At(T=>_Q(T,e)),m=At(T=>R4e(T,e)),b=At(T=>MQ(T,u,e,l)),y=At(T=>nQ(T,e));if(E.useLayoutEffect(()=>{if(!(r!=="auto"||!g||tL(i)||E.isValidElement(i)||y==null)){var T=a.current;if(T){var R=T.getCalculatedWidth();Math.round(g.width)!==Math.round(R)&&c(DBe({id:e,width:R}))}}},[b,g,c,i,e,r,y]),g==null||m==null||y==null)return null;var{dangerouslySetInnerHTML:v,ticks:x}=t,M=lG(t,QHe),{id:w}=y,C=lG(y,JHe);return E.createElement(mL,MP({},M,C,{ref:a,labelRef:s,scale:h,x:m.x,y:m.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:g.width,height:g.height,className:An("recharts-".concat(u," ").concat(u),n),viewBox:o,ticks:b,axisType:u}))},r$e={allowDataOverflow:Si.allowDataOverflow,allowDecimals:Si.allowDecimals,allowDuplicatedCategory:Si.allowDuplicatedCategory,angle:Si.angle,axisLine:pc.axisLine,hide:!1,includeHidden:Si.includeHidden,interval:Si.interval,minTickGap:Si.minTickGap,mirror:Si.mirror,orientation:Si.orientation,padding:Si.padding,reversed:Si.reversed,scale:Si.scale,tick:Si.tick,tickCount:Si.tickCount,tickLine:pc.tickLine,tickSize:pc.tickSize,type:Si.type,width:Si.width,yAxisId:0},i$e=t=>{var e=Zr(t,r$e);return E.createElement(E.Fragment,null,E.createElement(t$e,{interval:e.interval,id:e.yAxisId,scale:e.scale,type:e.type,domain:e.domain,allowDataOverflow:e.allowDataOverflow,dataKey:e.dataKey,allowDuplicatedCategory:e.allowDuplicatedCategory,allowDecimals:e.allowDecimals,tickCount:e.tickCount,padding:e.padding,includeHidden:e.includeHidden,reversed:e.reversed,ticks:e.ticks,width:e.width,orientation:e.orientation,mirror:e.mirror,hide:e.hide,unit:e.unit,name:e.name,angle:e.angle,minTickGap:e.minTickGap,tick:e.tick,tickFormatter:e.tickFormatter}),E.createElement(n$e,e))},EP=E.memo(i$e,GJ);EP.displayName="YAxis";var a$e=(t,e)=>e,gL=Ve([a$e,Sn,JZ,fi,zQ,Oc,GUe,ui],QUe),xL=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)}},WJ=Ks("mouseClick"),qJ=rv();qJ.startListening({actionCreator:WJ,effect:(t,e)=>{var n=t.payload,r=gL(e.getState(),xL(n));r?.activeIndex!=null&&e.dispatch(V4e({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var AP=Ks("mouseMove"),XJ=rv(),f_=null;XJ.startListening({actionCreator:AP,effect:(t,e)=>{var n=t.payload;f_!==null&&cancelAnimationFrame(f_);var r=xL(n);f_=requestAnimationFrame(()=>{var i=e.getState(),a=$O(i,i.tooltip.settings.shared);if(a==="axis"){var s=gL(i,r);s?.activeIndex!=null?e.dispatch(kQ({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate})):e.dispatch(PQ())}f_=null})}});var cG={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},KJ=Ga({name:"rootProps",initialState:cG,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:cG.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}}}),s$e=KJ.reducer,{updateOptions:o$e}=KJ.actions,YJ=Ga({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:l$e}=YJ.actions,c$e=YJ.reducer,ZJ=Ks("keyDown"),QJ=Ks("focus"),vL=rv();vL.startListening({actionCreator:ZJ,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=VO(i,Gm(n),gv(n),yv(n)),o=s==null?-1:Number(s);if(!(!Number.isFinite(o)||o<0)){var l=Oc(n);if(a==="Enter"){var c=jS(n,"axis","hover",String(i.index));e.dispatch(pP({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:c}));return}var u=O4e(n),h=u==="left-to-right"?1:-1,g=a==="ArrowRight"?1:-1,m=o+g*h;if(!(l==null||m>=l.length||m<0)){var b=jS(n,"axis","hover",String(m));e.dispatch(pP({active:!0,activeIndex:m.toString(),activeDataKey:void 0,activeCoordinate:b}))}}}}}});vL.startListening({actionCreator:QJ,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=jS(n,"axis","hover",String(a));e.dispatch(pP({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:s}))}}}});var Rs=Ks("externalEvent"),JJ=rv(),bN=new Map;JJ.startListening({actionCreator:Rs,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=bN.get(i);a!==void 0&&cancelAnimationFrame(a);var s=requestAnimationFrame(()=>{try{var o=e.getState(),l={activeCoordinate:RUe(o),activeDataKey:KO(o),activeIndex:ad(o),activeLabel:$Q(o),activeTooltipIndex:ad(o),isTooltipActive:PUe(o)};n(l,r)}finally{bN.delete(i)}});bN.set(i,s)}}});var u$e=Ve([Vm],t=>t.tooltipItemPayloads),d$e=Ve([u$e,vv,(t,e,n)=>e,(t,e,n)=>n],(t,e,n,r)=>{var i=t.find(o=>o.settings.dataKey===r);if(i!=null){var{positions:a}=i;if(a!=null){var s=e(a,n);return s}}}),eee=Ks("touchMove"),tee=rv();tee.startListening({actionCreator:eee,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=$O(r,r.tooltip.settings.shared);if(i==="axis"){var a=gL(r,xL({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));a?.activeIndex!=null&&e.dispatch(kQ({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate}))}else if(i==="item"){var s,o=n.touches[0];if(document.elementFromPoint==null)return;var l=document.elementFromPoint(o.clientX,o.clientY);if(!l||!l.getAttribute)return;var c=l.getAttribute(SY),u=(s=l.getAttribute(wY))!==null&&s!==void 0?s:void 0,h=d$e(e.getState(),c,u);e.dispatch(RQ({activeDataKey:u,activeIndex:c,activeCoordinate:h}))}}}});var f$e=$K({brush:S8e,cartesianAxis:OBe,chartData:NFe,errorBars:JBe,graphicalItems:z5e,layout:nke,legend:uDe,options:MFe,polarAxis:t5e,polarOptions:c$e,referenceElements:N8e,rootProps:s$e,tooltip:G4e,zIndex:fFe}),h$e=function(e){return TPe({reducer:f$e,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([qJ.middleware,XJ.middleware,vL.middleware,JJ.middleware,tee.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(iY({type:"raf"}))},devTools:Im.devToolsEnabled})};function nee(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=ca(),a=E.useRef(null);if(i)return n;a.current==null&&(a.current=h$e(e));var s=RD;return E.createElement(M6e,{context:s,store:a.current},n)}function p$e(t){var{layout:e,margin:n}=t,r=er(),i=ca();return E.useEffect(()=>{i||(r(JPe(e)),r(QPe(n)))},[r,i,e,n]),null}var ree=E.memo(p$e,MM);function iee(t){var e=er();return E.useEffect(()=>{e(o$e(t))},[e,t]),null}function uG(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=SJ("".concat(r).concat(e)),a=er();return E.useLayoutEffect(()=>(a(uFe({zIndex:e,elementId:i,isPanorama:n})),()=>{a(dFe({zIndex:e,isPanorama:n}))}),[a,e,i,n]),E.createElement("g",{tabIndex:-1,id:i})}function dG(t){var{children:e,isPanorama:n}=t,r=At(eFe);if(!r||r.length===0)return e;var i=r.filter(s=>s<0),a=r.filter(s=>s>0);return E.createElement(E.Fragment,null,i.map(s=>E.createElement(uG,{key:s,zIndex:s,isPanorama:n})),e,a.map(s=>E.createElement(uG,{key:s,zIndex:s,isPanorama:n})))}var m$e=["children"];function g$e(t,e){if(t==null)return{};var n,r,i=x$e(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 x$e(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 qS(){return qS=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},qS.apply(null,arguments)}var v$e={width:"100%",height:"100%",display:"block"},b$e=E.forwardRef((t,e)=>{var n=BD(),r=HD(),i=zY();if(!cl(n)||!cl(r))return null;var{children:a,otherAttributes:s,title:o,desc:l}=t,c,u;return s!=null&&(typeof s.tabIndex=="number"?c=s.tabIndex:c=i?0:void 0,typeof s.role=="string"?u=s.role:u=i?"application":void 0),E.createElement(yD,qS({},s,{title:o,desc:l,role:u,tabIndex:c,width:n,height:r,style:v$e,ref:e}),a)}),y$e=t=>{var{children:e}=t,n=At(Yw);if(!n)return null;var{width:r,height:i,y:a,x:s}=n;return E.createElement(yD,{width:r,height:i,x:s,y:a},e)},fG=E.forwardRef((t,e)=>{var{children:n}=t,r=g$e(t,m$e),i=ca();return i?E.createElement(y$e,null,E.createElement(dG,{isPanorama:!0},n)):E.createElement(b$e,qS({ref:e},r),E.createElement(dG,{isPanorama:!1},n))});function _$e(){var t=er(),[e,n]=E.useState(null),r=At(bke);return E.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;or(a)&&a!==r&&t(tke(a))}},[e,t,r]),n}function hG(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 S$e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?hG(Object(n),!0).forEach(function(r){w$e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):hG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function w$e(t,e,n){return(e=M$e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function M$e(t){var e=E$e(t,"string");return typeof e=="symbol"?e:e+""}function E$e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Gf(){return Gf=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},Gf.apply(null,arguments)}var A$e=()=>(UFe(),null);function XS(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var T$e=E.forwardRef((t,e)=>{var n,r,i=E.useRef(null),[a,s]=E.useState({containerWidth:XS((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:XS((r=t.style)===null||r===void 0?void 0:r.height)}),o=E.useCallback((c,u)=>{s(h=>{var g=Math.round(c),m=Math.round(u);return h.containerWidth===g&&h.containerHeight===m?h:{containerWidth:g,containerHeight:m}})},[]),l=E.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null&&typeof ResizeObserver<"u"){var{width:u,height:h}=c.getBoundingClientRect();o(u,h);var g=b=>{var{width:y,height:v}=b[0].contentRect;o(y,v)},m=new ResizeObserver(g);m.observe(c),i.current=m}},[e,o]);return E.useEffect(()=>()=>{var c=i.current;c?.disconnect()},[o]),E.createElement(E.Fragment,null,E.createElement(Qw,{width:a.containerWidth,height:a.containerHeight}),E.createElement("div",Gf({ref:l},t)))}),C$e=E.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=E.useState({containerWidth:XS(n),containerHeight:XS(r)}),s=E.useCallback((l,c)=>{a(u=>{var h=Math.round(l),g=Math.round(c);return u.containerWidth===h&&u.containerHeight===g?u:{containerWidth:h,containerHeight:g}})},[]),o=E.useCallback(l=>{if(typeof e=="function"&&e(l),l!=null){var{width:c,height:u}=l.getBoundingClientRect();s(c,u)}},[e,s]);return E.createElement(E.Fragment,null,E.createElement(Qw,{width:i.containerWidth,height:i.containerHeight}),E.createElement("div",Gf({ref:o},t)))}),N$e=E.forwardRef((t,e)=>{var{width:n,height:r}=t;return E.createElement(E.Fragment,null,E.createElement(Qw,{width:n,height:r}),E.createElement("div",Gf({ref:e},t)))}),R$e=E.forwardRef((t,e)=>{var{width:n,height:r}=t;return yc(n)||yc(r)?E.createElement(C$e,Gf({},t,{ref:e})):E.createElement(N$e,Gf({},t,{ref:e}))});function P$e(t){return t===!0?T$e:R$e}var k$e=E.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:s,onDoubleClick:o,onMouseDown:l,onMouseEnter:c,onMouseLeave:u,onMouseMove:h,onMouseUp:g,onTouchEnd:m,onTouchMove:b,onTouchStart:y,style:v,width:x,responsive:M,dispatchTouchEvents:w=!0}=t,C=E.useRef(null),T=er(),[R,A]=E.useState(null),[j,N]=E.useState(null),k=_$e(),F=zD(),I=F?.width>0?F.width:x,W=F?.height>0?F.height:i,D=E.useCallback(he=>{k(he),typeof e=="function"&&e(he),A(he),N(he),he!=null&&(C.current=he)},[k,e,A,N]),B=E.useCallback(he=>{T(WJ(he)),T(Rs({handler:a,reactEvent:he}))},[T,a]),G=E.useCallback(he=>{T(AP(he)),T(Rs({handler:c,reactEvent:he}))},[T,c]),V=E.useCallback(he=>{T(PQ()),T(Rs({handler:u,reactEvent:he}))},[T,u]),Z=E.useCallback(he=>{T(AP(he)),T(Rs({handler:h,reactEvent:he}))},[T,h]),Y=E.useCallback(()=>{T(QJ())},[T]),ee=E.useCallback(he=>{T(ZJ(he.key))},[T]),H=E.useCallback(he=>{T(Rs({handler:s,reactEvent:he}))},[T,s]),q=E.useCallback(he=>{T(Rs({handler:o,reactEvent:he}))},[T,o]),ae=E.useCallback(he=>{T(Rs({handler:l,reactEvent:he}))},[T,l]),ce=E.useCallback(he=>{T(Rs({handler:g,reactEvent:he}))},[T,g]),xe=E.useCallback(he=>{T(Rs({handler:y,reactEvent:he}))},[T,y]),ie=E.useCallback(he=>{w&&T(eee(he)),T(Rs({handler:b,reactEvent:he}))},[T,w,b]),ve=E.useCallback(he=>{T(Rs({handler:m,reactEvent:he}))},[T,m]),Pe=P$e(M);return E.createElement(ZQ.Provider,{value:R},E.createElement(aK.Provider,{value:j},E.createElement(Pe,{width:I??v?.width,height:W??v?.height,className:An("recharts-wrapper",r),style:S$e({position:"relative",cursor:"default",width:I,height:W},v),onClick:B,onContextMenu:H,onDoubleClick:q,onFocus:Y,onKeyDown:ee,onMouseDown:ae,onMouseEnter:G,onMouseLeave:V,onMouseMove:Z,onMouseUp:ce,onTouchEnd:ve,onTouchMove:ie,onTouchStart:xe,ref:D},E.createElement(A$e,null),n)))}),D$e=["width","height","responsive","children","className","style","compact","title","desc"];function O$e(t,e){if(t==null)return{};var n,r,i=L$e(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 L$e(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 aee=E.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:a,className:s,style:o,compact:l,title:c,desc:u}=t,h=O$e(t,D$e),g=Ha(h);return l?E.createElement(E.Fragment,null,E.createElement(Qw,{width:n,height:r}),E.createElement(fG,{otherAttributes:g,title:c,desc:u},a)):E.createElement(k$e,{className:s,style:o,width:n,height:r,responsive:i??!1,onClick:t.onClick,onMouseLeave:t.onMouseLeave,onMouseEnter:t.onMouseEnter,onMouseMove:t.onMouseMove,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onContextMenu:t.onContextMenu,onDoubleClick:t.onDoubleClick,onTouchStart:t.onTouchStart,onTouchMove:t.onTouchMove,onTouchEnd:t.onTouchEnd},E.createElement(fG,{otherAttributes:g,title:c,desc:u,ref:e},E.createElement(P8e,null,a)))});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)}var I$e={top:5,right:5,bottom:5,left:5},j$e={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:I$e,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},see=E.forwardRef(function(e,n){var r,i=Zr(e.categoricalChartProps,j$e),{chartName:a,defaultTooltipEventType:s,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,categoricalChartProps:c}=e,u={chartName:a,defaultTooltipEventType:s,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,eventEmitter:void 0};return E.createElement(nee,{preloadedState:{options:u},reduxStoreName:(r=c.id)!==null&&r!==void 0?r:a},E.createElement(kJ,{chartData:c.data}),E.createElement(ree,{layout:i.layout,margin:i.margin}),E.createElement(iee,{baseValue:i.baseValue,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),E.createElement(aee,TP({},i,{ref:n})))}),U$e=["axis","item"],F$e=E.forwardRef((t,e)=>E.createElement(see,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:U$e,tooltipPayloadSearcher:eL,categoricalChartProps:t,ref:e}));function z$e(t){var e=er();return E.useEffect(()=>{e(l$e(t))},[e,t]),null}var B$e=["layout"];function CP(){return CP=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},CP.apply(null,arguments)}function H$e(t,e){if(t==null)return{};var n,r,i=$$e(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 $$e(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 V$e={top:5,right:5,bottom:5,left:5},oee={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:V$e,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},G$e=E.forwardRef(function(e,n){var r,i=Zr(e.categoricalChartProps,oee),{layout:a}=i,s=H$e(i,B$e),{chartName:o,defaultTooltipEventType:l,validateTooltipEventTypes:c,tooltipPayloadSearcher:u}=e,h={chartName:o,defaultTooltipEventType:l,validateTooltipEventTypes:c,tooltipPayloadSearcher:u,eventEmitter:void 0};return E.createElement(nee,{preloadedState:{options:h},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:o},E.createElement(kJ,{chartData:i.data}),E.createElement(ree,{layout:a,margin:i.margin}),E.createElement(iee,{baseValue:void 0,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),E.createElement(z$e,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),E.createElement(aee,CP({},s,{ref:n})))});function pG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function mG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?pG(Object(n),!0).forEach(function(r){W$e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):pG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function W$e(t,e,n){return(e=q$e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function q$e(t){var e=X$e(t,"string");return typeof e=="symbol"?e:e+""}function X$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 K$e=["item"],Y$e=mG(mG({},oee),{},{layout:"centric",startAngle:0,endAngle:360}),Z$e=E.forwardRef((t,e)=>{var n=Zr(t,Y$e);return E.createElement(G$e,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:K$e,tooltipPayloadSearcher:eL,categoricalChartProps:n,ref:e})}),Q$e=["axis"],J$e=E.forwardRef((t,e)=>E.createElement(see,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Q$e,tooltipPayloadSearcher:eL,categoricalChartProps:t,ref:e}));const h_=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function eVe(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 tVe({archives:t,currency:e="$"}){const[n,r]=E.useState("30d"),i=E.useMemo(()=>{const g=eVe(n);return t.filter(m=>new Date(m.completed_at||m.created_at)>=g)},[t,n]),a=E.useMemo(()=>{const g=new Map;return i.forEach(m=>{const y=new Date(m.completed_at||m.created_at).toISOString().split("T")[0],v=g.get(y)||{date:y,filament:0,cost:0,prints:0};v.filament+=m.filament_used_grams||0,v.cost+=m.cost||0,v.prints+=1,g.set(y,v)}),Array.from(g.values()).sort((m,b)=>m.date.localeCompare(b.date)).map(m=>({...m,dateLabel:new Date(m.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),s=E.useMemo(()=>{if(n==="7d"||n==="30d")return a;const g=new Map;return i.forEach(m=>{const b=new Date(m.completed_at||m.created_at),y=new Date(b);y.setDate(b.getDate()-b.getDay());const v=y.toISOString().split("T")[0],x=g.get(v)||{week:v,filament:0,cost:0,prints:0};x.filament+=m.filament_used_grams||0,x.cost+=m.cost||0,x.prints+=1,g.set(v,x)}),Array.from(g.values()).sort((m,b)=>m.week.localeCompare(b.week)).map(m=>({date:m.week,dateLabel:`Week of ${new Date(m.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...m}))},[i,a,n]),o=E.useMemo(()=>{const g=new Map;return i.forEach(m=>{const y=(m.filament_type||"Unknown").split(", ");y.forEach(v=>{const x=(m.filament_used_grams||0)/y.length;g.set(v,(g.get(v)||0)+x)})}),Array.from(g.entries()).map(([m,b])=>({name:m,value:Math.round(b)})).sort((m,b)=>b.value-m.value)},[i]),l=E.useMemo(()=>{const g=new Date,m=[];for(let b=5;b>=0;b--){const y=new Date(g.getFullYear(),g.getMonth()-b,1),v=new Date(g.getFullYear(),g.getMonth()-b+1,0),x=y.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),M=t.filter(w=>{const C=new Date(w.completed_at||w.created_at);return C>=y&&C<=v});m.push({month:x,filament:Math.round(M.reduce((w,C)=>w+(C.filament_used_grams||0),0)),cost:M.reduce((w,C)=>w+(C.cost||0),0),prints:M.length})}return m},[t]),c=n==="7d"||n==="30d"?a:s,u=i.reduce((g,m)=>g+(m.filament_used_grams||0),0),h=i.reduce((g,m)=>g+(m.cost||0),0);return f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),f.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(g=>f.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))})]}),f.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[f.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[f.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),f.jsxs("p",{className:"text-2xl font-bold text-white",children:[(u/1e3).toFixed(2),"kg"]}),f.jsxs("p",{className:"text-xs text-bambu-gray",children:[u.toFixed(0),"g total"]})]}),f.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[f.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),f.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,h.toFixed(2)]}),f.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),f.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[f.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),f.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(u/i.length).toFixed(0):0,"g"]}),f.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(h/i.length).toFixed(2):"0.00"," avg"]})]})]}),c.length>0?f.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[f.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),f.jsx(zC,{width:"100%",height:250,children:f.jsxs(J$e,{data:c,children:[f.jsx("defs",{children:f.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[f.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),f.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),f.jsx(_P,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),f.jsx(wP,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),f.jsx(EP,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),f.jsx(iN,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:g=>[`${g.toFixed(0)}g`,"Filament"]}),f.jsx(VJ,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):f.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),f.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[f.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[f.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),o.length>0?f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsx(zC,{width:160,height:160,children:f.jsxs(Z$e,{children:[f.jsx(EJ,{data:o,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:o.map((g,m)=>f.jsx(Sv,{fill:h_[m%h_.length]},`cell-${m}`))}),f.jsx(iN,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:g=>[`${g}g`,"Usage"]})]})}),f.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:o.map((g,m)=>{const b=o.reduce((v,x)=>v+x.value,0),y=b>0?(g.value/b*100).toFixed(0):0;return f.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[f.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:h_[m%h_.length]}}),f.jsx("span",{className:"text-white truncate flex-1",children:g.name}),f.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[y,"%"]})]},g.name)})})]}):f.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),f.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[f.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),f.jsx(zC,{width:"100%",height:200,children:f.jsxs(F$e,{data:l,children:[f.jsx(_P,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),f.jsx(wP,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),f.jsx(EP,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),f.jsx(iN,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(g,m)=>[m==="filament"?`${g}g`:m==="cost"?`${e}${g.toFixed(2)}`:g,m==="filament"?"Filament":m==="cost"?"Cost":"Prints"]}),f.jsx(FY,{}),f.jsx(RJ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function nVe({id:t,title:e,children:n,isHidden:r,size:i,onToggleVisibility:a,onToggleSize:s}){const{attributes:o,listeners:l,setNodeRef:c,transform:u,transition:h,isDragging:g}=QX({id:t}),m={transform:um.Transform.toString(u),transition:h,opacity:g?.5:1};return r?null:f.jsxs("div",{ref:c,style:{...m,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${g?"ring-2 ring-bambu-green shadow-lg":""}`,children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{...o,...l,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:f.jsx(XP,{className:"w-4 h-4 text-bambu-gray"})}),f.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.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?f.jsx(Poe,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):f.jsx(Toe,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),f.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:f.jsx(WP,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),f.jsx("div",{className:"p-4",children:n})]})}function rVe({widgets:t,storageKey:e,columns:n=4}){const r=()=>{const v={};return t.forEach(x=>{v[x.id]=x.defaultSize||4}),v},[i,a]=E.useState(()=>{const v=localStorage.getItem(e);if(v)try{const x=JSON.parse(v);return x.sizes||(x.sizes=r()),x}catch{}return{order:t.map(x=>x.id),hidden:t.filter(x=>x.defaultVisible===!1).map(x=>x.id),sizes:r()}}),[s,o]=E.useState(!1);E.useEffect(()=>{localStorage.setItem(e,JSON.stringify(i))},[i,e]),E.useEffect(()=>{const x=t.map(M=>M.id).filter(M=>!i.order.includes(M));x.length>0&&a(M=>({...M,order:[...M.order,...x]}))},[t,i.order]);const l=RX(J1(Pw,{activationConstraint:{distance:8}}),J1(Rw,{coordinateGetter:JX})),c=v=>{const{active:x,over:M}=v;M&&x.id!==M.id&&a(w=>{const C=w.order.indexOf(x.id),T=w.order.indexOf(M.id);return{...w,order:Ow(w.order,C,T)}})},u=v=>{a(x=>({...x,hidden:x.hidden.includes(v)?x.hidden.filter(M=>M!==v):[...x.hidden,v]}))},h=v=>{a(x=>{const M=x.sizes[v]||4,w=M===1?2:M===2?4:1;return{...x,sizes:{...x.sizes,[v]:w}}})},g=()=>{const v={order:t.map(x=>x.id),hidden:t.filter(x=>x.defaultVisible===!1).map(x=>x.id),sizes:r()};a(v)},m=i.order.map(v=>t.find(x=>x.id===v)).filter(Boolean),b=m.filter(v=>!i.hidden.includes(v.id)),y=m.filter(v=>i.hidden.includes(v.id));return f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-end gap-2",children:[y.length>0&&f.jsxs(qe,{variant:"secondary",size:"sm",onClick:()=>o(!s),children:[f.jsx(W_,{className:"w-4 h-4"}),y.length," Hidden"]}),f.jsxs(qe,{variant:"secondary",size:"sm",onClick:g,children:[f.jsx(tw,{className:"w-4 h-4"}),"Reset Layout"]})]}),s&&y.length>0&&f.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[f.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),f.jsx("div",{className:"flex flex-wrap gap-2",children:y.map(v=>f.jsxs("button",{onClick:()=>u(v.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:[f.jsx(W_,{className:"w-3 h-3"}),v.title]},v.id))})]}),f.jsx(qX,{sensors:l,collisionDetection:OX,onDragEnd:c,children:f.jsx(YX,{items:b.map(v=>v.id),strategy:vD,children:f.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:b.map(v=>f.jsx(nVe,{id:v.id,title:v.title,isHidden:i.hidden.includes(v.id),size:i.sizes[v.id]||2,onToggleVisibility:()=>u(v.id),onToggleSize:()=>h(v.id),children:v.component},v.id))})})}),b.length===0&&f.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[f.jsx("p",{children:"All widgets are hidden."}),f.jsx(qe,{className:"mt-4",onClick:g,children:"Reset Layout"})]})]})}function iVe({stats:t,currency:e}){return f.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:f.jsx(K_,{className:"w-5 h-5"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),f.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:f.jsx(Ni,{className:"w-5 h-5"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),f.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:f.jsx(K_,{className:"w-5 h-5"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),f.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:f.jsx(QU,{className:"w-5 h-5"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),f.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:f.jsx(b9,{className:"w-5 h-5"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),f.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:f.jsx(QU,{className:"w-5 h-5"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),f.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function aVe({stats:t}){const e=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0;return f.jsxs("div",{className:"flex items-center gap-6",children:[f.jsxs("div",{className:"relative w-28 h-28",children:[f.jsxs("svg",{className:"w-full h-full -rotate-90",children:[f.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),f.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${e*3.02} 302`})]}),f.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:f.jsxs("span",{className:"text-xl font-bold text-white",children:[e,"%"]})})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(gc,{className:"w-4 h-4 text-bambu-green"}),f.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),f.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(z0,{className:"w-4 h-4 text-red-400"}),f.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),f.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]})]})}function sVe({stats:t,printerMap:e}){const n=t?.average_time_accuracy;if(n==null)return f.jsx("div",{className:"flex items-center justify-center h-full",children:f.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=(l=>l>=95&&l<=105?"#00ae42":l>105?"#3b82f6":"#f97316")(n),o=n-100;return f.jsxs("div",{className:"flex items-center gap-6",children:[f.jsxs("div",{className:"relative w-28 h-28",children:[f.jsxs("svg",{className:"w-full h-full -rotate-90",children:[f.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),f.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:s,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i*3.02} 302`})]}),f.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[f.jsxs("span",{className:"text-xl font-bold text-white",children:[n.toFixed(0),"%"]}),f.jsxs("span",{className:`text-xs ${o>=0?"text-blue-400":"text-orange-400"}`,children:[o>=0?"+":"",o.toFixed(0),"%"]})]})]}),f.jsxs("div",{className:"space-y-2 flex-1",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[f.jsx(Sle,{className:"w-3 h-3"}),f.jsx("span",{children:"100% = perfect estimate"})]}),t?.time_accuracy_by_printer&&Object.keys(t.time_accuracy_by_printer).length>0&&f.jsx("div",{className:"space-y-1 mt-2",children:Object.entries(t.time_accuracy_by_printer).slice(0,3).map(([l,c])=>f.jsxs("div",{className:"flex items-center justify-between text-xs",children:[f.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(l)||`Printer ${l}`}),f.jsxs("span",{className:`font-medium ${c>=95&&c<=105?"text-bambu-green":c>105?"text-blue-400":"text-orange-400"}`,children:[c.toFixed(0),"%"]})]},l))})]})]})}function oVe({stats:t}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return f.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 f.jsx("div",{className:"space-y-3",children:e.map(([n,r])=>{const i=Math.round(r/(t.total_prints||1)*100);return f.jsxs("div",{children:[f.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[f.jsx("span",{className:"text-white",children:n}),f.jsxs("span",{className:"text-bambu-gray",children:[r," prints"]})]}),f.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:f.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${i}%`}})})]},n)})})}function lVe({printDates:t}){return f.jsx(XNe,{printDates:t,months:4})}function cVe({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?f.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):f.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>f.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[f.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:f.jsx(nl,{className:"w-4 h-4 text-bambu-green"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),f.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function uVe({archives:t,currency:e}){return!t||t.length===0?f.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):f.jsx(tVe,{archives:t,currency:e})}function dVe(){const{data:t,isLoading:e}=Nt({queryKey:["archiveStats"],queryFn:ze.getArchiveStats}),{data:n}=Nt({queryKey:["printers"],queryFn:ze.getPrinters}),{data:r}=Nt({queryKey:["archives"],queryFn:()=>ze.getArchives(void 0,1e3,0)}),{data:i}=Nt({queryKey:["settings"],queryFn:ze.getSettings}),a=i?.currency||"$",s=new Map(n?.map(c=>[String(c.id),c.name])||[]),o=r?.map(c=>c.created_at)||[];if(e)return f.jsx("div",{className:"p-8",children:f.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const l=[{id:"quick-stats",title:"Quick Stats",component:f.jsx(iVe,{stats:t,currency:a}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:f.jsx(aVe,{stats:t}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:f.jsx(sVe,{stats:t,printerMap:s}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:f.jsx(oVe,{stats:t}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:f.jsx(lVe,{printDates:o}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:f.jsx(cVe,{stats:t,printerMap:s}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:f.jsx(uVe,{archives:r||[],currency:a}),defaultSize:4}];return f.jsxs("div",{className:"p-8",children:[f.jsxs("div",{className:"mb-6",children:[f.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),f.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),f.jsx(rVe,{widgets:l,storageKey:"bambusy-dashboard-layout"})]})}function fVe({plug:t,onEdit:e}){const n=In(),[r,i]=E.useState(!1),[a,s]=E.useState(!1),[o,l]=E.useState(!1),[c,u]=E.useState(!1),{data:h,isLoading:g,refetch:m}=Nt({queryKey:["smart-plug-status",t.id],queryFn:()=>ze.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:b}=Nt({queryKey:["printers"],queryFn:ze.getPrinters}),y=b?.find(R=>R.id===t.printer_id),v=Rt({mutationFn:R=>ze.controlSmartPlug(t.id,R),onSuccess:()=>{m()}}),x=Rt({mutationFn:R=>ze.updateSmartPlug(t.id,R),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),M=Rt({mutationFn:()=>ze.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),w=h?.state==="ON",C=h?.reachable??!1,T=v.isPending;return f.jsxs(f.Fragment,{children:[f.jsx(Ht,{className:"relative",children:f.jsxs(Gt,{className:"p-4",children:[f.jsxs("div",{className:"flex items-start justify-between mb-3",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:`p-2 rounded-lg ${C?w?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:f.jsx(UN,{className:`w-5 h-5 ${C?w?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),f.jsxs("div",{children:[f.jsx("h3",{className:"font-medium text-white",children:t.name}),f.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),f.jsx("div",{className:"flex items-center gap-2",children:g?f.jsx($t,{className:"w-4 h-4 text-bambu-gray animate-spin"}):C?f.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[f.jsx(v9,{className:"w-4 h-4 text-bambu-green"}),f.jsx("span",{className:w?"text-bambu-green":"text-bambu-gray",children:h?.state||"Unknown"})]}):f.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[f.jsx(ZP,{className:"w-4 h-4"}),f.jsx("span",{children:"Offline"})]})})]}),y&&f.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[f.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),f.jsx("span",{className:"text-sm text-white",children:y.name})]}),f.jsxs("div",{className:"flex gap-2 mb-3",children:[f.jsxs(qe,{size:"sm",variant:w?"primary":"secondary",disabled:!C||T,onClick:()=>s(!0),className:"flex-1",children:[T?f.jsx($t,{className:"w-4 h-4 animate-spin"}):f.jsx(Wf,{className:"w-4 h-4"}),"On"]}),f.jsxs(qe,{size:"sm",variant:w?"secondary":"primary",disabled:!C||T,onClick:()=>l(!0),className:"flex-1",children:[T?f.jsx($t,{className:"w-4 h-4 animate-spin"}):f.jsx(f9,{className:"w-4 h-4"}),"Off"]})]}),f.jsxs("button",{onClick:()=>u(!c),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[f.jsxs("span",{className:"flex items-center gap-2",children:[f.jsx(nw,{className:"w-4 h-4"}),"Automation Settings"]}),f.jsx("span",{children:c?"-":"+"})]}),c&&f.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm text-white",children:"Enabled"}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),f.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:t.enabled,onChange:R=>x.mutate({enabled:R.target.checked}),className:"sr-only peer"}),f.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"})]})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm text-white",children:"Auto On"}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),f.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:R=>x.mutate({auto_on:R.target.checked}),className:"sr-only peer"}),f.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"})]})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),f.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:R=>x.mutate({auto_off:R.target.checked}),className:"sr-only peer"}),f.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&&f.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsxs("button",{onClick:()=>x.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[f.jsx(Ni,{className:"w-4 h-4"}),"Time"]}),f.jsxs("button",{onClick:()=>x.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[f.jsx(_x,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),f.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:R=>x.mutate({off_delay_minutes:parseInt(R.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),f.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:R=>x.mutate({off_temp_threshold:parseInt(R.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),f.jsxs("div",{className:"flex gap-2 pt-2",children:[f.jsxs(qe,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[f.jsx(d9,{className:"w-4 h-4"}),"Edit"]}),f.jsx(qe,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:f.jsx(fr,{className:"w-4 h-4"})})]})]})]})}),r&&f.jsx(ja,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{M.mutate(),i(!1)},onCancel:()=>i(!1)}),a&&f.jsx(ja,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{v.mutate("on"),s(!1)},onCancel:()=>s(!1)}),o&&f.jsx(ja,{title:"Turn Off Smart Plug",message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:"Turn Off",variant:"danger",onConfirm:()=>{v.mutate("off"),l(!1)},onCancel:()=>l(!1)})]})}function hVe({plug:t,onClose:e}){const n=In(),r=!!t,[i,a]=E.useState(t?.name||""),[s,o]=E.useState(t?.ip_address||""),[l,c]=E.useState(t?.username||""),[u,h]=E.useState(t?.password||""),[g,m]=E.useState(t?.printer_id||null),[b,y]=E.useState(null),[v,x]=E.useState(null),{data:M}=Nt({queryKey:["printers"],queryFn:ze.getPrinters}),{data:w}=Nt({queryKey:["smart-plugs"],queryFn:ze.getSmartPlugs});E.useEffect(()=>{const k=F=>{F.key==="Escape"&&e()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[e]);const C=Rt({mutationFn:()=>ze.testSmartPlugConnection(s,l||null,u||null),onSuccess:k=>{y(k),x(null),!i&&k.device_name&&a(k.device_name)},onError:k=>{y(null),x(k.message)}}),T=Rt({mutationFn:k=>ze.createSmartPlug(k),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:k=>{x(k.message)}}),R=Rt({mutationFn:k=>ze.updateSmartPlug(t.id,k),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:k=>{x(k.message)}}),A=M?.filter(k=>!w?.some(I=>I.printer_id===k.id&&I.id!==t?.id)),j=k=>{if(k.preventDefault(),x(null),!i.trim()){x("Name is required");return}if(!s.trim()){x("IP address is required");return}const F={name:i.trim(),ip_address:s.trim(),username:l.trim()||null,password:u.trim()||null,printer_id:g};r?R.mutate(F):T.mutate(F)},N=T.isPending||R.isPending;return f.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:f.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:k=>k.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),f.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(ln,{className:"w-5 h-5"})})]}),f.jsxs("form",{onSubmit:j,className:"p-6 space-y-4",children:[v&&f.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:v}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx("input",{type:"text",value:s,onChange:k=>{o(k.target.value),y(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),f.jsxs(qe,{type:"button",variant:"secondary",onClick:()=>C.mutate(),disabled:!s.trim()||C.isPending,children:[C.isPending?f.jsx($t,{className:"w-4 h-4 animate-spin"}):f.jsx(v9,{className:"w-4 h-4"}),"Test"]})]})]}),b&&f.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${b.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:b.success?f.jsxs(f.Fragment,{children:[f.jsx(gc,{className:"w-5 h-5"}),f.jsxs("div",{children:[f.jsx("p",{className:"font-medium",children:"Connected!"}),f.jsxs("p",{className:"text-sm opacity-80",children:[b.device_name&&`Device: ${b.device_name} - `,"State: ",b.state]})]})]}):f.jsxs(f.Fragment,{children:[f.jsx(ZP,{className:"w-5 h-5"}),f.jsx("span",{children:"Connection failed"})]})}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),f.jsx("input",{type:"text",value:i,onChange:k=>a(k.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"})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),f.jsx("input",{type:"text",value:l,onChange:k=>c(k.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"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),f.jsx("input",{type:"password",value:u,onChange:k=>h(k.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"})]})]}),f.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),f.jsxs("select",{value:g??"",onChange:k=>m(k.target.value?Number(k.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:[f.jsx("option",{value:"",children:"No printer (manual control only)"}),A?.map(k=>f.jsx("option",{value:k.id,children:k.name},k.id))]}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),f.jsxs("div",{className:"flex gap-3 pt-2",children:[f.jsx(qe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),f.jsxs(qe,{type:"submit",disabled:N,className:"flex-1",children:[N?f.jsx($t,{className:"w-4 h-4 animate-spin"}):f.jsx(qo,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function is({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return f.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-9 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:f.jsx("span",{className:`pointer-events-none absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const pVe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email"};function mVe({provider:t,onEdit:e}){const n=In(),[r,i]=E.useState(!1),[a,s]=E.useState(!1),[o,l]=E.useState(null),{data:c}=Nt({queryKey:["printers"],queryFn:ze.getPrinters}),u=c?.find(y=>y.id===t.printer_id),h=Rt({mutationFn:y=>ze.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=Rt({mutationFn:()=>ze.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=Rt({mutationFn:()=>ze.testNotificationProvider(t.id),onSuccess:y=>{l(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{l({success:!1,message:y.message})}}),b=y=>y||"";return f.jsxs(f.Fragment,{children:[f.jsx(Ht,{className:"relative",children:f.jsxs(Gt,{className:"p-4",children:[f.jsxs("div",{className:"flex items-start justify-between mb-3",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:f.jsx(IN,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),f.jsxs("div",{children:[f.jsx("h3",{className:"font-medium text-white",children:t.name}),f.jsx("p",{className:"text-sm text-bambu-gray",children:pVe[t.provider_type]||t.provider_type})]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[t.last_success&&f.jsxs("span",{className:"text-xs text-bambu-green",children:["Last sent: ",new Date(t.last_success).toLocaleDateString()]}),t.last_error&&f.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"})]})]}),u&&f.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[f.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),f.jsx("span",{className:"text-sm text-white",children:u.name})]}),!u&&!t.printer_id&&f.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:f.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),f.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&f.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&f.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&f.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&f.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&f.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&f.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&f.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Error"}),t.on_filament_low&&f.jsx("span",{className:"px-2 py-0.5 bg-amber-500/20 text-amber-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&f.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.quiet_hours_enabled&&f.jsxs("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded flex items-center gap-1",children:[f.jsx(X_,{className:"w-3 h-3"}),"Quiet"]})]}),f.jsx("div",{className:"mb-3",children:f.jsxs(qe,{size:"sm",variant:"secondary",disabled:m.isPending,onClick:()=>{l(null),m.mutate()},className:"w-full",children:[m.isPending?f.jsx($t,{className:"w-4 h-4 animate-spin"}):f.jsx(h9,{className:"w-4 h-4"}),"Send Test Notification"]})}),o&&f.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${o.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[o.success?f.jsx(gc,{className:"w-4 h-4"}):f.jsx(z0,{className:"w-4 h-4"}),f.jsx("span",{children:o.message})]}),f.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:[f.jsxs("span",{className:"flex items-center gap-2",children:[f.jsx(nw,{className:"w-4 h-4"}),"Event Settings"]}),a?f.jsx(r9,{className:"w-4 h-4"}):f.jsx(F0,{className:"w-4 h-4"})]}),a&&f.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm text-white",children:"Enabled"}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),f.jsx(is,{checked:t.enabled,onChange:y=>h.mutate({enabled:y})})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("p",{className:"text-sm text-white",children:"Print Started"}),f.jsx(is,{checked:t.on_print_start,onChange:y=>h.mutate({on_print_start:y})})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),f.jsx(is,{checked:t.on_print_complete,onChange:y=>h.mutate({on_print_complete:y})})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),f.jsx(is,{checked:t.on_print_failed,onChange:y=>h.mutate({on_print_failed:y})})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),f.jsx(is,{checked:t.on_print_stopped,onChange:y=>h.mutate({on_print_stopped:y})})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),f.jsx(is,{checked:t.on_print_progress,onChange:y=>h.mutate({on_print_progress:y})})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),f.jsx(is,{checked:t.on_printer_offline,onChange:y=>h.mutate({on_printer_offline:y})})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),f.jsx(is,{checked:t.on_printer_error,onChange:y=>h.mutate({on_printer_error:y})})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),f.jsx(is,{checked:t.on_filament_low,onChange:y=>h.mutate({on_filament_low:y})})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),f.jsx(is,{checked:t.on_maintenance_due??!1,onChange:y=>h.mutate({on_maintenance_due:y})})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(X_,{className:"w-4 h-4 text-purple-400"}),f.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),f.jsx(is,{checked:t.quiet_hours_enabled,onChange:y=>h.mutate({quiet_hours_enabled:y})})]}),t.quiet_hours_enabled&&f.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Ni,{className:"w-4 h-4 text-bambu-gray"}),f.jsxs("span",{className:"text-sm text-white",children:[b(t.quiet_hours_start)||"22:00"," - ",b(t.quiet_hours_end)||"07:00"]})]}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),f.jsxs("div",{className:"flex gap-2 pt-2",children:[f.jsxs(qe,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[f.jsx(d9,{className:"w-4 h-4"}),"Edit"]}),f.jsx(qe,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:f.jsx(fr,{className:"w-4 h-4"})})]})]})]})}),r&&f.jsx(ja,{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 gG=[{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"email",label:"Email",description:"SMTP email notifications"}];function gVe({provider:t,onClose:e}){const n=In(),r=!!t,[i,a]=E.useState(t?.name||""),[s,o]=E.useState(t?.provider_type||"ntfy"),[l,c]=E.useState(t?.printer_id||null),[u,h]=E.useState(t?.quiet_hours_enabled||!1),[g,m]=E.useState(t?.quiet_hours_start||"22:00"),[b,y]=E.useState(t?.quiet_hours_end||"07:00"),[v,x]=E.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([B,G])=>[B,String(G)])):{}),[M,w]=E.useState(null),[C,T]=E.useState(null),{data:R}=Nt({queryKey:["printers"],queryFn:ze.getPrinters});E.useEffect(()=>{const B=G=>{G.key==="Escape"&&e()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[e]);const A=Rt({mutationFn:()=>ze.testNotificationConfig({provider_type:s,config:v}),onSuccess:B=>{w(B),T(null)},onError:B=>{w({success:!1,message:B.message})}}),j=Rt({mutationFn:B=>ze.createNotificationProvider(B),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:B=>{T(B.message)}}),N=Rt({mutationFn:B=>ze.updateNotificationProvider(t.id,B),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:B=>{T(B.message)}}),k=B=>{if(B.preventDefault(),T(null),!i.trim()){T("Name is required");return}const G=W(s);for(const Z of G)if(!v[Z.key]?.trim()){T(`${Z.label} is required`);return}const V={name:i.trim(),provider_type:s,config:v,printer_id:l,quiet_hours_enabled:u,quiet_hours_start:u?g:null,quiet_hours_end:u?b:null};r?N.mutate(V):j.mutate(V)},F=j.isPending||N.isPending,I=B=>{switch(B){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambutrack",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}];default:return[]}},W=B=>I(B).filter(G=>G.required),D=I(s);return f.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:f.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8",onClick:B=>B.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),f.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(ln,{className:"w-5 h-5"})})]}),f.jsxs("form",{onSubmit:k,className:"p-6 space-y-4",children:[C&&f.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:C}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),f.jsx("input",{type:"text",value:i,onChange:B=>a(B.target.value),placeholder:"My Notifications",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),f.jsx("select",{value:s,onChange:B=>{o(B.target.value),x({}),w(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:gG.map(B=>f.jsx("option",{value:B.value,children:B.label},B.value))}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:gG.find(B=>B.value===s)?.description})]}),f.jsxs("div",{className:"space-y-3",children:[f.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),D.map(B=>f.jsxs("div",{children:[f.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[B.label," ",B.required&&"*"]}),B.type==="select"&&B.options?f.jsx("select",{value:v[B.key]||B.options[0]?.value||"",onChange:G=>{x({...v,[B.key]:G.target.value}),w(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:B.options.map(G=>f.jsx("option",{value:G.value,children:G.label},G.value))}):f.jsx("input",{type:B.type,value:v[B.key]||"",onChange:G=>{x({...v,[B.key]:G.target.value}),w(null)},placeholder:B.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},B.key))]}),f.jsx("div",{className:"flex gap-2",children:f.jsxs(qe,{type:"button",variant:"secondary",onClick:()=>{w(null),A.mutate()},disabled:A.isPending||!v[W(s)[0]?.key],className:"flex-1",children:[A.isPending?f.jsx($t,{className:"w-4 h-4 animate-spin"}):f.jsx(h9,{className:"w-4 h-4"}),"Test Configuration"]})}),M&&f.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${M.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:M.success?f.jsxs(f.Fragment,{children:[f.jsx(gc,{className:"w-5 h-5"}),f.jsx("span",{children:M.message})]}):f.jsxs(f.Fragment,{children:[f.jsx(z0,{className:"w-5 h-5"}),f.jsx("span",{children:M.message})]})}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),f.jsxs("select",{value:l??"",onChange:B=>c(B.target.value?Number(B.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"",children:"All printers"}),R?.map(B=>f.jsx("option",{value:B.id,children:B.name},B.id))]}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),f.jsx(is,{checked:u,onChange:h})]}),u&&f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),f.jsx("input",{type:"time",value:g,onChange:B=>m(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),f.jsx("input",{type:"time",value:b,onChange:B=>y(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),f.jsxs("div",{className:"flex gap-3 pt-2",children:[f.jsx(qe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),f.jsxs(qe,{type:"submit",disabled:F,className:"flex-1",children:[F?f.jsx($t,{className:"w-4 h-4 animate-spin"}):f.jsx(qo,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}async function xVe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function vVe(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 bVe(){const t=In(),[e,n]=E.useState(!1),[r,i]=E.useState(""),[a,s]=E.useState("auto"),[o,l]=E.useState(!1),[c,u]=E.useState(!1),[h,g]=E.useState("all"),{data:m,isLoading:b}=Nt({queryKey:["spoolman-settings"],queryFn:xVe}),{data:y,isLoading:v,refetch:x}=Nt({queryKey:["spoolman-status"],queryFn:ze.getSpoolmanStatus,refetchInterval:3e4}),{data:M}=Nt({queryKey:["printers"],queryFn:ze.getPrinters});E.useEffect(()=>{m&&(n(m.spoolman_enabled==="true"),i(m.spoolman_url||""),s(m.spoolman_sync_mode||"auto"))},[m]),E.useEffect(()=>{if(m){const I=m.spoolman_enabled==="true"!==e||(m.spoolman_url||"")!==r||(m.spoolman_sync_mode||"auto")!==a;l(I)}},[m,e,r,a]);const w=Rt({mutationFn:()=>vVe({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:a}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),l(!1),u(!0),setTimeout(()=>u(!1),2e3)}}),C=Rt({mutationFn:ze.connectSpoolman,onSuccess:()=>{x()}}),T=Rt({mutationFn:ze.disconnectSpoolman,onSuccess:()=>{x()}}),R=Rt({mutationFn:ze.syncAllPrintersAms,onSuccess:I=>{I.success}}),A=Rt({mutationFn:I=>ze.syncPrinterAms(I),onSuccess:I=>{I.success}}),j=()=>{h==="all"?R.mutate():A.mutate(h)},N=R.isPending||A.isPending,k=h==="all"?R.data:A.data,F=h==="all"?R.isSuccess:A.isSuccess;return b?f.jsxs(Ht,{children:[f.jsx(Xl,{children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(ZU,{className:"w-5 h-5 text-bambu-green"}),f.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),f.jsx(Gt,{children:f.jsx("div",{className:"flex justify-center py-8",children:f.jsx($t,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):f.jsxs(Ht,{children:[f.jsx(Xl,{children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(ZU,{className:"w-5 h-5 text-bambu-green"}),f.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),o&&f.jsx(qe,{size:"sm",onClick:()=>w.mutate(),disabled:w.isPending,children:w.isPending?f.jsx($t,{className:"w-4 h-4 animate-spin"}):c?f.jsx(Mf,{className:"w-4 h-4"}):"Save"})]})}),f.jsxs(Gt,{className:"space-y-4",children:[f.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-white",children:"Enable Spoolman"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),f.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:e,onChange:I=>n(I.target.checked),className:"sr-only peer"}),f.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.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),f.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:I=>i(I.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"}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),f.jsxs("select",{value:a,onChange:I=>s(I.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:[f.jsx("option",{value:"auto",children:"Automatic"}),f.jsx("option",{value:"manual",children:"Manual Only"})]}),f.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&&f.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center justify-between mb-3",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),v?f.jsx($t,{className:"w-4 h-4 text-bambu-gray animate-spin"}):y?.connected?f.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[f.jsx(Mf,{className:"w-4 h-4"}),"Connected"]}):f.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[f.jsx(ln,{className:"w-4 h-4"}),"Disconnected"]})]}),f.jsx("div",{className:"flex gap-2",children:y?.connected?f.jsxs(qe,{variant:"secondary",size:"sm",onClick:()=>T.mutate(),disabled:T.isPending,children:[T.isPending?f.jsx($t,{className:"w-4 h-4 animate-spin"}):f.jsx(goe,{className:"w-4 h-4"}),"Disconnect"]}):f.jsxs(qe,{size:"sm",onClick:()=>C.mutate(),disabled:C.isPending||!r,children:[C.isPending?f.jsx($t,{className:"w-4 h-4 animate-spin"}):f.jsx(voe,{className:"w-4 h-4"}),"Connect"]})})]}),C.isError&&f.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:C.error.message}),y?.connected&&f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"relative flex-1",children:[f.jsxs("select",{value:h,onChange:I=>g(I.target.value==="all"?"all":Number(I.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:[f.jsx("option",{value:"all",children:"All Printers"}),M?.map(I=>f.jsx("option",{value:I.id,children:I.name},I.id))]}),f.jsx(F0,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),f.jsxs(qe,{variant:"secondary",size:"sm",onClick:j,disabled:N,children:[N?f.jsx($t,{className:"w-4 h-4 animate-spin"}):f.jsx(Mo,{className:"w-4 h-4"}),"Sync"]})]})]}),F&&k&&f.jsx("div",{className:`mt-2 p-2 rounded text-sm ${k.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:k.success?`Synced ${k.synced_count} trays successfully`:`Synced ${k.synced_count} trays with ${k.errors.length} errors`})]})]})]})}function yVe(){const t=In(),{t:e,i18n:n}=DP(),[r,i]=E.useState(null),[a,s]=E.useState(!1),[o,l]=E.useState(!1),[c,u]=E.useState(!1),[h,g]=E.useState(null),[m,b]=E.useState(!1),[y,v]=E.useState(null),[x,M]=E.useState(S9()),w=q=>{M(q),nce(q)},C=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:T,isLoading:R}=Nt({queryKey:["settings"],queryFn:ze.getSettings}),{data:A,isLoading:j}=Nt({queryKey:["smart-plugs"],queryFn:ze.getSmartPlugs}),{data:N,isLoading:k}=Nt({queryKey:["notification-providers"],queryFn:ze.getNotificationProviders}),{data:F}=Nt({queryKey:["ffmpeg-status"],queryFn:ze.checkFfmpeg}),{data:I}=Nt({queryKey:["version"],queryFn:ze.getVersion}),{data:W,refetch:D,isRefetching:B}=Nt({queryKey:["updateCheck"],queryFn:ze.checkForUpdates,staleTime:300*1e3}),{data:G,refetch:V}=Nt({queryKey:["updateStatus"],queryFn:ze.getUpdateStatus,refetchInterval:q=>{const ae=q.state.data;return ae?.status==="downloading"||ae?.status==="installing"?1e3:!1}}),Z=Rt({mutationFn:ze.applyUpdate,onSuccess:()=>{V()}});E.useEffect(()=>{T&&!r&&i(T)},[T,r]),E.useEffect(()=>{if(T&&r){const q=T.auto_archive!==r.auto_archive||T.save_thumbnails!==r.save_thumbnails||T.capture_finish_photo!==r.capture_finish_photo||T.default_filament_cost!==r.default_filament_cost||T.currency!==r.currency||T.energy_cost_per_kwh!==r.energy_cost_per_kwh||T.energy_tracking_mode!==r.energy_tracking_mode||T.check_updates!==r.check_updates||T.notification_language!==r.notification_language||T.ams_humidity_good!==r.ams_humidity_good||T.ams_humidity_fair!==r.ams_humidity_fair||T.ams_temp_good!==r.ams_temp_good||T.ams_temp_fair!==r.ams_temp_fair;s(q)}},[T,r]);const Y=Rt({mutationFn:ze.updateSettings,onSuccess:q=>{t.setQueryData(["settings"],q),i(q),s(!1),l(!0),setTimeout(()=>l(!1),2e3),t.invalidateQueries({queryKey:["archiveStats"]})}}),ee=()=>{r&&Y.mutate(r)},H=(q,ae)=>{r&&i({...r,[q]:ae})};return R||!r?f.jsx("div",{className:"p-8 flex justify-center",children:f.jsx($t,{className:"w-8 h-8 text-bambu-green animate-spin"})}):f.jsxs("div",{className:"p-8",children:[f.jsxs("div",{className:"mb-8 flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),f.jsx("p",{className:"text-bambu-gray",children:"Configure Bambusy"})]}),f.jsxs(qe,{onClick:ee,disabled:!a||Y.isPending,children:[Y.isPending?f.jsx($t,{className:"w-4 h-4 animate-spin"}):o?f.jsx(Mf,{className:"w-4 h-4"}):f.jsx(qo,{className:"w-4 h-4"}),o?"Saved!":"Save"]})]}),Y.isError&&f.jsxs("div",{className:"mb-6 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:["Failed to save settings: ",Y.error.message]}),f.jsxs("div",{className:"flex gap-8",children:[f.jsxs("div",{className:"space-y-6 flex-1 max-w-xl",children:[f.jsxs(Ht,{children:[f.jsx(Xl,{children:f.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),f.jsxs(Gt,{className:"space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-white",children:"Auto-archive prints"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),f.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:r.auto_archive,onChange:q=>H("auto_archive",q.target.checked),className:"sr-only peer"}),f.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.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-white",children:"Save thumbnails"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),f.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:r.save_thumbnails,onChange:q=>H("save_thumbnails",q.target.checked),className:"sr-only peer"}),f.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.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-white",children:"Capture finish photo"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),f.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:r.capture_finish_photo,onChange:q=>H("capture_finish_photo",q.target.checked),className:"sr-only peer"}),f.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"})]})]}),r.capture_finish_photo&&F&&!F.installed&&f.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[f.jsx(Eo,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),f.jsxs("div",{className:"text-sm",children:[f.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),f.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",f.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",f.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]}),f.jsxs(Ht,{children:[f.jsx(Xl,{children:f.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),f.jsxs(Gt,{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),f.jsx("input",{type:"number",step:"0.01",min:"0",value:r.default_filament_cost,onChange:q=>H("default_filament_cost",parseFloat(q.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"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),f.jsxs("select",{value:r.currency,onChange:q=>H("currency",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:[f.jsx("option",{value:"USD",children:"USD ($)"}),f.jsx("option",{value:"EUR",children:"EUR (€)"}),f.jsx("option",{value:"GBP",children:"GBP (£)"}),f.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),f.jsx("option",{value:"JPY",children:"JPY (¥)"}),f.jsx("option",{value:"CNY",children:"CNY (¥)"}),f.jsx("option",{value:"CAD",children:"CAD ($)"}),f.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),f.jsx("input",{type:"number",step:"0.01",min:"0",value:r.energy_cost_per_kwh,onChange:q=>H("energy_cost_per_kwh",parseFloat(q.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"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),f.jsxs("select",{value:r.energy_tracking_mode||"total",onChange:q=>H("energy_tracking_mode",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:[f.jsx("option",{value:"print",children:"Prints Only"}),f.jsx("option",{value:"total",children:"Total Consumption"})]}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:r.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),f.jsxs(Ht,{children:[f.jsx(Xl,{children:f.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),f.jsxs(Gt,{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[f.jsx(q_,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),f.jsx("select",{value:n.language,onChange:q=>n.changeLanguage(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:PU.map(q=>f.jsxs("option",{value:q.code,children:[q.nativeName," (",q.name,")"]},q.code))}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),f.jsx("select",{value:x,onChange:q=>w(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:x_.map(q=>f.jsx("option",{value:q.to,children:e(q.labelKey)},q.id))}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-white",children:"Sidebar order"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),f.jsxs(qe,{variant:"secondary",size:"sm",onClick:C,children:[f.jsx(tw,{className:"w-4 h-4"}),"Reset"]})]})]})]}),f.jsxs(Ht,{children:[f.jsx(Xl,{children:f.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),f.jsxs(Gt,{className:"space-y-4",children:[f.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"flex items-center gap-2 text-white",children:[f.jsx(Rse,{className:"w-4 h-4 text-blue-400"}),f.jsx("span",{className:"font-medium",children:"Humidity"})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"number",min:"0",max:"100",value:r.ams_humidity_good??40,onChange:q=>H("ams_humidity_good",parseInt(q.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"}),f.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"number",min:"0",max:"100",value:r.ams_humidity_fair??60,onChange:q=>H("ams_humidity_fair",parseInt(q.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"}),f.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),f.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-2 text-white",children:[f.jsx(_x,{className:"w-4 h-4 text-orange-400"}),f.jsx("span",{className:"font-medium",children:"Temperature"})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:r.ams_temp_good??28,onChange:q=>H("ams_temp_good",parseFloat(q.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"}),f.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:r.ams_temp_fair??35,onChange:q=>H("ams_temp_fair",parseFloat(q.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"}),f.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]})]})]})]}),f.jsxs("div",{className:"space-y-6 flex-1 max-w-md",children:[f.jsx(bVe,{}),f.jsxs(Ht,{children:[f.jsx(Xl,{children:f.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),f.jsxs(Gt,{className:"space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-white",children:"Check for updates"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),f.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:r.check_updates,onChange:q=>H("check_updates",q.target.checked),className:"sr-only peer"}),f.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.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[f.jsxs("div",{className:"flex items-center justify-between mb-2",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-white",children:"Current version"}),f.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",I?.version||"..."]})]}),f.jsxs(qe,{variant:"secondary",size:"sm",onClick:()=>D(),disabled:B,children:[B?f.jsx($t,{className:"w-4 h-4 animate-spin"}):f.jsx(Mo,{className:"w-4 h-4"}),"Check now"]})]}),W?.update_available?f.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[f.jsxs("div",{className:"flex items-start justify-between",children:[f.jsxs("div",{children:[f.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",W.latest_version]}),W.release_name&&W.release_name!==W.latest_version&&f.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:W.release_name}),W.release_notes&&f.jsx("p",{className:"text-sm text-bambu-gray mt-2 whitespace-pre-line line-clamp-3",children:W.release_notes})]}),W.release_url&&f.jsx("a",{href:W.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:f.jsx(xc,{className:"w-4 h-4"})})]}),G?.status==="downloading"||G?.status==="installing"?f.jsxs("div",{className:"mt-3",children:[f.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[f.jsx($t,{className:"w-4 h-4 animate-spin"}),f.jsx("span",{children:G.message})]}),f.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:f.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${G.progress}%`}})})]}):G?.status==="complete"?f.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:G.message}):G?.status==="error"?f.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:G.error||G.message}):f.jsxs(qe,{className:"mt-3",onClick:()=>Z.mutate(),disabled:Z.isPending,children:[Z.isPending?f.jsx($t,{className:"w-4 h-4 animate-spin"}):f.jsx(tl,{className:"w-4 h-4"}),"Install Update"]})]}):W?.error?f.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: ",W.error]}):W&&!W.update_available?f.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]})]}),f.jsx("div",{className:"w-80 flex-shrink-0",children:f.jsxs(Ht,{children:[f.jsx(Xl,{children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(UN,{className:"w-5 h-5 text-bambu-green"}),f.jsx("h2",{className:"text-lg font-semibold text-white",children:"Smart Plugs"})]}),f.jsxs(qe,{size:"sm",onClick:()=>{g(null),u(!0)},children:[f.jsx(ra,{className:"w-4 h-4"}),"Add"]})]})}),f.jsxs(Gt,{children:[f.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Connect Tasmota-based smart plugs to automate power control for your printers."}),j?f.jsx("div",{className:"flex justify-center py-8",children:f.jsx($t,{className:"w-6 h-6 text-bambu-green animate-spin"})}):A&&A.length>0?f.jsx("div",{className:"space-y-4",children:A.map(q=>f.jsx(fVe,{plug:q,onEdit:ae=>{g(ae),u(!0)}},q.id))}):f.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[f.jsx(UN,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),f.jsx("p",{children:"No smart plugs configured"}),f.jsx("p",{className:"text-sm mt-1",children:"Add a Tasmota plug to get started"})]})]})]})}),f.jsx("div",{className:"w-80 flex-shrink-0",children:f.jsxs(Ht,{children:[f.jsx(Xl,{children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(IN,{className:"w-5 h-5 text-bambu-green"}),f.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notifications"})]}),f.jsxs(qe,{size:"sm",onClick:()=>{v(null),b(!0)},children:[f.jsx(ra,{className:"w-4 h-4"}),"Add"]})]})}),f.jsxs(Gt,{children:[f.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Get notified about print events via WhatsApp, Telegram, Email, and more."}),f.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary mb-4",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-white",children:e("settings.notificationLanguage")}),f.jsx("p",{className:"text-sm text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),f.jsx("select",{value:r.notification_language||"en",onChange:q=>H("notification_language",q.target.value),className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green",children:PU.map(q=>f.jsx("option",{value:q.code,children:q.nativeName},q.code))})]}),k?f.jsx("div",{className:"flex justify-center py-8",children:f.jsx($t,{className:"w-6 h-6 text-bambu-green animate-spin"})}):N&&N.length>0?f.jsx("div",{className:"space-y-4",children:N.map(q=>f.jsx(mVe,{provider:q,onEdit:ae=>{v(ae),b(!0)}},q.id))}):f.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[f.jsx(IN,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),f.jsx("p",{children:"No notification providers configured"}),f.jsx("p",{className:"text-sm mt-1",children:"Add a provider to get started"})]})]})]})})]}),c&&f.jsx(hVe,{plug:h,onClose:()=>{u(!1),g(null)}}),m&&f.jsx(gVe,{provider:y,onClose:()=>{b(!1),v(null)}})]})}const lee=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},_Ve=t=>t.startsWith("HH")?"HF":"S",SVe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},NP=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 yN({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:s}){const o=_Ve(t.nozzle_id),l=t.nozzle_diameter,c=()=>{r&&a?a():e()};return f.jsxs("div",{className:"flex items-center gap-2",children:[r&&f.jsx("button",{onClick:a,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?f.jsx(Tf,{className:"w-4 h-4 text-bambu-green"}):f.jsx(Wp,{className:"w-4 h-4"})}),f.jsxs("button",{onClick:c,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:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:lee(t.k_value)}),f.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),s&&f.jsx("span",{title:"Has note",children:f.jsx(m9,{className:"w-3 h-3 text-yellow-500"})}),f.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[o," ",l]})]}),s&&f.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&&f.jsx("button",{onClick:u=>{u.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:f.jsx(Vp,{className:"w-4 h-4"})})]})}function _N({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:a="",initialNoteKey:s=null,onClose:o,onSave:l,onSaveNote:c}){const{showToast:u}=sa(),[h,g]=E.useState(t?.name||""),[m,b]=E.useState(t?.k_value?lee(t.k_value):"0.020"),[y,v]=E.useState(t?.filament_id||""),[x,M]=E.useState(t?.nozzle_id?SVe(t.nozzle_id):"HH00"),[w,C]=E.useState(t?.nozzle_diameter||n),[T,R]=E.useState(t?[t.extruder_id]:i?[0,1]:[0]),[A,j]=E.useState(!1),[N,k]=E.useState({current:0,total:0}),[F,I]=E.useState(a),W=ur.useMemo(()=>{const ee=new Map;for(const H of r)if(H.filament_id&&!ee.has(H.filament_id)){const q=NP(H.name||"");ee.set(H.filament_id,{id:H.filament_id,name:q||H.filament_id})}return Array.from(ee.values()).sort((H,q)=>H.name.localeCompare(q.name))},[r]),D=Rt({mutationFn:ee=>(console.log("[KProfile] Calling API..."),ze.setKProfile(e,ee)),onSuccess:ee=>{if(console.log("[KProfile] Save success:",ee),u("K-profile saved"),c&&F!==a){let H;F===""&&s?H=s:t&&t.slot_id>0?H=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:H=`name_${h}_${y}`,c(H,F)}j(!0),setTimeout(()=>{j(!1),l()},2500)},onError:ee=>{console.error("[KProfile] Save error:",ee),u(ee.message,"error"),j(!1)}}),B=Rt({mutationFn:ee=>(console.log("[KProfile] Deleting profile..."),ze.deleteKProfile(e,ee)),onSuccess:ee=>{console.log("[KProfile] Delete success:",ee),u("K-profile deleted"),j(!0),setTimeout(()=>{j(!1),o()},4e3)},onError:ee=>{console.error("[KProfile] Delete error:",ee),u(ee.message,"error"),j(!1)}}),[G,V]=E.useState(!1),Z=()=>{t&&B.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})},Y=async ee=>{if(ee.preventDefault(),i&&!t&&T.length===0){u("Please select at least one extruder","error");return}const H=parseFloat(m).toFixed(6),q=`${x}-${w}`;if(t||T.length===1){const ce={name:h,k_value:H,filament_id:y,nozzle_id:q,nozzle_diameter:w,extruder_id:t?t.extruder_id:T[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",ce),D.mutate(ce);return}j(!0),k({current:1,total:T.length});const ae=T.map(ce=>({name:h,k_value:H,filament_id:y,nozzle_id:q,nozzle_diameter:w,extruder_id:ce,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${ae.length} profiles in batch:`,ae);try{if(await ze.setKProfilesBatch(e,ae),u(`K-profile saved to ${T.length} extruders`),c&&F){const ce=`name_${h}_${y}`;c(ce,F)}}catch(ce){console.error("[KProfile] Failed to save batch:",ce),u("Failed to save K-profiles","error"),j(!1),k({current:0,total:0});return}k({current:T.length,total:T.length}),setTimeout(()=>{j(!1),k({current:0,total:0}),l()},3e3)};return f.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[f.jsxs(Ht,{className:"w-full max-w-md relative",children:[A&&f.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[f.jsx($t,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),f.jsx("p",{className:"text-white font-medium",children:N.total>1?`Saving to extruder ${N.current}/${N.total}...`:"Syncing with printer..."}),f.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),f.jsxs(Gt,{className:"p-0",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),f.jsx("button",{onClick:o,className:"text-bambu-gray hover:text-white transition-colors",disabled:A,children:f.jsx(ln,{className:"w-5 h-5"})})]}),f.jsxs("form",{onSubmit:Y,className:"p-4 space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),f.jsx("input",{type:"text",value:h,onChange:ee=>g(ee.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})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),f.jsx("input",{type:"text",inputMode:"decimal",value:m,onChange:ee=>{const H=ee.target.value;(H===""||/^\d*\.?\d*$/.test(H))&&b(H)},onBlur:ee=>{const H=parseFloat(ee.target.value);isNaN(H)||b((Math.trunc(H*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}),f.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"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),f.jsxs("select",{value:y,onChange:ee=>{const H=ee.target.value;if(v(H),!t&&H&&!h){const q=W.find(ae=>ae.id===H);q&&g(`${x==="HH00"?"HF":"S"} ${q.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:[f.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&f.jsx("option",{value:t.filament_id,children:W.find(ee=>ee.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&W.map(ee=>f.jsx("option",{value:ee.id,children:ee.name},ee.id))]}),!t&&W.length===0&&f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),f.jsxs("select",{value:x,onChange:ee=>{const H=ee.target.value;if(M(H),!t&&y&&!h){const q=W.find(ae=>ae.id===y);q&&g(`${H==="HS00"?"HF":"S"} ${q.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:[f.jsx("option",{value:"HH00",children:"High Flow"}),f.jsx("option",{value:"HS00",children:"Standard"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),f.jsxs("select",{value:w,onChange:ee=>C(ee.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:[f.jsx("option",{value:"0.2",children:"0.2mm"}),f.jsx("option",{value:"0.4",children:"0.4mm"}),f.jsx("option",{value:"0.6",children:"0.6mm"}),f.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?f.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"}):f.jsxs("div",{className:"flex gap-4",children:[f.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:T.includes(1),onChange:ee=>{ee.target.checked?R([...T,1]):R(T.filter(H=>H!==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"}),f.jsx("span",{className:"text-white",children:"Left"})]}),f.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:T.includes(0),onChange:ee=>{ee.target.checked?R([...T,0]):R(T.filter(H=>H!==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"}),f.jsx("span",{className:"text-white",children:"Right"})]})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),f.jsx("textarea",{value:F,onChange:ee=>I(ee.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"}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Notes are saved in Bambusy, not on the printer"})]}),f.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&f.jsx(qe,{type:"button",variant:"secondary",onClick:()=>V(!0),disabled:B.isPending||A,className:"text-red-500 hover:bg-red-500/10",children:B.isPending?f.jsx($t,{className:"w-4 h-4 animate-spin"}):f.jsx(fr,{className:"w-4 h-4"})}),f.jsx(qe,{type:"button",variant:"secondary",onClick:o,disabled:A,className:"flex-1",children:"Cancel"}),f.jsxs(qe,{type:"submit",disabled:D.isPending||A,className:"flex-1",children:[D.isPending?f.jsx($t,{className:"w-4 h-4 animate-spin"}):f.jsx(qP,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),G&&f.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:f.jsx(Ht,{className:"w-full max-w-sm",children:f.jsxs(Gt,{className:"p-6",children:[f.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[f.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:f.jsx(fr,{className:"w-5 h-5 text-red-500"})}),f.jsxs("div",{children:[f.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),f.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",f.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),f.jsxs("div",{className:"flex gap-3",children:[f.jsx(qe,{variant:"secondary",onClick:()=>V(!1),className:"flex-1",children:"Cancel"}),f.jsxs(qe,{onClick:()=>{V(!1),Z()},disabled:B.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[B.isPending?f.jsx($t,{className:"w-4 h-4 animate-spin"}):f.jsx(fr,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const p_={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function wVe(){const{showToast:t}=sa(),[e,n]=E.useState(null),[r,i]=E.useState(()=>localStorage.getItem(p_.NOZZLE_DIAMETER)||"0.4"),[a,s]=E.useState(null),[o,l]=E.useState(!1),[c,u]=E.useState(null),[h,g]=E.useState(""),[m,b]=E.useState("all"),[y,v]=E.useState("all"),[x,M]=E.useState(()=>localStorage.getItem(p_.SORT_OPTION)||"name"),[w,C]=E.useState(!1),[T,R]=E.useState(new Set),[A,j]=E.useState(!1),[N,k]=E.useState(!1),F=K=>`${K.slot_id}_${K.extruder_id}`;E.useEffect(()=>{localStorage.setItem(p_.NOZZLE_DIAMETER,r)},[r]),E.useEffect(()=>{localStorage.setItem(p_.SORT_OPTION,x)},[x]);const{data:I,isLoading:W}=Nt({queryKey:["printers"],queryFn:ze.getPrinters}),{data:D,isLoading:B,isFetching:G,error:V,refetch:Z}=Nt({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const K=await ze.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",K?.profiles?.length||0,"profiles"),K},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:Y}=Nt({queryKey:["kprofiles",e,"0.4"],queryFn:()=>ze.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:ee,refetch:H}=Nt({queryKey:["kprofile-notes",e],queryFn:()=>ze.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),q=V?.message?.includes("not connected");E.useEffect(()=>{if(!e&&I&&I.length>0){const K=I.find(Q=>Q.is_active);K&&n(K.id)}},[e,I]),E.useEffect(()=>{if(e){const K=setTimeout(()=>{Z()},150);return()=>clearTimeout(K)}},[e,r]);const ae=I?.filter(K=>K.is_active)||[],ce=ur.useMemo(()=>D?.profiles?D.profiles.filter(Q=>{const oe=h.toLowerCase(),Ne=!oe||Q.name.toLowerCase().includes(oe)||Q.filament_id.toLowerCase().includes(oe),Ee=m==="all"||m==="left"&&Q.extruder_id===1||m==="right"&&Q.extruder_id===0,re=y==="all"||y==="hf"&&Q.nozzle_id.startsWith("HH")||y==="s"&&Q.nozzle_id.startsWith("HS");return Ne&&Ee&&re}).sort((Q,oe)=>{switch(x){case"k_value":return parseFloat(Q.k_value)-parseFloat(oe.k_value);case"filament":return NP(Q.name).localeCompare(NP(oe.name));case"name":default:return Q.name.localeCompare(oe.name)}}):[],[D?.profiles,h,m,y,x]),xe=I?.find(K=>K.id===e),ie=xe?.nozzle_count===2;E.useEffect(()=>{const K=Q=>{Q.target instanceof HTMLInputElement||Q.target instanceof HTMLTextAreaElement||Q.target instanceof HTMLSelectElement||a||o||c||(Q.key==="r"||Q.key==="R"?(Q.preventDefault(),Z()):Q.key==="n"||Q.key==="N"?(Q.preventDefault(),l(!0)):Q.key==="Escape"&&w&&(Q.preventDefault(),C(!1),R(new Set)))};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[a,o,c,w,Z]);const ve=E.useCallback(()=>{if(!D?.profiles||D.profiles.length===0){t("No profiles to export","error");return}const K={version:1,exported_at:new Date().toISOString(),printer:xe?.name||"Unknown",nozzle_diameter:r,profiles:D.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}))},Q=new Blob([JSON.stringify(K,null,2)],{type:"application/json"}),oe=URL.createObjectURL(Q),Ne=document.createElement("a");Ne.href=oe,Ne.download=`kprofiles_${xe?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Ne),Ne.click(),document.body.removeChild(Ne),URL.revokeObjectURL(oe),t(`Exported ${D.profiles.length} profiles`)},[D?.profiles,xe,r,t]),Pe=E.useCallback(()=>{const K=document.createElement("input");K.type="file",K.accept=".json",K.onchange=async Q=>{const oe=Q.target.files?.[0];if(oe)try{const Ne=await oe.text(),Ee=JSON.parse(Ne);if(!Ee.profiles||!Array.isArray(Ee.profiles)){t("Invalid file format","error");return}let re=0;for(const U of Ee.profiles)if(!(!U.name||!U.k_value||!U.filament_id))try{await ze.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}),re++,await new Promise(L=>setTimeout(L,500))}catch(L){console.error("Failed to import profile:",U.name,L)}t(`Imported ${re} of ${Ee.profiles.length} profiles`),Z()}catch(Ne){console.error("Import error:",Ne),t("Failed to parse import file","error")}},K.click()},[e,r,t,Z]),he=E.useCallback(K=>{R(Q=>{const oe=new Set(Q);return oe.has(K)?oe.delete(K):oe.add(K),oe})},[]),we=E.useCallback(()=>{R(new Set(ce.map(K=>F(K))))},[ce,F]),Le=E.useCallback(()=>{T.size!==0&&j(!0)},[T.size]),de=E.useCallback(async()=>{const K=ce.filter(oe=>T.has(F(oe)));k(!0);let Q=0;for(const oe of K)try{await ze.deleteKProfile(e,{slot_id:oe.slot_id,extruder_id:oe.extruder_id,nozzle_id:oe.nozzle_id,nozzle_diameter:oe.nozzle_diameter,filament_id:oe.filament_id,setting_id:oe.setting_id}),Q++,await new Promise(Ne=>setTimeout(Ne,300))}catch(Ne){console.error("Failed to delete profile:",oe.name,Ne)}t(`Deleted ${Q} profiles`),k(!1),j(!1),C(!1),R(new Set),Z()},[e,T,ce,t,Z,F]),lt=E.useCallback(K=>{const Q=[];return K.setting_id&&Q.push(K.setting_id),Q.push(`slot_${K.slot_id}_${K.filament_id}_${K.extruder_id}`),Q.push(`name_${K.name}_${K.filament_id}`),Q},[]),$=E.useCallback(async(K,Q)=>{if(e)try{await ze.setKProfileNote(e,K,Q),H()}catch(oe){console.error("Failed to save note:",oe),t("Failed to save note","error")}},[e,H,t]),z=E.useCallback(K=>{if(!ee?.notes)return{note:"",key:null};const Q=lt(K);for(const oe of Q)if(ee.notes[oe])return{note:ee.notes[oe],key:oe};return{note:"",key:null}},[ee,lt]),ne=E.useCallback(K=>z(K).note,[z]);return W?f.jsx("div",{className:"flex justify-center py-12",children:f.jsx($t,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!I||I.length===0?f.jsx(Ht,{children:f.jsxs(Gt,{className:"py-12 text-center",children:[f.jsx(wo,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),f.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),f.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):ae.length===0?f.jsx(Ht,{children:f.jsxs(Gt,{className:"py-12 text-center",children:[f.jsx(nl,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),f.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),f.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):f.jsxs(f.Fragment,{children:[G&&!B&&f.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[f.jsx($t,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),f.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),f.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[f.jsxs("div",{className:"flex-1 min-w-48",children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),f.jsx("select",{value:e||"",onChange:K=>n(parseInt(K.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:ae.map(K=>f.jsx("option",{value:K.id,children:K.name},K.id))})]}),f.jsxs("div",{className:"w-32",children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),f.jsxs("select",{value:r,onChange:K=>i(K.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"0.2",children:"0.2mm"}),f.jsx("option",{value:"0.4",children:"0.4mm"}),f.jsx("option",{value:"0.6",children:"0.6mm"}),f.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),f.jsxs("div",{className:"flex items-end gap-2",children:[f.jsxs(qe,{variant:"secondary",onClick:()=>Z(),disabled:G,children:[f.jsx(Mo,{className:`w-4 h-4 ${G?"animate-spin":""}`}),"Refresh"]}),f.jsxs(qe,{onClick:()=>l(!0),children:[f.jsx(ra,{className:"w-4 h-4"}),"Add Profile"]})]})]}),f.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[f.jsxs("div",{className:"flex-1 min-w-48 relative",children:[f.jsx(Xu,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),f.jsx("input",{type:"text",value:h,onChange:K=>g(K.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"})]}),ie&&f.jsx("div",{className:"w-36",children:f.jsxs("select",{value:m,onChange:K=>b(K.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"all",children:"All Extruders"}),f.jsx("option",{value:"left",children:"Left Only"}),f.jsx("option",{value:"right",children:"Right Only"})]})}),f.jsx("div",{className:"w-32",children:f.jsxs("select",{value:y,onChange:K=>v(K.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"all",children:"All Flow"}),f.jsx("option",{value:"hf",children:"HF Only"}),f.jsx("option",{value:"s",children:"S Only"})]})}),f.jsx("div",{className:"w-32",children:f.jsxs("select",{value:x,onChange:K=>M(K.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"name",children:"Sort: Name"}),f.jsx("option",{value:"k_value",children:"Sort: K-Value"}),f.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),f.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[f.jsxs(qe,{variant:"secondary",onClick:ve,disabled:!D?.profiles?.length,title:"Export profiles to JSON",children:[f.jsx(tl,{className:"w-4 h-4"}),"Export"]}),f.jsxs(qe,{variant:"secondary",onClick:Pe,title:"Import profiles from JSON",children:[f.jsx(Ku,{className:"w-4 h-4"}),"Import"]}),f.jsx("div",{className:"flex-1"}),w?f.jsxs(f.Fragment,{children:[f.jsxs(qe,{variant:"secondary",onClick:we,title:"Select all visible profiles",children:[f.jsx(Tf,{className:"w-4 h-4"}),"Select All"]}),f.jsxs(qe,{variant:"secondary",onClick:Le,disabled:T.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${T.size} selected profiles`,children:[f.jsx(fr,{className:"w-4 h-4"}),"Delete (",T.size,")"]}),f.jsxs(qe,{variant:"secondary",onClick:()=>{C(!1),R(new Set)},children:[f.jsx(ln,{className:"w-4 h-4"}),"Cancel"]})]}):f.jsxs(qe,{variant:"secondary",onClick:()=>C(!0),disabled:!ce.length,title:"Enter selection mode for bulk delete",children:[f.jsx(Tf,{className:"w-4 h-4"}),"Select"]})]}),B?f.jsx("div",{className:"flex justify-center py-12",children:f.jsx($t,{className:"w-8 h-8 text-bambu-green animate-spin"})}):q?f.jsx(Ht,{children:f.jsxs(Gt,{className:"py-12 text-center",children:[f.jsx(ZP,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),f.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),f.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),f.jsxs(qe,{variant:"secondary",onClick:()=>Z(),children:[f.jsx(Mo,{className:"w-4 h-4"}),"Retry"]})]})}):ce.length>0?ie?f.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[f.jsxs("div",{children:[f.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),f.jsx("div",{className:"space-y-1",children:ce.filter(K=>K.extruder_id===1).map(K=>f.jsx(yN,{profile:K,onEdit:()=>s(K),onCopy:()=>u(K),selectionMode:w,isSelected:T.has(F(K)),onToggleSelect:()=>he(F(K)),note:ne(K)},F(K)))})]}),f.jsxs("div",{children:[f.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),f.jsx("div",{className:"space-y-1",children:ce.filter(K=>K.extruder_id===0).map(K=>f.jsx(yN,{profile:K,onEdit:()=>s(K),onCopy:()=>u(K),selectionMode:w,isSelected:T.has(F(K)),onToggleSelect:()=>he(F(K)),note:ne(K)},F(K)))})]})]}):f.jsx("div",{className:"space-y-1",children:ce.map(K=>f.jsx(yN,{profile:K,onEdit:()=>s(K),onCopy:()=>u(K),selectionMode:w,isSelected:T.has(F(K)),onToggleSelect:()=>he(F(K)),note:ne(K)},F(K)))}):h||m!=="all"||y!=="all"?f.jsx(Ht,{children:f.jsxs(Gt,{className:"py-12 text-center",children:[f.jsx(Xu,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),f.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),f.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):f.jsx(Ht,{children:f.jsxs(Gt,{className:"py-12 text-center",children:[f.jsx(qP,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),f.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),f.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",r,"mm nozzle"]}),f.jsxs(qe,{onClick:()=>l(!0),children:[f.jsx(ra,{className:"w-4 h-4"}),"Create First Profile"]})]})}),a&&e&&(()=>{const{note:K,key:Q}=z(a);return f.jsx(_N,{profile:a,printerId:e,nozzleDiameter:r,existingProfiles:Y?.profiles||D?.profiles,isDualNozzle:ie,initialNote:K,initialNoteKey:Q,onSaveNote:$,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),s(null),Z()},onSave:()=>{s(null),Z()}})})(),o&&e&&f.jsx(_N,{printerId:e,nozzleDiameter:r,existingProfiles:Y?.profiles||D?.profiles,isDualNozzle:ie,onSaveNote:$,onClose:()=>{l(!1),Z()},onSave:()=>{l(!1),Z()}}),c&&e&&f.jsx(_N,{printerId:e,nozzleDiameter:r,existingProfiles:Y?.profiles||D?.profiles,isDualNozzle:ie,onSaveNote:$,profile:{...c,slot_id:0,name:`${c.name} (Copy)`},onClose:()=>{u(null),Z()},onSave:()=>{u(null),Z()}}),A&&f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:f.jsx(Ht,{className:"w-full max-w-sm",children:f.jsxs(Gt,{className:"p-6",children:[f.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[f.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:f.jsx(fr,{className:"w-5 h-5 text-red-500"})}),f.jsxs("div",{children:[f.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),f.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",f.jsx("span",{className:"text-white font-medium",children:T.size})," selected profiles from the printer?"]}),f.jsxs("div",{className:"flex gap-3",children:[f.jsx(qe,{variant:"secondary",onClick:()=>j(!1),disabled:N,className:"flex-1",children:"Cancel"}),f.jsxs(qe,{onClick:de,disabled:N,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[N?f.jsx($t,{className:"w-4 h-4 animate-spin"}):f.jsx(fr,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function bL(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,a=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),s=a?(a[1]||a[2])+"mm":null,o=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),l=o?o[1]+"mm":null,c=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),u=c?c[1].toUpperCase():null;return{printer:i,nozzle:s,layerHeight:l,filamentType:u}}function L0(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function MVe(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 EVe({onSuccess:t}){const{showToast:e}=sa(),[n,r]=E.useState("email"),[i,a]=E.useState(""),[s,o]=E.useState(""),[l,c]=E.useState(""),[u,h]=E.useState(""),[g,m]=E.useState("global"),b=Rt({mutationFn:()=>ze.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")}),y=Rt({mutationFn:()=>ze.cloudVerify(i,l),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):e(w.message,"error")},onError:w=>e(w.message,"error")}),v=Rt({mutationFn:()=>ze.cloudSetToken(u),onSuccess:()=>{e("Token set successfully"),t()},onError:w=>e(w.message,"error")}),x=w=>{w.preventDefault(),n==="email"?b.mutate():n==="code"?y.mutate():n==="token"&&v.mutate()},M=b.isPending||y.isPending||v.isPending;return f.jsx(Ht,{className:"max-w-md mx-auto",children:f.jsxs(Gt,{children:[f.jsxs("div",{className:"text-center mb-6",children:[f.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:f.jsx(VP,{className:"w-6 h-6 text-bambu-green"})}),f.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),f.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),f.jsxs("form",{onSubmit:x,className:"space-y-4",children:[n==="email"&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),f.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})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),f.jsx("input",{type:"password",value:s,onChange:w=>o(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})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),f.jsxs("select",{value:g,onChange:w=>m(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:[f.jsx("option",{value:"global",children:"Global"}),f.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),f.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),f.jsx("input",{type:"text",value:l,onChange:w=>c(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"&&f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),f.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),f.jsx("textarea",{value:u,onChange:w=>h(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})]}),f.jsxs("div",{className:"flex gap-2",children:[n==="code"&&f.jsx(qe,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),f.jsxs(qe,{type:"submit",disabled:M,className:"flex-1",children:[M?f.jsx($t,{className:"w-4 h-4 animate-spin"}):f.jsx(tF,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&f.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:f.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[f.jsx(coe,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&f.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:f.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[f.jsx(tF,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function gp({label:t,value:e,options:n,onChange:r}){const[i,a]=E.useState(!1),s=n.find(o=>o.value===e);return f.jsxs("div",{className:"relative",children:[f.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:[f.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),f.jsx("span",{children:s?.label||"All"}),f.jsx(F0,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),f.jsx("div",{className:"absolute top-full left-0 mt-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 py-1 max-h-60 overflow-y-auto",children:n.map(o=>f.jsxs("button",{onClick:()=>{r(o.value),a(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${e===o.value?"text-bambu-green":"text-white"}`,children:[f.jsx("span",{children:o.label}),o.count!==void 0&&f.jsx("span",{className:"text-bambu-gray text-xs",children:o.count})]},o.value))})]})]})}function AVe(){const[t,e]=E.useState(!1);E.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?f.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:f.jsx($p,{className:"w-5 h-5"})}):null}function SN({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:s}){const o=bL(t.name),l=L0(t.setting_id);return f.jsxs("div",{className:"flex items-center gap-2 group",children:[f.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:f.jsxs("div",{className:"flex items-center gap-2",children:[i&&a!==void 0&&f.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&&l&&f.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),f.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),o.filamentType&&t.type==="filament"&&f.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.filamentType}),o.layerHeight&&t.type==="process"&&f.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.layerHeight}),o.printer&&f.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.printer})]})}),f.jsx("button",{onClick:c=>{c.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:"Duplicate",children:f.jsx(Vp,{className:"w-4 h-4"})})]})}function RP(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(`
  8227. `)){const i=t.replace(/\\n/g,`
  8228. `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
  8229. `);if(i.length>1)return`"""
  8230. `+i.map(a=>n+" "+a).join(`
  8231. `)+`
  8232. `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
  8233. `+t.map(i=>n+" "+RP(i,e+1)).join(`,
  8234. `)+`
  8235. `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
  8236. `+r.map(([a,s])=>n+" "+JSON.stringify(a)+": "+RP(s,e+1)).join(`,
  8237. `)+`
  8238. `+n+"}"}return String(t)}function TVe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:a}=sa(),s=In(),[o,l]=E.useState(!1),{data:c,isLoading:u}=Nt({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>ze.getCloudSettingDetail(t.setting_id)}),h=Rt({mutationFn:()=>ze.deleteCloudSetting(t.setting_id),onSuccess:()=>{a("Preset deleted"),s.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:b=>a(b.message,"error")}),g=L0(t.setting_id),m=bL(t.name,c?.setting?.inherits);return f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:f.jsx(Ht,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:f.jsxs(Gt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[f.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),g&&f.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),f.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[f.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),m.printer&&f.jsxs(f.Fragment,{children:[f.jsx("span",{children:"•"}),f.jsx("span",{children:m.printer})]})]})]}),f.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:f.jsx(ln,{className:"w-5 h-5"})})]}),f.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:u?f.jsx("div",{className:"flex items-center justify-center py-16",children:f.jsx($t,{className:"w-8 h-8 text-bambu-green animate-spin"})}):c?f.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:RP(c)}):f.jsx("div",{className:"text-center py-16 text-bambu-gray",children:"Failed to load preset details"})}),o?f.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[f.jsx(Eo,{className:"w-5 h-5"}),f.jsx("span",{className:"font-medium",children:"Delete this preset?"})]}),f.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:['This will permanently delete "',t.name,'" from Bambu Cloud. This cannot be undone.']}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(qe,{variant:"secondary",onClick:()=>l(!1),disabled:h.isPending,className:"flex-1",children:"Cancel"}),f.jsxs(qe,{variant:"danger",onClick:()=>h.mutate(),disabled:h.isPending,className:"flex-1",children:[h.isPending?f.jsx($t,{className:"w-4 h-4 animate-spin"}):f.jsx(fr,{className:"w-4 h-4"}),"Delete"]})]})]}):f.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:f.jsxs("div",{className:"flex gap-2",children:[f.jsx(qe,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),f.jsxs(qe,{variant:"secondary",onClick:r,children:[f.jsx(Vp,{className:"w-4 h-4"}),"Duplicate"]}),g&&f.jsxs(f.Fragment,{children:[f.jsxs(qe,{variant:"secondary",onClick:i,disabled:u||!c,children:[f.jsx(Af,{className:"w-4 h-4"}),"Edit"]}),f.jsx(qe,{variant:"danger",onClick:()=>l(!0),children:f.jsx(fr,{className:"w-4 h-4"})})]})]})})]})})})}function cee(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function uee(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function CVe({onClose:t,onApply:e}){const{showToast:n}=sa(),[r,i]=E.useState(cee),[a,s]=E.useState("all"),[o,l]=E.useState(null),[c,u]=E.useState(""),[h,g]=E.useState(""),[m,b]=E.useState("{}"),[y,v]=E.useState(null),[x,M]=E.useState(null),w=a==="all"?r:r.filter(I=>I.type===a),C=I=>{i(I),uee(I)},T=I=>{const W=r.filter(D=>D.id!==I);C(W),M(null),n("Template deleted")},R=I=>{l(I.id),u(I.name),g(I.description),b(JSON.stringify(I.settings,null,2)),v(null)},A=()=>{if(!(!o||!c.trim()))try{const I=JSON.parse(m),W=r.map(D=>D.id===o?{...D,name:c.trim(),description:h.trim(),settings:I}:D);C(W),l(null),n("Template updated")}catch(I){v(I.message)}},j=()=>{l(null),u(""),g(""),b("{}"),v(null)},N=I=>{const W=r.map(D=>D.id===I?{...D,showInModal:!D.showInModal}:D);C(W)},k={filament:{label:"Filament",icon:GP,color:"text-amber-400"},print:{label:"Process",icon:nw,color:"text-blue-400"},printer:{label:"Printer",icon:nl,color:"text-purple-400"}},F=x?r.find(I=>I.id===x):null;return E.useEffect(()=>{const I=W=>{W.key==="Escape"&&(x?M(null):o?j():t())};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[x,o,t]),f.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[F&&f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:f.jsx(Ht,{className:"w-full max-w-md",children:f.jsxs(Gt,{className:"p-6",children:[f.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[f.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:f.jsx(Eo,{className:"w-6 h-6 text-red-400"})}),f.jsxs("div",{children:[f.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Template"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"This action cannot be undone"})]})]}),f.jsxs("p",{className:"text-white mb-6",children:['Are you sure you want to delete "',f.jsx("span",{className:"font-medium",children:F.name}),'"?']}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(qe,{variant:"secondary",onClick:()=>M(null),className:"flex-1",children:"Cancel"}),f.jsxs(qe,{onClick:()=>T(x),className:"flex-1 bg-red-500 hover:bg-red-600",children:[f.jsx(fr,{className:"w-4 h-4"}),"Delete"]})]})]})})}),f.jsx(Ht,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:f.jsxs(Gt,{className:"p-0 flex flex-col h-full",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[f.jsx(Xx,{className:"w-5 h-5 text-amber-400"}),"Quick Templates"]}),f.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:f.jsx(ln,{className:"w-5 h-5"})})]}),f.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[f.jsx("span",{className:"text-sm text-bambu-gray",children:"Type:"}),["all","filament","print","printer"].map(I=>f.jsx("button",{onClick:()=>s(I),className:`px-3 py-1 text-sm rounded-lg transition-colors ${a===I?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:I==="all"?"All":k[I].label},I))]}),f.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:w.length===0?f.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[f.jsx(Xx,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),f.jsx("p",{children:"No templates yet"}),f.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):f.jsx("div",{className:"space-y-2",children:w.map(I=>{const W=k[I.type],D=W.icon;return o===I.id?f.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[f.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[f.jsx("input",{type:"text",value:c,onChange:B=>u(B.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}),f.jsx("input",{type:"text",value:h,onChange:B=>g(B.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"})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:"Settings (JSON)"}),f.jsx("textarea",{value:m,onChange:B=>{b(B.target.value),v(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${y?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),y&&f.jsx("p",{className:"text-xs text-red-400 mt-1",children:y})]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsxs(qe,{size:"sm",onClick:A,disabled:!c.trim(),children:[f.jsx(qo,{className:"w-4 h-4"}),"Save"]}),f.jsx(qe,{size:"sm",variant:"secondary",onClick:j,children:"Cancel"})]})]},I.id):f.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:[f.jsx(D,{className:`w-5 h-5 ${W.color} flex-shrink-0`}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("p",{className:"text-sm font-medium text-white",children:I.name}),f.jsx("p",{className:"text-xs text-bambu-gray truncate",children:I.description})]}),f.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(I.settings).length," fields"]}),f.jsx("button",{onClick:()=>N(I.id),className:`p-1 transition-colors ${I.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:I.showInModal?"Shown in modals":"Hidden in modals",children:I.showInModal?f.jsx(W_,{className:"w-4 h-4"}):f.jsx(WP,{className:"w-4 h-4"})}),f.jsx("button",{onClick:()=>e(I),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),f.jsx("button",{onClick:()=>R(I),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:f.jsx(Af,{className:"w-4 h-4"})}),f.jsx("button",{onClick:()=>M(I.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:f.jsx(fr,{className:"w-4 h-4"})})]},I.id)})})})]})})]})}function dee({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[a,s]=E.useState("changes"),[o,l]=E.useState(""),c=E.useMemo(()=>{const m=new Set([...Object.keys(e),...Object.keys(n)]),b=[];for(const y of m){if(y==="inherits"||y==="version")continue;const v=e[y],x=n[y],M=y in e,w=y in n;let C;!M&&w?C="added":M&&!w?C="removed":JSON.stringify(v)!==JSON.stringify(x)?C="changed":C="same",b.push({key:y,left:v,right:x,status:C})}return b.sort((y,v)=>{const x={changed:0,added:1,removed:2,same:3};return x[y.status]!==x[v.status]?x[y.status]-x[v.status]:y.key.localeCompare(v.key)})},[e,n]),u=E.useMemo(()=>{let m=[...c];if(a==="changes"&&(m=m.filter(b=>b.status!=="same")),o){const b=o.toLowerCase();m=m.filter(y=>y.key.toLowerCase().includes(b)||String(y.left).toLowerCase().includes(b)||String(y.right).toLowerCase().includes(b))}return m},[c,a,o]),h=E.useMemo(()=>({added:c.filter(m=>m.status==="added").length,removed:c.filter(m=>m.status==="removed").length,changed:c.filter(m=>m.status==="changed").length,same:c.filter(m=>m.status==="same").length}),[c]),g=m=>{if(m===void 0)return"—";if(m===null)return"null";if(Array.isArray(m))return m.length===0?"[]":m.length===1?String(m[0]):m.join(", ");if(typeof m=="object")return JSON.stringify(m);const b=String(m);if(b.includes("\\n")||b.length>100){const y=b.split("\\n").length;if(y>1)return`[${y} lines of G-code/script]`;if(b.length>100)return b.substring(0,100)+"…"}return b};return E.useEffect(()=>{const m=b=>{b.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]),f.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:f.jsx(Ht,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:f.jsxs(Gt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[f.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[f.jsx(yx,{className:"w-5 h-5 text-blue-400"}),"Compare Presets"]}),f.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:f.jsx(ln,{className:"w-5 h-5"})})]}),f.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[f.jsxs("div",{className:"text-center",children:[f.jsx("span",{className:"text-sm text-bambu-gray",children:"Left:"}),f.jsx("p",{className:"text-white font-medium truncate",children:r})]}),f.jsxs("div",{className:"text-center",children:[f.jsx("span",{className:"text-sm text-bambu-gray",children:"Right:"}),f.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),f.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[f.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[f.jsx(ra,{className:"w-3.5 h-3.5"}),h.added," added"]}),f.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[f.jsx(nF,{className:"w-3.5 h-3.5"}),h.removed," removed"]}),f.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[f.jsx(LN,{className:"w-3.5 h-3.5"}),h.changed," changed"]}),f.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[f.jsx(BA,{className:"w-3.5 h-3.5"}),h.same," same"]})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsxs("div",{className:"relative",children:[f.jsx(Xu,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),f.jsx("input",{type:"text",value:o,onChange:m=>l(m.target.value),placeholder:"Search fields...",className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),h.same>0&&f.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[f.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"}),f.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"})]})]})]}),f.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:u.length===0?f.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[f.jsx(BA,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),f.jsx("p",{children:a==="changes"?"No differences found":"No fields match the search"})]}):f.jsxs("table",{className:"w-full",children:[f.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:f.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[f.jsx("th",{className:"text-left p-3 w-1/3",children:"Field"}),f.jsx("th",{className:"text-left p-3 w-1/3",children:r}),f.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),f.jsx("tbody",{children:u.map(m=>{const b={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[m.status],y={added:f.jsx(ra,{className:"w-3.5 h-3.5 text-green-400"}),removed:f.jsx(nF,{className:"w-3.5 h-3.5 text-red-400"}),changed:f.jsx(LN,{className:"w-3.5 h-3.5 text-amber-400"}),same:f.jsx(BA,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[m.status];return f.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${b}`,children:[f.jsx("td",{className:"p-3",children:f.jsxs("div",{className:"flex items-center gap-2",children:[y,f.jsx("span",{className:"text-sm text-white font-mono",children:m.key})]})}),f.jsx("td",{className:"p-3",children:f.jsx("span",{className:`text-sm font-mono break-all ${m.status==="removed"?"text-red-300":m.status==="changed"?"text-white":"text-bambu-gray"}`,children:g(m.left)})}),f.jsx("td",{className:"p-3",children:f.jsx("span",{className:`text-sm font-mono break-all ${m.status==="added"?"text-green-300":m.status==="changed"?"text-white":"text-bambu-gray"}`,children:g(m.right)})})]},m.key)})})]})})]})})})}function NVe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=sa(),i=In(),a=!!e?.setting_id,[s,o]=E.useState("common"),[l,c]=E.useState(e?.type||"filament"),[u,h]=E.useState(e?.name?a?e.name:`${e.name} (Copy)`:""),[g,m]=E.useState(e?.base_id||""),[b,y]=E.useState(""),[v,x]=E.useState(e?.setting||{inherits:""}),[M,w]=E.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[C,T]=E.useState(null),[R,A]=E.useState(""),[j,N]=E.useState(!1),[k,F]=E.useState(""),[I,W]=E.useState(!1),[D,B]=E.useState(cee),[G,V]=E.useState(!1),[Z,Y]=E.useState(""),[ee,H]=E.useState(""),[q,ae]=E.useState(!0),[ce,xe]=E.useState(null),[ie,ve]=E.useState(!1),Pe=E.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[l]||[],[n,l]),he=E.useMemo(()=>Pe.filter(le=>L0(le.setting_id)),[Pe]),{data:we}=Nt({queryKey:["cloudFields",l],queryFn:()=>ze.getCloudFields(l==="print"?"process":l),staleTime:1e3*60*60}),{data:Le}=Nt({queryKey:["allPresetDetails",l,he.map(le=>le.setting_id).join(",")],queryFn:async()=>{const le={};for(let Fe=0;Fe<he.length;Fe+=5){const Xe=he.slice(Fe,Fe+5);(await Promise.all(Xe.map(async ue=>{try{const Qe=await ze.getCloudSettingDetail(ue.setting_id);return{id:ue.setting_id,detail:Qe}}catch{return null}}))).forEach(ue=>{ue&&(le[ue.id]=ue.detail)})}return le},enabled:he.length>0,staleTime:1e3*60*10}),{data:de,isLoading:lt}=Nt({queryKey:["cloudSettingDetail",g],queryFn:()=>ze.getCloudSettingDetail(g),enabled:!!g});E.useEffect(()=>{s!=="json"&&w(JSON.stringify(v,null,2))},[v,s]);const $=E.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[l]||[]).filter(Ze=>!L0(Ze.setting_id)).sort((Ze,Fe)=>Ze.name.localeCompare(Fe.name)),[n,l]);E.useEffect(()=>{if(!g)return;const le=$.find(Ze=>Ze.setting_id===g);le&&(y(le.name),a||(x({inherits:le.name}),w(JSON.stringify({inherits:le.name},null,2))))},[g,$,a]);const z=E.useMemo(()=>{const le=we?.fields||[],Ze=new Set(le.map(ue=>ue.key)),Fe=new Set,Xe=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);Le&&Object.values(Le).forEach(ue=>{ue?.setting&&Object.keys(ue.setting).forEach(Qe=>{!Ze.has(Qe)&&!Xe.has(Qe)&&Fe.add(Qe)})}),Object.keys(v).forEach(ue=>{!Ze.has(ue)&&!Xe.has(ue)&&Fe.add(ue)});const ct=Array.from(Fe).sort().map(ue=>({key:ue,label:ue.replace(/_/g," ").replace(/\b\w/g,Qe=>Qe.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...le,...ct]},[we,Le,v]),ne=z.filter(le=>le.label.toLowerCase().includes(R.toLowerCase())||le.key.toLowerCase().includes(R.toLowerCase())),K=()=>{if(k.trim()){const le=k.trim().toLowerCase().replace(/\s+/g,"_");Q(le,""),F(""),W(!1),r(`Field "${le}" added`)}},Q=(le,Ze)=>{x(Fe=>{const Xe={...Fe};return Ze===""||Ze===void 0?delete Xe[le]:Xe[le]=Ze,Xe})},oe=le=>{x(Ze=>({...Ze,...le.settings})),xe(le.name),r("Template applied")},Ne=()=>{if(!Z.trim())return;const le={...v};if(delete le.inherits,Object.keys(le).length===0){r("No overrides to save","error");return}const Ze={id:Date.now().toString(),name:Z.trim(),description:ee.trim()||"Custom template",type:l,settings:le,showInModal:q},Fe=[...D,Ze];B(Fe),uee(Fe),V(!1),Y(""),H(""),ae(!0),r("Template saved")},Ee=E.useMemo(()=>D.filter(le=>le.type===l&&le.showInModal),[l,D]),re=le=>{w(le);try{const Ze=JSON.parse(le);x(Ze),T(null)}catch(Ze){T(Ze.message)}},U=le=>{le.preventDefault(),N(!1);const Ze=le.dataTransfer.files[0];if(Ze&&Ze.name.endsWith(".json")){const Fe=new FileReader;Fe.onload=Xe=>{try{const ct=Xe.target?.result,ue=JSON.parse(ct),Qe=ue.setting||ue;x(pe=>({...pe,...Qe})),w(JSON.stringify({...v,...Qe},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},Fe.readAsText(Ze)}},L=Rt({mutationFn:()=>{const le={...v},Ze=l==="filament"?"filament_settings_id":l==="print"?"print_settings_id":"printer_settings_id";le[Ze]=`"${u}"`;const Fe={type:l,name:u,base_id:g,setting:le};return ze.createCloudSetting(Fe)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:le=>r(le.message,"error")}),J=Rt({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return ze.updateCloudSetting(e.setting_id,{name:u,setting:v})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:le=>r(le.message,"error")}),ge=a?J:L,ye=de?.setting?.inherits,me=ye?$.find(le=>le.name===ye):void 0,{data:et}=Nt({queryKey:["cloudSettingDetail",me?.setting_id],queryFn:()=>ze.getCloudSettingDetail(me.setting_id),enabled:!!me?.setting_id}),Ie=E.useMemo(()=>{const le=et?.setting||{},Ze=de?.setting||{},Fe=g&&Le?.[g]?.setting?Le[g].setting:{};return{...le,...Ze,...Fe}},[g,de,et,Le]),Ke=le=>{if(le==null)return"";if(Array.isArray(le)){const Ze=[...new Set(le.map(Fe=>String(Fe)))];return Ze.length===1?Ze[0]:le.join(", ")}return String(le)},st=le=>{const Ze=v[le.key],Fe=Ie[le.key],Xe=Ke(Fe),ct=lt?"Loading...":Xe||"",ue="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(le.type==="boolean"){const Qe=Ze==="1"||Ze===void 0&&Fe==="1";return f.jsx("button",{type:"button",onClick:()=>Q(le.key,Ze==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Qe?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:f.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Qe?"translate-x-3.5":"translate-x-0.5"}`})})}return le.type==="select"?f.jsxs("select",{value:Ze||"",onChange:Qe=>Q(le.key,Qe.target.value),className:ue,children:[f.jsx("option",{value:"",children:ct}),le.options?.map(Qe=>f.jsx("option",{value:Qe.value,children:Qe.label},Qe.value))]}):f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:le.type==="number"?"number":"text",value:Ze!==void 0?String(Ze):"",onChange:Qe=>Q(le.key,Qe.target.value),step:le.step,min:le.min,max:le.max,placeholder:ct,className:ue}),le.unit&&f.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:le.unit})]})},je=E.useMemo(()=>de?.setting?de.setting:{},[de]);return f.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:le=>{le.preventDefault(),N(!0)},onDragLeave:()=>N(!1),onDrop:U,children:[ie&&g&&f.jsx(dee,{onClose:()=>ve(!1),leftPreset:je,rightPreset:v,leftLabel:`Base: ${b||g}`,rightLabel:`Current: ${u||"New Preset"}`}),f.jsx(Ht,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:f.jsxs(Gt,{className:"p-0 flex flex-col h-full",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{children:[f.jsx("h2",{className:"text-xl font-semibold text-white",children:a?"Edit Preset":e?"Duplicate Preset":"Create New Preset"}),f.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize settings for your new preset"})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[g&&f.jsxs("button",{onClick:()=>ve(!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:[f.jsx(yx,{className:"w-4 h-4"}),"Compare"]}),f.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:f.jsx(ln,{className:"w-5 h-5"})})]})]}),j&&f.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:f.jsxs("div",{className:"text-center",children:[f.jsx(Ku,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),f.jsx("p",{className:"text-bambu-green font-medium",children:"Drop JSON file to import"})]})}),f.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[f.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Type"}),f.jsxs("select",{value:l,onChange:le=>{c(le.target.value),m("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"filament",children:"Filament"}),f.jsx("option",{value:"print",children:"Process"}),f.jsx("option",{value:"printer",children:"Printer"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Base Preset"}),f.jsxs("select",{value:g,onChange:le=>m(le.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:[f.jsx("option",{value:"",children:"Select base preset..."}),$.map(le=>f.jsx("option",{value:le.setting_id,children:le.name},le.setting_id))]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Preset Name"}),f.jsx("input",{type:"text",value:u,onChange:le=>h(le.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"My Custom Preset"})]})]}),b&&f.jsx("div",{className:"text-xs text-bambu-gray",children:f.jsxs("p",{className:"flex items-center gap-1",children:[f.jsx(Mf,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",f.jsx("span",{className:"text-white",children:b}),lt&&f.jsx($t,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),f.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[f.jsxs("button",{onClick:()=>o("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[f.jsx(rF,{className:"w-4 h-4"}),"Common"]}),f.jsxs("button",{onClick:()=>o("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[f.jsx(KP,{className:"w-4 h-4"}),"All Fields"]}),f.jsxs("button",{onClick:()=>o("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[f.jsx(wse,{className:"w-4 h-4"}),"JSON",C&&f.jsx(wo,{className:"w-3 h-3 text-red-400"})]}),f.jsx("div",{className:"flex-1"}),f.jsxs("button",{onClick:()=>{const le={name:u,type:l,base_id:g,setting:v},Ze=new Blob([JSON.stringify(le,null,2)],{type:"application/json"}),Fe=URL.createObjectURL(Ze),Xe=document.createElement("a");Xe.href=Fe,Xe.download=`${u||"preset"}.json`,document.body.appendChild(Xe),Xe.click(),document.body.removeChild(Xe),URL.revokeObjectURL(Fe),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:[f.jsx(tl,{className:"w-4 h-4"}),"Export"]}),f.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:[f.jsx(Ku,{className:"w-4 h-4"}),"Import"]}),f.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:le=>{const Ze=le.target.files?.[0];if(Ze){const Fe=new FileReader;Fe.onload=Xe=>{try{const ct=JSON.parse(Xe.target?.result),ue=ct.setting||ct;x(Qe=>({...Qe,...ue})),r("File imported")}catch{r("Invalid JSON","error")}},Fe.readAsText(Ze)}}})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[s==="common"&&f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between mb-3",children:[f.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[f.jsx(Xx,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(v).filter(le=>le!=="inherits").length>0&&f.jsxs("button",{onClick:()=>V(!G),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[f.jsx(qo,{className:"w-3 h-3"}),"Save as template"]})]}),G&&f.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[f.jsx("input",{type:"text",value:Z,onChange:le=>Y(le.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}),f.jsx("input",{type:"text",value:ee,onChange:le=>H(le.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"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex gap-2",children:[f.jsxs(qe,{size:"sm",onClick:Ne,disabled:!Z.trim(),children:[f.jsx(qo,{className:"w-3 h-3"}),"Save"]}),f.jsx(qe,{size:"sm",variant:"secondary",onClick:()=>V(!1),children:"Cancel"})]}),f.jsxs("button",{onClick:()=>ae(!q),className:`flex items-center gap-1.5 text-xs transition-colors ${q?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[q?f.jsx(W_,{className:"w-3.5 h-3.5"}):f.jsx(WP,{className:"w-3.5 h-3.5"}),q?"Show in modals":"Hidden in modals"]})]})]}),ce&&f.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:[f.jsx(Mf,{className:"w-4 h-4 text-bambu-green"}),f.jsxs("span",{className:"text-sm text-bambu-green",children:["Template applied: ",f.jsx("span",{className:"font-medium",children:ce})]}),f.jsx("button",{onClick:()=>xe(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:f.jsx(ln,{className:"w-4 h-4"})})]}),f.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Ee.map(le=>f.jsxs("button",{onClick:()=>oe(le),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[f.jsx("p",{className:"text-sm font-medium text-white",children:le.name}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:le.description})]},le.id)),Ee.length===0&&f.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."})]}),f.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:"Manage templates via the Templates button on the main page"})]}),f.jsxs("div",{children:[f.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Common Settings"}),f.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:z.slice(0,10).map(le=>f.jsxs("div",{className:"flex items-center justify-between gap-4",children:[f.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:le.label}),f.jsx("div",{className:"w-48",children:st(le)})]},le.key))})]}),Object.keys(v).length>1&&f.jsxs("div",{children:[f.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Current Overrides"}),f.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(v).filter(([le])=>le!=="inherits").map(([le,Ze])=>f.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[le,": ",String(Ze).slice(0,20),f.jsx("button",{onClick:()=>Q(le,void 0),className:"hover:text-white",children:f.jsx(ln,{className:"w-3 h-3"})})]},le))})]})]}),s==="fields"&&f.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[f.jsx("h3",{className:"text-sm font-medium text-white",children:"Available Fields"}),f.jsx("span",{className:"text-xs text-bambu-gray",children:Le?`${z.length} fields`:"Loading..."})]}),f.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[f.jsx(Xu,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),f.jsx("input",{type:"text",value:R,onChange:le=>A(le.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"})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[ne.filter(le=>!(le.key in v)).map(le=>{const Ze=Ie[le.key],Fe=Ke(Ze);return f.jsxs("div",{onClick:()=>{x(Xe=>({...Xe,[le.key]:Fe||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("p",{className:"text-sm text-white truncate",children:le.label}),f.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:le.key})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Fe&&f.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:Fe,children:[Fe.slice(0,20),Fe.length>20?"...":""]}),f.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:f.jsx(ra,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},le.key)}),ne.filter(le=>!(le.key in v)).length===0&&f.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:R?"No matching fields":"All fields added"})]}),f.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:I?f.jsxs("div",{className:"flex gap-2",children:[f.jsx("input",{type:"text",value:k,onChange:le=>F(le.target.value),onKeyDown:le=>le.key==="Enter"&&K(),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}),f.jsx(qe,{size:"sm",onClick:K,disabled:!k.trim(),children:f.jsx(ra,{className:"w-4 h-4"})}),f.jsx(qe,{size:"sm",variant:"secondary",onClick:()=>{W(!1),F("")},children:f.jsx(ln,{className:"w-4 h-4"})})]}):f.jsxs("button",{onClick:()=>W(!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:[f.jsx(ra,{className:"w-4 h-4"}),"Add custom field"]})})]}),f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[f.jsx("h3",{className:"text-sm font-medium text-white",children:"Your Overrides"}),f.jsxs("span",{className:"text-xs text-bambu-gray",children:[Object.keys(v).filter(le=>le!=="inherits").length," fields"]})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(v).filter(([le])=>le!=="inherits").map(([le,Ze])=>{const Fe=z.find(Xe=>Xe.key===le);return f.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center justify-between mb-2",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm font-medium text-white",children:Fe?.label||le}),f.jsx("p",{className:"text-xs text-bambu-gray-dark",children:le})]}),f.jsx("button",{onClick:()=>Q(le,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:f.jsx(ln,{className:"w-4 h-4"})})]}),Fe?st(Fe):f.jsx("input",{type:"text",value:String(Ze),onChange:Xe=>Q(le,Xe.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"})]},le)}),Object.keys(v).filter(le=>le!=="inherits").length===0&&f.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[f.jsx(rF,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),f.jsx("p",{className:"text-sm",children:"No overrides yet"}),f.jsx("p",{className:"text-xs mt-1",children:"Click fields on the left to add them"})]})]}),Object.keys(v).filter(le=>le!=="inherits").length>0&&f.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:f.jsxs("button",{onClick:()=>{V(!0),o("common")},className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[f.jsx(qo,{className:"w-4 h-4"}),"Save as template"]})})]})]}),s==="json"&&f.jsxs("div",{className:"space-y-2",children:[C&&f.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[f.jsx(wo,{className:"w-4 h-4"}),C]}),f.jsx("textarea",{value:M,onChange:le=>re(le.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 ${C?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Tip: Drag & drop a .json file anywhere on this modal to import settings"})]})]}),f.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[f.jsx(qe,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),f.jsxs(qe,{onClick:()=>ge.mutate(),disabled:ge.isPending||!u.trim()||!a&&!g||!!C,className:"flex-1",children:[ge.isPending?f.jsx($t,{className:"w-4 h-4 animate-spin"}):a?f.jsx(qo,{className:"w-4 h-4"}):f.jsx(ra,{className:"w-4 h-4"}),a?"Save":e?"Duplicate":"Create"]})]})]})})]})}function RVe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i}){const[a,s]=E.useState(""),[o,l]=E.useState("all"),[c,u]=E.useState("all"),[h,g]=E.useState("all"),[m,b]=E.useState("all"),[y,v]=E.useState("all"),[x,M]=E.useState("all"),[w,C]=E.useState(null),[T,R]=E.useState(!1),[A,j]=E.useState(!1),[N,k]=E.useState(null),[F,I]=E.useState(null),[W,D]=E.useState(null),[B,G]=E.useState(!1),[V,Z]=E.useState([null,null]),[Y,ee]=E.useState(!1),[H,q]=E.useState(null),ae=In(),ce=E.useMemo(()=>[...t.filament.map(ne=>({...ne,type:"filament"})),...t.printer.map(ne=>({...ne,type:"printer"})),...t.process.map(ne=>({...ne,type:"process"}))].map(ne=>({...ne,meta:bL(ne.name)})),[t]),xe=E.useMemo(()=>{const z=new Set,ne=new Set,K=new Set;return ce.forEach(Q=>{Q.meta.nozzle&&z.add(Q.meta.nozzle),Q.meta.filamentType&&ne.add(Q.meta.filamentType),Q.meta.layerHeight&&K.add(Q.meta.layerHeight)}),{printers:i.map(Q=>({id:Q.id.toString(),name:Q.name})),nozzles:Array.from(z).sort((Q,oe)=>parseFloat(Q)-parseFloat(oe)),filaments:Array.from(ne).sort(),layerHeights:Array.from(K).sort((Q,oe)=>parseFloat(Q)-parseFloat(oe))}},[ce,i]),ie=E.useMemo(()=>h==="all"?null:i.find(ne=>ne.id.toString()===h)?.model||null,[h,i]),ve=E.useMemo(()=>ce.filter(z=>o==="all"||z.type===o).filter(z=>{if(c==="all")return!0;const ne=L0(z.setting_id);return c==="custom"?ne:!ne}).filter(z=>{if(h==="all"||!ie)return!0;const ne=z.meta.printer?.toLowerCase()||"",K=ie.toLowerCase();return ne.includes(K)||K.includes(ne)}).filter(z=>m==="all"||z.meta.nozzle===m).filter(z=>y==="all"||z.meta.filamentType===y).filter(z=>x==="all"||z.meta.layerHeight===x).filter(z=>a===""||z.name.toLowerCase().includes(a.toLowerCase())).sort((z,ne)=>z.name.localeCompare(ne.name)),[ce,o,c,h,ie,m,y,x,a]),Pe=z=>{if(B){const ne=V[0]?.setting_id===z.setting_id,K=V[1]?.setting_id===z.setting_id;if(ne)Z([V[1],null]);else if(K)Z([V[0],null]);else if(!V[0])Z([z,null]);else if(V[1]){if(V[0].type!==z.type)return;Z([V[0],z])}else{if(V[0].type!==z.type)return;Z([V[0],z])}}else C(z)},he=z=>{if(V[0]?.setting_id===z.setting_id)return 0;if(V[1]?.setting_id===z.setting_id)return 1},we=async z=>{try{const ne=await ze.getCloudSettingDetail(z.setting_id),K=z.type==="process"?"print":z.type;k({type:K,name:z.name,base_id:ne.base_id||"GFSA00",setting:ne.setting||{}}),C(null)}catch(ne){console.error("Failed to fetch preset details for duplication:",ne)}},Le=async z=>{try{ae.removeQueries({queryKey:["cloudSettingDetail",z.setting_id]});const ne=await ze.getCloudSettingDetail(z.setting_id),K=z.type==="process"?"print":z.type;I({type:K,name:z.name,base_id:ne.base_id||"GFSA00",setting:ne.setting||{},setting_id:z.setting_id}),C(null)}catch(ne){console.error("Failed to fetch preset details for editing:",ne)}},de=()=>{l("all"),u("all"),g("all"),b("all"),v("all"),M("all"),s("")},lt=o!=="all"||c!=="all"||h!=="all"||m!=="all"||y!=="all"||x!=="all"||a!=="",$=t.filament.length+t.printer.length+t.process.length;return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"space-y-4 mb-6",children:[f.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[f.jsxs("div",{className:"relative flex-1",children:[f.jsx(Xu,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),f.jsx("input",{type:"text",value:a,onChange:z=>s(z.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"})]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsxs(qe,{variant:B?"primary":"secondary",onClick:()=>{B?(G(!1),Z([null,null])):G(!0)},children:[f.jsx(yx,{className:"w-4 h-4"}),B?"Cancel":"Compare"]}),f.jsxs(qe,{variant:"secondary",onClick:()=>j(!0),children:[f.jsx(Xx,{className:"w-4 h-4"}),"Templates"]}),f.jsxs(qe,{variant:"secondary",onClick:n,disabled:r,children:[f.jsx(Mo,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),f.jsxs(qe,{onClick:()=>R(!0),children:[f.jsx(ra,{className:"w-4 h-4"}),"New Preset"]})]})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsx(a9,{className:"w-4 h-4 text-bambu-gray"}),f.jsx(gp,{label:"Type",value:o,options:[{value:"all",label:"All",count:$},{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:z=>l(z)}),f.jsx(gp,{label:"Owner",value:c,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:z=>u(z)}),xe.printers.length>0&&f.jsx(gp,{label:"Printer",value:h,options:[{value:"all",label:"All"},...xe.printers.map(z=>({value:z.id,label:z.name}))],onChange:g}),xe.nozzles.length>0&&f.jsx(gp,{label:"Nozzle",value:m,options:[{value:"all",label:"All"},...xe.nozzles.map(z=>({value:z,label:z}))],onChange:b}),xe.filaments.length>0&&(o==="all"||o==="filament")&&f.jsx(gp,{label:"Filament",value:y,options:[{value:"all",label:"All"},...xe.filaments.map(z=>({value:z,label:z}))],onChange:v}),xe.layerHeights.length>0&&(o==="all"||o==="process")&&f.jsx(gp,{label:"Layer",value:x,options:[{value:"all",label:"All"},...xe.layerHeights.map(z=>({value:z,label:z}))],onChange:M}),lt&&f.jsx("button",{onClick:de,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),B&&f.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsx(yx,{className:"w-5 h-5 text-blue-400"}),f.jsx("span",{className:"text-white font-medium",children:"Compare Mode"}),f.jsx("span",{className:"text-bambu-gray",children:V[0]?`Select another ${V[0].type} preset`:"Click two presets of the same type to compare"})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${V[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:V[0]?V[0].name:"1. Select first"}),f.jsx(LN,{className:"w-4 h-4 text-bambu-gray"}),f.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${V[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:V[1]?V[1].name:"2. Select second"})]}),V[0]&&V[1]&&f.jsxs(qe,{size:"sm",onClick:async()=>{try{const[z,ne]=await Promise.all([ze.getCloudSettingDetail(V[0].setting_id),ze.getCloudSettingDetail(V[1].setting_id)]);q([z.setting||{},ne.setting||{}]),ee(!0)}catch{}},children:[f.jsx(yx,{className:"w-4 h-4"}),"Compare Now"]})]})]})}),f.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Ni,{className:"w-3 h-3"}),"Last synced: ",MVe(e.toISOString())]}),f.jsxs("span",{children:["Showing ",ve.length," of ",$," presets"]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),f.jsx("span",{children:"= My preset (editable)"})]})]}),ve.length===0?f.jsxs("div",{className:"text-center py-16",children:[f.jsx(Gp,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),f.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),lt&&f.jsx("button",{onClick:de,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:"Clear filters"})]}):f.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[f.jsx(GP,{className:"w-4 h-4 text-amber-400"}),f.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Filament"}),f.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ve.filter(z=>z.type==="filament").length,")"]})]}),f.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ve.filter(z=>z.type==="filament").map(z=>f.jsx(SN,{setting:z,onClick:()=>Pe(z),onDuplicate:()=>we(z),compareMode:B,isCompareSelected:he(z)!==void 0,compareIndex:he(z),compareDisabled:B&&!!V[0]&&V[0].type!==z.type},z.setting_id)),ve.filter(z=>z.type==="filament").length===0&&f.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No filament presets"})]})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[f.jsx(nw,{className:"w-4 h-4 text-blue-400"}),f.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Process"}),f.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ve.filter(z=>z.type==="process").length,")"]})]}),f.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ve.filter(z=>z.type==="process").map(z=>f.jsx(SN,{setting:z,onClick:()=>Pe(z),onDuplicate:()=>we(z),compareMode:B,isCompareSelected:he(z)!==void 0,compareIndex:he(z),compareDisabled:B&&!!V[0]&&V[0].type!==z.type},z.setting_id)),ve.filter(z=>z.type==="process").length===0&&f.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No process presets"})]})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[f.jsx(nl,{className:"w-4 h-4 text-purple-400"}),f.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Printer"}),f.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ve.filter(z=>z.type==="printer").length,")"]})]}),f.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ve.filter(z=>z.type==="printer").map(z=>f.jsx(SN,{setting:z,onClick:()=>Pe(z),onDuplicate:()=>we(z),compareMode:B,isCompareSelected:he(z)!==void 0,compareIndex:he(z),compareDisabled:B&&!!V[0]&&V[0].type!==z.type},z.setting_id)),ve.filter(z=>z.type==="printer").length===0&&f.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),w&&f.jsx(TVe,{setting:w,onClose:()=>C(null),onDeleted:()=>C(null),onDuplicate:()=>we(w),onEdit:()=>Le(w)}),(T||N||F||W)&&f.jsx(NVe,{onClose:()=>{R(!1),k(null),I(null),D(null)},initialData:F||N||(W?{type:W.type,name:"",base_id:"",setting:W.setting}:void 0),allPresets:t}),A&&f.jsx(CVe,{onClose:()=>j(!1),onApply:z=>{D({type:z.type,setting:z.settings}),j(!1)}}),Y&&H&&V[0]&&V[1]&&f.jsx(dee,{onClose:()=>{ee(!1),q(null)},leftPreset:H[0],rightPreset:H[1],leftLabel:V[0].name,rightLabel:V[1].name})]})}function PVe(){const t=In(),{showToast:e}=sa(),[n,r]=E.useState("cloud"),[i,a]=E.useState(),{data:s,isLoading:o}=Nt({queryKey:["cloudStatus"],queryFn:ze.getCloudStatus}),{data:l=[]}=Nt({queryKey:["printers"],queryFn:ze.getPrinters}),{data:c,isLoading:u,refetch:h,dataUpdatedAt:g}=Nt({queryKey:["cloudSettings"],queryFn:()=>ze.getCloudSettings(),enabled:!!s?.is_authenticated,retry:!1,staleTime:1e3*60*5});E.useEffect(()=>{g&&a(new Date(g))},[g]);const m=Rt({mutationFn:ze.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),b=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return o?f.jsx("div",{className:"p-8 flex items-center justify-center min-h-[400px]",children:f.jsx($t,{className:"w-8 h-8 text-bambu-green animate-spin"})}):f.jsxs("div",{className:"p-6 lg:p-8",children:[f.jsxs("div",{className:"mb-6",children:[f.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),f.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),f.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[f.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:[f.jsx(VP,{className:"w-4 h-4"}),"Cloud Profiles"]}),f.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:[f.jsx(qP,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&f.jsxs(f.Fragment,{children:[s?.is_authenticated&&f.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),f.jsxs("span",{className:"text-sm text-bambu-gray",children:["Connected as ",f.jsx("span",{className:"text-white",children:s.email})]})]}),f.jsxs(qe,{variant:"secondary",size:"sm",onClick:()=>m.mutate(),disabled:m.isPending,children:[f.jsx(Eoe,{className:"w-4 h-4"}),"Logout"]})]}),s?.is_authenticated?u?f.jsx("div",{className:"flex items-center justify-center py-16",children:f.jsx($t,{className:"w-8 h-8 text-bambu-green animate-spin"})}):c?f.jsx(RVe,{settings:c,lastSyncTime:i,onRefresh:()=>h(),isRefreshing:u,printers:l}):f.jsxs("div",{className:"text-center py-16",children:[f.jsx("p",{className:"text-bambu-gray mb-4",children:"Failed to load profiles"}),f.jsx(qe,{onClick:()=>h(),children:"Retry"})]}):f.jsx(EVe,{onSuccess:b})]}),n==="kprofiles"&&f.jsx(wVe,{}),f.jsx(AVe,{})]})}const PP={Droplet:GP,Flame:Wse,Ruler:Joe,Sparkles:Xx,Square:Wp,Cable:ese,Wrench:qp};function U_(t){return t&&PP[t]||qp}function Hx(t){return t<1?`${Math.round(t*60)}m`:`${t.toFixed(1)}h`}function kVe(t){const e=Math.floor(t),n=Math.round((t-e)*60);return e===0?`${n} minutes`:n===0?`${e} hours`:`${e}h ${n}m`}function DVe({item:t,onPerform:e,onToggle:n}){const r=U_(t.maintenance_type_icon),i=Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100)),a=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-yellow-400":"text-bambu-green":"text-bambu-gray",s=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-yellow-500":"bg-bambu-green":"bg-bambu-gray/30",o=()=>t.enabled?t.is_due?`Overdue by ${Hx(Math.abs(t.hours_until_due))}`:t.is_warning?`Due in ${Hx(t.hours_until_due)}`:`${Hx(t.hours_until_due)} left`:"Disabled";return f.jsxs("div",{className:`flex items-center gap-4 p-3 rounded-lg ${t.is_due?"bg-red-500/10":t.is_warning?"bg-yellow-500/10":"bg-bambu-dark"}`,children:[f.jsxs("div",{className:"flex items-center gap-3 min-w-[180px]",children:[f.jsx(r,{className:`w-4 h-4 ${a()}`}),f.jsx("span",{className:`text-sm ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name})]}),f.jsx("div",{className:"flex-1 max-w-[200px]",children:f.jsx("div",{className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:f.jsx("div",{className:`h-full transition-all ${s()}`,style:{width:`${i}%`}})})}),f.jsxs("div",{className:`text-xs min-w-[120px] ${a()}`,children:[t.is_due&&f.jsx(Eo,{className:"w-3 h-3 inline mr-1"}),t.is_warning&&f.jsx(Ni,{className:"w-3 h-3 inline mr-1"}),!t.is_due&&!t.is_warning&&t.enabled&&f.jsx(Mf,{className:"w-3 h-3 inline mr-1"}),o()]}),f.jsx(is,{checked:t.enabled,onChange:l=>n(t.id,l)}),f.jsxs(qe,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"min-w-[70px]",children:[f.jsx(tw,{className:"w-3 h-3"}),"Done"]})]})}function OVe({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,a]=E.useState(!1),[s,o]=E.useState(!1),[l,c]=E.useState(t.total_print_hours.toFixed(1)),u=[...t.maintenance_items].sort((m,b)=>m.maintenance_type_id-b.maintenance_type_id),h=[...t.maintenance_items].filter(m=>m.enabled).sort((m,b)=>m.is_due&&!b.is_due?-1:!m.is_due&&b.is_due?1:m.is_warning&&!b.is_warning?-1:!m.is_warning&&b.is_warning?1:m.hours_until_due-b.hours_until_due)[0],g=()=>{const m=parseFloat(l);!isNaN(m)&&m>=0&&(r(t.printer_id,m),o(!1))};return f.jsxs(Ht,{children:[f.jsxs("div",{className:"p-4",children:[f.jsxs("div",{className:"flex items-center justify-between mb-4",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:t.printer_name}),t.due_count>0&&f.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",children:[f.jsx(Eo,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&f.jsxs("span",{className:"px-2.5 py-1 bg-yellow-500/20 text-yellow-400 text-xs font-medium rounded-full flex items-center gap-1",children:[f.jsx(Ni,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&f.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",children:[f.jsx(Mf,{className:"w-3 h-3"}),"All good"]})]}),f.jsx("button",{onClick:()=>a(!i),className:"flex items-center gap-1 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded transition-colors",children:i?f.jsxs(f.Fragment,{children:[f.jsx(r9,{className:"w-4 h-4"}),"Hide"]}):f.jsxs(f.Fragment,{children:[f.jsx(F0,{className:"w-4 h-4"}),"Details"]})})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg",children:[f.jsx("div",{className:"text-xs text-bambu-gray mb-1 uppercase tracking-wide",children:"Total Print Time"}),s?f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"number",value:l,onChange:m=>c(m.target.value),onKeyDown:m=>{m.key==="Enter"&&g(),m.key==="Escape"&&o(!1)},className:"w-20 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-lg font-semibold",min:"0",step:"1",autoFocus:!0}),f.jsx("span",{className:"text-sm text-bambu-gray",children:"hours"}),f.jsxs("div",{className:"flex gap-1 ml-auto",children:[f.jsx(qe,{size:"sm",onClick:g,children:"Save"}),f.jsx(qe,{size:"sm",variant:"secondary",onClick:()=>o(!1),children:"✕"})]})]}):f.jsxs("button",{onClick:()=>{c(Math.round(t.total_print_hours).toString()),o(!0)},className:"flex items-center gap-2 group",title:"Click to edit total print hours",children:[f.jsx("span",{className:"text-xl font-semibold text-white group-hover:text-bambu-green transition-colors",children:kVe(t.total_print_hours)}),f.jsx(YP,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})]})]}),f.jsxs("div",{className:`p-3 rounded-lg ${h?.is_due?"bg-red-500/10":h?.is_warning?"bg-yellow-500/10":"bg-bambu-dark"}`,children:[f.jsx("div",{className:"text-xs text-bambu-gray mb-1 uppercase tracking-wide",children:"Next Maintenance"}),h?f.jsxs("div",{children:[f.jsx("div",{className:`text-lg font-semibold ${h.is_due?"text-red-400":h.is_warning?"text-yellow-400":"text-white"}`,children:h.maintenance_type_name}),f.jsx("div",{className:`text-sm ${h.is_due?"text-red-400":h.is_warning?"text-yellow-400":"text-bambu-gray"}`,children:h.is_due?f.jsxs(f.Fragment,{children:["Overdue by ",Hx(Math.abs(h.hours_until_due))]}):f.jsxs(f.Fragment,{children:["Due in ",Hx(h.hours_until_due)]})})]}):f.jsx("div",{className:"text-white",children:"No tasks enabled"})]})]})]}),i&&f.jsx(Gt,{className:"pt-0 space-y-2 border-t border-bambu-dark-tertiary mt-4",children:f.jsx("div",{className:"pt-4",children:u.map(m=>f.jsx(DVe,{item:m,onPerform:e,onToggle:n},m.id))})})]})}function LVe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onDeleteType:i}){const[a,s]=E.useState(null),[o,l]=E.useState(""),[c,u]=E.useState(!1),[h,g]=E.useState(""),[m,b]=E.useState("100"),[y,v]=E.useState("Wrench"),x=(R,A)=>{const j=parseFloat(o);if(!isNaN(j)&&j>0){const N=Math.abs(j-A)<.01?null:j;n(R,N)}s(null)},M=R=>{R.preventDefault(),h.trim()&&parseFloat(m)>0&&(r({name:h.trim(),default_interval_hours:parseFloat(m),icon:y}),g(""),b("100"),u(!1))},w=t?.map(R=>({printerId:R.printer_id,printerName:R.printer_name,items:R.maintenance_items.sort((A,j)=>A.maintenance_type_id-j.maintenance_type_id)})).sort((R,A)=>R.printerName.localeCompare(A.printerName))||[],C=e.filter(R=>R.is_system),T=e.filter(R=>!R.is_system);return f.jsxs("div",{className:"space-y-8",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between mb-4",children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),f.jsxs(qe,{size:"sm",variant:"secondary",onClick:()=>u(!c),children:[f.jsx(ra,{className:"w-4 h-4"}),"Add Custom Type"]})]}),c&&f.jsx(Ht,{className:"mb-4",children:f.jsx("div",{className:"p-4",children:f.jsx("form",{onSubmit:M,children:f.jsxs("div",{className:"flex gap-3 items-end",children:[f.jsxs("div",{className:"flex-1",children:[f.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Name"}),f.jsx("input",{type:"text",value:h,onChange:R=>g(R.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",placeholder:"e.g., Replace HEPA Filter",autoFocus:!0})]}),f.jsxs("div",{className:"w-28",children:[f.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Interval (hours)"}),f.jsx("input",{type:"number",value:m,onChange:R=>b(R.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"1"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Icon"}),f.jsx("div",{className:"flex gap-1",children:Object.keys(PP).map(R=>{const A=PP[R];return f.jsx("button",{type:"button",onClick:()=>v(R),className:`p-2 rounded ${y===R?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:f.jsx(A,{className:"w-4 h-4"})},R)})})]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(qe,{type:"submit",size:"sm",disabled:!h.trim(),children:"Add"}),f.jsx(qe,{type:"button",size:"sm",variant:"secondary",onClick:()=>u(!1),children:"Cancel"})]})]})})})}),f.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[C.map(R=>{const A=U_(R.icon);return f.jsx("div",{className:"bg-bambu-dark-secondary rounded-lg p-4 border border-bambu-dark-tertiary",children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"p-2 bg-bambu-dark rounded-lg",children:f.jsx(A,{className:"w-5 h-5 text-bambu-gray"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:"text-sm font-medium text-white truncate",children:R.name}),f.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5",children:[R.default_interval_hours,"h interval"]})]})]})},R.id)}),T.map(R=>{const A=U_(R.icon);return f.jsx("div",{className:"bg-bambu-dark-secondary rounded-lg p-4 border border-bambu-green/30",children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"p-2 bg-bambu-green/20 rounded-lg",children:f.jsx(A,{className:"w-5 h-5 text-bambu-green"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-sm font-medium text-white truncate",children:R.name}),f.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),f.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5",children:[R.default_interval_hours,"h interval"]})]}),f.jsx("button",{onClick:()=>{confirm(`Delete "${R.name}"?`)&&i(R.id)},className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:f.jsx(fr,{className:"w-4 h-4"})})]})},R.id)})]})]}),w.length>0&&f.jsxs("div",{children:[f.jsx("h2",{className:"text-lg font-semibold text-white mb-2",children:"Interval Overrides"}),f.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Set custom intervals per printer."}),f.jsx("div",{className:"space-y-3",children:w.map(R=>f.jsx(Ht,{children:f.jsxs("div",{className:"p-4",children:[f.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:R.printerName}),f.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:R.items.map(A=>{const j=U_(A.maintenance_type_icon),k=e.find(I=>I.id===A.maintenance_type_id)?.default_interval_hours||A.interval_hours,F=a===A.id;return f.jsxs("div",{className:"flex items-center gap-2 p-2 bg-bambu-dark rounded-lg",children:[f.jsx(j,{className:"w-4 h-4 text-bambu-gray shrink-0"}),f.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:A.maintenance_type_name}),F?f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("input",{type:"number",value:o,onChange:I=>l(I.target.value),onKeyDown:I=>{I.key==="Enter"&&x(A.id,k),I.key==="Escape"&&s(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1",autoFocus:!0}),f.jsx(qe,{size:"sm",onClick:()=>x(A.id,k),children:"OK"})]}):f.jsxs("button",{onClick:()=>{s(A.id),l(A.interval_hours.toString())},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",children:[A.interval_hours,"h",f.jsx(YP,{className:"w-3 h-3 inline ml-1.5 text-bambu-gray"})]})]},A.id)})})]})},R.printerId))})]}),w.length===0&&f.jsx(Ht,{children:f.jsxs(Gt,{className:"text-center py-12",children:[f.jsx(Ni,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),f.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),f.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function IVe(){const t=In(),{showToast:e}=sa(),[n,r]=E.useState("status"),{data:i,isLoading:a}=Nt({queryKey:["maintenanceOverview"],queryFn:ze.getMaintenanceOverview}),{data:s}=Nt({queryKey:["maintenanceTypes"],queryFn:ze.getMaintenanceTypes}),o=Rt({mutationFn:({id:x,notes:M})=>ze.performMaintenance(x,M),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as done")},onError:x=>{e(x.message,"error")}}),l=Rt({mutationFn:({id:x,data:M})=>ze.updateMaintenanceItem(x,M),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:x=>{e(x.message,"error")}}),c=Rt({mutationFn:ze.createMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onError:x=>{e(x.message,"error")}}),u=Rt({mutationFn:ze.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:x=>{e(x.message,"error")}}),h=Rt({mutationFn:({printerId:x,hours:M})=>ze.setPrinterHours(x,M),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:x=>{e(x.message,"error")}}),g=x=>{o.mutate({id:x})},m=(x,M)=>{l.mutate({id:x,data:{enabled:M}})},b=(x,M)=>{h.mutate({printerId:x,hours:M})};if(a)return f.jsx("div",{className:"p-8 flex justify-center",children:f.jsx($t,{className:"w-8 h-8 text-bambu-green animate-spin"})});const y=i?.reduce((x,M)=>x+M.due_count,0)||0,v=i?.reduce((x,M)=>x+M.warning_count,0)||0;return f.jsxs("div",{className:"p-8",children:[f.jsxs("div",{className:"mb-6",children:[f.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),f.jsx("p",{className:"text-bambu-gray text-sm",children:n==="status"?f.jsxs(f.Fragment,{children:[y>0&&f.jsxs("span",{className:"text-red-400",children:[y," tasks overdue"]}),y>0&&v>0&&" · ",v>0&&f.jsxs("span",{className:"text-yellow-400",children:[v," due soon"]}),y===0&&v===0&&"All maintenance up to date"]}):"Configure maintenance types and intervals"})]}),f.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[f.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"}),f.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"?f.jsx("div",{className:"space-y-4",children:i&&i.length>0?[...i].sort((x,M)=>x.printer_name.localeCompare(M.printer_name)).map(x=>f.jsx(OVe,{overview:x,onPerform:g,onToggle:m,onSetHours:b},x.printer_id)):f.jsx(Ht,{children:f.jsxs(Gt,{className:"text-center py-12",children:[f.jsx(qp,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),f.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),f.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to start tracking maintenance"})]})})}):f.jsx(LVe,{overview:i,types:s||[],onUpdateInterval:(x,M)=>l.mutate({id:x,data:{custom_interval_hours:M}}),onAddType:x=>c.mutate(x),onDeleteType:x=>u.mutate(x)})]})}function jVe(){const{printerId:t}=oie(),e=parseInt(t||"0",10),[n,r]=E.useState("stream"),[i,a]=E.useState(!1),[s,o]=E.useState(!0),[l,c]=E.useState(Date.now()),[u,h]=E.useState(!1),[g,m]=E.useState(!1),b=E.useRef(null),y=E.useRef(null),{data:v}=Nt({queryKey:["printer",e],queryFn:()=>ze.getPrinter(e),enabled:e>0});E.useEffect(()=>(v&&(document.title=`${v.name} - Camera`),()=>{document.title="Bambusy"}),[v]),E.useEffect(()=>()=>{b.current&&(b.current.src="")},[]),E.useEffect(()=>{if(s&&!u){const N=setTimeout(()=>{o(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(N)}},[n,s,l,u]),E.useEffect(()=>{const j=()=>{m(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",j),()=>document.removeEventListener("fullscreenchange",j)},[]);const x=()=>{a(!0),o(!1)},M=()=>{o(!1),a(!1)},w=j=>{n===j||u||(h(!0),o(!0),a(!1),b.current&&(b.current.src=""),setTimeout(()=>{r(j),c(Date.now()),h(!1)},100))},C=()=>{u||(h(!0),o(!0),a(!1),b.current&&(b.current.src=""),setTimeout(()=>{c(Date.now()),h(!1)},100))},T=()=>{y.current&&(document.fullscreenElement?document.exitFullscreen():y.current.requestFullscreen())},R=u?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${l}`:`/api/v1/printers/${e}/camera/snapshot?t=${l}`,A=s||u;return e?f.jsxs("div",{ref:y,className:"min-h-screen bg-black flex flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[f.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[f.jsx(G_,{className:"w-4 h-4"}),v?.name||`Printer ${e}`]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[f.jsx("button",{onClick:()=>w("stream"),disabled:A,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"}),f.jsx("button",{onClick:()=>w("snapshot"),disabled:A,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"})]}),f.jsx("button",{onClick:C,disabled:A,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:f.jsx(Mo,{className:`w-4 h-4 text-bambu-gray ${A?"animate-spin":""}`})}),f.jsx("button",{onClick:T,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:g?"Exit fullscreen":"Fullscreen",children:g?f.jsx(Doe,{className:"w-4 h-4 text-bambu-gray"}):f.jsx(Noe,{className:"w-4 h-4 text-bambu-gray"})})]})]}),f.jsx("div",{className:"flex-1 flex items-center justify-center p-2",children:f.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(s||u)&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:f.jsxs("div",{className:"text-center",children:[f.jsx(Mo,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:n==="stream"?"Connecting to camera...":"Capturing snapshot..."})]})}),i&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:f.jsxs("div",{className:"text-center p-4",children:[f.jsx(Eo,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),f.jsx("p",{className:"text-white mb-2",children:"Camera unavailable"}),f.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:"Make sure the printer is powered on and connected."}),f.jsx("button",{onClick:C,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),f.jsx("img",{ref:b,src:R,alt:"Camera stream",className:"max-w-full max-h-full object-contain",onError:R?x:void 0,onLoad:R?M:void 0},l)]})})]}):f.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:f.jsx("p",{className:"text-white",children:"Invalid printer ID"})})}function UVe(){const t=E.useRef(null),e=E.useRef(null),n=In(),[r,i]=E.useState(!1),a=E.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const c=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,u=new WebSocket(c);let h=null;u.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),h=window.setInterval(()=>{u.readyState===WebSocket.OPEN&&u.send(JSON.stringify({type:"ping"}))},3e4)},u.onmessage=g=>{try{const m=JSON.parse(g.data);s(m)}catch{}},u.onclose=g=>{console.log("[WebSocket] Closed",g.code,g.reason),h&&(clearInterval(h),h=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{a()},3e3)},u.onerror=g=>{console.error("[WebSocket] Error",g),u.close()},t.current=u},[]),s=E.useCallback(l=>{switch(l.type){case"printer_status":l.printer_id!==void 0&&n.setQueryData(["printerStatus",l.printer_id],c=>{const u={...c,...l.data};return u.wifi_signal==null&&c?.wifi_signal!=null&&(u.wifi_signal=c.wifi_signal),u});break;case"print_complete":n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]});break;case"archive_created":n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]});break}},[n]);E.useEffect(()=>(a(),()=>{e.current&&clearTimeout(e.current),t.current&&t.current.close()}),[a]);const o=E.useCallback(l=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(l))},[]);return{isConnected:r,sendMessage:o}}const FVe=new Mae({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function zVe({children:t}){return UVe(),f.jsx(f.Fragment,{children:t})}function BVe(){return f.jsx(Zle,{children:f.jsx(sce,{children:f.jsx(Eae,{client:FVe,children:f.jsx(zVe,{children:f.jsx(Wie,{children:f.jsxs(wie,{children:[f.jsx(Fo,{path:"/camera/:printerId",element:f.jsx(jVe,{})}),f.jsxs(Fo,{path:"/",element:f.jsx(rce,{}),children:[f.jsx(Fo,{index:!0,element:f.jsx(Ice,{})}),f.jsx(Fo,{path:"archives",element:f.jsx(lCe,{})}),f.jsx(Fo,{path:"queue",element:f.jsx(qNe,{})}),f.jsx(Fo,{path:"stats",element:f.jsx(dVe,{})}),f.jsx(Fo,{path:"profiles",element:f.jsx(PVe,{})}),f.jsx(Fo,{path:"maintenance",element:f.jsx(IVe,{})}),f.jsx(Fo,{path:"settings",element:f.jsx(yVe,{})})]})]})})})})})})}Ane.createRoot(document.getElementById("root")).render(f.jsx(E.StrictMode,{children:f.jsx(BVe,{})}));