| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665 |
- function Pae(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var n_=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Uo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var _T={exports:{}},Qx={};var SU;function Rae(){if(SU)return Qx;SU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,s){var o=null;if(s!==void 0&&(o=""+s),i.key!==void 0&&(o=""+i.key),"key"in i){s={};for(var l in i)l!=="key"&&(s[l]=i[l])}else s=i;return i=s.ref,{$$typeof:t,type:r,key:o,ref:i!==void 0?i:null,props:s}}return Qx.Fragment=e,Qx.jsx=n,Qx.jsxs=n,Qx}var NU;function Dae(){return NU||(NU=1,_T.exports=Rae()),_T.exports}var a=Dae(),wT={exports:{}},gn={};var MU;function Oae(){if(MU)return gn;MU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),m=Symbol.iterator;function g(z){return z===null||typeof z!="object"?null:(z=m&&z[m]||z["@@iterator"],typeof z=="function"?z:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,b={};function v(z,W,se){this.props=z,this.context=W,this.refs=b,this.updater=se||x}v.prototype.isReactComponent={},v.prototype.setState=function(z,W){if(typeof z!="object"&&typeof z!="function"&&z!=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,z,W,"setState")},v.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function N(){}N.prototype=v.prototype;function S(z,W,se){this.props=z,this.context=W,this.refs=b,this.updater=se||x}var T=S.prototype=new N;T.constructor=S,y(T,v.prototype),T.isPureReactComponent=!0;var E=Array.isArray;function k(){}var C={H:null,A:null,T:null,S:null},D=Object.prototype.hasOwnProperty;function A(z,W,se){var ae=se.ref;return{$$typeof:t,type:z,key:W,ref:ae!==void 0?ae:null,props:se}}function R(z,W){return A(z.type,W,z.props)}function F(z){return typeof z=="object"&&z!==null&&z.$$typeof===t}function O(z){var W={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(se){return W[se]})}var q=/\/+/g;function j(z,W){return typeof z=="object"&&z!==null&&z.key!=null?O(""+z.key):W.toString(36)}function G(z){switch(z.status){case"fulfilled":return z.value;case"rejected":throw z.reason;default:switch(typeof z.status=="string"?z.then(k,k):(z.status="pending",z.then(function(W){z.status==="pending"&&(z.status="fulfilled",z.value=W)},function(W){z.status==="pending"&&(z.status="rejected",z.reason=W)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function Y(z,W,se,ae,de){var me=typeof z;(me==="undefined"||me==="boolean")&&(z=null);var xe=!1;if(z===null)xe=!0;else switch(me){case"bigint":case"string":case"number":xe=!0;break;case"object":switch(z.$$typeof){case t:case e:xe=!0;break;case d:return xe=z._init,Y(xe(z._payload),W,se,ae,de)}}if(xe)return de=de(z),xe=ae===""?"."+j(z,0):ae,E(de)?(se="",xe!=null&&(se=xe.replace(q,"$&/")+"/"),Y(de,W,se,"",function(Ce){return Ce})):de!=null&&(F(de)&&(de=R(de,se+(de.key==null||z&&z.key===de.key?"":(""+de.key).replace(q,"$&/")+"/")+xe)),W.push(de)),1;xe=0;var be=ae===""?".":ae+":";if(E(z))for(var fe=0;fe<z.length;fe++)ae=z[fe],me=be+j(ae,fe),xe+=Y(ae,W,se,me,de);else if(fe=g(z),typeof fe=="function")for(z=fe.call(z),fe=0;!(ae=z.next()).done;)ae=ae.value,me=be+j(ae,fe++),xe+=Y(ae,W,se,me,de);else if(me==="object"){if(typeof z.then=="function")return Y(G(z),W,se,ae,de);throw W=String(z),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.")}return xe}function K(z,W,se){if(z==null)return z;var ae=[],de=0;return Y(z,ae,"","",function(me){return W.call(se,me,de++)}),ae}function Z(z){if(z._status===-1){var W=z._result;W=W(),W.then(function(se){(z._status===0||z._status===-1)&&(z._status=1,z._result=se)},function(se){(z._status===0||z._status===-1)&&(z._status=2,z._result=se)}),z._status===-1&&(z._status=0,z._result=W)}if(z._status===1)return z._result.default;throw z._result}var te=typeof reportError=="function"?reportError:function(z){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var W=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof z=="object"&&z!==null&&typeof z.message=="string"?String(z.message):String(z),error:z});if(!window.dispatchEvent(W))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",z);return}console.error(z)},ne={map:K,forEach:function(z,W,se){K(z,function(){W.apply(this,arguments)},se)},count:function(z){var W=0;return K(z,function(){W++}),W},toArray:function(z){return K(z,function(W){return W})||[]},only:function(z){if(!F(z))throw Error("React.Children.only expected to receive a single React element child.");return z}};return gn.Activity=f,gn.Children=ne,gn.Component=v,gn.Fragment=n,gn.Profiler=i,gn.PureComponent=S,gn.StrictMode=r,gn.Suspense=c,gn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,gn.__COMPILER_RUNTIME={__proto__:null,c:function(z){return C.H.useMemoCache(z)}},gn.cache=function(z){return function(){return z.apply(null,arguments)}},gn.cacheSignal=function(){return null},gn.cloneElement=function(z,W,se){if(z==null)throw Error("The argument must be a React element, but you passed "+z+".");var ae=y({},z.props),de=z.key;if(W!=null)for(me in W.key!==void 0&&(de=""+W.key),W)!D.call(W,me)||me==="key"||me==="__self"||me==="__source"||me==="ref"&&W.ref===void 0||(ae[me]=W[me]);var me=arguments.length-2;if(me===1)ae.children=se;else if(1<me){for(var xe=Array(me),be=0;be<me;be++)xe[be]=arguments[be+2];ae.children=xe}return A(z.type,de,ae)},gn.createContext=function(z){return z={$$typeof:o,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null},z.Provider=z,z.Consumer={$$typeof:s,_context:z},z},gn.createElement=function(z,W,se){var ae,de={},me=null;if(W!=null)for(ae in W.key!==void 0&&(me=""+W.key),W)D.call(W,ae)&&ae!=="key"&&ae!=="__self"&&ae!=="__source"&&(de[ae]=W[ae]);var xe=arguments.length-2;if(xe===1)de.children=se;else if(1<xe){for(var be=Array(xe),fe=0;fe<xe;fe++)be[fe]=arguments[fe+2];de.children=be}if(z&&z.defaultProps)for(ae in xe=z.defaultProps,xe)de[ae]===void 0&&(de[ae]=xe[ae]);return A(z,me,de)},gn.createRef=function(){return{current:null}},gn.forwardRef=function(z){return{$$typeof:l,render:z}},gn.isValidElement=F,gn.lazy=function(z){return{$$typeof:d,_payload:{_status:-1,_result:z},_init:Z}},gn.memo=function(z,W){return{$$typeof:u,type:z,compare:W===void 0?null:W}},gn.startTransition=function(z){var W=C.T,se={};C.T=se;try{var ae=z(),de=C.S;de!==null&&de(se,ae),typeof ae=="object"&&ae!==null&&typeof ae.then=="function"&&ae.then(k,te)}catch(me){te(me)}finally{W!==null&&se.types!==null&&(W.types=se.types),C.T=W}},gn.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},gn.use=function(z){return C.H.use(z)},gn.useActionState=function(z,W,se){return C.H.useActionState(z,W,se)},gn.useCallback=function(z,W){return C.H.useCallback(z,W)},gn.useContext=function(z){return C.H.useContext(z)},gn.useDebugValue=function(){},gn.useDeferredValue=function(z,W){return C.H.useDeferredValue(z,W)},gn.useEffect=function(z,W){return C.H.useEffect(z,W)},gn.useEffectEvent=function(z){return C.H.useEffectEvent(z)},gn.useId=function(){return C.H.useId()},gn.useImperativeHandle=function(z,W,se){return C.H.useImperativeHandle(z,W,se)},gn.useInsertionEffect=function(z,W){return C.H.useInsertionEffect(z,W)},gn.useLayoutEffect=function(z,W){return C.H.useLayoutEffect(z,W)},gn.useMemo=function(z,W){return C.H.useMemo(z,W)},gn.useOptimistic=function(z,W){return C.H.useOptimistic(z,W)},gn.useReducer=function(z,W,se){return C.H.useReducer(z,W,se)},gn.useRef=function(z){return C.H.useRef(z)},gn.useState=function(z){return C.H.useState(z)},gn.useSyncExternalStore=function(z,W,se){return C.H.useSyncExternalStore(z,W,se)},gn.useTransition=function(){return C.H.useTransition()},gn.version="19.2.0",gn}var EU;function Ig(){return EU||(EU=1,wT.exports=Oae()),wT.exports}var w=Ig();const zr=Uo(w),Lae=Pae({__proto__:null,default:zr},[w]);var ST={exports:{}},Zx={},NT={exports:{}},MT={};var TU;function Iae(){return TU||(TU=1,(function(t){function e(Y,K){var Z=Y.length;Y.push(K);e:for(;0<Z;){var te=Z-1>>>1,ne=Y[te];if(0<i(ne,K))Y[te]=K,Y[Z]=ne,Z=te;else break e}}function n(Y){return Y.length===0?null:Y[0]}function r(Y){if(Y.length===0)return null;var K=Y[0],Z=Y.pop();if(Z!==K){Y[0]=Z;e:for(var te=0,ne=Y.length,z=ne>>>1;te<z;){var W=2*(te+1)-1,se=Y[W],ae=W+1,de=Y[ae];if(0>i(se,Z))ae<ne&&0>i(de,se)?(Y[te]=de,Y[ae]=Z,te=ae):(Y[te]=se,Y[W]=Z,te=W);else if(ae<ne&&0>i(de,Z))Y[te]=de,Y[ae]=Z,te=ae;else break e}}return K}function i(Y,K){var Z=Y.sortIndex-K.sortIndex;return Z!==0?Z:Y.id-K.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var c=[],u=[],d=1,f=null,m=3,g=!1,x=!1,y=!1,b=!1,v=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function T(Y){for(var K=n(u);K!==null;){if(K.callback===null)r(u);else if(K.startTime<=Y)r(u),K.sortIndex=K.expirationTime,e(c,K);else break;K=n(u)}}function E(Y){if(y=!1,T(Y),!x)if(n(c)!==null)x=!0,k||(k=!0,O());else{var K=n(u);K!==null&&G(E,K.startTime-Y)}}var k=!1,C=-1,D=5,A=-1;function R(){return b?!0:!(t.unstable_now()-A<D)}function F(){if(b=!1,k){var Y=t.unstable_now();A=Y;var K=!0;try{e:{x=!1,y&&(y=!1,N(C),C=-1),g=!0;var Z=m;try{t:{for(T(Y),f=n(c);f!==null&&!(f.expirationTime>Y&&R());){var te=f.callback;if(typeof te=="function"){f.callback=null,m=f.priorityLevel;var ne=te(f.expirationTime<=Y);if(Y=t.unstable_now(),typeof ne=="function"){f.callback=ne,T(Y),K=!0;break t}f===n(c)&&r(c),T(Y)}else r(c);f=n(c)}if(f!==null)K=!0;else{var z=n(u);z!==null&&G(E,z.startTime-Y),K=!1}}break e}finally{f=null,m=Z,g=!1}K=void 0}}finally{K?O():k=!1}}}var O;if(typeof S=="function")O=function(){S(F)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,j=q.port2;q.port1.onmessage=F,O=function(){j.postMessage(null)}}else O=function(){v(F,0)};function G(Y,K){C=v(function(){Y(t.unstable_now())},K)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(Y){Y.callback=null},t.unstable_forceFrameRate=function(Y){0>Y||125<Y?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):D=0<Y?Math.floor(1e3/Y):5},t.unstable_getCurrentPriorityLevel=function(){return m},t.unstable_next=function(Y){switch(m){case 1:case 2:case 3:var K=3;break;default:K=m}var Z=m;m=K;try{return Y()}finally{m=Z}},t.unstable_requestPaint=function(){b=!0},t.unstable_runWithPriority=function(Y,K){switch(Y){case 1:case 2:case 3:case 4:case 5:break;default:Y=3}var Z=m;m=Y;try{return K()}finally{m=Z}},t.unstable_scheduleCallback=function(Y,K,Z){var te=t.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?te+Z:te):Z=te,Y){case 1:var ne=-1;break;case 2:ne=250;break;case 5:ne=1073741823;break;case 4:ne=1e4;break;default:ne=5e3}return ne=Z+ne,Y={id:d++,callback:K,priorityLevel:Y,startTime:Z,expirationTime:ne,sortIndex:-1},Z>te?(Y.sortIndex=Z,e(u,Y),n(c)===null&&Y===n(u)&&(y?(N(C),C=-1):y=!0,G(E,Z-te))):(Y.sortIndex=ne,e(c,Y),x||g||(x=!0,k||(k=!0,O()))),Y},t.unstable_shouldYield=R,t.unstable_wrapCallback=function(Y){var K=m;return function(){var Z=m;m=K;try{return Y.apply(this,arguments)}finally{m=Z}}}})(MT)),MT}var CU;function Fae(){return CU||(CU=1,NT.exports=Iae()),NT.exports}var ET={exports:{}},Ta={};var AU;function Uae(){if(AU)return Ta;AU=1;var t=Ig();function e(c){var u="https://react.dev/errors/"+c;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)u+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function s(c,u,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:f==null?null:""+f,children:c,containerInfo:u,implementation:d}}var o=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(c,u){if(c==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return Ta.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Ta.createPortal=function(c,u){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(e(299));return s(c,u,null,d)},Ta.flushSync=function(c){var u=o.T,d=r.p;try{if(o.T=null,r.p=2,c)return c()}finally{o.T=u,r.p=d,r.d.f()}},Ta.preconnect=function(c,u){typeof c=="string"&&(u?(u=u.crossOrigin,u=typeof u=="string"?u==="use-credentials"?u:"":void 0):u=null,r.d.C(c,u))},Ta.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},Ta.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin),m=typeof u.integrity=="string"?u.integrity:void 0,g=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:m,fetchPriority:g}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:m,fetchPriority:g,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},Ta.preinitModule=function(c,u){if(typeof c=="string")if(typeof u=="object"&&u!==null){if(u.as==null||u.as==="script"){var d=l(u.as,u.crossOrigin);r.d.M(c,{crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0})}}else u==null&&r.d.M(c)},Ta.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin);r.d.L(c,d,{crossOrigin:f,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0,type:typeof u.type=="string"?u.type:void 0,fetchPriority:typeof u.fetchPriority=="string"?u.fetchPriority:void 0,referrerPolicy:typeof u.referrerPolicy=="string"?u.referrerPolicy:void 0,imageSrcSet:typeof u.imageSrcSet=="string"?u.imageSrcSet:void 0,imageSizes:typeof u.imageSizes=="string"?u.imageSizes:void 0,media:typeof u.media=="string"?u.media:void 0})}},Ta.preloadModule=function(c,u){if(typeof c=="string")if(u){var d=l(u.as,u.crossOrigin);r.d.m(c,{as:typeof u.as=="string"&&u.as!=="script"?u.as:void 0,crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0})}else r.d.m(c)},Ta.requestFormReset=function(c){r.d.r(c)},Ta.unstable_batchedUpdates=function(c,u){return c(u)},Ta.useFormState=function(c,u,d){return o.H.useFormState(c,u,d)},Ta.useFormStatus=function(){return o.H.useHostTransitionStatus()},Ta.version="19.2.0",Ta}var kU;function oq(){if(kU)return ET.exports;kU=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(),ET.exports=Uae(),ET.exports}var jU;function zae(){if(jU)return Zx;jU=1;var t=Fae(),e=Ig(),n=oq();function r(h){var p="https://react.dev/errors/"+h;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)p+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+h+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(h){return!(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)}function s(h){var p=h,_=h;if(h.alternate)for(;p.return;)p=p.return;else{h=p;do p=h,(p.flags&4098)!==0&&(_=p.return),h=p.return;while(h)}return p.tag===3?_:null}function o(h){if(h.tag===13){var p=h.memoizedState;if(p===null&&(h=h.alternate,h!==null&&(p=h.memoizedState)),p!==null)return p.dehydrated}return null}function l(h){if(h.tag===31){var p=h.memoizedState;if(p===null&&(h=h.alternate,h!==null&&(p=h.memoizedState)),p!==null)return p.dehydrated}return null}function c(h){if(s(h)!==h)throw Error(r(188))}function u(h){var p=h.alternate;if(!p){if(p=s(h),p===null)throw Error(r(188));return p!==h?null:h}for(var _=h,M=p;;){var P=_.return;if(P===null)break;var L=P.alternate;if(L===null){if(M=P.return,M!==null){_=M;continue}break}if(P.child===L.child){for(L=P.child;L;){if(L===_)return c(P),h;if(L===M)return c(P),p;L=L.sibling}throw Error(r(188))}if(_.return!==M.return)_=P,M=L;else{for(var J=!1,pe=P.child;pe;){if(pe===_){J=!0,_=P,M=L;break}if(pe===M){J=!0,M=P,_=L;break}pe=pe.sibling}if(!J){for(pe=L.child;pe;){if(pe===_){J=!0,_=L,M=P;break}if(pe===M){J=!0,M=L,_=P;break}pe=pe.sibling}if(!J)throw Error(r(189))}}if(_.alternate!==M)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?h:p}function d(h){var p=h.tag;if(p===5||p===26||p===27||p===6)return h;for(h=h.child;h!==null;){if(p=d(h),p!==null)return p;h=h.sibling}return null}var f=Object.assign,m=Symbol.for("react.element"),g=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),S=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),A=Symbol.for("react.activity"),R=Symbol.for("react.memo_cache_sentinel"),F=Symbol.iterator;function O(h){return h===null||typeof h!="object"?null:(h=F&&h[F]||h["@@iterator"],typeof h=="function"?h:null)}var q=Symbol.for("react.client.reference");function j(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===q?null:h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case y:return"Fragment";case v:return"Profiler";case b:return"StrictMode";case E:return"Suspense";case k:return"SuspenseList";case A:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case x:return"Portal";case S:return h.displayName||"Context";case N:return(h._context.displayName||"Context")+".Consumer";case T:var p=h.render;return h=h.displayName,h||(h=p.displayName||p.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case C:return p=h.displayName||null,p!==null?p:j(h.type)||"Memo";case D:p=h._payload,h=h._init;try{return j(h(p))}catch{}}return null}var G=Array.isArray,Y=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z={pending:!1,data:null,method:null,action:null},te=[],ne=-1;function z(h){return{current:h}}function W(h){0>ne||(h.current=te[ne],te[ne]=null,ne--)}function se(h,p){ne++,te[ne]=h.current,h.current=p}var ae=z(null),de=z(null),me=z(null),xe=z(null);function be(h,p){switch(se(me,p),se(de,h),se(ae,null),p.nodeType){case 9:case 11:h=(h=p.documentElement)&&(h=h.namespaceURI)?qF(h):0;break;default:if(h=p.tagName,p=p.namespaceURI)p=qF(p),h=WF(p,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}W(ae),se(ae,h)}function fe(){W(ae),W(de),W(me)}function Ce(h){h.memoizedState!==null&&se(xe,h);var p=ae.current,_=WF(p,h.type);p!==_&&(se(de,h),se(ae,_))}function Ne(h){de.current===h&&(W(ae),W(de)),xe.current===h&&(W(xe),Wx._currentValue=Z)}var re,He;function H(h){if(re===void 0)try{throw Error()}catch(_){var p=_.stack.trim().match(/\n( *(at )?)/);re=p&&p[1]||"",He=-1<_.stack.indexOf(`
- at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+re+h+He}var B=!1;function X(h,p){if(!h||B)return"";B=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var M={DetermineComponentFrameRoot:function(){try{if(p){var vt=function(){throw Error()};if(Object.defineProperty(vt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(vt,[])}catch(ft){var at=ft}Reflect.construct(h,[],vt)}else{try{vt.call()}catch(ft){at=ft}h.call(vt.prototype)}}else{try{throw Error()}catch(ft){at=ft}(vt=h())&&typeof vt.catch=="function"&&vt.catch(function(){})}}catch(ft){if(ft&&at&&typeof ft.stack=="string")return[ft.stack,at.stack]}return[null,null]}};M.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var P=Object.getOwnPropertyDescriptor(M.DetermineComponentFrameRoot,"name");P&&P.configurable&&Object.defineProperty(M.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var L=M.DetermineComponentFrameRoot(),J=L[0],pe=L[1];if(J&&pe){var ze=J.split(`
- `),rt=pe.split(`
- `);for(P=M=0;M<ze.length&&!ze[M].includes("DetermineComponentFrameRoot");)M++;for(;P<rt.length&&!rt[P].includes("DetermineComponentFrameRoot");)P++;if(M===ze.length||P===rt.length)for(M=ze.length-1,P=rt.length-1;1<=M&&0<=P&&ze[M]!==rt[P];)P--;for(;1<=M&&0<=P;M--,P--)if(ze[M]!==rt[P]){if(M!==1||P!==1)do if(M--,P--,0>P||ze[M]!==rt[P]){var xt=`
- `+ze[M].replace(" at new "," at ");return h.displayName&&xt.includes("<anonymous>")&&(xt=xt.replace("<anonymous>",h.displayName)),xt}while(1<=M&&0<=P);break}}}finally{B=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?H(_):""}function U(h,p){switch(h.tag){case 26:case 27:case 5:return H(h.type);case 16:return H("Lazy");case 13:return h.child!==p&&p!==null?H("Suspense Fallback"):H("Suspense");case 19:return H("SuspenseList");case 0:case 15:return X(h.type,!1);case 11:return X(h.type.render,!1);case 1:return X(h.type,!0);case 31:return H("Activity");default:return""}}function Q(h){try{var p="",_=null;do p+=U(h,_),_=h,h=h.return;while(h);return p}catch(M){return`
- Error generating stack: `+M.message+`
- `+M.stack}}var le=Object.prototype.hasOwnProperty,Pe=t.unstable_scheduleCallback,Oe=t.unstable_cancelCallback,je=t.unstable_shouldYield,$=t.unstable_requestPaint,I=t.unstable_now,V=t.unstable_getCurrentPriorityLevel,ie=t.unstable_ImmediatePriority,Se=t.unstable_UserBlockingPriority,ye=t.unstable_NormalPriority,$e=t.unstable_LowPriority,Ue=t.unstable_IdlePriority,Ge=t.log,We=t.unstable_setDisableYieldValue,Ye=null,oe=null;function ve(h){if(typeof Ge=="function"&&We(h),oe&&typeof oe.setStrictMode=="function")try{oe.setStrictMode(Ye,h)}catch{}}var Le=Math.clz32?Math.clz32:_e,Ke=Math.log,lt=Math.LN2;function _e(h){return h>>>=0,h===0?32:31-(Ke(h)/lt|0)|0}var ce=256,ee=262144,ke=4194304;function De(h){var p=h&42;if(p!==0)return p;switch(h&-h){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return h&261888;case 262144:case 524288:case 1048576:case 2097152:return h&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return h&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return h}}function Ae(h,p,_){var M=h.pendingLanes;if(M===0)return 0;var P=0,L=h.suspendedLanes,J=h.pingedLanes;h=h.warmLanes;var pe=M&134217727;return pe!==0?(M=pe&~L,M!==0?P=De(M):(J&=pe,J!==0?P=De(J):_||(_=pe&~h,_!==0&&(P=De(_))))):(pe=M&~L,pe!==0?P=De(pe):J!==0?P=De(J):_||(_=M&~h,_!==0&&(P=De(_)))),P===0?0:p!==0&&p!==P&&(p&L)===0&&(L=P&-P,_=p&-p,L>=_||L===32&&(_&4194048)!==0)?p:P}function Je(h,p){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&p)===0}function gt(h,p){switch(h){case 1:case 2:case 4:case 8:case 64:return p+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return p+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function At(){var h=ke;return ke<<=1,(ke&62914560)===0&&(ke=4194304),h}function jt(h){for(var p=[],_=0;31>_;_++)p.push(h);return p}function ln(h,p){h.pendingLanes|=p,p!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function Lt(h,p,_,M,P,L){var J=h.pendingLanes;h.pendingLanes=_,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=_,h.entangledLanes&=_,h.errorRecoveryDisabledLanes&=_,h.shellSuspendCounter=0;var pe=h.entanglements,ze=h.expirationTimes,rt=h.hiddenUpdates;for(_=J&~_;0<_;){var xt=31-Le(_),vt=1<<xt;pe[xt]=0,ze[xt]=-1;var at=rt[xt];if(at!==null)for(rt[xt]=null,xt=0;xt<at.length;xt++){var ft=at[xt];ft!==null&&(ft.lane&=-536870913)}_&=~vt}M!==0&&Cn(h,M,0),L!==0&&P===0&&h.tag!==0&&(h.suspendedLanes|=L&~(J&~p))}function Cn(h,p,_){h.pendingLanes|=p,h.suspendedLanes&=~p;var M=31-Le(p);h.entangledLanes|=p,h.entanglements[M]=h.entanglements[M]|1073741824|_&261930}function en(h,p){var _=h.entangledLanes|=p;for(h=h.entanglements;_;){var M=31-Le(_),P=1<<M;P&p|h[M]&p&&(h[M]|=p),_&=~P}}function er(h,p){var _=p&-p;return _=(_&42)!==0?1:ur(_),(_&(h.suspendedLanes|p))!==0?0:_}function ur(h){switch(h){case 2:h=1;break;case 8:h=4;break;case 32:h=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:h=128;break;case 268435456:h=134217728;break;default:h=0}return h}function Un(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function wr(){var h=K.p;return h!==0?h:(h=window.event,h===void 0?32:gU(h.type))}function jr(h,p){var _=K.p;try{return K.p=h,p()}finally{K.p=_}}var Zn=Math.random().toString(36).slice(2),Xt="__reactFiber$"+Zn,zn="__reactProps$"+Zn,Wn="__reactContainer$"+Zn,Zr="__reactEvents$"+Zn,Ee="__reactListeners$"+Zn,Xe="__reactHandles$"+Zn,it="__reactResources$"+Zn,st="__reactMarker$"+Zn;function et(h){delete h[Xt],delete h[zn],delete h[Zr],delete h[Ee],delete h[Xe]}function Ct(h){var p=h[Xt];if(p)return p;for(var _=h.parentNode;_;){if(p=_[Wn]||_[Xt]){if(_=p.alternate,p.child!==null||_!==null&&_.child!==null)for(h=eU(h);h!==null;){if(_=h[Xt])return _;h=eU(h)}return p}h=_,_=h.parentNode}return null}function ue(h){if(h=h[Xt]||h[Wn]){var p=h.tag;if(p===5||p===6||p===13||p===31||p===26||p===27||p===3)return h}return null}function ge(h){var p=h.tag;if(p===5||p===26||p===27||p===6)return h.stateNode;throw Error(r(33))}function Fe(h){var p=h[it];return p||(p=h[it]={hoistableStyles:new Map,hoistableScripts:new Map}),p}function Ie(h){h[st]=!0}var Me=new Set,mt={};function wt(h,p){kt(h,p),kt(h+"Capture",p)}function kt(h,p){for(mt[h]=p,h=0;h<p.length;h++)Me.add(p[h])}var pt=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]*$"),zt={},Pt={};function Mt(h){return le.call(Pt,h)?!0:le.call(zt,h)?!1:pt.test(h)?Pt[h]=!0:(zt[h]=!0,!1)}function nn(h,p,_){if(Mt(p))if(_===null)h.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":h.removeAttribute(p);return;case"boolean":var M=p.toLowerCase().slice(0,5);if(M!=="data-"&&M!=="aria-"){h.removeAttribute(p);return}}h.setAttribute(p,""+_)}}function Bt(h,p,_){if(_===null)h.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(p);return}h.setAttribute(p,""+_)}}function tn(h,p,_,M){if(M===null)h.removeAttribute(_);else{switch(typeof M){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(_);return}h.setAttributeNS(p,_,""+M)}}function cn(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function we(h){var p=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(p==="checkbox"||p==="radio")}function bt(h,p,_){var M=Object.getOwnPropertyDescriptor(h.constructor.prototype,p);if(!h.hasOwnProperty(p)&&typeof M<"u"&&typeof M.get=="function"&&typeof M.set=="function"){var P=M.get,L=M.set;return Object.defineProperty(h,p,{configurable:!0,get:function(){return P.call(this)},set:function(J){_=""+J,L.call(this,J)}}),Object.defineProperty(h,p,{enumerable:M.enumerable}),{getValue:function(){return _},setValue:function(J){_=""+J},stopTracking:function(){h._valueTracker=null,delete h[p]}}}}function $t(h){if(!h._valueTracker){var p=we(h)?"checked":"value";h._valueTracker=bt(h,p,""+h[p])}}function Be(h){if(!h)return!1;var p=h._valueTracker;if(!p)return!0;var _=p.getValue(),M="";return h&&(M=we(h)?h.checked?"true":"false":h.value),h=M,h!==_?(p.setValue(h),!0):!1}function Et(h){if(h=h||(typeof document<"u"?document:void 0),typeof h>"u")return null;try{return h.activeElement||h.body}catch{return h.body}}var Wt=/[\n"\\]/g;function dt(h){return h.replace(Wt,function(p){return"\\"+p.charCodeAt(0).toString(16)+" "})}function Kt(h,p,_,M,P,L,J,pe){h.name="",J!=null&&typeof J!="function"&&typeof J!="symbol"&&typeof J!="boolean"?h.type=J:h.removeAttribute("type"),p!=null?J==="number"?(p===0&&h.value===""||h.value!=p)&&(h.value=""+cn(p)):h.value!==""+cn(p)&&(h.value=""+cn(p)):J!=="submit"&&J!=="reset"||h.removeAttribute("value"),p!=null?En(h,J,cn(p)):_!=null?En(h,J,cn(_)):M!=null&&h.removeAttribute("value"),P==null&&L!=null&&(h.defaultChecked=!!L),P!=null&&(h.checked=P&&typeof P!="function"&&typeof P!="symbol"),pe!=null&&typeof pe!="function"&&typeof pe!="symbol"&&typeof pe!="boolean"?h.name=""+cn(pe):h.removeAttribute("name")}function sn(h,p,_,M,P,L,J,pe){if(L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"&&(h.type=L),p!=null||_!=null){if(!(L!=="submit"&&L!=="reset"||p!=null)){$t(h);return}_=_!=null?""+cn(_):"",p=p!=null?""+cn(p):_,pe||p===h.value||(h.value=p),h.defaultValue=p}M=M??P,M=typeof M!="function"&&typeof M!="symbol"&&!!M,h.checked=pe?h.checked:!!M,h.defaultChecked=!!M,J!=null&&typeof J!="function"&&typeof J!="symbol"&&typeof J!="boolean"&&(h.name=J),$t(h)}function En(h,p,_){p==="number"&&Et(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function On(h,p,_,M){if(h=h.options,p){p={};for(var P=0;P<_.length;P++)p["$"+_[P]]=!0;for(_=0;_<h.length;_++)P=p.hasOwnProperty("$"+h[_].value),h[_].selected!==P&&(h[_].selected=P),P&&M&&(h[_].defaultSelected=!0)}else{for(_=""+cn(_),p=null,P=0;P<h.length;P++){if(h[P].value===_){h[P].selected=!0,M&&(h[P].defaultSelected=!0);return}p!==null||h[P].disabled||(p=h[P])}p!==null&&(p.selected=!0)}}function Tr(h,p,_){if(p!=null&&(p=""+cn(p),p!==h.value&&(h.value=p),_==null)){h.defaultValue!==p&&(h.defaultValue=p);return}h.defaultValue=_!=null?""+cn(_):""}function Gt(h,p,_,M){if(p==null){if(M!=null){if(_!=null)throw Error(r(92));if(G(M)){if(1<M.length)throw Error(r(93));M=M[0]}_=M}_==null&&(_=""),p=_}_=cn(p),h.defaultValue=_,M=h.textContent,M===_&&M!==""&&M!==null&&(h.value=M),$t(h)}function hn(h,p){if(p){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=p;return}}h.textContent=p}var ki=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 tc(h,p,_){var M=p.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?M?h.setProperty(p,""):p==="float"?h.cssFloat="":h[p]="":M?h.setProperty(p,_):typeof _!="number"||_===0||ki.has(p)?p==="float"?h.cssFloat=_:h[p]=(""+_).trim():h[p]=_+"px"}function xh(h,p,_){if(p!=null&&typeof p!="object")throw Error(r(62));if(h=h.style,_!=null){for(var M in _)!_.hasOwnProperty(M)||p!=null&&p.hasOwnProperty(M)||(M.indexOf("--")===0?h.setProperty(M,""):M==="float"?h.cssFloat="":h[M]="");for(var P in p)M=p[P],p.hasOwnProperty(P)&&_[P]!==M&&tc(h,P,M)}else for(var L in p)p.hasOwnProperty(L)&&tc(h,L,p[L])}function bh(h){if(h.indexOf("-")===-1)return!1;switch(h){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var cx=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"]]),nc=/^[\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 qi(h){return nc.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function ca(){}var rc=null;function ua(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var um=null,dm=null;function GL(h){var p=ue(h);if(p&&(h=p.stateNode)){var _=h[zn]||null;e:switch(h=p.stateNode,p.type){case"input":if(Kt(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),p=_.name,_.type==="radio"&&p!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+dt(""+p)+'"][type="radio"]'),p=0;p<_.length;p++){var M=_[p];if(M!==h&&M.form===h.form){var P=M[zn]||null;if(!P)throw Error(r(90));Kt(M,P.value,P.defaultValue,P.defaultValue,P.checked,P.defaultChecked,P.type,P.name)}}for(p=0;p<_.length;p++)M=_[p],M.form===h.form&&Be(M)}break e;case"textarea":Tr(h,_.value,_.defaultValue);break e;case"select":p=_.value,p!=null&&On(h,!!_.multiple,p,!1)}}}var vM=!1;function qL(h,p,_){if(vM)return h(p,_);vM=!0;try{var M=h(p);return M}finally{if(vM=!1,(um!==null||dm!==null)&&(Dv(),um&&(p=um,h=dm,dm=um=null,GL(p),h)))for(p=0;p<h.length;p++)GL(h[p])}}function ux(h,p){var _=h.stateNode;if(_===null)return null;var M=_[zn]||null;if(M===null)return null;_=M[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":(M=!M.disabled)||(h=h.type,M=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!M;break e;default:h=!1}if(h)return null;if(_&&typeof _!="function")throw Error(r(231,p,typeof _));return _}var ic=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_M=!1;if(ic)try{var dx={};Object.defineProperty(dx,"passive",{get:function(){_M=!0}}),window.addEventListener("test",dx,dx),window.removeEventListener("test",dx,dx)}catch{_M=!1}var Mu=null,wM=null,Ky=null;function WL(){if(Ky)return Ky;var h,p=wM,_=p.length,M,P="value"in Mu?Mu.value:Mu.textContent,L=P.length;for(h=0;h<_&&p[h]===P[h];h++);var J=_-h;for(M=1;M<=J&&p[_-M]===P[L-M];M++);return Ky=P.slice(h,1<M?1-M:void 0)}function Xy(h){var p=h.keyCode;return"charCode"in h?(h=h.charCode,h===0&&p===13&&(h=13)):h=p,h===10&&(h=13),32<=h||h===13?h:0}function Yy(){return!0}function KL(){return!1}function as(h){function p(_,M,P,L,J){this._reactName=_,this._targetInst=P,this.type=M,this.nativeEvent=L,this.target=J,this.currentTarget=null;for(var pe in h)h.hasOwnProperty(pe)&&(_=h[pe],this[pe]=_?_(L):L[pe]);return this.isDefaultPrevented=(L.defaultPrevented!=null?L.defaultPrevented:L.returnValue===!1)?Yy:KL,this.isPropagationStopped=KL,this}return f(p.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=Yy)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=Yy)},persist:function(){},isPersistent:Yy}),p}var yh={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Qy=as(yh),hx=f({},yh,{view:0,detail:0}),kre=as(hx),SM,NM,fx,Zy=f({},hx,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:EM,button:0,buttons:0,relatedTarget:function(h){return h.relatedTarget===void 0?h.fromElement===h.srcElement?h.toElement:h.fromElement:h.relatedTarget},movementX:function(h){return"movementX"in h?h.movementX:(h!==fx&&(fx&&h.type==="mousemove"?(SM=h.screenX-fx.screenX,NM=h.screenY-fx.screenY):NM=SM=0,fx=h),SM)},movementY:function(h){return"movementY"in h?h.movementY:NM}}),XL=as(Zy),jre=f({},Zy,{dataTransfer:0}),Pre=as(jre),Rre=f({},hx,{relatedTarget:0}),MM=as(Rre),Dre=f({},yh,{animationName:0,elapsedTime:0,pseudoElement:0}),Ore=as(Dre),Lre=f({},yh,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),Ire=as(Lre),Fre=f({},yh,{data:0}),YL=as(Fre),Ure={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},zre={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"},Bre={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function $re(h){var p=this.nativeEvent;return p.getModifierState?p.getModifierState(h):(h=Bre[h])?!!p[h]:!1}function EM(){return $re}var Hre=f({},hx,{key:function(h){if(h.key){var p=Ure[h.key]||h.key;if(p!=="Unidentified")return p}return h.type==="keypress"?(h=Xy(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?zre[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:EM,charCode:function(h){return h.type==="keypress"?Xy(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?Xy(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),Vre=as(Hre),Gre=f({},Zy,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),QL=as(Gre),qre=f({},hx,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:EM}),Wre=as(qre),Kre=f({},yh,{propertyName:0,elapsedTime:0,pseudoElement:0}),Xre=as(Kre),Yre=f({},Zy,{deltaX:function(h){return"deltaX"in h?h.deltaX:"wheelDeltaX"in h?-h.wheelDeltaX:0},deltaY:function(h){return"deltaY"in h?h.deltaY:"wheelDeltaY"in h?-h.wheelDeltaY:"wheelDelta"in h?-h.wheelDelta:0},deltaZ:0,deltaMode:0}),Qre=as(Yre),Zre=f({},yh,{newState:0,oldState:0}),Jre=as(Zre),eie=[9,13,27,32],TM=ic&&"CompositionEvent"in window,mx=null;ic&&"documentMode"in document&&(mx=document.documentMode);var tie=ic&&"TextEvent"in window&&!mx,ZL=ic&&(!TM||mx&&8<mx&&11>=mx),JL=" ",eI=!1;function tI(h,p){switch(h){case"keyup":return eie.indexOf(p.keyCode)!==-1;case"keydown":return p.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function nI(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var hm=!1;function nie(h,p){switch(h){case"compositionend":return nI(p);case"keypress":return p.which!==32?null:(eI=!0,JL);case"textInput":return h=p.data,h===JL&&eI?null:h;default:return null}}function rie(h,p){if(hm)return h==="compositionend"||!TM&&tI(h,p)?(h=WL(),Ky=wM=Mu=null,hm=!1,h):null;switch(h){case"paste":return null;case"keypress":if(!(p.ctrlKey||p.altKey||p.metaKey)||p.ctrlKey&&p.altKey){if(p.char&&1<p.char.length)return p.char;if(p.which)return String.fromCharCode(p.which)}return null;case"compositionend":return ZL&&p.locale!=="ko"?null:p.data;default:return null}}var iie={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 rI(h){var p=h&&h.nodeName&&h.nodeName.toLowerCase();return p==="input"?!!iie[h.type]:p==="textarea"}function iI(h,p,_,M){um?dm?dm.push(M):dm=[M]:um=M,p=Bv(p,"onChange"),0<p.length&&(_=new Qy("onChange","change",null,_,M),h.push({event:_,listeners:p}))}var px=null,gx=null;function aie(h){zF(h,0)}function Jy(h){var p=ge(h);if(Be(p))return h}function aI(h,p){if(h==="change")return p}var sI=!1;if(ic){var CM;if(ic){var AM="oninput"in document;if(!AM){var oI=document.createElement("div");oI.setAttribute("oninput","return;"),AM=typeof oI.oninput=="function"}CM=AM}else CM=!1;sI=CM&&(!document.documentMode||9<document.documentMode)}function lI(){px&&(px.detachEvent("onpropertychange",cI),gx=px=null)}function cI(h){if(h.propertyName==="value"&&Jy(gx)){var p=[];iI(p,gx,h,ua(h)),qL(aie,p)}}function sie(h,p,_){h==="focusin"?(lI(),px=p,gx=_,px.attachEvent("onpropertychange",cI)):h==="focusout"&&lI()}function oie(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return Jy(gx)}function lie(h,p){if(h==="click")return Jy(p)}function cie(h,p){if(h==="input"||h==="change")return Jy(p)}function uie(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var ks=typeof Object.is=="function"?Object.is:uie;function xx(h,p){if(ks(h,p))return!0;if(typeof h!="object"||h===null||typeof p!="object"||p===null)return!1;var _=Object.keys(h),M=Object.keys(p);if(_.length!==M.length)return!1;for(M=0;M<_.length;M++){var P=_[M];if(!le.call(p,P)||!ks(h[P],p[P]))return!1}return!0}function uI(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function dI(h,p){var _=uI(h);h=0;for(var M;_;){if(_.nodeType===3){if(M=h+_.textContent.length,h<=p&&M>=p)return{node:_,offset:p-h};h=M}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=uI(_)}}function hI(h,p){return h&&p?h===p?!0:h&&h.nodeType===3?!1:p&&p.nodeType===3?hI(h,p.parentNode):"contains"in h?h.contains(p):h.compareDocumentPosition?!!(h.compareDocumentPosition(p)&16):!1:!1}function fI(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var p=Et(h.document);p instanceof h.HTMLIFrameElement;){try{var _=typeof p.contentWindow.location.href=="string"}catch{_=!1}if(_)h=p.contentWindow;else break;p=Et(h.document)}return p}function kM(h){var p=h&&h.nodeName&&h.nodeName.toLowerCase();return p&&(p==="input"&&(h.type==="text"||h.type==="search"||h.type==="tel"||h.type==="url"||h.type==="password")||p==="textarea"||h.contentEditable==="true")}var die=ic&&"documentMode"in document&&11>=document.documentMode,fm=null,jM=null,bx=null,PM=!1;function mI(h,p,_){var M=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;PM||fm==null||fm!==Et(M)||(M=fm,"selectionStart"in M&&kM(M)?M={start:M.selectionStart,end:M.selectionEnd}:(M=(M.ownerDocument&&M.ownerDocument.defaultView||window).getSelection(),M={anchorNode:M.anchorNode,anchorOffset:M.anchorOffset,focusNode:M.focusNode,focusOffset:M.focusOffset}),bx&&xx(bx,M)||(bx=M,M=Bv(jM,"onSelect"),0<M.length&&(p=new Qy("onSelect","select",null,p,_),h.push({event:p,listeners:M}),p.target=fm)))}function vh(h,p){var _={};return _[h.toLowerCase()]=p.toLowerCase(),_["Webkit"+h]="webkit"+p,_["Moz"+h]="moz"+p,_}var mm={animationend:vh("Animation","AnimationEnd"),animationiteration:vh("Animation","AnimationIteration"),animationstart:vh("Animation","AnimationStart"),transitionrun:vh("Transition","TransitionRun"),transitionstart:vh("Transition","TransitionStart"),transitioncancel:vh("Transition","TransitionCancel"),transitionend:vh("Transition","TransitionEnd")},RM={},pI={};ic&&(pI=document.createElement("div").style,"AnimationEvent"in window||(delete mm.animationend.animation,delete mm.animationiteration.animation,delete mm.animationstart.animation),"TransitionEvent"in window||delete mm.transitionend.transition);function _h(h){if(RM[h])return RM[h];if(!mm[h])return h;var p=mm[h],_;for(_ in p)if(p.hasOwnProperty(_)&&_ in pI)return RM[h]=p[_];return h}var gI=_h("animationend"),xI=_h("animationiteration"),bI=_h("animationstart"),hie=_h("transitionrun"),fie=_h("transitionstart"),mie=_h("transitioncancel"),yI=_h("transitionend"),vI=new Map,DM="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(" ");DM.push("scrollEnd");function $o(h,p){vI.set(h,p),wt(p,[h])}var ev=typeof reportError=="function"?reportError:function(h){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var p=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof h=="object"&&h!==null&&typeof h.message=="string"?String(h.message):String(h),error:h});if(!window.dispatchEvent(p))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",h);return}console.error(h)},no=[],pm=0,OM=0;function tv(){for(var h=pm,p=OM=pm=0;p<h;){var _=no[p];no[p++]=null;var M=no[p];no[p++]=null;var P=no[p];no[p++]=null;var L=no[p];if(no[p++]=null,M!==null&&P!==null){var J=M.pending;J===null?P.next=P:(P.next=J.next,J.next=P),M.pending=P}L!==0&&_I(_,P,L)}}function nv(h,p,_,M){no[pm++]=h,no[pm++]=p,no[pm++]=_,no[pm++]=M,OM|=M,h.lanes|=M,h=h.alternate,h!==null&&(h.lanes|=M)}function LM(h,p,_,M){return nv(h,p,_,M),rv(h)}function wh(h,p){return nv(h,null,null,p),rv(h)}function _I(h,p,_){h.lanes|=_;var M=h.alternate;M!==null&&(M.lanes|=_);for(var P=!1,L=h.return;L!==null;)L.childLanes|=_,M=L.alternate,M!==null&&(M.childLanes|=_),L.tag===22&&(h=L.stateNode,h===null||h._visibility&1||(P=!0)),h=L,L=L.return;return h.tag===3?(L=h.stateNode,P&&p!==null&&(P=31-Le(_),h=L.hiddenUpdates,M=h[P],M===null?h[P]=[p]:M.push(p),p.lane=_|536870912),L):null}function rv(h){if(50<zx)throw zx=0,GE=null,Error(r(185));for(var p=h.return;p!==null;)h=p,p=h.return;return h.tag===3?h.stateNode:null}var gm={};function pie(h,p,_,M){this.tag=h,this.key=_,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=p,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=M,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function js(h,p,_,M){return new pie(h,p,_,M)}function IM(h){return h=h.prototype,!(!h||!h.isReactComponent)}function ac(h,p){var _=h.alternate;return _===null?(_=js(h.tag,p,h.key,h.mode),_.elementType=h.elementType,_.type=h.type,_.stateNode=h.stateNode,_.alternate=h,h.alternate=_):(_.pendingProps=p,_.type=h.type,_.flags=0,_.subtreeFlags=0,_.deletions=null),_.flags=h.flags&65011712,_.childLanes=h.childLanes,_.lanes=h.lanes,_.child=h.child,_.memoizedProps=h.memoizedProps,_.memoizedState=h.memoizedState,_.updateQueue=h.updateQueue,p=h.dependencies,_.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext},_.sibling=h.sibling,_.index=h.index,_.ref=h.ref,_.refCleanup=h.refCleanup,_}function wI(h,p){h.flags&=65011714;var _=h.alternate;return _===null?(h.childLanes=0,h.lanes=p,h.child=null,h.subtreeFlags=0,h.memoizedProps=null,h.memoizedState=null,h.updateQueue=null,h.dependencies=null,h.stateNode=null):(h.childLanes=_.childLanes,h.lanes=_.lanes,h.child=_.child,h.subtreeFlags=0,h.deletions=null,h.memoizedProps=_.memoizedProps,h.memoizedState=_.memoizedState,h.updateQueue=_.updateQueue,h.type=_.type,p=_.dependencies,h.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext}),h}function iv(h,p,_,M,P,L){var J=0;if(M=h,typeof h=="function")IM(h)&&(J=1);else if(typeof h=="string")J=vae(h,_,ae.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case A:return h=js(31,_,p,P),h.elementType=A,h.lanes=L,h;case y:return Sh(_.children,P,L,p);case b:J=8,P|=24;break;case v:return h=js(12,_,p,P|2),h.elementType=v,h.lanes=L,h;case E:return h=js(13,_,p,P),h.elementType=E,h.lanes=L,h;case k:return h=js(19,_,p,P),h.elementType=k,h.lanes=L,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case S:J=10;break e;case N:J=9;break e;case T:J=11;break e;case C:J=14;break e;case D:J=16,M=null;break e}J=29,_=Error(r(130,h===null?"null":typeof h,"")),M=null}return p=js(J,_,p,P),p.elementType=h,p.type=M,p.lanes=L,p}function Sh(h,p,_,M){return h=js(7,h,M,p),h.lanes=_,h}function FM(h,p,_){return h=js(6,h,null,p),h.lanes=_,h}function SI(h){var p=js(18,null,null,0);return p.stateNode=h,p}function UM(h,p,_){return p=js(4,h.children!==null?h.children:[],h.key,p),p.lanes=_,p.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},p}var NI=new WeakMap;function ro(h,p){if(typeof h=="object"&&h!==null){var _=NI.get(h);return _!==void 0?_:(p={value:h,source:p,stack:Q(p)},NI.set(h,p),p)}return{value:h,source:p,stack:Q(p)}}var xm=[],bm=0,av=null,yx=0,io=[],ao=0,Eu=null,gl=1,xl="";function sc(h,p){xm[bm++]=yx,xm[bm++]=av,av=h,yx=p}function MI(h,p,_){io[ao++]=gl,io[ao++]=xl,io[ao++]=Eu,Eu=h;var M=gl;h=xl;var P=32-Le(M)-1;M&=~(1<<P),_+=1;var L=32-Le(p)+P;if(30<L){var J=P-P%5;L=(M&(1<<J)-1).toString(32),M>>=J,P-=J,gl=1<<32-Le(p)+P|_<<P|M,xl=L+h}else gl=1<<L|_<<P|M,xl=h}function zM(h){h.return!==null&&(sc(h,1),MI(h,1,0))}function BM(h){for(;h===av;)av=xm[--bm],xm[bm]=null,yx=xm[--bm],xm[bm]=null;for(;h===Eu;)Eu=io[--ao],io[ao]=null,xl=io[--ao],io[ao]=null,gl=io[--ao],io[ao]=null}function EI(h,p){io[ao++]=gl,io[ao++]=xl,io[ao++]=Eu,gl=p.id,xl=p.overflow,Eu=h}var da=null,Pr=null,Bn=!1,Tu=null,so=!1,$M=Error(r(519));function Cu(h){var p=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw vx(ro(p,h)),$M}function TI(h){var p=h.stateNode,_=h.type,M=h.memoizedProps;switch(p[Xt]=h,p[zn]=M,_){case"dialog":jn("cancel",p),jn("close",p);break;case"iframe":case"object":case"embed":jn("load",p);break;case"video":case"audio":for(_=0;_<$x.length;_++)jn($x[_],p);break;case"source":jn("error",p);break;case"img":case"image":case"link":jn("error",p),jn("load",p);break;case"details":jn("toggle",p);break;case"input":jn("invalid",p),sn(p,M.value,M.defaultValue,M.checked,M.defaultChecked,M.type,M.name,!0);break;case"select":jn("invalid",p);break;case"textarea":jn("invalid",p),Gt(p,M.value,M.defaultValue,M.children)}_=M.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||p.textContent===""+_||M.suppressHydrationWarning===!0||VF(p.textContent,_)?(M.popover!=null&&(jn("beforetoggle",p),jn("toggle",p)),M.onScroll!=null&&jn("scroll",p),M.onScrollEnd!=null&&jn("scrollend",p),M.onClick!=null&&(p.onclick=ca),p=!0):p=!1,p||Cu(h,!0)}function CI(h){for(da=h.return;da;)switch(da.tag){case 5:case 31:case 13:so=!1;return;case 27:case 3:so=!0;return;default:da=da.return}}function ym(h){if(h!==da)return!1;if(!Bn)return CI(h),Bn=!0,!1;var p=h.tag,_;if((_=p!==3&&p!==27)&&((_=p===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||sT(h.type,h.memoizedProps)),_=!_),_&&Pr&&Cu(h),CI(h),p===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));Pr=JF(h)}else if(p===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));Pr=JF(h)}else p===27?(p=Pr,$u(h.type)?(h=dT,dT=null,Pr=h):Pr=p):Pr=da?lo(h.stateNode.nextSibling):null;return!0}function Nh(){Pr=da=null,Bn=!1}function HM(){var h=Tu;return h!==null&&(us===null?us=h:us.push.apply(us,h),Tu=null),h}function vx(h){Tu===null?Tu=[h]:Tu.push(h)}var VM=z(null),Mh=null,oc=null;function Au(h,p,_){se(VM,p._currentValue),p._currentValue=_}function lc(h){h._currentValue=VM.current,W(VM)}function GM(h,p,_){for(;h!==null;){var M=h.alternate;if((h.childLanes&p)!==p?(h.childLanes|=p,M!==null&&(M.childLanes|=p)):M!==null&&(M.childLanes&p)!==p&&(M.childLanes|=p),h===_)break;h=h.return}}function qM(h,p,_,M){var P=h.child;for(P!==null&&(P.return=h);P!==null;){var L=P.dependencies;if(L!==null){var J=P.child;L=L.firstContext;e:for(;L!==null;){var pe=L;L=P;for(var ze=0;ze<p.length;ze++)if(pe.context===p[ze]){L.lanes|=_,pe=L.alternate,pe!==null&&(pe.lanes|=_),GM(L.return,_,h),M||(J=null);break e}L=pe.next}}else if(P.tag===18){if(J=P.return,J===null)throw Error(r(341));J.lanes|=_,L=J.alternate,L!==null&&(L.lanes|=_),GM(J,_,h),J=null}else J=P.child;if(J!==null)J.return=P;else for(J=P;J!==null;){if(J===h){J=null;break}if(P=J.sibling,P!==null){P.return=J.return,J=P;break}J=J.return}P=J}}function vm(h,p,_,M){h=null;for(var P=p,L=!1;P!==null;){if(!L){if((P.flags&524288)!==0)L=!0;else if((P.flags&262144)!==0)break}if(P.tag===10){var J=P.alternate;if(J===null)throw Error(r(387));if(J=J.memoizedProps,J!==null){var pe=P.type;ks(P.pendingProps.value,J.value)||(h!==null?h.push(pe):h=[pe])}}else if(P===xe.current){if(J=P.alternate,J===null)throw Error(r(387));J.memoizedState.memoizedState!==P.memoizedState.memoizedState&&(h!==null?h.push(Wx):h=[Wx])}P=P.return}h!==null&&qM(p,h,_,M),p.flags|=262144}function sv(h){for(h=h.firstContext;h!==null;){if(!ks(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function Eh(h){Mh=h,oc=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function ha(h){return AI(Mh,h)}function ov(h,p){return Mh===null&&Eh(h),AI(h,p)}function AI(h,p){var _=p._currentValue;if(p={context:p,memoizedValue:_,next:null},oc===null){if(h===null)throw Error(r(308));oc=p,h.dependencies={lanes:0,firstContext:p},h.flags|=524288}else oc=oc.next=p;return _}var gie=typeof AbortController<"u"?AbortController:function(){var h=[],p=this.signal={aborted:!1,addEventListener:function(_,M){h.push(M)}};this.abort=function(){p.aborted=!0,h.forEach(function(_){return _()})}},xie=t.unstable_scheduleCallback,bie=t.unstable_NormalPriority,pi={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function WM(){return{controller:new gie,data:new Map,refCount:0}}function _x(h){h.refCount--,h.refCount===0&&xie(bie,function(){h.controller.abort()})}var wx=null,KM=0,_m=0,wm=null;function yie(h,p){if(wx===null){var _=wx=[];KM=0,_m=QE(),wm={status:"pending",value:void 0,then:function(M){_.push(M)}}}return KM++,p.then(kI,kI),p}function kI(){if(--KM===0&&wx!==null){wm!==null&&(wm.status="fulfilled");var h=wx;wx=null,_m=0,wm=null;for(var p=0;p<h.length;p++)(0,h[p])()}}function vie(h,p){var _=[],M={status:"pending",value:null,reason:null,then:function(P){_.push(P)}};return h.then(function(){M.status="fulfilled",M.value=p;for(var P=0;P<_.length;P++)(0,_[P])(p)},function(P){for(M.status="rejected",M.reason=P,P=0;P<_.length;P++)(0,_[P])(void 0)}),M}var jI=Y.S;Y.S=function(h,p){mF=I(),typeof p=="object"&&p!==null&&typeof p.then=="function"&&yie(h,p),jI!==null&&jI(h,p)};var Th=z(null);function XM(){var h=Th.current;return h!==null?h:Sr.pooledCache}function lv(h,p){p===null?se(Th,Th.current):se(Th,p.pool)}function PI(){var h=XM();return h===null?null:{parent:pi._currentValue,pool:h}}var Sm=Error(r(460)),YM=Error(r(474)),cv=Error(r(542)),uv={then:function(){}};function RI(h){return h=h.status,h==="fulfilled"||h==="rejected"}function DI(h,p,_){switch(_=h[_],_===void 0?h.push(p):_!==p&&(p.then(ca,ca),p=_),p.status){case"fulfilled":return p.value;case"rejected":throw h=p.reason,LI(h),h;default:if(typeof p.status=="string")p.then(ca,ca);else{if(h=Sr,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=p,h.status="pending",h.then(function(M){if(p.status==="pending"){var P=p;P.status="fulfilled",P.value=M}},function(M){if(p.status==="pending"){var P=p;P.status="rejected",P.reason=M}})}switch(p.status){case"fulfilled":return p.value;case"rejected":throw h=p.reason,LI(h),h}throw Ah=p,Sm}}function Ch(h){try{var p=h._init;return p(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(Ah=_,Sm):_}}var Ah=null;function OI(){if(Ah===null)throw Error(r(459));var h=Ah;return Ah=null,h}function LI(h){if(h===Sm||h===cv)throw Error(r(483))}var Nm=null,Sx=0;function dv(h){var p=Sx;return Sx+=1,Nm===null&&(Nm=[]),DI(Nm,h,p)}function Nx(h,p){p=p.props.ref,h.ref=p!==void 0?p:null}function hv(h,p){throw p.$$typeof===m?Error(r(525)):(h=Object.prototype.toString.call(p),Error(r(31,h==="[object Object]"?"object with keys {"+Object.keys(p).join(", ")+"}":h)))}function II(h){function p(Ze,Ve){if(h){var nt=Ze.deletions;nt===null?(Ze.deletions=[Ve],Ze.flags|=16):nt.push(Ve)}}function _(Ze,Ve){if(!h)return null;for(;Ve!==null;)p(Ze,Ve),Ve=Ve.sibling;return null}function M(Ze){for(var Ve=new Map;Ze!==null;)Ze.key!==null?Ve.set(Ze.key,Ze):Ve.set(Ze.index,Ze),Ze=Ze.sibling;return Ve}function P(Ze,Ve){return Ze=ac(Ze,Ve),Ze.index=0,Ze.sibling=null,Ze}function L(Ze,Ve,nt){return Ze.index=nt,h?(nt=Ze.alternate,nt!==null?(nt=nt.index,nt<Ve?(Ze.flags|=67108866,Ve):nt):(Ze.flags|=67108866,Ve)):(Ze.flags|=1048576,Ve)}function J(Ze){return h&&Ze.alternate===null&&(Ze.flags|=67108866),Ze}function pe(Ze,Ve,nt,yt){return Ve===null||Ve.tag!==6?(Ve=FM(nt,Ze.mode,yt),Ve.return=Ze,Ve):(Ve=P(Ve,nt),Ve.return=Ze,Ve)}function ze(Ze,Ve,nt,yt){var Yt=nt.type;return Yt===y?xt(Ze,Ve,nt.props.children,yt,nt.key):Ve!==null&&(Ve.elementType===Yt||typeof Yt=="object"&&Yt!==null&&Yt.$$typeof===D&&Ch(Yt)===Ve.type)?(Ve=P(Ve,nt.props),Nx(Ve,nt),Ve.return=Ze,Ve):(Ve=iv(nt.type,nt.key,nt.props,null,Ze.mode,yt),Nx(Ve,nt),Ve.return=Ze,Ve)}function rt(Ze,Ve,nt,yt){return Ve===null||Ve.tag!==4||Ve.stateNode.containerInfo!==nt.containerInfo||Ve.stateNode.implementation!==nt.implementation?(Ve=UM(nt,Ze.mode,yt),Ve.return=Ze,Ve):(Ve=P(Ve,nt.children||[]),Ve.return=Ze,Ve)}function xt(Ze,Ve,nt,yt,Yt){return Ve===null||Ve.tag!==7?(Ve=Sh(nt,Ze.mode,yt,Yt),Ve.return=Ze,Ve):(Ve=P(Ve,nt),Ve.return=Ze,Ve)}function vt(Ze,Ve,nt){if(typeof Ve=="string"&&Ve!==""||typeof Ve=="number"||typeof Ve=="bigint")return Ve=FM(""+Ve,Ze.mode,nt),Ve.return=Ze,Ve;if(typeof Ve=="object"&&Ve!==null){switch(Ve.$$typeof){case g:return nt=iv(Ve.type,Ve.key,Ve.props,null,Ze.mode,nt),Nx(nt,Ve),nt.return=Ze,nt;case x:return Ve=UM(Ve,Ze.mode,nt),Ve.return=Ze,Ve;case D:return Ve=Ch(Ve),vt(Ze,Ve,nt)}if(G(Ve)||O(Ve))return Ve=Sh(Ve,Ze.mode,nt,null),Ve.return=Ze,Ve;if(typeof Ve.then=="function")return vt(Ze,dv(Ve),nt);if(Ve.$$typeof===S)return vt(Ze,ov(Ze,Ve),nt);hv(Ze,Ve)}return null}function at(Ze,Ve,nt,yt){var Yt=Ve!==null?Ve.key:null;if(typeof nt=="string"&&nt!==""||typeof nt=="number"||typeof nt=="bigint")return Yt!==null?null:pe(Ze,Ve,""+nt,yt);if(typeof nt=="object"&&nt!==null){switch(nt.$$typeof){case g:return nt.key===Yt?ze(Ze,Ve,nt,yt):null;case x:return nt.key===Yt?rt(Ze,Ve,nt,yt):null;case D:return nt=Ch(nt),at(Ze,Ve,nt,yt)}if(G(nt)||O(nt))return Yt!==null?null:xt(Ze,Ve,nt,yt,null);if(typeof nt.then=="function")return at(Ze,Ve,dv(nt),yt);if(nt.$$typeof===S)return at(Ze,Ve,ov(Ze,nt),yt);hv(Ze,nt)}return null}function ft(Ze,Ve,nt,yt,Yt){if(typeof yt=="string"&&yt!==""||typeof yt=="number"||typeof yt=="bigint")return Ze=Ze.get(nt)||null,pe(Ve,Ze,""+yt,Yt);if(typeof yt=="object"&&yt!==null){switch(yt.$$typeof){case g:return Ze=Ze.get(yt.key===null?nt:yt.key)||null,ze(Ve,Ze,yt,Yt);case x:return Ze=Ze.get(yt.key===null?nt:yt.key)||null,rt(Ve,Ze,yt,Yt);case D:return yt=Ch(yt),ft(Ze,Ve,nt,yt,Yt)}if(G(yt)||O(yt))return Ze=Ze.get(nt)||null,xt(Ve,Ze,yt,Yt,null);if(typeof yt.then=="function")return ft(Ze,Ve,nt,dv(yt),Yt);if(yt.$$typeof===S)return ft(Ze,Ve,nt,ov(Ve,yt),Yt);hv(Ve,yt)}return null}function Vt(Ze,Ve,nt,yt){for(var Yt=null,Kn=null,qt=Ve,yn=Ve=0,In=null;qt!==null&&yn<nt.length;yn++){qt.index>yn?(In=qt,qt=null):In=qt.sibling;var Xn=at(Ze,qt,nt[yn],yt);if(Xn===null){qt===null&&(qt=In);break}h&&qt&&Xn.alternate===null&&p(Ze,qt),Ve=L(Xn,Ve,yn),Kn===null?Yt=Xn:Kn.sibling=Xn,Kn=Xn,qt=In}if(yn===nt.length)return _(Ze,qt),Bn&&sc(Ze,yn),Yt;if(qt===null){for(;yn<nt.length;yn++)qt=vt(Ze,nt[yn],yt),qt!==null&&(Ve=L(qt,Ve,yn),Kn===null?Yt=qt:Kn.sibling=qt,Kn=qt);return Bn&&sc(Ze,yn),Yt}for(qt=M(qt);yn<nt.length;yn++)In=ft(qt,Ze,yn,nt[yn],yt),In!==null&&(h&&In.alternate!==null&&qt.delete(In.key===null?yn:In.key),Ve=L(In,Ve,yn),Kn===null?Yt=In:Kn.sibling=In,Kn=In);return h&&qt.forEach(function(Wu){return p(Ze,Wu)}),Bn&&sc(Ze,yn),Yt}function rn(Ze,Ve,nt,yt){if(nt==null)throw Error(r(151));for(var Yt=null,Kn=null,qt=Ve,yn=Ve=0,In=null,Xn=nt.next();qt!==null&&!Xn.done;yn++,Xn=nt.next()){qt.index>yn?(In=qt,qt=null):In=qt.sibling;var Wu=at(Ze,qt,Xn.value,yt);if(Wu===null){qt===null&&(qt=In);break}h&&qt&&Wu.alternate===null&&p(Ze,qt),Ve=L(Wu,Ve,yn),Kn===null?Yt=Wu:Kn.sibling=Wu,Kn=Wu,qt=In}if(Xn.done)return _(Ze,qt),Bn&&sc(Ze,yn),Yt;if(qt===null){for(;!Xn.done;yn++,Xn=nt.next())Xn=vt(Ze,Xn.value,yt),Xn!==null&&(Ve=L(Xn,Ve,yn),Kn===null?Yt=Xn:Kn.sibling=Xn,Kn=Xn);return Bn&&sc(Ze,yn),Yt}for(qt=M(qt);!Xn.done;yn++,Xn=nt.next())Xn=ft(qt,Ze,yn,Xn.value,yt),Xn!==null&&(h&&Xn.alternate!==null&&qt.delete(Xn.key===null?yn:Xn.key),Ve=L(Xn,Ve,yn),Kn===null?Yt=Xn:Kn.sibling=Xn,Kn=Xn);return h&&qt.forEach(function(jae){return p(Ze,jae)}),Bn&&sc(Ze,yn),Yt}function fr(Ze,Ve,nt,yt){if(typeof nt=="object"&&nt!==null&&nt.type===y&&nt.key===null&&(nt=nt.props.children),typeof nt=="object"&&nt!==null){switch(nt.$$typeof){case g:e:{for(var Yt=nt.key;Ve!==null;){if(Ve.key===Yt){if(Yt=nt.type,Yt===y){if(Ve.tag===7){_(Ze,Ve.sibling),yt=P(Ve,nt.props.children),yt.return=Ze,Ze=yt;break e}}else if(Ve.elementType===Yt||typeof Yt=="object"&&Yt!==null&&Yt.$$typeof===D&&Ch(Yt)===Ve.type){_(Ze,Ve.sibling),yt=P(Ve,nt.props),Nx(yt,nt),yt.return=Ze,Ze=yt;break e}_(Ze,Ve);break}else p(Ze,Ve);Ve=Ve.sibling}nt.type===y?(yt=Sh(nt.props.children,Ze.mode,yt,nt.key),yt.return=Ze,Ze=yt):(yt=iv(nt.type,nt.key,nt.props,null,Ze.mode,yt),Nx(yt,nt),yt.return=Ze,Ze=yt)}return J(Ze);case x:e:{for(Yt=nt.key;Ve!==null;){if(Ve.key===Yt)if(Ve.tag===4&&Ve.stateNode.containerInfo===nt.containerInfo&&Ve.stateNode.implementation===nt.implementation){_(Ze,Ve.sibling),yt=P(Ve,nt.children||[]),yt.return=Ze,Ze=yt;break e}else{_(Ze,Ve);break}else p(Ze,Ve);Ve=Ve.sibling}yt=UM(nt,Ze.mode,yt),yt.return=Ze,Ze=yt}return J(Ze);case D:return nt=Ch(nt),fr(Ze,Ve,nt,yt)}if(G(nt))return Vt(Ze,Ve,nt,yt);if(O(nt)){if(Yt=O(nt),typeof Yt!="function")throw Error(r(150));return nt=Yt.call(nt),rn(Ze,Ve,nt,yt)}if(typeof nt.then=="function")return fr(Ze,Ve,dv(nt),yt);if(nt.$$typeof===S)return fr(Ze,Ve,ov(Ze,nt),yt);hv(Ze,nt)}return typeof nt=="string"&&nt!==""||typeof nt=="number"||typeof nt=="bigint"?(nt=""+nt,Ve!==null&&Ve.tag===6?(_(Ze,Ve.sibling),yt=P(Ve,nt),yt.return=Ze,Ze=yt):(_(Ze,Ve),yt=FM(nt,Ze.mode,yt),yt.return=Ze,Ze=yt),J(Ze)):_(Ze,Ve)}return function(Ze,Ve,nt,yt){try{Sx=0;var Yt=fr(Ze,Ve,nt,yt);return Nm=null,Yt}catch(qt){if(qt===Sm||qt===cv)throw qt;var Kn=js(29,qt,null,Ze.mode);return Kn.lanes=yt,Kn.return=Ze,Kn}finally{}}}var kh=II(!0),FI=II(!1),ku=!1;function QM(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ZM(h,p){h=h.updateQueue,p.updateQueue===h&&(p.updateQueue={baseState:h.baseState,firstBaseUpdate:h.firstBaseUpdate,lastBaseUpdate:h.lastBaseUpdate,shared:h.shared,callbacks:null})}function ju(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function Pu(h,p,_){var M=h.updateQueue;if(M===null)return null;if(M=M.shared,(Jn&2)!==0){var P=M.pending;return P===null?p.next=p:(p.next=P.next,P.next=p),M.pending=p,p=rv(h),_I(h,null,_),p}return nv(h,M,p,_),rv(h)}function Mx(h,p,_){if(p=p.updateQueue,p!==null&&(p=p.shared,(_&4194048)!==0)){var M=p.lanes;M&=h.pendingLanes,_|=M,p.lanes=_,en(h,_)}}function JM(h,p){var _=h.updateQueue,M=h.alternate;if(M!==null&&(M=M.updateQueue,_===M)){var P=null,L=null;if(_=_.firstBaseUpdate,_!==null){do{var J={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};L===null?P=L=J:L=L.next=J,_=_.next}while(_!==null);L===null?P=L=p:L=L.next=p}else P=L=p;_={baseState:M.baseState,firstBaseUpdate:P,lastBaseUpdate:L,shared:M.shared,callbacks:M.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=p:h.next=p,_.lastBaseUpdate=p}var eE=!1;function Ex(){if(eE){var h=wm;if(h!==null)throw h}}function Tx(h,p,_,M){eE=!1;var P=h.updateQueue;ku=!1;var L=P.firstBaseUpdate,J=P.lastBaseUpdate,pe=P.shared.pending;if(pe!==null){P.shared.pending=null;var ze=pe,rt=ze.next;ze.next=null,J===null?L=rt:J.next=rt,J=ze;var xt=h.alternate;xt!==null&&(xt=xt.updateQueue,pe=xt.lastBaseUpdate,pe!==J&&(pe===null?xt.firstBaseUpdate=rt:pe.next=rt,xt.lastBaseUpdate=ze))}if(L!==null){var vt=P.baseState;J=0,xt=rt=ze=null,pe=L;do{var at=pe.lane&-536870913,ft=at!==pe.lane;if(ft?(Ln&at)===at:(M&at)===at){at!==0&&at===_m&&(eE=!0),xt!==null&&(xt=xt.next={lane:0,tag:pe.tag,payload:pe.payload,callback:null,next:null});e:{var Vt=h,rn=pe;at=p;var fr=_;switch(rn.tag){case 1:if(Vt=rn.payload,typeof Vt=="function"){vt=Vt.call(fr,vt,at);break e}vt=Vt;break e;case 3:Vt.flags=Vt.flags&-65537|128;case 0:if(Vt=rn.payload,at=typeof Vt=="function"?Vt.call(fr,vt,at):Vt,at==null)break e;vt=f({},vt,at);break e;case 2:ku=!0}}at=pe.callback,at!==null&&(h.flags|=64,ft&&(h.flags|=8192),ft=P.callbacks,ft===null?P.callbacks=[at]:ft.push(at))}else ft={lane:at,tag:pe.tag,payload:pe.payload,callback:pe.callback,next:null},xt===null?(rt=xt=ft,ze=vt):xt=xt.next=ft,J|=at;if(pe=pe.next,pe===null){if(pe=P.shared.pending,pe===null)break;ft=pe,pe=ft.next,ft.next=null,P.lastBaseUpdate=ft,P.shared.pending=null}}while(!0);xt===null&&(ze=vt),P.baseState=ze,P.firstBaseUpdate=rt,P.lastBaseUpdate=xt,L===null&&(P.shared.lanes=0),Iu|=J,h.lanes=J,h.memoizedState=vt}}function UI(h,p){if(typeof h!="function")throw Error(r(191,h));h.call(p)}function zI(h,p){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)UI(_[h],p)}var Mm=z(null),fv=z(0);function BI(h,p){h=xc,se(fv,h),se(Mm,p),xc=h|p.baseLanes}function tE(){se(fv,xc),se(Mm,Mm.current)}function nE(){xc=fv.current,W(Mm),W(fv)}var Ps=z(null),oo=null;function Ru(h){var p=h.alternate;se(ci,ci.current&1),se(Ps,h),oo===null&&(p===null||Mm.current!==null||p.memoizedState!==null)&&(oo=h)}function rE(h){se(ci,ci.current),se(Ps,h),oo===null&&(oo=h)}function $I(h){h.tag===22?(se(ci,ci.current),se(Ps,h),oo===null&&(oo=h)):Du()}function Du(){se(ci,ci.current),se(Ps,Ps.current)}function Rs(h){W(Ps),oo===h&&(oo=null),W(ci)}var ci=z(0);function mv(h){for(var p=h;p!==null;){if(p.tag===13){var _=p.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||cT(_)||uT(_)))return p}else if(p.tag===19&&(p.memoizedProps.revealOrder==="forwards"||p.memoizedProps.revealOrder==="backwards"||p.memoizedProps.revealOrder==="unstable_legacy-backwards"||p.memoizedProps.revealOrder==="together")){if((p.flags&128)!==0)return p}else if(p.child!==null){p.child.return=p,p=p.child;continue}if(p===h)break;for(;p.sibling===null;){if(p.return===null||p.return===h)return null;p=p.return}p.sibling.return=p.return,p=p.sibling}return null}var cc=0,bn=null,dr=null,gi=null,pv=!1,Em=!1,jh=!1,gv=0,Cx=0,Tm=null,_ie=0;function Jr(){throw Error(r(321))}function iE(h,p){if(p===null)return!1;for(var _=0;_<p.length&&_<h.length;_++)if(!ks(h[_],p[_]))return!1;return!0}function aE(h,p,_,M,P,L){return cc=L,bn=p,p.memoizedState=null,p.updateQueue=null,p.lanes=0,Y.H=h===null||h.memoizedState===null?M5:vE,jh=!1,L=_(M,P),jh=!1,Em&&(L=VI(p,_,M,P)),HI(h),L}function HI(h){Y.H=jx;var p=dr!==null&&dr.next!==null;if(cc=0,gi=dr=bn=null,pv=!1,Cx=0,Tm=null,p)throw Error(r(300));h===null||xi||(h=h.dependencies,h!==null&&sv(h)&&(xi=!0))}function VI(h,p,_,M){bn=h;var P=0;do{if(Em&&(Tm=null),Cx=0,Em=!1,25<=P)throw Error(r(301));if(P+=1,gi=dr=null,h.updateQueue!=null){var L=h.updateQueue;L.lastEffect=null,L.events=null,L.stores=null,L.memoCache!=null&&(L.memoCache.index=0)}Y.H=E5,L=p(_,M)}while(Em);return L}function wie(){var h=Y.H,p=h.useState()[0];return p=typeof p.then=="function"?Ax(p):p,h=h.useState()[0],(dr!==null?dr.memoizedState:null)!==h&&(bn.flags|=1024),p}function sE(){var h=gv!==0;return gv=0,h}function oE(h,p,_){p.updateQueue=h.updateQueue,p.flags&=-2053,h.lanes&=~_}function lE(h){if(pv){for(h=h.memoizedState;h!==null;){var p=h.queue;p!==null&&(p.pending=null),h=h.next}pv=!1}cc=0,gi=dr=bn=null,Em=!1,Cx=gv=0,Tm=null}function Ha(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return gi===null?bn.memoizedState=gi=h:gi=gi.next=h,gi}function ui(){if(dr===null){var h=bn.alternate;h=h!==null?h.memoizedState:null}else h=dr.next;var p=gi===null?bn.memoizedState:gi.next;if(p!==null)gi=p,dr=h;else{if(h===null)throw bn.alternate===null?Error(r(467)):Error(r(310));dr=h,h={memoizedState:dr.memoizedState,baseState:dr.baseState,baseQueue:dr.baseQueue,queue:dr.queue,next:null},gi===null?bn.memoizedState=gi=h:gi=gi.next=h}return gi}function xv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ax(h){var p=Cx;return Cx+=1,Tm===null&&(Tm=[]),h=DI(Tm,h,p),p=bn,(gi===null?p.memoizedState:gi.next)===null&&(p=p.alternate,Y.H=p===null||p.memoizedState===null?M5:vE),h}function bv(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return Ax(h);if(h.$$typeof===S)return ha(h)}throw Error(r(438,String(h)))}function cE(h){var p=null,_=bn.updateQueue;if(_!==null&&(p=_.memoCache),p==null){var M=bn.alternate;M!==null&&(M=M.updateQueue,M!==null&&(M=M.memoCache,M!=null&&(p={data:M.data.map(function(P){return P.slice()}),index:0})))}if(p==null&&(p={data:[],index:0}),_===null&&(_=xv(),bn.updateQueue=_),_.memoCache=p,_=p.data[p.index],_===void 0)for(_=p.data[p.index]=Array(h),M=0;M<h;M++)_[M]=R;return p.index++,_}function uc(h,p){return typeof p=="function"?p(h):p}function yv(h){var p=ui();return uE(p,dr,h)}function uE(h,p,_){var M=h.queue;if(M===null)throw Error(r(311));M.lastRenderedReducer=_;var P=h.baseQueue,L=M.pending;if(L!==null){if(P!==null){var J=P.next;P.next=L.next,L.next=J}p.baseQueue=P=L,M.pending=null}if(L=h.baseState,P===null)h.memoizedState=L;else{p=P.next;var pe=J=null,ze=null,rt=p,xt=!1;do{var vt=rt.lane&-536870913;if(vt!==rt.lane?(Ln&vt)===vt:(cc&vt)===vt){var at=rt.revertLane;if(at===0)ze!==null&&(ze=ze.next={lane:0,revertLane:0,gesture:null,action:rt.action,hasEagerState:rt.hasEagerState,eagerState:rt.eagerState,next:null}),vt===_m&&(xt=!0);else if((cc&at)===at){rt=rt.next,at===_m&&(xt=!0);continue}else vt={lane:0,revertLane:rt.revertLane,gesture:null,action:rt.action,hasEagerState:rt.hasEagerState,eagerState:rt.eagerState,next:null},ze===null?(pe=ze=vt,J=L):ze=ze.next=vt,bn.lanes|=at,Iu|=at;vt=rt.action,jh&&_(L,vt),L=rt.hasEagerState?rt.eagerState:_(L,vt)}else at={lane:vt,revertLane:rt.revertLane,gesture:rt.gesture,action:rt.action,hasEagerState:rt.hasEagerState,eagerState:rt.eagerState,next:null},ze===null?(pe=ze=at,J=L):ze=ze.next=at,bn.lanes|=vt,Iu|=vt;rt=rt.next}while(rt!==null&&rt!==p);if(ze===null?J=L:ze.next=pe,!ks(L,h.memoizedState)&&(xi=!0,xt&&(_=wm,_!==null)))throw _;h.memoizedState=L,h.baseState=J,h.baseQueue=ze,M.lastRenderedState=L}return P===null&&(M.lanes=0),[h.memoizedState,M.dispatch]}function dE(h){var p=ui(),_=p.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var M=_.dispatch,P=_.pending,L=p.memoizedState;if(P!==null){_.pending=null;var J=P=P.next;do L=h(L,J.action),J=J.next;while(J!==P);ks(L,p.memoizedState)||(xi=!0),p.memoizedState=L,p.baseQueue===null&&(p.baseState=L),_.lastRenderedState=L}return[L,M]}function GI(h,p,_){var M=bn,P=ui(),L=Bn;if(L){if(_===void 0)throw Error(r(407));_=_()}else _=p();var J=!ks((dr||P).memoizedState,_);if(J&&(P.memoizedState=_,xi=!0),P=P.queue,mE(KI.bind(null,M,P,h),[h]),P.getSnapshot!==p||J||gi!==null&&gi.memoizedState.tag&1){if(M.flags|=2048,Cm(9,{destroy:void 0},WI.bind(null,M,P,_,p),null),Sr===null)throw Error(r(349));L||(cc&127)!==0||qI(M,p,_)}return _}function qI(h,p,_){h.flags|=16384,h={getSnapshot:p,value:_},p=bn.updateQueue,p===null?(p=xv(),bn.updateQueue=p,p.stores=[h]):(_=p.stores,_===null?p.stores=[h]:_.push(h))}function WI(h,p,_,M){p.value=_,p.getSnapshot=M,XI(p)&&YI(h)}function KI(h,p,_){return _(function(){XI(p)&&YI(h)})}function XI(h){var p=h.getSnapshot;h=h.value;try{var _=p();return!ks(h,_)}catch{return!0}}function YI(h){var p=wh(h,2);p!==null&&ds(p,h,2)}function hE(h){var p=Ha();if(typeof h=="function"){var _=h;if(h=_(),jh){ve(!0);try{_()}finally{ve(!1)}}}return p.memoizedState=p.baseState=h,p.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:uc,lastRenderedState:h},p}function QI(h,p,_,M){return h.baseState=_,uE(h,dr,typeof M=="function"?M:uc)}function Sie(h,p,_,M,P){if(wv(h))throw Error(r(485));if(h=p.action,h!==null){var L={payload:P,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(J){L.listeners.push(J)}};Y.T!==null?_(!0):L.isTransition=!1,M(L),_=p.pending,_===null?(L.next=p.pending=L,ZI(p,L)):(L.next=_.next,p.pending=_.next=L)}}function ZI(h,p){var _=p.action,M=p.payload,P=h.state;if(p.isTransition){var L=Y.T,J={};Y.T=J;try{var pe=_(P,M),ze=Y.S;ze!==null&&ze(J,pe),JI(h,p,pe)}catch(rt){fE(h,p,rt)}finally{L!==null&&J.types!==null&&(L.types=J.types),Y.T=L}}else try{L=_(P,M),JI(h,p,L)}catch(rt){fE(h,p,rt)}}function JI(h,p,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(M){e5(h,p,M)},function(M){return fE(h,p,M)}):e5(h,p,_)}function e5(h,p,_){p.status="fulfilled",p.value=_,t5(p),h.state=_,p=h.pending,p!==null&&(_=p.next,_===p?h.pending=null:(_=_.next,p.next=_,ZI(h,_)))}function fE(h,p,_){var M=h.pending;if(h.pending=null,M!==null){M=M.next;do p.status="rejected",p.reason=_,t5(p),p=p.next;while(p!==M)}h.action=null}function t5(h){h=h.listeners;for(var p=0;p<h.length;p++)(0,h[p])()}function n5(h,p){return p}function r5(h,p){if(Bn){var _=Sr.formState;if(_!==null){e:{var M=bn;if(Bn){if(Pr){t:{for(var P=Pr,L=so;P.nodeType!==8;){if(!L){P=null;break t}if(P=lo(P.nextSibling),P===null){P=null;break t}}L=P.data,P=L==="F!"||L==="F"?P:null}if(P){Pr=lo(P.nextSibling),M=P.data==="F!";break e}}Cu(M)}M=!1}M&&(p=_[0])}}return _=Ha(),_.memoizedState=_.baseState=p,M={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n5,lastRenderedState:p},_.queue=M,_=w5.bind(null,bn,M),M.dispatch=_,M=hE(!1),L=yE.bind(null,bn,!1,M.queue),M=Ha(),P={state:p,dispatch:null,action:h,pending:null},M.queue=P,_=Sie.bind(null,bn,P,L,_),P.dispatch=_,M.memoizedState=h,[p,_,!1]}function i5(h){var p=ui();return a5(p,dr,h)}function a5(h,p,_){if(p=uE(h,p,n5)[0],h=yv(uc)[0],typeof p=="object"&&p!==null&&typeof p.then=="function")try{var M=Ax(p)}catch(J){throw J===Sm?cv:J}else M=p;p=ui();var P=p.queue,L=P.dispatch;return _!==p.memoizedState&&(bn.flags|=2048,Cm(9,{destroy:void 0},Nie.bind(null,P,_),null)),[M,L,h]}function Nie(h,p){h.action=p}function s5(h){var p=ui(),_=dr;if(_!==null)return a5(p,_,h);ui(),p=p.memoizedState,_=ui();var M=_.queue.dispatch;return _.memoizedState=h,[p,M,!1]}function Cm(h,p,_,M){return h={tag:h,create:_,deps:M,inst:p,next:null},p=bn.updateQueue,p===null&&(p=xv(),bn.updateQueue=p),_=p.lastEffect,_===null?p.lastEffect=h.next=h:(M=_.next,_.next=h,h.next=M,p.lastEffect=h),h}function o5(){return ui().memoizedState}function vv(h,p,_,M){var P=Ha();bn.flags|=h,P.memoizedState=Cm(1|p,{destroy:void 0},_,M===void 0?null:M)}function _v(h,p,_,M){var P=ui();M=M===void 0?null:M;var L=P.memoizedState.inst;dr!==null&&M!==null&&iE(M,dr.memoizedState.deps)?P.memoizedState=Cm(p,L,_,M):(bn.flags|=h,P.memoizedState=Cm(1|p,L,_,M))}function l5(h,p){vv(8390656,8,h,p)}function mE(h,p){_v(2048,8,h,p)}function Mie(h){bn.flags|=4;var p=bn.updateQueue;if(p===null)p=xv(),bn.updateQueue=p,p.events=[h];else{var _=p.events;_===null?p.events=[h]:_.push(h)}}function c5(h){var p=ui().memoizedState;return Mie({ref:p,nextImpl:h}),function(){if((Jn&2)!==0)throw Error(r(440));return p.impl.apply(void 0,arguments)}}function u5(h,p){return _v(4,2,h,p)}function d5(h,p){return _v(4,4,h,p)}function h5(h,p){if(typeof p=="function"){h=h();var _=p(h);return function(){typeof _=="function"?_():p(null)}}if(p!=null)return h=h(),p.current=h,function(){p.current=null}}function f5(h,p,_){_=_!=null?_.concat([h]):null,_v(4,4,h5.bind(null,p,h),_)}function pE(){}function m5(h,p){var _=ui();p=p===void 0?null:p;var M=_.memoizedState;return p!==null&&iE(p,M[1])?M[0]:(_.memoizedState=[h,p],h)}function p5(h,p){var _=ui();p=p===void 0?null:p;var M=_.memoizedState;if(p!==null&&iE(p,M[1]))return M[0];if(M=h(),jh){ve(!0);try{h()}finally{ve(!1)}}return _.memoizedState=[M,p],M}function gE(h,p,_){return _===void 0||(cc&1073741824)!==0&&(Ln&261930)===0?h.memoizedState=p:(h.memoizedState=_,h=gF(),bn.lanes|=h,Iu|=h,_)}function g5(h,p,_,M){return ks(_,p)?_:Mm.current!==null?(h=gE(h,_,M),ks(h,p)||(xi=!0),h):(cc&42)===0||(cc&1073741824)!==0&&(Ln&261930)===0?(xi=!0,h.memoizedState=_):(h=gF(),bn.lanes|=h,Iu|=h,p)}function x5(h,p,_,M,P){var L=K.p;K.p=L!==0&&8>L?L:8;var J=Y.T,pe={};Y.T=pe,yE(h,!1,p,_);try{var ze=P(),rt=Y.S;if(rt!==null&&rt(pe,ze),ze!==null&&typeof ze=="object"&&typeof ze.then=="function"){var xt=vie(ze,M);kx(h,p,xt,Ls(h))}else kx(h,p,M,Ls(h))}catch(vt){kx(h,p,{then:function(){},status:"rejected",reason:vt},Ls())}finally{K.p=L,J!==null&&pe.types!==null&&(J.types=pe.types),Y.T=J}}function Eie(){}function xE(h,p,_,M){if(h.tag!==5)throw Error(r(476));var P=b5(h).queue;x5(h,P,p,Z,_===null?Eie:function(){return y5(h),_(M)})}function b5(h){var p=h.memoizedState;if(p!==null)return p;p={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:uc,lastRenderedState:Z},next:null};var _={};return p.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:uc,lastRenderedState:_},next:null},h.memoizedState=p,h=h.alternate,h!==null&&(h.memoizedState=p),p}function y5(h){var p=b5(h);p.next===null&&(p=h.alternate.memoizedState),kx(h,p.next.queue,{},Ls())}function bE(){return ha(Wx)}function v5(){return ui().memoizedState}function _5(){return ui().memoizedState}function Tie(h){for(var p=h.return;p!==null;){switch(p.tag){case 24:case 3:var _=Ls();h=ju(_);var M=Pu(p,h,_);M!==null&&(ds(M,p,_),Mx(M,p,_)),p={cache:WM()},h.payload=p;return}p=p.return}}function Cie(h,p,_){var M=Ls();_={lane:M,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},wv(h)?S5(p,_):(_=LM(h,p,_,M),_!==null&&(ds(_,h,M),N5(_,p,M)))}function w5(h,p,_){var M=Ls();kx(h,p,_,M)}function kx(h,p,_,M){var P={lane:M,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(wv(h))S5(p,P);else{var L=h.alternate;if(h.lanes===0&&(L===null||L.lanes===0)&&(L=p.lastRenderedReducer,L!==null))try{var J=p.lastRenderedState,pe=L(J,_);if(P.hasEagerState=!0,P.eagerState=pe,ks(pe,J))return nv(h,p,P,0),Sr===null&&tv(),!1}catch{}finally{}if(_=LM(h,p,P,M),_!==null)return ds(_,h,M),N5(_,p,M),!0}return!1}function yE(h,p,_,M){if(M={lane:2,revertLane:QE(),gesture:null,action:M,hasEagerState:!1,eagerState:null,next:null},wv(h)){if(p)throw Error(r(479))}else p=LM(h,_,M,2),p!==null&&ds(p,h,2)}function wv(h){var p=h.alternate;return h===bn||p!==null&&p===bn}function S5(h,p){Em=pv=!0;var _=h.pending;_===null?p.next=p:(p.next=_.next,_.next=p),h.pending=p}function N5(h,p,_){if((_&4194048)!==0){var M=p.lanes;M&=h.pendingLanes,_|=M,p.lanes=_,en(h,_)}}var jx={readContext:ha,use:bv,useCallback:Jr,useContext:Jr,useEffect:Jr,useImperativeHandle:Jr,useLayoutEffect:Jr,useInsertionEffect:Jr,useMemo:Jr,useReducer:Jr,useRef:Jr,useState:Jr,useDebugValue:Jr,useDeferredValue:Jr,useTransition:Jr,useSyncExternalStore:Jr,useId:Jr,useHostTransitionStatus:Jr,useFormState:Jr,useActionState:Jr,useOptimistic:Jr,useMemoCache:Jr,useCacheRefresh:Jr};jx.useEffectEvent=Jr;var M5={readContext:ha,use:bv,useCallback:function(h,p){return Ha().memoizedState=[h,p===void 0?null:p],h},useContext:ha,useEffect:l5,useImperativeHandle:function(h,p,_){_=_!=null?_.concat([h]):null,vv(4194308,4,h5.bind(null,p,h),_)},useLayoutEffect:function(h,p){return vv(4194308,4,h,p)},useInsertionEffect:function(h,p){vv(4,2,h,p)},useMemo:function(h,p){var _=Ha();p=p===void 0?null:p;var M=h();if(jh){ve(!0);try{h()}finally{ve(!1)}}return _.memoizedState=[M,p],M},useReducer:function(h,p,_){var M=Ha();if(_!==void 0){var P=_(p);if(jh){ve(!0);try{_(p)}finally{ve(!1)}}}else P=p;return M.memoizedState=M.baseState=P,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:P},M.queue=h,h=h.dispatch=Cie.bind(null,bn,h),[M.memoizedState,h]},useRef:function(h){var p=Ha();return h={current:h},p.memoizedState=h},useState:function(h){h=hE(h);var p=h.queue,_=w5.bind(null,bn,p);return p.dispatch=_,[h.memoizedState,_]},useDebugValue:pE,useDeferredValue:function(h,p){var _=Ha();return gE(_,h,p)},useTransition:function(){var h=hE(!1);return h=x5.bind(null,bn,h.queue,!0,!1),Ha().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,p,_){var M=bn,P=Ha();if(Bn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=p(),Sr===null)throw Error(r(349));(Ln&127)!==0||qI(M,p,_)}P.memoizedState=_;var L={value:_,getSnapshot:p};return P.queue=L,l5(KI.bind(null,M,L,h),[h]),M.flags|=2048,Cm(9,{destroy:void 0},WI.bind(null,M,L,_,p),null),_},useId:function(){var h=Ha(),p=Sr.identifierPrefix;if(Bn){var _=xl,M=gl;_=(M&~(1<<32-Le(M)-1)).toString(32)+_,p="_"+p+"R_"+_,_=gv++,0<_&&(p+="H"+_.toString(32)),p+="_"}else _=_ie++,p="_"+p+"r_"+_.toString(32)+"_";return h.memoizedState=p},useHostTransitionStatus:bE,useFormState:r5,useActionState:r5,useOptimistic:function(h){var p=Ha();p.memoizedState=p.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return p.queue=_,p=yE.bind(null,bn,!0,_),_.dispatch=p,[h,p]},useMemoCache:cE,useCacheRefresh:function(){return Ha().memoizedState=Tie.bind(null,bn)},useEffectEvent:function(h){var p=Ha(),_={impl:h};return p.memoizedState=_,function(){if((Jn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},vE={readContext:ha,use:bv,useCallback:m5,useContext:ha,useEffect:mE,useImperativeHandle:f5,useInsertionEffect:u5,useLayoutEffect:d5,useMemo:p5,useReducer:yv,useRef:o5,useState:function(){return yv(uc)},useDebugValue:pE,useDeferredValue:function(h,p){var _=ui();return g5(_,dr.memoizedState,h,p)},useTransition:function(){var h=yv(uc)[0],p=ui().memoizedState;return[typeof h=="boolean"?h:Ax(h),p]},useSyncExternalStore:GI,useId:v5,useHostTransitionStatus:bE,useFormState:i5,useActionState:i5,useOptimistic:function(h,p){var _=ui();return QI(_,dr,h,p)},useMemoCache:cE,useCacheRefresh:_5};vE.useEffectEvent=c5;var E5={readContext:ha,use:bv,useCallback:m5,useContext:ha,useEffect:mE,useImperativeHandle:f5,useInsertionEffect:u5,useLayoutEffect:d5,useMemo:p5,useReducer:dE,useRef:o5,useState:function(){return dE(uc)},useDebugValue:pE,useDeferredValue:function(h,p){var _=ui();return dr===null?gE(_,h,p):g5(_,dr.memoizedState,h,p)},useTransition:function(){var h=dE(uc)[0],p=ui().memoizedState;return[typeof h=="boolean"?h:Ax(h),p]},useSyncExternalStore:GI,useId:v5,useHostTransitionStatus:bE,useFormState:s5,useActionState:s5,useOptimistic:function(h,p){var _=ui();return dr!==null?QI(_,dr,h,p):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:cE,useCacheRefresh:_5};E5.useEffectEvent=c5;function _E(h,p,_,M){p=h.memoizedState,_=_(M,p),_=_==null?p:f({},p,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var wE={enqueueSetState:function(h,p,_){h=h._reactInternals;var M=Ls(),P=ju(M);P.payload=p,_!=null&&(P.callback=_),p=Pu(h,P,M),p!==null&&(ds(p,h,M),Mx(p,h,M))},enqueueReplaceState:function(h,p,_){h=h._reactInternals;var M=Ls(),P=ju(M);P.tag=1,P.payload=p,_!=null&&(P.callback=_),p=Pu(h,P,M),p!==null&&(ds(p,h,M),Mx(p,h,M))},enqueueForceUpdate:function(h,p){h=h._reactInternals;var _=Ls(),M=ju(_);M.tag=2,p!=null&&(M.callback=p),p=Pu(h,M,_),p!==null&&(ds(p,h,_),Mx(p,h,_))}};function T5(h,p,_,M,P,L,J){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(M,L,J):p.prototype&&p.prototype.isPureReactComponent?!xx(_,M)||!xx(P,L):!0}function C5(h,p,_,M){h=p.state,typeof p.componentWillReceiveProps=="function"&&p.componentWillReceiveProps(_,M),typeof p.UNSAFE_componentWillReceiveProps=="function"&&p.UNSAFE_componentWillReceiveProps(_,M),p.state!==h&&wE.enqueueReplaceState(p,p.state,null)}function Ph(h,p){var _=p;if("ref"in p){_={};for(var M in p)M!=="ref"&&(_[M]=p[M])}if(h=h.defaultProps){_===p&&(_=f({},_));for(var P in h)_[P]===void 0&&(_[P]=h[P])}return _}function A5(h){ev(h)}function k5(h){console.error(h)}function j5(h){ev(h)}function Sv(h,p){try{var _=h.onUncaughtError;_(p.value,{componentStack:p.stack})}catch(M){setTimeout(function(){throw M})}}function P5(h,p,_){try{var M=h.onCaughtError;M(_.value,{componentStack:_.stack,errorBoundary:p.tag===1?p.stateNode:null})}catch(P){setTimeout(function(){throw P})}}function SE(h,p,_){return _=ju(_),_.tag=3,_.payload={element:null},_.callback=function(){Sv(h,p)},_}function R5(h){return h=ju(h),h.tag=3,h}function D5(h,p,_,M){var P=_.type.getDerivedStateFromError;if(typeof P=="function"){var L=M.value;h.payload=function(){return P(L)},h.callback=function(){P5(p,_,M)}}var J=_.stateNode;J!==null&&typeof J.componentDidCatch=="function"&&(h.callback=function(){P5(p,_,M),typeof P!="function"&&(Fu===null?Fu=new Set([this]):Fu.add(this));var pe=M.stack;this.componentDidCatch(M.value,{componentStack:pe!==null?pe:""})})}function Aie(h,p,_,M,P){if(_.flags|=32768,M!==null&&typeof M=="object"&&typeof M.then=="function"){if(p=_.alternate,p!==null&&vm(p,_,P,!0),_=Ps.current,_!==null){switch(_.tag){case 31:case 13:return oo===null?Ov():_.alternate===null&&ei===0&&(ei=3),_.flags&=-257,_.flags|=65536,_.lanes=P,M===uv?_.flags|=16384:(p=_.updateQueue,p===null?_.updateQueue=new Set([M]):p.add(M),KE(h,M,P)),!1;case 22:return _.flags|=65536,M===uv?_.flags|=16384:(p=_.updateQueue,p===null?(p={transitions:null,markerInstances:null,retryQueue:new Set([M])},_.updateQueue=p):(_=p.retryQueue,_===null?p.retryQueue=new Set([M]):_.add(M)),KE(h,M,P)),!1}throw Error(r(435,_.tag))}return KE(h,M,P),Ov(),!1}if(Bn)return p=Ps.current,p!==null?((p.flags&65536)===0&&(p.flags|=256),p.flags|=65536,p.lanes=P,M!==$M&&(h=Error(r(422),{cause:M}),vx(ro(h,_)))):(M!==$M&&(p=Error(r(423),{cause:M}),vx(ro(p,_))),h=h.current.alternate,h.flags|=65536,P&=-P,h.lanes|=P,M=ro(M,_),P=SE(h.stateNode,M,P),JM(h,P),ei!==4&&(ei=2)),!1;var L=Error(r(520),{cause:M});if(L=ro(L,_),Ux===null?Ux=[L]:Ux.push(L),ei!==4&&(ei=2),p===null)return!0;M=ro(M,_),_=p;do{switch(_.tag){case 3:return _.flags|=65536,h=P&-P,_.lanes|=h,h=SE(_.stateNode,M,h),JM(_,h),!1;case 1:if(p=_.type,L=_.stateNode,(_.flags&128)===0&&(typeof p.getDerivedStateFromError=="function"||L!==null&&typeof L.componentDidCatch=="function"&&(Fu===null||!Fu.has(L))))return _.flags|=65536,P&=-P,_.lanes|=P,P=R5(P),D5(P,h,_,M),JM(_,P),!1}_=_.return}while(_!==null);return!1}var NE=Error(r(461)),xi=!1;function fa(h,p,_,M){p.child=h===null?FI(p,null,_,M):kh(p,h.child,_,M)}function O5(h,p,_,M,P){_=_.render;var L=p.ref;if("ref"in M){var J={};for(var pe in M)pe!=="ref"&&(J[pe]=M[pe])}else J=M;return Eh(p),M=aE(h,p,_,J,L,P),pe=sE(),h!==null&&!xi?(oE(h,p,P),dc(h,p,P)):(Bn&&pe&&zM(p),p.flags|=1,fa(h,p,M,P),p.child)}function L5(h,p,_,M,P){if(h===null){var L=_.type;return typeof L=="function"&&!IM(L)&&L.defaultProps===void 0&&_.compare===null?(p.tag=15,p.type=L,I5(h,p,L,M,P)):(h=iv(_.type,null,M,p,p.mode,P),h.ref=p.ref,h.return=p,p.child=h)}if(L=h.child,!PE(h,P)){var J=L.memoizedProps;if(_=_.compare,_=_!==null?_:xx,_(J,M)&&h.ref===p.ref)return dc(h,p,P)}return p.flags|=1,h=ac(L,M),h.ref=p.ref,h.return=p,p.child=h}function I5(h,p,_,M,P){if(h!==null){var L=h.memoizedProps;if(xx(L,M)&&h.ref===p.ref)if(xi=!1,p.pendingProps=M=L,PE(h,P))(h.flags&131072)!==0&&(xi=!0);else return p.lanes=h.lanes,dc(h,p,P)}return ME(h,p,_,M,P)}function F5(h,p,_,M){var P=M.children,L=h!==null?h.memoizedState:null;if(h===null&&p.stateNode===null&&(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),M.mode==="hidden"){if((p.flags&128)!==0){if(L=L!==null?L.baseLanes|_:_,h!==null){for(M=p.child=h.child,P=0;M!==null;)P=P|M.lanes|M.childLanes,M=M.sibling;M=P&~L}else M=0,p.child=null;return U5(h,p,L,_,M)}if((_&536870912)!==0)p.memoizedState={baseLanes:0,cachePool:null},h!==null&&lv(p,L!==null?L.cachePool:null),L!==null?BI(p,L):tE(),$I(p);else return M=p.lanes=536870912,U5(h,p,L!==null?L.baseLanes|_:_,_,M)}else L!==null?(lv(p,L.cachePool),BI(p,L),Du(),p.memoizedState=null):(h!==null&&lv(p,null),tE(),Du());return fa(h,p,P,_),p.child}function Px(h,p){return h!==null&&h.tag===22||p.stateNode!==null||(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),p.sibling}function U5(h,p,_,M,P){var L=XM();return L=L===null?null:{parent:pi._currentValue,pool:L},p.memoizedState={baseLanes:_,cachePool:L},h!==null&&lv(p,null),tE(),$I(p),h!==null&&vm(h,p,M,!0),p.childLanes=P,null}function Nv(h,p){return p=Ev({mode:p.mode,children:p.children},h.mode),p.ref=h.ref,h.child=p,p.return=h,p}function z5(h,p,_){return kh(p,h.child,null,_),h=Nv(p,p.pendingProps),h.flags|=2,Rs(p),p.memoizedState=null,h}function kie(h,p,_){var M=p.pendingProps,P=(p.flags&128)!==0;if(p.flags&=-129,h===null){if(Bn){if(M.mode==="hidden")return h=Nv(p,M),p.lanes=536870912,Px(null,h);if(rE(p),(h=Pr)?(h=ZF(h,so),h=h!==null&&h.data==="&"?h:null,h!==null&&(p.memoizedState={dehydrated:h,treeContext:Eu!==null?{id:gl,overflow:xl}:null,retryLane:536870912,hydrationErrors:null},_=SI(h),_.return=p,p.child=_,da=p,Pr=null)):h=null,h===null)throw Cu(p);return p.lanes=536870912,null}return Nv(p,M)}var L=h.memoizedState;if(L!==null){var J=L.dehydrated;if(rE(p),P)if(p.flags&256)p.flags&=-257,p=z5(h,p,_);else if(p.memoizedState!==null)p.child=h.child,p.flags|=128,p=null;else throw Error(r(558));else if(xi||vm(h,p,_,!1),P=(_&h.childLanes)!==0,xi||P){if(M=Sr,M!==null&&(J=er(M,_),J!==0&&J!==L.retryLane))throw L.retryLane=J,wh(h,J),ds(M,h,J),NE;Ov(),p=z5(h,p,_)}else h=L.treeContext,Pr=lo(J.nextSibling),da=p,Bn=!0,Tu=null,so=!1,h!==null&&EI(p,h),p=Nv(p,M),p.flags|=4096;return p}return h=ac(h.child,{mode:M.mode,children:M.children}),h.ref=p.ref,p.child=h,h.return=p,h}function Mv(h,p){var _=p.ref;if(_===null)h!==null&&h.ref!==null&&(p.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(h===null||h.ref!==_)&&(p.flags|=4194816)}}function ME(h,p,_,M,P){return Eh(p),_=aE(h,p,_,M,void 0,P),M=sE(),h!==null&&!xi?(oE(h,p,P),dc(h,p,P)):(Bn&&M&&zM(p),p.flags|=1,fa(h,p,_,P),p.child)}function B5(h,p,_,M,P,L){return Eh(p),p.updateQueue=null,_=VI(p,M,_,P),HI(h),M=sE(),h!==null&&!xi?(oE(h,p,L),dc(h,p,L)):(Bn&&M&&zM(p),p.flags|=1,fa(h,p,_,L),p.child)}function $5(h,p,_,M,P){if(Eh(p),p.stateNode===null){var L=gm,J=_.contextType;typeof J=="object"&&J!==null&&(L=ha(J)),L=new _(M,L),p.memoizedState=L.state!==null&&L.state!==void 0?L.state:null,L.updater=wE,p.stateNode=L,L._reactInternals=p,L=p.stateNode,L.props=M,L.state=p.memoizedState,L.refs={},QM(p),J=_.contextType,L.context=typeof J=="object"&&J!==null?ha(J):gm,L.state=p.memoizedState,J=_.getDerivedStateFromProps,typeof J=="function"&&(_E(p,_,J,M),L.state=p.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof L.getSnapshotBeforeUpdate=="function"||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(J=L.state,typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount(),J!==L.state&&wE.enqueueReplaceState(L,L.state,null),Tx(p,M,L,P),Ex(),L.state=p.memoizedState),typeof L.componentDidMount=="function"&&(p.flags|=4194308),M=!0}else if(h===null){L=p.stateNode;var pe=p.memoizedProps,ze=Ph(_,pe);L.props=ze;var rt=L.context,xt=_.contextType;J=gm,typeof xt=="object"&&xt!==null&&(J=ha(xt));var vt=_.getDerivedStateFromProps;xt=typeof vt=="function"||typeof L.getSnapshotBeforeUpdate=="function",pe=p.pendingProps!==pe,xt||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(pe||rt!==J)&&C5(p,L,M,J),ku=!1;var at=p.memoizedState;L.state=at,Tx(p,M,L,P),Ex(),rt=p.memoizedState,pe||at!==rt||ku?(typeof vt=="function"&&(_E(p,_,vt,M),rt=p.memoizedState),(ze=ku||T5(p,_,ze,M,at,rt,J))?(xt||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount()),typeof L.componentDidMount=="function"&&(p.flags|=4194308)):(typeof L.componentDidMount=="function"&&(p.flags|=4194308),p.memoizedProps=M,p.memoizedState=rt),L.props=M,L.state=rt,L.context=J,M=ze):(typeof L.componentDidMount=="function"&&(p.flags|=4194308),M=!1)}else{L=p.stateNode,ZM(h,p),J=p.memoizedProps,xt=Ph(_,J),L.props=xt,vt=p.pendingProps,at=L.context,rt=_.contextType,ze=gm,typeof rt=="object"&&rt!==null&&(ze=ha(rt)),pe=_.getDerivedStateFromProps,(rt=typeof pe=="function"||typeof L.getSnapshotBeforeUpdate=="function")||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(J!==vt||at!==ze)&&C5(p,L,M,ze),ku=!1,at=p.memoizedState,L.state=at,Tx(p,M,L,P),Ex();var ft=p.memoizedState;J!==vt||at!==ft||ku||h!==null&&h.dependencies!==null&&sv(h.dependencies)?(typeof pe=="function"&&(_E(p,_,pe,M),ft=p.memoizedState),(xt=ku||T5(p,_,xt,M,at,ft,ze)||h!==null&&h.dependencies!==null&&sv(h.dependencies))?(rt||typeof L.UNSAFE_componentWillUpdate!="function"&&typeof L.componentWillUpdate!="function"||(typeof L.componentWillUpdate=="function"&&L.componentWillUpdate(M,ft,ze),typeof L.UNSAFE_componentWillUpdate=="function"&&L.UNSAFE_componentWillUpdate(M,ft,ze)),typeof L.componentDidUpdate=="function"&&(p.flags|=4),typeof L.getSnapshotBeforeUpdate=="function"&&(p.flags|=1024)):(typeof L.componentDidUpdate!="function"||J===h.memoizedProps&&at===h.memoizedState||(p.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||J===h.memoizedProps&&at===h.memoizedState||(p.flags|=1024),p.memoizedProps=M,p.memoizedState=ft),L.props=M,L.state=ft,L.context=ze,M=xt):(typeof L.componentDidUpdate!="function"||J===h.memoizedProps&&at===h.memoizedState||(p.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||J===h.memoizedProps&&at===h.memoizedState||(p.flags|=1024),M=!1)}return L=M,Mv(h,p),M=(p.flags&128)!==0,L||M?(L=p.stateNode,_=M&&typeof _.getDerivedStateFromError!="function"?null:L.render(),p.flags|=1,h!==null&&M?(p.child=kh(p,h.child,null,P),p.child=kh(p,null,_,P)):fa(h,p,_,P),p.memoizedState=L.state,h=p.child):h=dc(h,p,P),h}function H5(h,p,_,M){return Nh(),p.flags|=256,fa(h,p,_,M),p.child}var EE={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function TE(h){return{baseLanes:h,cachePool:PI()}}function CE(h,p,_){return h=h!==null?h.childLanes&~_:0,p&&(h|=Os),h}function V5(h,p,_){var M=p.pendingProps,P=!1,L=(p.flags&128)!==0,J;if((J=L)||(J=h!==null&&h.memoizedState===null?!1:(ci.current&2)!==0),J&&(P=!0,p.flags&=-129),J=(p.flags&32)!==0,p.flags&=-33,h===null){if(Bn){if(P?Ru(p):Du(),(h=Pr)?(h=ZF(h,so),h=h!==null&&h.data!=="&"?h:null,h!==null&&(p.memoizedState={dehydrated:h,treeContext:Eu!==null?{id:gl,overflow:xl}:null,retryLane:536870912,hydrationErrors:null},_=SI(h),_.return=p,p.child=_,da=p,Pr=null)):h=null,h===null)throw Cu(p);return uT(h)?p.lanes=32:p.lanes=536870912,null}var pe=M.children;return M=M.fallback,P?(Du(),P=p.mode,pe=Ev({mode:"hidden",children:pe},P),M=Sh(M,P,_,null),pe.return=p,M.return=p,pe.sibling=M,p.child=pe,M=p.child,M.memoizedState=TE(_),M.childLanes=CE(h,J,_),p.memoizedState=EE,Px(null,M)):(Ru(p),AE(p,pe))}var ze=h.memoizedState;if(ze!==null&&(pe=ze.dehydrated,pe!==null)){if(L)p.flags&256?(Ru(p),p.flags&=-257,p=kE(h,p,_)):p.memoizedState!==null?(Du(),p.child=h.child,p.flags|=128,p=null):(Du(),pe=M.fallback,P=p.mode,M=Ev({mode:"visible",children:M.children},P),pe=Sh(pe,P,_,null),pe.flags|=2,M.return=p,pe.return=p,M.sibling=pe,p.child=M,kh(p,h.child,null,_),M=p.child,M.memoizedState=TE(_),M.childLanes=CE(h,J,_),p.memoizedState=EE,p=Px(null,M));else if(Ru(p),uT(pe)){if(J=pe.nextSibling&&pe.nextSibling.dataset,J)var rt=J.dgst;J=rt,M=Error(r(419)),M.stack="",M.digest=J,vx({value:M,source:null,stack:null}),p=kE(h,p,_)}else if(xi||vm(h,p,_,!1),J=(_&h.childLanes)!==0,xi||J){if(J=Sr,J!==null&&(M=er(J,_),M!==0&&M!==ze.retryLane))throw ze.retryLane=M,wh(h,M),ds(J,h,M),NE;cT(pe)||Ov(),p=kE(h,p,_)}else cT(pe)?(p.flags|=192,p.child=h.child,p=null):(h=ze.treeContext,Pr=lo(pe.nextSibling),da=p,Bn=!0,Tu=null,so=!1,h!==null&&EI(p,h),p=AE(p,M.children),p.flags|=4096);return p}return P?(Du(),pe=M.fallback,P=p.mode,ze=h.child,rt=ze.sibling,M=ac(ze,{mode:"hidden",children:M.children}),M.subtreeFlags=ze.subtreeFlags&65011712,rt!==null?pe=ac(rt,pe):(pe=Sh(pe,P,_,null),pe.flags|=2),pe.return=p,M.return=p,M.sibling=pe,p.child=M,Px(null,M),M=p.child,pe=h.child.memoizedState,pe===null?pe=TE(_):(P=pe.cachePool,P!==null?(ze=pi._currentValue,P=P.parent!==ze?{parent:ze,pool:ze}:P):P=PI(),pe={baseLanes:pe.baseLanes|_,cachePool:P}),M.memoizedState=pe,M.childLanes=CE(h,J,_),p.memoizedState=EE,Px(h.child,M)):(Ru(p),_=h.child,h=_.sibling,_=ac(_,{mode:"visible",children:M.children}),_.return=p,_.sibling=null,h!==null&&(J=p.deletions,J===null?(p.deletions=[h],p.flags|=16):J.push(h)),p.child=_,p.memoizedState=null,_)}function AE(h,p){return p=Ev({mode:"visible",children:p},h.mode),p.return=h,h.child=p}function Ev(h,p){return h=js(22,h,null,p),h.lanes=0,h}function kE(h,p,_){return kh(p,h.child,null,_),h=AE(p,p.pendingProps.children),h.flags|=2,p.memoizedState=null,h}function G5(h,p,_){h.lanes|=p;var M=h.alternate;M!==null&&(M.lanes|=p),GM(h.return,p,_)}function jE(h,p,_,M,P,L){var J=h.memoizedState;J===null?h.memoizedState={isBackwards:p,rendering:null,renderingStartTime:0,last:M,tail:_,tailMode:P,treeForkCount:L}:(J.isBackwards=p,J.rendering=null,J.renderingStartTime=0,J.last=M,J.tail=_,J.tailMode=P,J.treeForkCount=L)}function q5(h,p,_){var M=p.pendingProps,P=M.revealOrder,L=M.tail;M=M.children;var J=ci.current,pe=(J&2)!==0;if(pe?(J=J&1|2,p.flags|=128):J&=1,se(ci,J),fa(h,p,M,_),M=Bn?yx:0,!pe&&h!==null&&(h.flags&128)!==0)e:for(h=p.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&G5(h,_,p);else if(h.tag===19)G5(h,_,p);else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===p)break e;for(;h.sibling===null;){if(h.return===null||h.return===p)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}switch(P){case"forwards":for(_=p.child,P=null;_!==null;)h=_.alternate,h!==null&&mv(h)===null&&(P=_),_=_.sibling;_=P,_===null?(P=p.child,p.child=null):(P=_.sibling,_.sibling=null),jE(p,!1,P,_,L,M);break;case"backwards":case"unstable_legacy-backwards":for(_=null,P=p.child,p.child=null;P!==null;){if(h=P.alternate,h!==null&&mv(h)===null){p.child=P;break}h=P.sibling,P.sibling=_,_=P,P=h}jE(p,!0,_,null,L,M);break;case"together":jE(p,!1,null,null,void 0,M);break;default:p.memoizedState=null}return p.child}function dc(h,p,_){if(h!==null&&(p.dependencies=h.dependencies),Iu|=p.lanes,(_&p.childLanes)===0)if(h!==null){if(vm(h,p,_,!1),(_&p.childLanes)===0)return null}else return null;if(h!==null&&p.child!==h.child)throw Error(r(153));if(p.child!==null){for(h=p.child,_=ac(h,h.pendingProps),p.child=_,_.return=p;h.sibling!==null;)h=h.sibling,_=_.sibling=ac(h,h.pendingProps),_.return=p;_.sibling=null}return p.child}function PE(h,p){return(h.lanes&p)!==0?!0:(h=h.dependencies,!!(h!==null&&sv(h)))}function jie(h,p,_){switch(p.tag){case 3:be(p,p.stateNode.containerInfo),Au(p,pi,h.memoizedState.cache),Nh();break;case 27:case 5:Ce(p);break;case 4:be(p,p.stateNode.containerInfo);break;case 10:Au(p,p.type,p.memoizedProps.value);break;case 31:if(p.memoizedState!==null)return p.flags|=128,rE(p),null;break;case 13:var M=p.memoizedState;if(M!==null)return M.dehydrated!==null?(Ru(p),p.flags|=128,null):(_&p.child.childLanes)!==0?V5(h,p,_):(Ru(p),h=dc(h,p,_),h!==null?h.sibling:null);Ru(p);break;case 19:var P=(h.flags&128)!==0;if(M=(_&p.childLanes)!==0,M||(vm(h,p,_,!1),M=(_&p.childLanes)!==0),P){if(M)return q5(h,p,_);p.flags|=128}if(P=p.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),se(ci,ci.current),M)break;return null;case 22:return p.lanes=0,F5(h,p,_,p.pendingProps);case 24:Au(p,pi,h.memoizedState.cache)}return dc(h,p,_)}function W5(h,p,_){if(h!==null)if(h.memoizedProps!==p.pendingProps)xi=!0;else{if(!PE(h,_)&&(p.flags&128)===0)return xi=!1,jie(h,p,_);xi=(h.flags&131072)!==0}else xi=!1,Bn&&(p.flags&1048576)!==0&&MI(p,yx,p.index);switch(p.lanes=0,p.tag){case 16:e:{var M=p.pendingProps;if(h=Ch(p.elementType),p.type=h,typeof h=="function")IM(h)?(M=Ph(h,M),p.tag=1,p=$5(null,p,h,M,_)):(p.tag=0,p=ME(null,p,h,M,_));else{if(h!=null){var P=h.$$typeof;if(P===T){p.tag=11,p=O5(null,p,h,M,_);break e}else if(P===C){p.tag=14,p=L5(null,p,h,M,_);break e}}throw p=j(h)||h,Error(r(306,p,""))}}return p;case 0:return ME(h,p,p.type,p.pendingProps,_);case 1:return M=p.type,P=Ph(M,p.pendingProps),$5(h,p,M,P,_);case 3:e:{if(be(p,p.stateNode.containerInfo),h===null)throw Error(r(387));M=p.pendingProps;var L=p.memoizedState;P=L.element,ZM(h,p),Tx(p,M,null,_);var J=p.memoizedState;if(M=J.cache,Au(p,pi,M),M!==L.cache&&qM(p,[pi],_,!0),Ex(),M=J.element,L.isDehydrated)if(L={element:M,isDehydrated:!1,cache:J.cache},p.updateQueue.baseState=L,p.memoizedState=L,p.flags&256){p=H5(h,p,M,_);break e}else if(M!==P){P=ro(Error(r(424)),p),vx(P),p=H5(h,p,M,_);break e}else{switch(h=p.stateNode.containerInfo,h.nodeType){case 9:h=h.body;break;default:h=h.nodeName==="HTML"?h.ownerDocument.body:h}for(Pr=lo(h.firstChild),da=p,Bn=!0,Tu=null,so=!0,_=FI(p,null,M,_),p.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(Nh(),M===P){p=dc(h,p,_);break e}fa(h,p,M,_)}p=p.child}return p;case 26:return Mv(h,p),h===null?(_=iU(p.type,null,p.pendingProps,null))?p.memoizedState=_:Bn||(_=p.type,h=p.pendingProps,M=$v(me.current).createElement(_),M[Xt]=p,M[zn]=h,ma(M,_,h),Ie(M),p.stateNode=M):p.memoizedState=iU(p.type,h.memoizedProps,p.pendingProps,h.memoizedState),null;case 27:return Ce(p),h===null&&Bn&&(M=p.stateNode=tU(p.type,p.pendingProps,me.current),da=p,so=!0,P=Pr,$u(p.type)?(dT=P,Pr=lo(M.firstChild)):Pr=P),fa(h,p,p.pendingProps.children,_),Mv(h,p),h===null&&(p.flags|=4194304),p.child;case 5:return h===null&&Bn&&((P=M=Pr)&&(M=oae(M,p.type,p.pendingProps,so),M!==null?(p.stateNode=M,da=p,Pr=lo(M.firstChild),so=!1,P=!0):P=!1),P||Cu(p)),Ce(p),P=p.type,L=p.pendingProps,J=h!==null?h.memoizedProps:null,M=L.children,sT(P,L)?M=null:J!==null&&sT(P,J)&&(p.flags|=32),p.memoizedState!==null&&(P=aE(h,p,wie,null,null,_),Wx._currentValue=P),Mv(h,p),fa(h,p,M,_),p.child;case 6:return h===null&&Bn&&((h=_=Pr)&&(_=lae(_,p.pendingProps,so),_!==null?(p.stateNode=_,da=p,Pr=null,h=!0):h=!1),h||Cu(p)),null;case 13:return V5(h,p,_);case 4:return be(p,p.stateNode.containerInfo),M=p.pendingProps,h===null?p.child=kh(p,null,M,_):fa(h,p,M,_),p.child;case 11:return O5(h,p,p.type,p.pendingProps,_);case 7:return fa(h,p,p.pendingProps,_),p.child;case 8:return fa(h,p,p.pendingProps.children,_),p.child;case 12:return fa(h,p,p.pendingProps.children,_),p.child;case 10:return M=p.pendingProps,Au(p,p.type,M.value),fa(h,p,M.children,_),p.child;case 9:return P=p.type._context,M=p.pendingProps.children,Eh(p),P=ha(P),M=M(P),p.flags|=1,fa(h,p,M,_),p.child;case 14:return L5(h,p,p.type,p.pendingProps,_);case 15:return I5(h,p,p.type,p.pendingProps,_);case 19:return q5(h,p,_);case 31:return kie(h,p,_);case 22:return F5(h,p,_,p.pendingProps);case 24:return Eh(p),M=ha(pi),h===null?(P=XM(),P===null&&(P=Sr,L=WM(),P.pooledCache=L,L.refCount++,L!==null&&(P.pooledCacheLanes|=_),P=L),p.memoizedState={parent:M,cache:P},QM(p),Au(p,pi,P)):((h.lanes&_)!==0&&(ZM(h,p),Tx(p,null,null,_),Ex()),P=h.memoizedState,L=p.memoizedState,P.parent!==M?(P={parent:M,cache:M},p.memoizedState=P,p.lanes===0&&(p.memoizedState=p.updateQueue.baseState=P),Au(p,pi,M)):(M=L.cache,Au(p,pi,M),M!==P.cache&&qM(p,[pi],_,!0))),fa(h,p,p.pendingProps.children,_),p.child;case 29:throw p.pendingProps}throw Error(r(156,p.tag))}function hc(h){h.flags|=4}function RE(h,p,_,M,P){if((p=(h.mode&32)!==0)&&(p=!1),p){if(h.flags|=16777216,(P&335544128)===P)if(h.stateNode.complete)h.flags|=8192;else if(vF())h.flags|=8192;else throw Ah=uv,YM}else h.flags&=-16777217}function K5(h,p){if(p.type!=="stylesheet"||(p.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!cU(p))if(vF())h.flags|=8192;else throw Ah=uv,YM}function Tv(h,p){p!==null&&(h.flags|=4),h.flags&16384&&(p=h.tag!==22?At():536870912,h.lanes|=p,Pm|=p)}function Rx(h,p){if(!Bn)switch(h.tailMode){case"hidden":p=h.tail;for(var _=null;p!==null;)p.alternate!==null&&(_=p),p=p.sibling;_===null?h.tail=null:_.sibling=null;break;case"collapsed":_=h.tail;for(var M=null;_!==null;)_.alternate!==null&&(M=_),_=_.sibling;M===null?p||h.tail===null?h.tail=null:h.tail.sibling=null:M.sibling=null}}function Rr(h){var p=h.alternate!==null&&h.alternate.child===h.child,_=0,M=0;if(p)for(var P=h.child;P!==null;)_|=P.lanes|P.childLanes,M|=P.subtreeFlags&65011712,M|=P.flags&65011712,P.return=h,P=P.sibling;else for(P=h.child;P!==null;)_|=P.lanes|P.childLanes,M|=P.subtreeFlags,M|=P.flags,P.return=h,P=P.sibling;return h.subtreeFlags|=M,h.childLanes=_,p}function Pie(h,p,_){var M=p.pendingProps;switch(BM(p),p.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Rr(p),null;case 1:return Rr(p),null;case 3:return _=p.stateNode,M=null,h!==null&&(M=h.memoizedState.cache),p.memoizedState.cache!==M&&(p.flags|=2048),lc(pi),fe(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(ym(p)?hc(p):h===null||h.memoizedState.isDehydrated&&(p.flags&256)===0||(p.flags|=1024,HM())),Rr(p),null;case 26:var P=p.type,L=p.memoizedState;return h===null?(hc(p),L!==null?(Rr(p),K5(p,L)):(Rr(p),RE(p,P,null,M,_))):L?L!==h.memoizedState?(hc(p),Rr(p),K5(p,L)):(Rr(p),p.flags&=-16777217):(h=h.memoizedProps,h!==M&&hc(p),Rr(p),RE(p,P,h,M,_)),null;case 27:if(Ne(p),_=me.current,P=p.type,h!==null&&p.stateNode!=null)h.memoizedProps!==M&&hc(p);else{if(!M){if(p.stateNode===null)throw Error(r(166));return Rr(p),null}h=ae.current,ym(p)?TI(p):(h=tU(P,M,_),p.stateNode=h,hc(p))}return Rr(p),null;case 5:if(Ne(p),P=p.type,h!==null&&p.stateNode!=null)h.memoizedProps!==M&&hc(p);else{if(!M){if(p.stateNode===null)throw Error(r(166));return Rr(p),null}if(L=ae.current,ym(p))TI(p);else{var J=$v(me.current);switch(L){case 1:L=J.createElementNS("http://www.w3.org/2000/svg",P);break;case 2:L=J.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;default:switch(P){case"svg":L=J.createElementNS("http://www.w3.org/2000/svg",P);break;case"math":L=J.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;case"script":L=J.createElement("div"),L.innerHTML="<script><\/script>",L=L.removeChild(L.firstChild);break;case"select":L=typeof M.is=="string"?J.createElement("select",{is:M.is}):J.createElement("select"),M.multiple?L.multiple=!0:M.size&&(L.size=M.size);break;default:L=typeof M.is=="string"?J.createElement(P,{is:M.is}):J.createElement(P)}}L[Xt]=p,L[zn]=M;e:for(J=p.child;J!==null;){if(J.tag===5||J.tag===6)L.appendChild(J.stateNode);else if(J.tag!==4&&J.tag!==27&&J.child!==null){J.child.return=J,J=J.child;continue}if(J===p)break e;for(;J.sibling===null;){if(J.return===null||J.return===p)break e;J=J.return}J.sibling.return=J.return,J=J.sibling}p.stateNode=L;e:switch(ma(L,P,M),P){case"button":case"input":case"select":case"textarea":M=!!M.autoFocus;break e;case"img":M=!0;break e;default:M=!1}M&&hc(p)}}return Rr(p),RE(p,p.type,h===null?null:h.memoizedProps,p.pendingProps,_),null;case 6:if(h&&p.stateNode!=null)h.memoizedProps!==M&&hc(p);else{if(typeof M!="string"&&p.stateNode===null)throw Error(r(166));if(h=me.current,ym(p)){if(h=p.stateNode,_=p.memoizedProps,M=null,P=da,P!==null)switch(P.tag){case 27:case 5:M=P.memoizedProps}h[Xt]=p,h=!!(h.nodeValue===_||M!==null&&M.suppressHydrationWarning===!0||VF(h.nodeValue,_)),h||Cu(p,!0)}else h=$v(h).createTextNode(M),h[Xt]=p,p.stateNode=h}return Rr(p),null;case 31:if(_=p.memoizedState,h===null||h.memoizedState!==null){if(M=ym(p),_!==null){if(h===null){if(!M)throw Error(r(318));if(h=p.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(557));h[Xt]=p}else Nh(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;Rr(p),h=!1}else _=HM(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return p.flags&256?(Rs(p),p):(Rs(p),null);if((p.flags&128)!==0)throw Error(r(558))}return Rr(p),null;case 13:if(M=p.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(P=ym(p),M!==null&&M.dehydrated!==null){if(h===null){if(!P)throw Error(r(318));if(P=p.memoizedState,P=P!==null?P.dehydrated:null,!P)throw Error(r(317));P[Xt]=p}else Nh(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;Rr(p),P=!1}else P=HM(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=P),P=!0;if(!P)return p.flags&256?(Rs(p),p):(Rs(p),null)}return Rs(p),(p.flags&128)!==0?(p.lanes=_,p):(_=M!==null,h=h!==null&&h.memoizedState!==null,_&&(M=p.child,P=null,M.alternate!==null&&M.alternate.memoizedState!==null&&M.alternate.memoizedState.cachePool!==null&&(P=M.alternate.memoizedState.cachePool.pool),L=null,M.memoizedState!==null&&M.memoizedState.cachePool!==null&&(L=M.memoizedState.cachePool.pool),L!==P&&(M.flags|=2048)),_!==h&&_&&(p.child.flags|=8192),Tv(p,p.updateQueue),Rr(p),null);case 4:return fe(),h===null&&tT(p.stateNode.containerInfo),Rr(p),null;case 10:return lc(p.type),Rr(p),null;case 19:if(W(ci),M=p.memoizedState,M===null)return Rr(p),null;if(P=(p.flags&128)!==0,L=M.rendering,L===null)if(P)Rx(M,!1);else{if(ei!==0||h!==null&&(h.flags&128)!==0)for(h=p.child;h!==null;){if(L=mv(h),L!==null){for(p.flags|=128,Rx(M,!1),h=L.updateQueue,p.updateQueue=h,Tv(p,h),p.subtreeFlags=0,h=_,_=p.child;_!==null;)wI(_,h),_=_.sibling;return se(ci,ci.current&1|2),Bn&&sc(p,M.treeForkCount),p.child}h=h.sibling}M.tail!==null&&I()>Pv&&(p.flags|=128,P=!0,Rx(M,!1),p.lanes=4194304)}else{if(!P)if(h=mv(L),h!==null){if(p.flags|=128,P=!0,h=h.updateQueue,p.updateQueue=h,Tv(p,h),Rx(M,!0),M.tail===null&&M.tailMode==="hidden"&&!L.alternate&&!Bn)return Rr(p),null}else 2*I()-M.renderingStartTime>Pv&&_!==536870912&&(p.flags|=128,P=!0,Rx(M,!1),p.lanes=4194304);M.isBackwards?(L.sibling=p.child,p.child=L):(h=M.last,h!==null?h.sibling=L:p.child=L,M.last=L)}return M.tail!==null?(h=M.tail,M.rendering=h,M.tail=h.sibling,M.renderingStartTime=I(),h.sibling=null,_=ci.current,se(ci,P?_&1|2:_&1),Bn&&sc(p,M.treeForkCount),h):(Rr(p),null);case 22:case 23:return Rs(p),nE(),M=p.memoizedState!==null,h!==null?h.memoizedState!==null!==M&&(p.flags|=8192):M&&(p.flags|=8192),M?(_&536870912)!==0&&(p.flags&128)===0&&(Rr(p),p.subtreeFlags&6&&(p.flags|=8192)):Rr(p),_=p.updateQueue,_!==null&&Tv(p,_.retryQueue),_=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),M=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(M=p.memoizedState.cachePool.pool),M!==_&&(p.flags|=2048),h!==null&&W(Th),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),p.memoizedState.cache!==_&&(p.flags|=2048),lc(pi),Rr(p),null;case 25:return null;case 30:return null}throw Error(r(156,p.tag))}function Rie(h,p){switch(BM(p),p.tag){case 1:return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 3:return lc(pi),fe(),h=p.flags,(h&65536)!==0&&(h&128)===0?(p.flags=h&-65537|128,p):null;case 26:case 27:case 5:return Ne(p),null;case 31:if(p.memoizedState!==null){if(Rs(p),p.alternate===null)throw Error(r(340));Nh()}return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 13:if(Rs(p),h=p.memoizedState,h!==null&&h.dehydrated!==null){if(p.alternate===null)throw Error(r(340));Nh()}return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 19:return W(ci),null;case 4:return fe(),null;case 10:return lc(p.type),null;case 22:case 23:return Rs(p),nE(),h!==null&&W(Th),h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 24:return lc(pi),null;case 25:return null;default:return null}}function X5(h,p){switch(BM(p),p.tag){case 3:lc(pi),fe();break;case 26:case 27:case 5:Ne(p);break;case 4:fe();break;case 31:p.memoizedState!==null&&Rs(p);break;case 13:Rs(p);break;case 19:W(ci);break;case 10:lc(p.type);break;case 22:case 23:Rs(p),nE(),h!==null&&W(Th);break;case 24:lc(pi)}}function Dx(h,p){try{var _=p.updateQueue,M=_!==null?_.lastEffect:null;if(M!==null){var P=M.next;_=P;do{if((_.tag&h)===h){M=void 0;var L=_.create,J=_.inst;M=L(),J.destroy=M}_=_.next}while(_!==P)}}catch(pe){ar(p,p.return,pe)}}function Ou(h,p,_){try{var M=p.updateQueue,P=M!==null?M.lastEffect:null;if(P!==null){var L=P.next;M=L;do{if((M.tag&h)===h){var J=M.inst,pe=J.destroy;if(pe!==void 0){J.destroy=void 0,P=p;var ze=_,rt=pe;try{rt()}catch(xt){ar(P,ze,xt)}}}M=M.next}while(M!==L)}}catch(xt){ar(p,p.return,xt)}}function Y5(h){var p=h.updateQueue;if(p!==null){var _=h.stateNode;try{zI(p,_)}catch(M){ar(h,h.return,M)}}}function Q5(h,p,_){_.props=Ph(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(M){ar(h,p,M)}}function Ox(h,p){try{var _=h.ref;if(_!==null){switch(h.tag){case 26:case 27:case 5:var M=h.stateNode;break;case 30:M=h.stateNode;break;default:M=h.stateNode}typeof _=="function"?h.refCleanup=_(M):_.current=M}}catch(P){ar(h,p,P)}}function bl(h,p){var _=h.ref,M=h.refCleanup;if(_!==null)if(typeof M=="function")try{M()}catch(P){ar(h,p,P)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(P){ar(h,p,P)}else _.current=null}function Z5(h){var p=h.type,_=h.memoizedProps,M=h.stateNode;try{e:switch(p){case"button":case"input":case"select":case"textarea":_.autoFocus&&M.focus();break e;case"img":_.src?M.src=_.src:_.srcSet&&(M.srcset=_.srcSet)}}catch(P){ar(h,h.return,P)}}function DE(h,p,_){try{var M=h.stateNode;tae(M,h.type,_,p),M[zn]=p}catch(P){ar(h,h.return,P)}}function J5(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&$u(h.type)||h.tag===4}function OE(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||J5(h.return))return null;h=h.return}for(h.sibling.return=h.return,h=h.sibling;h.tag!==5&&h.tag!==6&&h.tag!==18;){if(h.tag===27&&$u(h.type)||h.flags&2||h.child===null||h.tag===4)continue e;h.child.return=h,h=h.child}if(!(h.flags&2))return h.stateNode}}function LE(h,p,_){var M=h.tag;if(M===5||M===6)h=h.stateNode,p?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(h,p):(p=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,p.appendChild(h),_=_._reactRootContainer,_!=null||p.onclick!==null||(p.onclick=ca));else if(M!==4&&(M===27&&$u(h.type)&&(_=h.stateNode,p=null),h=h.child,h!==null))for(LE(h,p,_),h=h.sibling;h!==null;)LE(h,p,_),h=h.sibling}function Cv(h,p,_){var M=h.tag;if(M===5||M===6)h=h.stateNode,p?_.insertBefore(h,p):_.appendChild(h);else if(M!==4&&(M===27&&$u(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(Cv(h,p,_),h=h.sibling;h!==null;)Cv(h,p,_),h=h.sibling}function eF(h){var p=h.stateNode,_=h.memoizedProps;try{for(var M=h.type,P=p.attributes;P.length;)p.removeAttributeNode(P[0]);ma(p,M,_),p[Xt]=h,p[zn]=_}catch(L){ar(h,h.return,L)}}var fc=!1,bi=!1,IE=!1,tF=typeof WeakSet=="function"?WeakSet:Set,Wi=null;function Die(h,p){if(h=h.containerInfo,iT=Xv,h=fI(h),kM(h)){if("selectionStart"in h)var _={start:h.selectionStart,end:h.selectionEnd};else e:{_=(_=h.ownerDocument)&&_.defaultView||window;var M=_.getSelection&&_.getSelection();if(M&&M.rangeCount!==0){_=M.anchorNode;var P=M.anchorOffset,L=M.focusNode;M=M.focusOffset;try{_.nodeType,L.nodeType}catch{_=null;break e}var J=0,pe=-1,ze=-1,rt=0,xt=0,vt=h,at=null;t:for(;;){for(var ft;vt!==_||P!==0&&vt.nodeType!==3||(pe=J+P),vt!==L||M!==0&&vt.nodeType!==3||(ze=J+M),vt.nodeType===3&&(J+=vt.nodeValue.length),(ft=vt.firstChild)!==null;)at=vt,vt=ft;for(;;){if(vt===h)break t;if(at===_&&++rt===P&&(pe=J),at===L&&++xt===M&&(ze=J),(ft=vt.nextSibling)!==null)break;vt=at,at=vt.parentNode}vt=ft}_=pe===-1||ze===-1?null:{start:pe,end:ze}}else _=null}_=_||{start:0,end:0}}else _=null;for(aT={focusedElem:h,selectionRange:_},Xv=!1,Wi=p;Wi!==null;)if(p=Wi,h=p.child,(p.subtreeFlags&1028)!==0&&h!==null)h.return=p,Wi=h;else for(;Wi!==null;){switch(p=Wi,L=p.alternate,h=p.flags,p.tag){case 0:if((h&4)!==0&&(h=p.updateQueue,h=h!==null?h.events:null,h!==null))for(_=0;_<h.length;_++)P=h[_],P.ref.impl=P.nextImpl;break;case 11:case 15:break;case 1:if((h&1024)!==0&&L!==null){h=void 0,_=p,P=L.memoizedProps,L=L.memoizedState,M=_.stateNode;try{var Vt=Ph(_.type,P);h=M.getSnapshotBeforeUpdate(Vt,L),M.__reactInternalSnapshotBeforeUpdate=h}catch(rn){ar(_,_.return,rn)}}break;case 3:if((h&1024)!==0){if(h=p.stateNode.containerInfo,_=h.nodeType,_===9)lT(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":lT(h);break;default:h.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((h&1024)!==0)throw Error(r(163))}if(h=p.sibling,h!==null){h.return=p.return,Wi=h;break}Wi=p.return}}function nF(h,p,_){var M=_.flags;switch(_.tag){case 0:case 11:case 15:pc(h,_),M&4&&Dx(5,_);break;case 1:if(pc(h,_),M&4)if(h=_.stateNode,p===null)try{h.componentDidMount()}catch(J){ar(_,_.return,J)}else{var P=Ph(_.type,p.memoizedProps);p=p.memoizedState;try{h.componentDidUpdate(P,p,h.__reactInternalSnapshotBeforeUpdate)}catch(J){ar(_,_.return,J)}}M&64&&Y5(_),M&512&&Ox(_,_.return);break;case 3:if(pc(h,_),M&64&&(h=_.updateQueue,h!==null)){if(p=null,_.child!==null)switch(_.child.tag){case 27:case 5:p=_.child.stateNode;break;case 1:p=_.child.stateNode}try{zI(h,p)}catch(J){ar(_,_.return,J)}}break;case 27:p===null&&M&4&&eF(_);case 26:case 5:pc(h,_),p===null&&M&4&&Z5(_),M&512&&Ox(_,_.return);break;case 12:pc(h,_);break;case 31:pc(h,_),M&4&&aF(h,_);break;case 13:pc(h,_),M&4&&sF(h,_),M&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=Hie.bind(null,_),cae(h,_))));break;case 22:if(M=_.memoizedState!==null||fc,!M){p=p!==null&&p.memoizedState!==null||bi,P=fc;var L=bi;fc=M,(bi=p)&&!L?gc(h,_,(_.subtreeFlags&8772)!==0):pc(h,_),fc=P,bi=L}break;case 30:break;default:pc(h,_)}}function rF(h){var p=h.alternate;p!==null&&(h.alternate=null,rF(p)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(p=h.stateNode,p!==null&&et(p)),h.stateNode=null,h.return=null,h.dependencies=null,h.memoizedProps=null,h.memoizedState=null,h.pendingProps=null,h.stateNode=null,h.updateQueue=null}var Fr=null,ss=!1;function mc(h,p,_){for(_=_.child;_!==null;)iF(h,p,_),_=_.sibling}function iF(h,p,_){if(oe&&typeof oe.onCommitFiberUnmount=="function")try{oe.onCommitFiberUnmount(Ye,_)}catch{}switch(_.tag){case 26:bi||bl(_,p),mc(h,p,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:bi||bl(_,p);var M=Fr,P=ss;$u(_.type)&&(Fr=_.stateNode,ss=!1),mc(h,p,_),Vx(_.stateNode),Fr=M,ss=P;break;case 5:bi||bl(_,p);case 6:if(M=Fr,P=ss,Fr=null,mc(h,p,_),Fr=M,ss=P,Fr!==null)if(ss)try{(Fr.nodeType===9?Fr.body:Fr.nodeName==="HTML"?Fr.ownerDocument.body:Fr).removeChild(_.stateNode)}catch(L){ar(_,p,L)}else try{Fr.removeChild(_.stateNode)}catch(L){ar(_,p,L)}break;case 18:Fr!==null&&(ss?(h=Fr,YF(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),zm(h)):YF(Fr,_.stateNode));break;case 4:M=Fr,P=ss,Fr=_.stateNode.containerInfo,ss=!0,mc(h,p,_),Fr=M,ss=P;break;case 0:case 11:case 14:case 15:Ou(2,_,p),bi||Ou(4,_,p),mc(h,p,_);break;case 1:bi||(bl(_,p),M=_.stateNode,typeof M.componentWillUnmount=="function"&&Q5(_,p,M)),mc(h,p,_);break;case 21:mc(h,p,_);break;case 22:bi=(M=bi)||_.memoizedState!==null,mc(h,p,_),bi=M;break;default:mc(h,p,_)}}function aF(h,p){if(p.memoizedState===null&&(h=p.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{zm(h)}catch(_){ar(p,p.return,_)}}}function sF(h,p){if(p.memoizedState===null&&(h=p.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{zm(h)}catch(_){ar(p,p.return,_)}}function Oie(h){switch(h.tag){case 31:case 13:case 19:var p=h.stateNode;return p===null&&(p=h.stateNode=new tF),p;case 22:return h=h.stateNode,p=h._retryCache,p===null&&(p=h._retryCache=new tF),p;default:throw Error(r(435,h.tag))}}function Av(h,p){var _=Oie(h);p.forEach(function(M){if(!_.has(M)){_.add(M);var P=Vie.bind(null,h,M);M.then(P,P)}})}function ls(h,p){var _=p.deletions;if(_!==null)for(var M=0;M<_.length;M++){var P=_[M],L=h,J=p,pe=J;e:for(;pe!==null;){switch(pe.tag){case 27:if($u(pe.type)){Fr=pe.stateNode,ss=!1;break e}break;case 5:Fr=pe.stateNode,ss=!1;break e;case 3:case 4:Fr=pe.stateNode.containerInfo,ss=!0;break e}pe=pe.return}if(Fr===null)throw Error(r(160));iF(L,J,P),Fr=null,ss=!1,L=P.alternate,L!==null&&(L.return=null),P.return=null}if(p.subtreeFlags&13886)for(p=p.child;p!==null;)oF(p,h),p=p.sibling}var Ho=null;function oF(h,p){var _=h.alternate,M=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:ls(p,h),cs(h),M&4&&(Ou(3,h,h.return),Dx(3,h),Ou(5,h,h.return));break;case 1:ls(p,h),cs(h),M&512&&(bi||_===null||bl(_,_.return)),M&64&&fc&&(h=h.updateQueue,h!==null&&(M=h.callbacks,M!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?M:_.concat(M))));break;case 26:var P=Ho;if(ls(p,h),cs(h),M&512&&(bi||_===null||bl(_,_.return)),M&4){var L=_!==null?_.memoizedState:null;if(M=h.memoizedState,_===null)if(M===null)if(h.stateNode===null){e:{M=h.type,_=h.memoizedProps,P=P.ownerDocument||P;t:switch(M){case"title":L=P.getElementsByTagName("title")[0],(!L||L[st]||L[Xt]||L.namespaceURI==="http://www.w3.org/2000/svg"||L.hasAttribute("itemprop"))&&(L=P.createElement(M),P.head.insertBefore(L,P.querySelector("head > title"))),ma(L,M,_),L[Xt]=h,Ie(L),M=L;break e;case"link":var J=oU("link","href",P).get(M+(_.href||""));if(J){for(var pe=0;pe<J.length;pe++)if(L=J[pe],L.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&L.getAttribute("rel")===(_.rel==null?null:_.rel)&&L.getAttribute("title")===(_.title==null?null:_.title)&&L.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){J.splice(pe,1);break t}}L=P.createElement(M),ma(L,M,_),P.head.appendChild(L);break;case"meta":if(J=oU("meta","content",P).get(M+(_.content||""))){for(pe=0;pe<J.length;pe++)if(L=J[pe],L.getAttribute("content")===(_.content==null?null:""+_.content)&&L.getAttribute("name")===(_.name==null?null:_.name)&&L.getAttribute("property")===(_.property==null?null:_.property)&&L.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&L.getAttribute("charset")===(_.charSet==null?null:_.charSet)){J.splice(pe,1);break t}}L=P.createElement(M),ma(L,M,_),P.head.appendChild(L);break;default:throw Error(r(468,M))}L[Xt]=h,Ie(L),M=L}h.stateNode=M}else lU(P,h.type,h.stateNode);else h.stateNode=sU(P,M,h.memoizedProps);else L!==M?(L===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):L.count--,M===null?lU(P,h.type,h.stateNode):sU(P,M,h.memoizedProps)):M===null&&h.stateNode!==null&&DE(h,h.memoizedProps,_.memoizedProps)}break;case 27:ls(p,h),cs(h),M&512&&(bi||_===null||bl(_,_.return)),_!==null&&M&4&&DE(h,h.memoizedProps,_.memoizedProps);break;case 5:if(ls(p,h),cs(h),M&512&&(bi||_===null||bl(_,_.return)),h.flags&32){P=h.stateNode;try{hn(P,"")}catch(Vt){ar(h,h.return,Vt)}}M&4&&h.stateNode!=null&&(P=h.memoizedProps,DE(h,P,_!==null?_.memoizedProps:P)),M&1024&&(IE=!0);break;case 6:if(ls(p,h),cs(h),M&4){if(h.stateNode===null)throw Error(r(162));M=h.memoizedProps,_=h.stateNode;try{_.nodeValue=M}catch(Vt){ar(h,h.return,Vt)}}break;case 3:if(Gv=null,P=Ho,Ho=Hv(p.containerInfo),ls(p,h),Ho=P,cs(h),M&4&&_!==null&&_.memoizedState.isDehydrated)try{zm(p.containerInfo)}catch(Vt){ar(h,h.return,Vt)}IE&&(IE=!1,lF(h));break;case 4:M=Ho,Ho=Hv(h.stateNode.containerInfo),ls(p,h),cs(h),Ho=M;break;case 12:ls(p,h),cs(h);break;case 31:ls(p,h),cs(h),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,Av(h,M)));break;case 13:ls(p,h),cs(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(jv=I()),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,Av(h,M)));break;case 22:P=h.memoizedState!==null;var ze=_!==null&&_.memoizedState!==null,rt=fc,xt=bi;if(fc=rt||P,bi=xt||ze,ls(p,h),bi=xt,fc=rt,cs(h),M&8192)e:for(p=h.stateNode,p._visibility=P?p._visibility&-2:p._visibility|1,P&&(_===null||ze||fc||bi||Rh(h)),_=null,p=h;;){if(p.tag===5||p.tag===26){if(_===null){ze=_=p;try{if(L=ze.stateNode,P)J=L.style,typeof J.setProperty=="function"?J.setProperty("display","none","important"):J.display="none";else{pe=ze.stateNode;var vt=ze.memoizedProps.style,at=vt!=null&&vt.hasOwnProperty("display")?vt.display:null;pe.style.display=at==null||typeof at=="boolean"?"":(""+at).trim()}}catch(Vt){ar(ze,ze.return,Vt)}}}else if(p.tag===6){if(_===null){ze=p;try{ze.stateNode.nodeValue=P?"":ze.memoizedProps}catch(Vt){ar(ze,ze.return,Vt)}}}else if(p.tag===18){if(_===null){ze=p;try{var ft=ze.stateNode;P?QF(ft,!0):QF(ze.stateNode,!1)}catch(Vt){ar(ze,ze.return,Vt)}}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===h)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===h)break e;for(;p.sibling===null;){if(p.return===null||p.return===h)break e;_===p&&(_=null),p=p.return}_===p&&(_=null),p.sibling.return=p.return,p=p.sibling}M&4&&(M=h.updateQueue,M!==null&&(_=M.retryQueue,_!==null&&(M.retryQueue=null,Av(h,_))));break;case 19:ls(p,h),cs(h),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,Av(h,M)));break;case 30:break;case 21:break;default:ls(p,h),cs(h)}}function cs(h){var p=h.flags;if(p&2){try{for(var _,M=h.return;M!==null;){if(J5(M)){_=M;break}M=M.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var P=_.stateNode,L=OE(h);Cv(h,L,P);break;case 5:var J=_.stateNode;_.flags&32&&(hn(J,""),_.flags&=-33);var pe=OE(h);Cv(h,pe,J);break;case 3:case 4:var ze=_.stateNode.containerInfo,rt=OE(h);LE(h,rt,ze);break;default:throw Error(r(161))}}catch(xt){ar(h,h.return,xt)}h.flags&=-3}p&4096&&(h.flags&=-4097)}function lF(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var p=h;lF(p),p.tag===5&&p.flags&1024&&p.stateNode.reset(),h=h.sibling}}function pc(h,p){if(p.subtreeFlags&8772)for(p=p.child;p!==null;)nF(h,p.alternate,p),p=p.sibling}function Rh(h){for(h=h.child;h!==null;){var p=h;switch(p.tag){case 0:case 11:case 14:case 15:Ou(4,p,p.return),Rh(p);break;case 1:bl(p,p.return);var _=p.stateNode;typeof _.componentWillUnmount=="function"&&Q5(p,p.return,_),Rh(p);break;case 27:Vx(p.stateNode);case 26:case 5:bl(p,p.return),Rh(p);break;case 22:p.memoizedState===null&&Rh(p);break;case 30:Rh(p);break;default:Rh(p)}h=h.sibling}}function gc(h,p,_){for(_=_&&(p.subtreeFlags&8772)!==0,p=p.child;p!==null;){var M=p.alternate,P=h,L=p,J=L.flags;switch(L.tag){case 0:case 11:case 15:gc(P,L,_),Dx(4,L);break;case 1:if(gc(P,L,_),M=L,P=M.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(rt){ar(M,M.return,rt)}if(M=L,P=M.updateQueue,P!==null){var pe=M.stateNode;try{var ze=P.shared.hiddenCallbacks;if(ze!==null)for(P.shared.hiddenCallbacks=null,P=0;P<ze.length;P++)UI(ze[P],pe)}catch(rt){ar(M,M.return,rt)}}_&&J&64&&Y5(L),Ox(L,L.return);break;case 27:eF(L);case 26:case 5:gc(P,L,_),_&&M===null&&J&4&&Z5(L),Ox(L,L.return);break;case 12:gc(P,L,_);break;case 31:gc(P,L,_),_&&J&4&&aF(P,L);break;case 13:gc(P,L,_),_&&J&4&&sF(P,L);break;case 22:L.memoizedState===null&&gc(P,L,_),Ox(L,L.return);break;case 30:break;default:gc(P,L,_)}p=p.sibling}}function FE(h,p){var _=null;h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),h=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(h=p.memoizedState.cachePool.pool),h!==_&&(h!=null&&h.refCount++,_!=null&&_x(_))}function UE(h,p){h=null,p.alternate!==null&&(h=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==h&&(p.refCount++,h!=null&&_x(h))}function Vo(h,p,_,M){if(p.subtreeFlags&10256)for(p=p.child;p!==null;)cF(h,p,_,M),p=p.sibling}function cF(h,p,_,M){var P=p.flags;switch(p.tag){case 0:case 11:case 15:Vo(h,p,_,M),P&2048&&Dx(9,p);break;case 1:Vo(h,p,_,M);break;case 3:Vo(h,p,_,M),P&2048&&(h=null,p.alternate!==null&&(h=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==h&&(p.refCount++,h!=null&&_x(h)));break;case 12:if(P&2048){Vo(h,p,_,M),h=p.stateNode;try{var L=p.memoizedProps,J=L.id,pe=L.onPostCommit;typeof pe=="function"&&pe(J,p.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(ze){ar(p,p.return,ze)}}else Vo(h,p,_,M);break;case 31:Vo(h,p,_,M);break;case 13:Vo(h,p,_,M);break;case 23:break;case 22:L=p.stateNode,J=p.alternate,p.memoizedState!==null?L._visibility&2?Vo(h,p,_,M):Lx(h,p):L._visibility&2?Vo(h,p,_,M):(L._visibility|=2,Am(h,p,_,M,(p.subtreeFlags&10256)!==0||!1)),P&2048&&FE(J,p);break;case 24:Vo(h,p,_,M),P&2048&&UE(p.alternate,p);break;default:Vo(h,p,_,M)}}function Am(h,p,_,M,P){for(P=P&&((p.subtreeFlags&10256)!==0||!1),p=p.child;p!==null;){var L=h,J=p,pe=_,ze=M,rt=J.flags;switch(J.tag){case 0:case 11:case 15:Am(L,J,pe,ze,P),Dx(8,J);break;case 23:break;case 22:var xt=J.stateNode;J.memoizedState!==null?xt._visibility&2?Am(L,J,pe,ze,P):Lx(L,J):(xt._visibility|=2,Am(L,J,pe,ze,P)),P&&rt&2048&&FE(J.alternate,J);break;case 24:Am(L,J,pe,ze,P),P&&rt&2048&&UE(J.alternate,J);break;default:Am(L,J,pe,ze,P)}p=p.sibling}}function Lx(h,p){if(p.subtreeFlags&10256)for(p=p.child;p!==null;){var _=h,M=p,P=M.flags;switch(M.tag){case 22:Lx(_,M),P&2048&&FE(M.alternate,M);break;case 24:Lx(_,M),P&2048&&UE(M.alternate,M);break;default:Lx(_,M)}p=p.sibling}}var Ix=8192;function km(h,p,_){if(h.subtreeFlags&Ix)for(h=h.child;h!==null;)uF(h,p,_),h=h.sibling}function uF(h,p,_){switch(h.tag){case 26:km(h,p,_),h.flags&Ix&&h.memoizedState!==null&&_ae(_,Ho,h.memoizedState,h.memoizedProps);break;case 5:km(h,p,_);break;case 3:case 4:var M=Ho;Ho=Hv(h.stateNode.containerInfo),km(h,p,_),Ho=M;break;case 22:h.memoizedState===null&&(M=h.alternate,M!==null&&M.memoizedState!==null?(M=Ix,Ix=16777216,km(h,p,_),Ix=M):km(h,p,_));break;default:km(h,p,_)}}function dF(h){var p=h.alternate;if(p!==null&&(h=p.child,h!==null)){p.child=null;do p=h.sibling,h.sibling=null,h=p;while(h!==null)}}function Fx(h){var p=h.deletions;if((h.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var M=p[_];Wi=M,fF(M,h)}dF(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)hF(h),h=h.sibling}function hF(h){switch(h.tag){case 0:case 11:case 15:Fx(h),h.flags&2048&&Ou(9,h,h.return);break;case 3:Fx(h);break;case 12:Fx(h);break;case 22:var p=h.stateNode;h.memoizedState!==null&&p._visibility&2&&(h.return===null||h.return.tag!==13)?(p._visibility&=-3,kv(h)):Fx(h);break;default:Fx(h)}}function kv(h){var p=h.deletions;if((h.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var M=p[_];Wi=M,fF(M,h)}dF(h)}for(h=h.child;h!==null;){switch(p=h,p.tag){case 0:case 11:case 15:Ou(8,p,p.return),kv(p);break;case 22:_=p.stateNode,_._visibility&2&&(_._visibility&=-3,kv(p));break;default:kv(p)}h=h.sibling}}function fF(h,p){for(;Wi!==null;){var _=Wi;switch(_.tag){case 0:case 11:case 15:Ou(8,_,p);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var M=_.memoizedState.cachePool.pool;M!=null&&M.refCount++}break;case 24:_x(_.memoizedState.cache)}if(M=_.child,M!==null)M.return=_,Wi=M;else e:for(_=h;Wi!==null;){M=Wi;var P=M.sibling,L=M.return;if(rF(M),M===_){Wi=null;break e}if(P!==null){P.return=L,Wi=P;break e}Wi=L}}}var Lie={getCacheForType:function(h){var p=ha(pi),_=p.data.get(h);return _===void 0&&(_=h(),p.data.set(h,_)),_},cacheSignal:function(){return ha(pi).controller.signal}},Iie=typeof WeakMap=="function"?WeakMap:Map,Jn=0,Sr=null,kn=null,Ln=0,ir=0,Ds=null,Lu=!1,jm=!1,zE=!1,xc=0,ei=0,Iu=0,Dh=0,BE=0,Os=0,Pm=0,Ux=null,us=null,$E=!1,jv=0,mF=0,Pv=1/0,Rv=null,Fu=null,ji=0,Uu=null,Rm=null,bc=0,HE=0,VE=null,pF=null,zx=0,GE=null;function Ls(){return(Jn&2)!==0&&Ln!==0?Ln&-Ln:Y.T!==null?QE():wr()}function gF(){if(Os===0)if((Ln&536870912)===0||Bn){var h=ee;ee<<=1,(ee&3932160)===0&&(ee=262144),Os=h}else Os=536870912;return h=Ps.current,h!==null&&(h.flags|=32),Os}function ds(h,p,_){(h===Sr&&(ir===2||ir===9)||h.cancelPendingCommit!==null)&&(Dm(h,0),zu(h,Ln,Os,!1)),ln(h,_),((Jn&2)===0||h!==Sr)&&(h===Sr&&((Jn&2)===0&&(Dh|=_),ei===4&&zu(h,Ln,Os,!1)),yl(h))}function xF(h,p,_){if((Jn&6)!==0)throw Error(r(327));var M=!_&&(p&127)===0&&(p&h.expiredLanes)===0||Je(h,p),P=M?zie(h,p):WE(h,p,!0),L=M;do{if(P===0){jm&&!M&&zu(h,p,0,!1);break}else{if(_=h.current.alternate,L&&!Fie(_)){P=WE(h,p,!1),L=!1;continue}if(P===2){if(L=p,h.errorRecoveryDisabledLanes&L)var J=0;else J=h.pendingLanes&-536870913,J=J!==0?J:J&536870912?536870912:0;if(J!==0){p=J;e:{var pe=h;P=Ux;var ze=pe.current.memoizedState.isDehydrated;if(ze&&(Dm(pe,J).flags|=256),J=WE(pe,J,!1),J!==2){if(zE&&!ze){pe.errorRecoveryDisabledLanes|=L,Dh|=L,P=4;break e}L=us,us=P,L!==null&&(us===null?us=L:us.push.apply(us,L))}P=J}if(L=!1,P!==2)continue}}if(P===1){Dm(h,0),zu(h,p,0,!0);break}e:{switch(M=h,L=P,L){case 0:case 1:throw Error(r(345));case 4:if((p&4194048)!==p)break;case 6:zu(M,p,Os,!Lu);break e;case 2:us=null;break;case 3:case 5:break;default:throw Error(r(329))}if((p&62914560)===p&&(P=jv+300-I(),10<P)){if(zu(M,p,Os,!Lu),Ae(M,0,!0)!==0)break e;bc=p,M.timeoutHandle=KF(bF.bind(null,M,_,us,Rv,$E,p,Os,Dh,Pm,Lu,L,"Throttled",-0,0),P);break e}bF(M,_,us,Rv,$E,p,Os,Dh,Pm,Lu,L,null,-0,0)}}break}while(!0);yl(h)}function bF(h,p,_,M,P,L,J,pe,ze,rt,xt,vt,at,ft){if(h.timeoutHandle=-1,vt=p.subtreeFlags,vt&8192||(vt&16785408)===16785408){vt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:ca},uF(p,L,vt);var Vt=(L&62914560)===L?jv-I():(L&4194048)===L?mF-I():0;if(Vt=wae(vt,Vt),Vt!==null){bc=L,h.cancelPendingCommit=Vt(EF.bind(null,h,p,L,_,M,P,J,pe,ze,xt,vt,null,at,ft)),zu(h,L,J,!rt);return}}EF(h,p,L,_,M,P,J,pe,ze)}function Fie(h){for(var p=h;;){var _=p.tag;if((_===0||_===11||_===15)&&p.flags&16384&&(_=p.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var M=0;M<_.length;M++){var P=_[M],L=P.getSnapshot;P=P.value;try{if(!ks(L(),P))return!1}catch{return!1}}if(_=p.child,p.subtreeFlags&16384&&_!==null)_.return=p,p=_;else{if(p===h)break;for(;p.sibling===null;){if(p.return===null||p.return===h)return!0;p=p.return}p.sibling.return=p.return,p=p.sibling}}return!0}function zu(h,p,_,M){p&=~BE,p&=~Dh,h.suspendedLanes|=p,h.pingedLanes&=~p,M&&(h.warmLanes|=p),M=h.expirationTimes;for(var P=p;0<P;){var L=31-Le(P),J=1<<L;M[L]=-1,P&=~J}_!==0&&Cn(h,_,p)}function Dv(){return(Jn&6)===0?(Bx(0),!1):!0}function qE(){if(kn!==null){if(ir===0)var h=kn.return;else h=kn,oc=Mh=null,lE(h),Nm=null,Sx=0,h=kn;for(;h!==null;)X5(h.alternate,h),h=h.return;kn=null}}function Dm(h,p){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,iae(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),bc=0,qE(),Sr=h,kn=_=ac(h.current,null),Ln=p,ir=0,Ds=null,Lu=!1,jm=Je(h,p),zE=!1,Pm=Os=BE=Dh=Iu=ei=0,us=Ux=null,$E=!1,(p&8)!==0&&(p|=p&32);var M=h.entangledLanes;if(M!==0)for(h=h.entanglements,M&=p;0<M;){var P=31-Le(M),L=1<<P;p|=h[P],M&=~L}return xc=p,tv(),_}function yF(h,p){bn=null,Y.H=jx,p===Sm||p===cv?(p=OI(),ir=3):p===YM?(p=OI(),ir=4):ir=p===NE?8:p!==null&&typeof p=="object"&&typeof p.then=="function"?6:1,Ds=p,kn===null&&(ei=1,Sv(h,ro(p,h.current)))}function vF(){var h=Ps.current;return h===null?!0:(Ln&4194048)===Ln?oo===null:(Ln&62914560)===Ln||(Ln&536870912)!==0?h===oo:!1}function _F(){var h=Y.H;return Y.H=jx,h===null?jx:h}function wF(){var h=Y.A;return Y.A=Lie,h}function Ov(){ei=4,Lu||(Ln&4194048)!==Ln&&Ps.current!==null||(jm=!0),(Iu&134217727)===0&&(Dh&134217727)===0||Sr===null||zu(Sr,Ln,Os,!1)}function WE(h,p,_){var M=Jn;Jn|=2;var P=_F(),L=wF();(Sr!==h||Ln!==p)&&(Rv=null,Dm(h,p)),p=!1;var J=ei;e:do try{if(ir!==0&&kn!==null){var pe=kn,ze=Ds;switch(ir){case 8:qE(),J=6;break e;case 3:case 2:case 9:case 6:Ps.current===null&&(p=!0);var rt=ir;if(ir=0,Ds=null,Om(h,pe,ze,rt),_&&jm){J=0;break e}break;default:rt=ir,ir=0,Ds=null,Om(h,pe,ze,rt)}}Uie(),J=ei;break}catch(xt){yF(h,xt)}while(!0);return p&&h.shellSuspendCounter++,oc=Mh=null,Jn=M,Y.H=P,Y.A=L,kn===null&&(Sr=null,Ln=0,tv()),J}function Uie(){for(;kn!==null;)SF(kn)}function zie(h,p){var _=Jn;Jn|=2;var M=_F(),P=wF();Sr!==h||Ln!==p?(Rv=null,Pv=I()+500,Dm(h,p)):jm=Je(h,p);e:do try{if(ir!==0&&kn!==null){p=kn;var L=Ds;t:switch(ir){case 1:ir=0,Ds=null,Om(h,p,L,1);break;case 2:case 9:if(RI(L)){ir=0,Ds=null,NF(p);break}p=function(){ir!==2&&ir!==9||Sr!==h||(ir=7),yl(h)},L.then(p,p);break e;case 3:ir=7;break e;case 4:ir=5;break e;case 7:RI(L)?(ir=0,Ds=null,NF(p)):(ir=0,Ds=null,Om(h,p,L,7));break;case 5:var J=null;switch(kn.tag){case 26:J=kn.memoizedState;case 5:case 27:var pe=kn;if(J?cU(J):pe.stateNode.complete){ir=0,Ds=null;var ze=pe.sibling;if(ze!==null)kn=ze;else{var rt=pe.return;rt!==null?(kn=rt,Lv(rt)):kn=null}break t}}ir=0,Ds=null,Om(h,p,L,5);break;case 6:ir=0,Ds=null,Om(h,p,L,6);break;case 8:qE(),ei=6;break e;default:throw Error(r(462))}}Bie();break}catch(xt){yF(h,xt)}while(!0);return oc=Mh=null,Y.H=M,Y.A=P,Jn=_,kn!==null?0:(Sr=null,Ln=0,tv(),ei)}function Bie(){for(;kn!==null&&!je();)SF(kn)}function SF(h){var p=W5(h.alternate,h,xc);h.memoizedProps=h.pendingProps,p===null?Lv(h):kn=p}function NF(h){var p=h,_=p.alternate;switch(p.tag){case 15:case 0:p=B5(_,p,p.pendingProps,p.type,void 0,Ln);break;case 11:p=B5(_,p,p.pendingProps,p.type.render,p.ref,Ln);break;case 5:lE(p);default:X5(_,p),p=kn=wI(p,xc),p=W5(_,p,xc)}h.memoizedProps=h.pendingProps,p===null?Lv(h):kn=p}function Om(h,p,_,M){oc=Mh=null,lE(p),Nm=null,Sx=0;var P=p.return;try{if(Aie(h,P,p,_,Ln)){ei=1,Sv(h,ro(_,h.current)),kn=null;return}}catch(L){if(P!==null)throw kn=P,L;ei=1,Sv(h,ro(_,h.current)),kn=null;return}p.flags&32768?(Bn||M===1?h=!0:jm||(Ln&536870912)!==0?h=!1:(Lu=h=!0,(M===2||M===9||M===3||M===6)&&(M=Ps.current,M!==null&&M.tag===13&&(M.flags|=16384))),MF(p,h)):Lv(p)}function Lv(h){var p=h;do{if((p.flags&32768)!==0){MF(p,Lu);return}h=p.return;var _=Pie(p.alternate,p,xc);if(_!==null){kn=_;return}if(p=p.sibling,p!==null){kn=p;return}kn=p=h}while(p!==null);ei===0&&(ei=5)}function MF(h,p){do{var _=Rie(h.alternate,h);if(_!==null){_.flags&=32767,kn=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!p&&(h=h.sibling,h!==null)){kn=h;return}kn=h=_}while(h!==null);ei=6,kn=null}function EF(h,p,_,M,P,L,J,pe,ze){h.cancelPendingCommit=null;do Iv();while(ji!==0);if((Jn&6)!==0)throw Error(r(327));if(p!==null){if(p===h.current)throw Error(r(177));if(L=p.lanes|p.childLanes,L|=OM,Lt(h,_,L,J,pe,ze),h===Sr&&(kn=Sr=null,Ln=0),Rm=p,Uu=h,bc=_,HE=L,VE=P,pF=M,(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,Gie(ye,function(){return jF(),null})):(h.callbackNode=null,h.callbackPriority=0),M=(p.flags&13878)!==0,(p.subtreeFlags&13878)!==0||M){M=Y.T,Y.T=null,P=K.p,K.p=2,J=Jn,Jn|=4;try{Die(h,p,_)}finally{Jn=J,K.p=P,Y.T=M}}ji=1,TF(),CF(),AF()}}function TF(){if(ji===1){ji=0;var h=Uu,p=Rm,_=(p.flags&13878)!==0;if((p.subtreeFlags&13878)!==0||_){_=Y.T,Y.T=null;var M=K.p;K.p=2;var P=Jn;Jn|=4;try{oF(p,h);var L=aT,J=fI(h.containerInfo),pe=L.focusedElem,ze=L.selectionRange;if(J!==pe&&pe&&pe.ownerDocument&&hI(pe.ownerDocument.documentElement,pe)){if(ze!==null&&kM(pe)){var rt=ze.start,xt=ze.end;if(xt===void 0&&(xt=rt),"selectionStart"in pe)pe.selectionStart=rt,pe.selectionEnd=Math.min(xt,pe.value.length);else{var vt=pe.ownerDocument||document,at=vt&&vt.defaultView||window;if(at.getSelection){var ft=at.getSelection(),Vt=pe.textContent.length,rn=Math.min(ze.start,Vt),fr=ze.end===void 0?rn:Math.min(ze.end,Vt);!ft.extend&&rn>fr&&(J=fr,fr=rn,rn=J);var Ze=dI(pe,rn),Ve=dI(pe,fr);if(Ze&&Ve&&(ft.rangeCount!==1||ft.anchorNode!==Ze.node||ft.anchorOffset!==Ze.offset||ft.focusNode!==Ve.node||ft.focusOffset!==Ve.offset)){var nt=vt.createRange();nt.setStart(Ze.node,Ze.offset),ft.removeAllRanges(),rn>fr?(ft.addRange(nt),ft.extend(Ve.node,Ve.offset)):(nt.setEnd(Ve.node,Ve.offset),ft.addRange(nt))}}}}for(vt=[],ft=pe;ft=ft.parentNode;)ft.nodeType===1&&vt.push({element:ft,left:ft.scrollLeft,top:ft.scrollTop});for(typeof pe.focus=="function"&&pe.focus(),pe=0;pe<vt.length;pe++){var yt=vt[pe];yt.element.scrollLeft=yt.left,yt.element.scrollTop=yt.top}}Xv=!!iT,aT=iT=null}finally{Jn=P,K.p=M,Y.T=_}}h.current=p,ji=2}}function CF(){if(ji===2){ji=0;var h=Uu,p=Rm,_=(p.flags&8772)!==0;if((p.subtreeFlags&8772)!==0||_){_=Y.T,Y.T=null;var M=K.p;K.p=2;var P=Jn;Jn|=4;try{nF(h,p.alternate,p)}finally{Jn=P,K.p=M,Y.T=_}}ji=3}}function AF(){if(ji===4||ji===3){ji=0,$();var h=Uu,p=Rm,_=bc,M=pF;(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?ji=5:(ji=0,Rm=Uu=null,kF(h,h.pendingLanes));var P=h.pendingLanes;if(P===0&&(Fu=null),Un(_),p=p.stateNode,oe&&typeof oe.onCommitFiberRoot=="function")try{oe.onCommitFiberRoot(Ye,p,void 0,(p.current.flags&128)===128)}catch{}if(M!==null){p=Y.T,P=K.p,K.p=2,Y.T=null;try{for(var L=h.onRecoverableError,J=0;J<M.length;J++){var pe=M[J];L(pe.value,{componentStack:pe.stack})}}finally{Y.T=p,K.p=P}}(bc&3)!==0&&Iv(),yl(h),P=h.pendingLanes,(_&261930)!==0&&(P&42)!==0?h===GE?zx++:(zx=0,GE=h):zx=0,Bx(0)}}function kF(h,p){(h.pooledCacheLanes&=p)===0&&(p=h.pooledCache,p!=null&&(h.pooledCache=null,_x(p)))}function Iv(){return TF(),CF(),AF(),jF()}function jF(){if(ji!==5)return!1;var h=Uu,p=HE;HE=0;var _=Un(bc),M=Y.T,P=K.p;try{K.p=32>_?32:_,Y.T=null,_=VE,VE=null;var L=Uu,J=bc;if(ji=0,Rm=Uu=null,bc=0,(Jn&6)!==0)throw Error(r(331));var pe=Jn;if(Jn|=4,hF(L.current),cF(L,L.current,J,_),Jn=pe,Bx(0,!1),oe&&typeof oe.onPostCommitFiberRoot=="function")try{oe.onPostCommitFiberRoot(Ye,L)}catch{}return!0}finally{K.p=P,Y.T=M,kF(h,p)}}function PF(h,p,_){p=ro(_,p),p=SE(h.stateNode,p,2),h=Pu(h,p,2),h!==null&&(ln(h,2),yl(h))}function ar(h,p,_){if(h.tag===3)PF(h,h,_);else for(;p!==null;){if(p.tag===3){PF(p,h,_);break}else if(p.tag===1){var M=p.stateNode;if(typeof p.type.getDerivedStateFromError=="function"||typeof M.componentDidCatch=="function"&&(Fu===null||!Fu.has(M))){h=ro(_,h),_=R5(2),M=Pu(p,_,2),M!==null&&(D5(_,M,p,h),ln(M,2),yl(M));break}}p=p.return}}function KE(h,p,_){var M=h.pingCache;if(M===null){M=h.pingCache=new Iie;var P=new Set;M.set(p,P)}else P=M.get(p),P===void 0&&(P=new Set,M.set(p,P));P.has(_)||(zE=!0,P.add(_),h=$ie.bind(null,h,p,_),p.then(h,h))}function $ie(h,p,_){var M=h.pingCache;M!==null&&M.delete(p),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,Sr===h&&(Ln&_)===_&&(ei===4||ei===3&&(Ln&62914560)===Ln&&300>I()-jv?(Jn&2)===0&&Dm(h,0):BE|=_,Pm===Ln&&(Pm=0)),yl(h)}function RF(h,p){p===0&&(p=At()),h=wh(h,p),h!==null&&(ln(h,p),yl(h))}function Hie(h){var p=h.memoizedState,_=0;p!==null&&(_=p.retryLane),RF(h,_)}function Vie(h,p){var _=0;switch(h.tag){case 31:case 13:var M=h.stateNode,P=h.memoizedState;P!==null&&(_=P.retryLane);break;case 19:M=h.stateNode;break;case 22:M=h.stateNode._retryCache;break;default:throw Error(r(314))}M!==null&&M.delete(p),RF(h,_)}function Gie(h,p){return Pe(h,p)}var Fv=null,Lm=null,XE=!1,Uv=!1,YE=!1,Bu=0;function yl(h){h!==Lm&&h.next===null&&(Lm===null?Fv=Lm=h:Lm=Lm.next=h),Uv=!0,XE||(XE=!0,Wie())}function Bx(h,p){if(!YE&&Uv){YE=!0;do for(var _=!1,M=Fv;M!==null;){if(h!==0){var P=M.pendingLanes;if(P===0)var L=0;else{var J=M.suspendedLanes,pe=M.pingedLanes;L=(1<<31-Le(42|h)+1)-1,L&=P&~(J&~pe),L=L&201326741?L&201326741|1:L?L|2:0}L!==0&&(_=!0,IF(M,L))}else L=Ln,L=Ae(M,M===Sr?L:0,M.cancelPendingCommit!==null||M.timeoutHandle!==-1),(L&3)===0||Je(M,L)||(_=!0,IF(M,L));M=M.next}while(_);YE=!1}}function qie(){DF()}function DF(){Uv=XE=!1;var h=0;Bu!==0&&rae()&&(h=Bu);for(var p=I(),_=null,M=Fv;M!==null;){var P=M.next,L=OF(M,p);L===0?(M.next=null,_===null?Fv=P:_.next=P,P===null&&(Lm=_)):(_=M,(h!==0||(L&3)!==0)&&(Uv=!0)),M=P}ji!==0&&ji!==5||Bx(h),Bu!==0&&(Bu=0)}function OF(h,p){for(var _=h.suspendedLanes,M=h.pingedLanes,P=h.expirationTimes,L=h.pendingLanes&-62914561;0<L;){var J=31-Le(L),pe=1<<J,ze=P[J];ze===-1?((pe&_)===0||(pe&M)!==0)&&(P[J]=gt(pe,p)):ze<=p&&(h.expiredLanes|=pe),L&=~pe}if(p=Sr,_=Ln,_=Ae(h,h===p?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),M=h.callbackNode,_===0||h===p&&(ir===2||ir===9)||h.cancelPendingCommit!==null)return M!==null&&M!==null&&Oe(M),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||Je(h,_)){if(p=_&-_,p===h.callbackPriority)return p;switch(M!==null&&Oe(M),Un(_)){case 2:case 8:_=Se;break;case 32:_=ye;break;case 268435456:_=Ue;break;default:_=ye}return M=LF.bind(null,h),_=Pe(_,M),h.callbackPriority=p,h.callbackNode=_,p}return M!==null&&M!==null&&Oe(M),h.callbackPriority=2,h.callbackNode=null,2}function LF(h,p){if(ji!==0&&ji!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(Iv()&&h.callbackNode!==_)return null;var M=Ln;return M=Ae(h,h===Sr?M:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),M===0?null:(xF(h,M,p),OF(h,I()),h.callbackNode!=null&&h.callbackNode===_?LF.bind(null,h):null)}function IF(h,p){if(Iv())return null;xF(h,p,!0)}function Wie(){aae(function(){(Jn&6)!==0?Pe(ie,qie):DF()})}function QE(){if(Bu===0){var h=_m;h===0&&(h=ce,ce<<=1,(ce&261888)===0&&(ce=256)),Bu=h}return Bu}function FF(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:qi(""+h)}function UF(h,p){var _=p.ownerDocument.createElement("input");return _.name=p.name,_.value=p.value,h.id&&_.setAttribute("form",h.id),p.parentNode.insertBefore(_,p),h=new FormData(h),_.parentNode.removeChild(_),h}function Kie(h,p,_,M,P){if(p==="submit"&&_&&_.stateNode===P){var L=FF((P[zn]||null).action),J=M.submitter;J&&(p=(p=J[zn]||null)?FF(p.formAction):J.getAttribute("formAction"),p!==null&&(L=p,J=null));var pe=new Qy("action","action",null,M,P);h.push({event:pe,listeners:[{instance:null,listener:function(){if(M.defaultPrevented){if(Bu!==0){var ze=J?UF(P,J):new FormData(P);xE(_,{pending:!0,data:ze,method:P.method,action:L},null,ze)}}else typeof L=="function"&&(pe.preventDefault(),ze=J?UF(P,J):new FormData(P),xE(_,{pending:!0,data:ze,method:P.method,action:L},L,ze))},currentTarget:P}]})}}for(var ZE=0;ZE<DM.length;ZE++){var JE=DM[ZE],Xie=JE.toLowerCase(),Yie=JE[0].toUpperCase()+JE.slice(1);$o(Xie,"on"+Yie)}$o(gI,"onAnimationEnd"),$o(xI,"onAnimationIteration"),$o(bI,"onAnimationStart"),$o("dblclick","onDoubleClick"),$o("focusin","onFocus"),$o("focusout","onBlur"),$o(hie,"onTransitionRun"),$o(fie,"onTransitionStart"),$o(mie,"onTransitionCancel"),$o(yI,"onTransitionEnd"),kt("onMouseEnter",["mouseout","mouseover"]),kt("onMouseLeave",["mouseout","mouseover"]),kt("onPointerEnter",["pointerout","pointerover"]),kt("onPointerLeave",["pointerout","pointerover"]),wt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),wt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),wt("onBeforeInput",["compositionend","keypress","textInput","paste"]),wt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),wt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),wt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var $x="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(" "),Qie=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat($x));function zF(h,p){p=(p&4)!==0;for(var _=0;_<h.length;_++){var M=h[_],P=M.event;M=M.listeners;e:{var L=void 0;if(p)for(var J=M.length-1;0<=J;J--){var pe=M[J],ze=pe.instance,rt=pe.currentTarget;if(pe=pe.listener,ze!==L&&P.isPropagationStopped())break e;L=pe,P.currentTarget=rt;try{L(P)}catch(xt){ev(xt)}P.currentTarget=null,L=ze}else for(J=0;J<M.length;J++){if(pe=M[J],ze=pe.instance,rt=pe.currentTarget,pe=pe.listener,ze!==L&&P.isPropagationStopped())break e;L=pe,P.currentTarget=rt;try{L(P)}catch(xt){ev(xt)}P.currentTarget=null,L=ze}}}}function jn(h,p){var _=p[Zr];_===void 0&&(_=p[Zr]=new Set);var M=h+"__bubble";_.has(M)||(BF(p,h,2,!1),_.add(M))}function eT(h,p,_){var M=0;p&&(M|=4),BF(_,h,M,p)}var zv="_reactListening"+Math.random().toString(36).slice(2);function tT(h){if(!h[zv]){h[zv]=!0,Me.forEach(function(_){_!=="selectionchange"&&(Qie.has(_)||eT(_,!1,h),eT(_,!0,h))});var p=h.nodeType===9?h:h.ownerDocument;p===null||p[zv]||(p[zv]=!0,eT("selectionchange",!1,p))}}function BF(h,p,_,M){switch(gU(p)){case 2:var P=Mae;break;case 8:P=Eae;break;default:P=gT}_=P.bind(null,p,_,h),P=void 0,!_M||p!=="touchstart"&&p!=="touchmove"&&p!=="wheel"||(P=!0),M?P!==void 0?h.addEventListener(p,_,{capture:!0,passive:P}):h.addEventListener(p,_,!0):P!==void 0?h.addEventListener(p,_,{passive:P}):h.addEventListener(p,_,!1)}function nT(h,p,_,M,P){var L=M;if((p&1)===0&&(p&2)===0&&M!==null)e:for(;;){if(M===null)return;var J=M.tag;if(J===3||J===4){var pe=M.stateNode.containerInfo;if(pe===P)break;if(J===4)for(J=M.return;J!==null;){var ze=J.tag;if((ze===3||ze===4)&&J.stateNode.containerInfo===P)return;J=J.return}for(;pe!==null;){if(J=Ct(pe),J===null)return;if(ze=J.tag,ze===5||ze===6||ze===26||ze===27){M=L=J;continue e}pe=pe.parentNode}}M=M.return}qL(function(){var rt=L,xt=ua(_),vt=[];e:{var at=vI.get(h);if(at!==void 0){var ft=Qy,Vt=h;switch(h){case"keypress":if(Xy(_)===0)break e;case"keydown":case"keyup":ft=Vre;break;case"focusin":Vt="focus",ft=MM;break;case"focusout":Vt="blur",ft=MM;break;case"beforeblur":case"afterblur":ft=MM;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ft=XL;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ft=Pre;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ft=Wre;break;case gI:case xI:case bI:ft=Ore;break;case yI:ft=Xre;break;case"scroll":case"scrollend":ft=kre;break;case"wheel":ft=Qre;break;case"copy":case"cut":case"paste":ft=Ire;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ft=QL;break;case"toggle":case"beforetoggle":ft=Jre}var rn=(p&4)!==0,fr=!rn&&(h==="scroll"||h==="scrollend"),Ze=rn?at!==null?at+"Capture":null:at;rn=[];for(var Ve=rt,nt;Ve!==null;){var yt=Ve;if(nt=yt.stateNode,yt=yt.tag,yt!==5&&yt!==26&&yt!==27||nt===null||Ze===null||(yt=ux(Ve,Ze),yt!=null&&rn.push(Hx(Ve,yt,nt))),fr)break;Ve=Ve.return}0<rn.length&&(at=new ft(at,Vt,null,_,xt),vt.push({event:at,listeners:rn}))}}if((p&7)===0){e:{if(at=h==="mouseover"||h==="pointerover",ft=h==="mouseout"||h==="pointerout",at&&_!==rc&&(Vt=_.relatedTarget||_.fromElement)&&(Ct(Vt)||Vt[Wn]))break e;if((ft||at)&&(at=xt.window===xt?xt:(at=xt.ownerDocument)?at.defaultView||at.parentWindow:window,ft?(Vt=_.relatedTarget||_.toElement,ft=rt,Vt=Vt?Ct(Vt):null,Vt!==null&&(fr=s(Vt),rn=Vt.tag,Vt!==fr||rn!==5&&rn!==27&&rn!==6)&&(Vt=null)):(ft=null,Vt=rt),ft!==Vt)){if(rn=XL,yt="onMouseLeave",Ze="onMouseEnter",Ve="mouse",(h==="pointerout"||h==="pointerover")&&(rn=QL,yt="onPointerLeave",Ze="onPointerEnter",Ve="pointer"),fr=ft==null?at:ge(ft),nt=Vt==null?at:ge(Vt),at=new rn(yt,Ve+"leave",ft,_,xt),at.target=fr,at.relatedTarget=nt,yt=null,Ct(xt)===rt&&(rn=new rn(Ze,Ve+"enter",Vt,_,xt),rn.target=nt,rn.relatedTarget=fr,yt=rn),fr=yt,ft&&Vt)t:{for(rn=Zie,Ze=ft,Ve=Vt,nt=0,yt=Ze;yt;yt=rn(yt))nt++;yt=0;for(var Yt=Ve;Yt;Yt=rn(Yt))yt++;for(;0<nt-yt;)Ze=rn(Ze),nt--;for(;0<yt-nt;)Ve=rn(Ve),yt--;for(;nt--;){if(Ze===Ve||Ve!==null&&Ze===Ve.alternate){rn=Ze;break t}Ze=rn(Ze),Ve=rn(Ve)}rn=null}else rn=null;ft!==null&&$F(vt,at,ft,rn,!1),Vt!==null&&fr!==null&&$F(vt,fr,Vt,rn,!0)}}e:{if(at=rt?ge(rt):window,ft=at.nodeName&&at.nodeName.toLowerCase(),ft==="select"||ft==="input"&&at.type==="file")var Kn=aI;else if(rI(at))if(sI)Kn=cie;else{Kn=oie;var qt=sie}else ft=at.nodeName,!ft||ft.toLowerCase()!=="input"||at.type!=="checkbox"&&at.type!=="radio"?rt&&bh(rt.elementType)&&(Kn=aI):Kn=lie;if(Kn&&(Kn=Kn(h,rt))){iI(vt,Kn,_,xt);break e}qt&&qt(h,at,rt),h==="focusout"&&rt&&at.type==="number"&&rt.memoizedProps.value!=null&&En(at,"number",at.value)}switch(qt=rt?ge(rt):window,h){case"focusin":(rI(qt)||qt.contentEditable==="true")&&(fm=qt,jM=rt,bx=null);break;case"focusout":bx=jM=fm=null;break;case"mousedown":PM=!0;break;case"contextmenu":case"mouseup":case"dragend":PM=!1,mI(vt,_,xt);break;case"selectionchange":if(die)break;case"keydown":case"keyup":mI(vt,_,xt)}var yn;if(TM)e:{switch(h){case"compositionstart":var In="onCompositionStart";break e;case"compositionend":In="onCompositionEnd";break e;case"compositionupdate":In="onCompositionUpdate";break e}In=void 0}else hm?tI(h,_)&&(In="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(In="onCompositionStart");In&&(ZL&&_.locale!=="ko"&&(hm||In!=="onCompositionStart"?In==="onCompositionEnd"&&hm&&(yn=WL()):(Mu=xt,wM="value"in Mu?Mu.value:Mu.textContent,hm=!0)),qt=Bv(rt,In),0<qt.length&&(In=new YL(In,h,null,_,xt),vt.push({event:In,listeners:qt}),yn?In.data=yn:(yn=nI(_),yn!==null&&(In.data=yn)))),(yn=tie?nie(h,_):rie(h,_))&&(In=Bv(rt,"onBeforeInput"),0<In.length&&(qt=new YL("onBeforeInput","beforeinput",null,_,xt),vt.push({event:qt,listeners:In}),qt.data=yn)),Kie(vt,h,rt,_,xt)}zF(vt,p)})}function Hx(h,p,_){return{instance:h,listener:p,currentTarget:_}}function Bv(h,p){for(var _=p+"Capture",M=[];h!==null;){var P=h,L=P.stateNode;if(P=P.tag,P!==5&&P!==26&&P!==27||L===null||(P=ux(h,_),P!=null&&M.unshift(Hx(h,P,L)),P=ux(h,p),P!=null&&M.push(Hx(h,P,L))),h.tag===3)return M;h=h.return}return[]}function Zie(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function $F(h,p,_,M,P){for(var L=p._reactName,J=[];_!==null&&_!==M;){var pe=_,ze=pe.alternate,rt=pe.stateNode;if(pe=pe.tag,ze!==null&&ze===M)break;pe!==5&&pe!==26&&pe!==27||rt===null||(ze=rt,P?(rt=ux(_,L),rt!=null&&J.unshift(Hx(_,rt,ze))):P||(rt=ux(_,L),rt!=null&&J.push(Hx(_,rt,ze)))),_=_.return}J.length!==0&&h.push({event:p,listeners:J})}var Jie=/\r\n?/g,eae=/\u0000|\uFFFD/g;function HF(h){return(typeof h=="string"?h:""+h).replace(Jie,`
- `).replace(eae,"")}function VF(h,p){return p=HF(p),HF(h)===p}function hr(h,p,_,M,P,L){switch(_){case"children":typeof M=="string"?p==="body"||p==="textarea"&&M===""||hn(h,M):(typeof M=="number"||typeof M=="bigint")&&p!=="body"&&hn(h,""+M);break;case"className":Bt(h,"class",M);break;case"tabIndex":Bt(h,"tabindex",M);break;case"dir":case"role":case"viewBox":case"width":case"height":Bt(h,_,M);break;case"style":xh(h,M,L);break;case"data":if(p!=="object"){Bt(h,"data",M);break}case"src":case"href":if(M===""&&(p!=="a"||_!=="href")){h.removeAttribute(_);break}if(M==null||typeof M=="function"||typeof M=="symbol"||typeof M=="boolean"){h.removeAttribute(_);break}M=qi(""+M),h.setAttribute(_,M);break;case"action":case"formAction":if(typeof M=="function"){h.setAttribute(_,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof L=="function"&&(_==="formAction"?(p!=="input"&&hr(h,p,"name",P.name,P,null),hr(h,p,"formEncType",P.formEncType,P,null),hr(h,p,"formMethod",P.formMethod,P,null),hr(h,p,"formTarget",P.formTarget,P,null)):(hr(h,p,"encType",P.encType,P,null),hr(h,p,"method",P.method,P,null),hr(h,p,"target",P.target,P,null)));if(M==null||typeof M=="symbol"||typeof M=="boolean"){h.removeAttribute(_);break}M=qi(""+M),h.setAttribute(_,M);break;case"onClick":M!=null&&(h.onclick=ca);break;case"onScroll":M!=null&&jn("scroll",h);break;case"onScrollEnd":M!=null&&jn("scrollend",h);break;case"dangerouslySetInnerHTML":if(M!=null){if(typeof M!="object"||!("__html"in M))throw Error(r(61));if(_=M.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"multiple":h.multiple=M&&typeof M!="function"&&typeof M!="symbol";break;case"muted":h.muted=M&&typeof M!="function"&&typeof M!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(M==null||typeof M=="function"||typeof M=="boolean"||typeof M=="symbol"){h.removeAttribute("xlink:href");break}_=qi(""+M),h.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",_);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":M!=null&&typeof M!="function"&&typeof M!="symbol"?h.setAttribute(_,""+M):h.removeAttribute(_);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":M&&typeof M!="function"&&typeof M!="symbol"?h.setAttribute(_,""):h.removeAttribute(_);break;case"capture":case"download":M===!0?h.setAttribute(_,""):M!==!1&&M!=null&&typeof M!="function"&&typeof M!="symbol"?h.setAttribute(_,M):h.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":M!=null&&typeof M!="function"&&typeof M!="symbol"&&!isNaN(M)&&1<=M?h.setAttribute(_,M):h.removeAttribute(_);break;case"rowSpan":case"start":M==null||typeof M=="function"||typeof M=="symbol"||isNaN(M)?h.removeAttribute(_):h.setAttribute(_,M);break;case"popover":jn("beforetoggle",h),jn("toggle",h),nn(h,"popover",M);break;case"xlinkActuate":tn(h,"http://www.w3.org/1999/xlink","xlink:actuate",M);break;case"xlinkArcrole":tn(h,"http://www.w3.org/1999/xlink","xlink:arcrole",M);break;case"xlinkRole":tn(h,"http://www.w3.org/1999/xlink","xlink:role",M);break;case"xlinkShow":tn(h,"http://www.w3.org/1999/xlink","xlink:show",M);break;case"xlinkTitle":tn(h,"http://www.w3.org/1999/xlink","xlink:title",M);break;case"xlinkType":tn(h,"http://www.w3.org/1999/xlink","xlink:type",M);break;case"xmlBase":tn(h,"http://www.w3.org/XML/1998/namespace","xml:base",M);break;case"xmlLang":tn(h,"http://www.w3.org/XML/1998/namespace","xml:lang",M);break;case"xmlSpace":tn(h,"http://www.w3.org/XML/1998/namespace","xml:space",M);break;case"is":nn(h,"is",M);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=cx.get(_)||_,nn(h,_,M))}}function rT(h,p,_,M,P,L){switch(_){case"style":xh(h,M,L);break;case"dangerouslySetInnerHTML":if(M!=null){if(typeof M!="object"||!("__html"in M))throw Error(r(61));if(_=M.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof M=="string"?hn(h,M):(typeof M=="number"||typeof M=="bigint")&&hn(h,""+M);break;case"onScroll":M!=null&&jn("scroll",h);break;case"onScrollEnd":M!=null&&jn("scrollend",h);break;case"onClick":M!=null&&(h.onclick=ca);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!mt.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(P=_.endsWith("Capture"),p=_.slice(2,P?_.length-7:void 0),L=h[zn]||null,L=L!=null?L[_]:null,typeof L=="function"&&h.removeEventListener(p,L,P),typeof M=="function")){typeof L!="function"&&L!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(p,M,P);break e}_ in h?h[_]=M:M===!0?h.setAttribute(_,""):nn(h,_,M)}}}function ma(h,p,_){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":jn("error",h),jn("load",h);var M=!1,P=!1,L;for(L in _)if(_.hasOwnProperty(L)){var J=_[L];if(J!=null)switch(L){case"src":M=!0;break;case"srcSet":P=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:hr(h,p,L,J,_,null)}}P&&hr(h,p,"srcSet",_.srcSet,_,null),M&&hr(h,p,"src",_.src,_,null);return;case"input":jn("invalid",h);var pe=L=J=P=null,ze=null,rt=null;for(M in _)if(_.hasOwnProperty(M)){var xt=_[M];if(xt!=null)switch(M){case"name":P=xt;break;case"type":J=xt;break;case"checked":ze=xt;break;case"defaultChecked":rt=xt;break;case"value":L=xt;break;case"defaultValue":pe=xt;break;case"children":case"dangerouslySetInnerHTML":if(xt!=null)throw Error(r(137,p));break;default:hr(h,p,M,xt,_,null)}}sn(h,L,pe,ze,rt,J,P,!1);return;case"select":jn("invalid",h),M=J=L=null;for(P in _)if(_.hasOwnProperty(P)&&(pe=_[P],pe!=null))switch(P){case"value":L=pe;break;case"defaultValue":J=pe;break;case"multiple":M=pe;default:hr(h,p,P,pe,_,null)}p=L,_=J,h.multiple=!!M,p!=null?On(h,!!M,p,!1):_!=null&&On(h,!!M,_,!0);return;case"textarea":jn("invalid",h),L=P=M=null;for(J in _)if(_.hasOwnProperty(J)&&(pe=_[J],pe!=null))switch(J){case"value":M=pe;break;case"defaultValue":P=pe;break;case"children":L=pe;break;case"dangerouslySetInnerHTML":if(pe!=null)throw Error(r(91));break;default:hr(h,p,J,pe,_,null)}Gt(h,M,P,L);return;case"option":for(ze in _)if(_.hasOwnProperty(ze)&&(M=_[ze],M!=null))switch(ze){case"selected":h.selected=M&&typeof M!="function"&&typeof M!="symbol";break;default:hr(h,p,ze,M,_,null)}return;case"dialog":jn("beforetoggle",h),jn("toggle",h),jn("cancel",h),jn("close",h);break;case"iframe":case"object":jn("load",h);break;case"video":case"audio":for(M=0;M<$x.length;M++)jn($x[M],h);break;case"image":jn("error",h),jn("load",h);break;case"details":jn("toggle",h);break;case"embed":case"source":case"link":jn("error",h),jn("load",h);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(rt in _)if(_.hasOwnProperty(rt)&&(M=_[rt],M!=null))switch(rt){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:hr(h,p,rt,M,_,null)}return;default:if(bh(p)){for(xt in _)_.hasOwnProperty(xt)&&(M=_[xt],M!==void 0&&rT(h,p,xt,M,_,void 0));return}}for(pe in _)_.hasOwnProperty(pe)&&(M=_[pe],M!=null&&hr(h,p,pe,M,_,null))}function tae(h,p,_,M){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var P=null,L=null,J=null,pe=null,ze=null,rt=null,xt=null;for(ft in _){var vt=_[ft];if(_.hasOwnProperty(ft)&&vt!=null)switch(ft){case"checked":break;case"value":break;case"defaultValue":ze=vt;default:M.hasOwnProperty(ft)||hr(h,p,ft,null,M,vt)}}for(var at in M){var ft=M[at];if(vt=_[at],M.hasOwnProperty(at)&&(ft!=null||vt!=null))switch(at){case"type":L=ft;break;case"name":P=ft;break;case"checked":rt=ft;break;case"defaultChecked":xt=ft;break;case"value":J=ft;break;case"defaultValue":pe=ft;break;case"children":case"dangerouslySetInnerHTML":if(ft!=null)throw Error(r(137,p));break;default:ft!==vt&&hr(h,p,at,ft,M,vt)}}Kt(h,J,pe,ze,rt,xt,L,P);return;case"select":ft=J=pe=at=null;for(L in _)if(ze=_[L],_.hasOwnProperty(L)&&ze!=null)switch(L){case"value":break;case"multiple":ft=ze;default:M.hasOwnProperty(L)||hr(h,p,L,null,M,ze)}for(P in M)if(L=M[P],ze=_[P],M.hasOwnProperty(P)&&(L!=null||ze!=null))switch(P){case"value":at=L;break;case"defaultValue":pe=L;break;case"multiple":J=L;default:L!==ze&&hr(h,p,P,L,M,ze)}p=pe,_=J,M=ft,at!=null?On(h,!!_,at,!1):!!M!=!!_&&(p!=null?On(h,!!_,p,!0):On(h,!!_,_?[]:"",!1));return;case"textarea":ft=at=null;for(pe in _)if(P=_[pe],_.hasOwnProperty(pe)&&P!=null&&!M.hasOwnProperty(pe))switch(pe){case"value":break;case"children":break;default:hr(h,p,pe,null,M,P)}for(J in M)if(P=M[J],L=_[J],M.hasOwnProperty(J)&&(P!=null||L!=null))switch(J){case"value":at=P;break;case"defaultValue":ft=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==L&&hr(h,p,J,P,M,L)}Tr(h,at,ft);return;case"option":for(var Vt in _)if(at=_[Vt],_.hasOwnProperty(Vt)&&at!=null&&!M.hasOwnProperty(Vt))switch(Vt){case"selected":h.selected=!1;break;default:hr(h,p,Vt,null,M,at)}for(ze in M)if(at=M[ze],ft=_[ze],M.hasOwnProperty(ze)&&at!==ft&&(at!=null||ft!=null))switch(ze){case"selected":h.selected=at&&typeof at!="function"&&typeof at!="symbol";break;default:hr(h,p,ze,at,M,ft)}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 rn in _)at=_[rn],_.hasOwnProperty(rn)&&at!=null&&!M.hasOwnProperty(rn)&&hr(h,p,rn,null,M,at);for(rt in M)if(at=M[rt],ft=_[rt],M.hasOwnProperty(rt)&&at!==ft&&(at!=null||ft!=null))switch(rt){case"children":case"dangerouslySetInnerHTML":if(at!=null)throw Error(r(137,p));break;default:hr(h,p,rt,at,M,ft)}return;default:if(bh(p)){for(var fr in _)at=_[fr],_.hasOwnProperty(fr)&&at!==void 0&&!M.hasOwnProperty(fr)&&rT(h,p,fr,void 0,M,at);for(xt in M)at=M[xt],ft=_[xt],!M.hasOwnProperty(xt)||at===ft||at===void 0&&ft===void 0||rT(h,p,xt,at,M,ft);return}}for(var Ze in _)at=_[Ze],_.hasOwnProperty(Ze)&&at!=null&&!M.hasOwnProperty(Ze)&&hr(h,p,Ze,null,M,at);for(vt in M)at=M[vt],ft=_[vt],!M.hasOwnProperty(vt)||at===ft||at==null&&ft==null||hr(h,p,vt,at,M,ft)}function GF(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function nae(){if(typeof performance.getEntriesByType=="function"){for(var h=0,p=0,_=performance.getEntriesByType("resource"),M=0;M<_.length;M++){var P=_[M],L=P.transferSize,J=P.initiatorType,pe=P.duration;if(L&&pe&&GF(J)){for(J=0,pe=P.responseEnd,M+=1;M<_.length;M++){var ze=_[M],rt=ze.startTime;if(rt>pe)break;var xt=ze.transferSize,vt=ze.initiatorType;xt&&GF(vt)&&(ze=ze.responseEnd,J+=xt*(ze<pe?1:(pe-rt)/(ze-rt)))}if(--M,p+=8*(L+J)/(P.duration/1e3),h++,10<h)break}}if(0<h)return p/h/1e6}return navigator.connection&&(h=navigator.connection.downlink,typeof h=="number")?h:5}var iT=null,aT=null;function $v(h){return h.nodeType===9?h:h.ownerDocument}function qF(h){switch(h){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function WF(h,p){if(h===0)switch(p){case"svg":return 1;case"math":return 2;default:return 0}return h===1&&p==="foreignObject"?0:h}function sT(h,p){return h==="textarea"||h==="noscript"||typeof p.children=="string"||typeof p.children=="number"||typeof p.children=="bigint"||typeof p.dangerouslySetInnerHTML=="object"&&p.dangerouslySetInnerHTML!==null&&p.dangerouslySetInnerHTML.__html!=null}var oT=null;function rae(){var h=window.event;return h&&h.type==="popstate"?h===oT?!1:(oT=h,!0):(oT=null,!1)}var KF=typeof setTimeout=="function"?setTimeout:void 0,iae=typeof clearTimeout=="function"?clearTimeout:void 0,XF=typeof Promise=="function"?Promise:void 0,aae=typeof queueMicrotask=="function"?queueMicrotask:typeof XF<"u"?function(h){return XF.resolve(null).then(h).catch(sae)}:KF;function sae(h){setTimeout(function(){throw h})}function $u(h){return h==="head"}function YF(h,p){var _=p,M=0;do{var P=_.nextSibling;if(h.removeChild(_),P&&P.nodeType===8)if(_=P.data,_==="/$"||_==="/&"){if(M===0){h.removeChild(P),zm(p);return}M--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")M++;else if(_==="html")Vx(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,Vx(_);for(var L=_.firstChild;L;){var J=L.nextSibling,pe=L.nodeName;L[st]||pe==="SCRIPT"||pe==="STYLE"||pe==="LINK"&&L.rel.toLowerCase()==="stylesheet"||_.removeChild(L),L=J}}else _==="body"&&Vx(h.ownerDocument.body);_=P}while(_);zm(p)}function QF(h,p){var _=h;h=0;do{var M=_.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||""),M&&M.nodeType===8)if(_=M.data,_==="/$"){if(h===0)break;h--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||h++;_=M}while(_)}function lT(h){var p=h.firstChild;for(p&&p.nodeType===10&&(p=p.nextSibling);p;){var _=p;switch(p=p.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":lT(_),et(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function oae(h,p,_,M){for(;h.nodeType===1;){var P=_;if(h.nodeName.toLowerCase()!==p.toLowerCase()){if(!M&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(M){if(!h[st])switch(p){case"meta":if(!h.hasAttribute("itemprop"))break;return h;case"link":if(L=h.getAttribute("rel"),L==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(L!==P.rel||h.getAttribute("href")!==(P.href==null||P.href===""?null:P.href)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin)||h.getAttribute("title")!==(P.title==null?null:P.title))break;return h;case"style":if(h.hasAttribute("data-precedence"))break;return h;case"script":if(L=h.getAttribute("src"),(L!==(P.src==null?null:P.src)||h.getAttribute("type")!==(P.type==null?null:P.type)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin))&&L&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(p==="input"&&h.type==="hidden"){var L=P.name==null?null:""+P.name;if(P.type==="hidden"&&h.getAttribute("name")===L)return h}else return h;if(h=lo(h.nextSibling),h===null)break}return null}function lae(h,p,_){if(p==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=lo(h.nextSibling),h===null))return null;return h}function ZF(h,p){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!p||(h=lo(h.nextSibling),h===null))return null;return h}function cT(h){return h.data==="$?"||h.data==="$~"}function uT(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function cae(h,p){var _=h.ownerDocument;if(h.data==="$~")h._reactRetry=p;else if(h.data!=="$?"||_.readyState!=="loading")p();else{var M=function(){p(),_.removeEventListener("DOMContentLoaded",M)};_.addEventListener("DOMContentLoaded",M),h._reactRetry=M}}function lo(h){for(;h!=null;h=h.nextSibling){var p=h.nodeType;if(p===1||p===3)break;if(p===8){if(p=h.data,p==="$"||p==="$!"||p==="$?"||p==="$~"||p==="&"||p==="F!"||p==="F")break;if(p==="/$"||p==="/&")return null}}return h}var dT=null;function JF(h){h=h.nextSibling;for(var p=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(p===0)return lo(h.nextSibling);p--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||p++}h=h.nextSibling}return null}function eU(h){h=h.previousSibling;for(var p=0;h;){if(h.nodeType===8){var _=h.data;if(_==="$"||_==="$!"||_==="$?"||_==="$~"||_==="&"){if(p===0)return h;p--}else _!=="/$"&&_!=="/&"||p++}h=h.previousSibling}return null}function tU(h,p,_){switch(p=$v(_),h){case"html":if(h=p.documentElement,!h)throw Error(r(452));return h;case"head":if(h=p.head,!h)throw Error(r(453));return h;case"body":if(h=p.body,!h)throw Error(r(454));return h;default:throw Error(r(451))}}function Vx(h){for(var p=h.attributes;p.length;)h.removeAttributeNode(p[0]);et(h)}var co=new Map,nU=new Set;function Hv(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var yc=K.d;K.d={f:uae,r:dae,D:hae,C:fae,L:mae,m:pae,X:xae,S:gae,M:bae};function uae(){var h=yc.f(),p=Dv();return h||p}function dae(h){var p=ue(h);p!==null&&p.tag===5&&p.type==="form"?y5(p):yc.r(h)}var Im=typeof document>"u"?null:document;function rU(h,p,_){var M=Im;if(M&&typeof p=="string"&&p){var P=dt(p);P='link[rel="'+h+'"][href="'+P+'"]',typeof _=="string"&&(P+='[crossorigin="'+_+'"]'),nU.has(P)||(nU.add(P),h={rel:h,crossOrigin:_,href:p},M.querySelector(P)===null&&(p=M.createElement("link"),ma(p,"link",h),Ie(p),M.head.appendChild(p)))}}function hae(h){yc.D(h),rU("dns-prefetch",h,null)}function fae(h,p){yc.C(h,p),rU("preconnect",h,p)}function mae(h,p,_){yc.L(h,p,_);var M=Im;if(M&&h&&p){var P='link[rel="preload"][as="'+dt(p)+'"]';p==="image"&&_&&_.imageSrcSet?(P+='[imagesrcset="'+dt(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(P+='[imagesizes="'+dt(_.imageSizes)+'"]')):P+='[href="'+dt(h)+'"]';var L=P;switch(p){case"style":L=Fm(h);break;case"script":L=Um(h)}co.has(L)||(h=f({rel:"preload",href:p==="image"&&_&&_.imageSrcSet?void 0:h,as:p},_),co.set(L,h),M.querySelector(P)!==null||p==="style"&&M.querySelector(Gx(L))||p==="script"&&M.querySelector(qx(L))||(p=M.createElement("link"),ma(p,"link",h),Ie(p),M.head.appendChild(p)))}}function pae(h,p){yc.m(h,p);var _=Im;if(_&&h){var M=p&&typeof p.as=="string"?p.as:"script",P='link[rel="modulepreload"][as="'+dt(M)+'"][href="'+dt(h)+'"]',L=P;switch(M){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":L=Um(h)}if(!co.has(L)&&(h=f({rel:"modulepreload",href:h},p),co.set(L,h),_.querySelector(P)===null)){switch(M){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(qx(L)))return}M=_.createElement("link"),ma(M,"link",h),Ie(M),_.head.appendChild(M)}}}function gae(h,p,_){yc.S(h,p,_);var M=Im;if(M&&h){var P=Fe(M).hoistableStyles,L=Fm(h);p=p||"default";var J=P.get(L);if(!J){var pe={loading:0,preload:null};if(J=M.querySelector(Gx(L)))pe.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":p},_),(_=co.get(L))&&hT(h,_);var ze=J=M.createElement("link");Ie(ze),ma(ze,"link",h),ze._p=new Promise(function(rt,xt){ze.onload=rt,ze.onerror=xt}),ze.addEventListener("load",function(){pe.loading|=1}),ze.addEventListener("error",function(){pe.loading|=2}),pe.loading|=4,Vv(J,p,M)}J={type:"stylesheet",instance:J,count:1,state:pe},P.set(L,J)}}}function xae(h,p){yc.X(h,p);var _=Im;if(_&&h){var M=Fe(_).hoistableScripts,P=Um(h),L=M.get(P);L||(L=_.querySelector(qx(P)),L||(h=f({src:h,async:!0},p),(p=co.get(P))&&fT(h,p),L=_.createElement("script"),Ie(L),ma(L,"link",h),_.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},M.set(P,L))}}function bae(h,p){yc.M(h,p);var _=Im;if(_&&h){var M=Fe(_).hoistableScripts,P=Um(h),L=M.get(P);L||(L=_.querySelector(qx(P)),L||(h=f({src:h,async:!0,type:"module"},p),(p=co.get(P))&&fT(h,p),L=_.createElement("script"),Ie(L),ma(L,"link",h),_.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},M.set(P,L))}}function iU(h,p,_,M){var P=(P=me.current)?Hv(P):null;if(!P)throw Error(r(446));switch(h){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(p=Fm(_.href),_=Fe(P).hoistableStyles,M=_.get(p),M||(M={type:"style",instance:null,count:0,state:null},_.set(p,M)),M):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){h=Fm(_.href);var L=Fe(P).hoistableStyles,J=L.get(h);if(J||(P=P.ownerDocument||P,J={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},L.set(h,J),(L=P.querySelector(Gx(h)))&&!L._p&&(J.instance=L,J.state.loading=5),co.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},co.set(h,_),L||yae(P,h,_,J.state))),p&&M===null)throw Error(r(528,""));return J}if(p&&M!==null)throw Error(r(529,""));return null;case"script":return p=_.async,_=_.src,typeof _=="string"&&p&&typeof p!="function"&&typeof p!="symbol"?(p=Um(_),_=Fe(P).hoistableScripts,M=_.get(p),M||(M={type:"script",instance:null,count:0,state:null},_.set(p,M)),M):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function Fm(h){return'href="'+dt(h)+'"'}function Gx(h){return'link[rel="stylesheet"]['+h+"]"}function aU(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function yae(h,p,_,M){h.querySelector('link[rel="preload"][as="style"]['+p+"]")?M.loading=1:(p=h.createElement("link"),M.preload=p,p.addEventListener("load",function(){return M.loading|=1}),p.addEventListener("error",function(){return M.loading|=2}),ma(p,"link",_),Ie(p),h.head.appendChild(p))}function Um(h){return'[src="'+dt(h)+'"]'}function qx(h){return"script[async]"+h}function sU(h,p,_){if(p.count++,p.instance===null)switch(p.type){case"style":var M=h.querySelector('style[data-href~="'+dt(_.href)+'"]');if(M)return p.instance=M,Ie(M),M;var P=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return M=(h.ownerDocument||h).createElement("style"),Ie(M),ma(M,"style",P),Vv(M,_.precedence,h),p.instance=M;case"stylesheet":P=Fm(_.href);var L=h.querySelector(Gx(P));if(L)return p.state.loading|=4,p.instance=L,Ie(L),L;M=aU(_),(P=co.get(P))&&hT(M,P),L=(h.ownerDocument||h).createElement("link"),Ie(L);var J=L;return J._p=new Promise(function(pe,ze){J.onload=pe,J.onerror=ze}),ma(L,"link",M),p.state.loading|=4,Vv(L,_.precedence,h),p.instance=L;case"script":return L=Um(_.src),(P=h.querySelector(qx(L)))?(p.instance=P,Ie(P),P):(M=_,(P=co.get(L))&&(M=f({},_),fT(M,P)),h=h.ownerDocument||h,P=h.createElement("script"),Ie(P),ma(P,"link",M),h.head.appendChild(P),p.instance=P);case"void":return null;default:throw Error(r(443,p.type))}else p.type==="stylesheet"&&(p.state.loading&4)===0&&(M=p.instance,p.state.loading|=4,Vv(M,_.precedence,h));return p.instance}function Vv(h,p,_){for(var M=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),P=M.length?M[M.length-1]:null,L=P,J=0;J<M.length;J++){var pe=M[J];if(pe.dataset.precedence===p)L=pe;else if(L!==P)break}L?L.parentNode.insertBefore(h,L.nextSibling):(p=_.nodeType===9?_.head:_,p.insertBefore(h,p.firstChild))}function hT(h,p){h.crossOrigin==null&&(h.crossOrigin=p.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=p.referrerPolicy),h.title==null&&(h.title=p.title)}function fT(h,p){h.crossOrigin==null&&(h.crossOrigin=p.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=p.referrerPolicy),h.integrity==null&&(h.integrity=p.integrity)}var Gv=null;function oU(h,p,_){if(Gv===null){var M=new Map,P=Gv=new Map;P.set(_,M)}else P=Gv,M=P.get(_),M||(M=new Map,P.set(_,M));if(M.has(h))return M;for(M.set(h,null),_=_.getElementsByTagName(h),P=0;P<_.length;P++){var L=_[P];if(!(L[st]||L[Xt]||h==="link"&&L.getAttribute("rel")==="stylesheet")&&L.namespaceURI!=="http://www.w3.org/2000/svg"){var J=L.getAttribute(p)||"";J=h+J;var pe=M.get(J);pe?pe.push(L):M.set(J,[L])}}return M}function lU(h,p,_){h=h.ownerDocument||h,h.head.insertBefore(_,p==="title"?h.querySelector("head > title"):null)}function vae(h,p,_){if(_===1||p.itemProp!=null)return!1;switch(h){case"meta":case"title":return!0;case"style":if(typeof p.precedence!="string"||typeof p.href!="string"||p.href==="")break;return!0;case"link":if(typeof p.rel!="string"||typeof p.href!="string"||p.href===""||p.onLoad||p.onError)break;switch(p.rel){case"stylesheet":return h=p.disabled,typeof p.precedence=="string"&&h==null;default:return!0}case"script":if(p.async&&typeof p.async!="function"&&typeof p.async!="symbol"&&!p.onLoad&&!p.onError&&p.src&&typeof p.src=="string")return!0}return!1}function cU(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function _ae(h,p,_,M){if(_.type==="stylesheet"&&(typeof M.media!="string"||matchMedia(M.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var P=Fm(M.href),L=p.querySelector(Gx(P));if(L){p=L._p,p!==null&&typeof p=="object"&&typeof p.then=="function"&&(h.count++,h=qv.bind(h),p.then(h,h)),_.state.loading|=4,_.instance=L,Ie(L);return}L=p.ownerDocument||p,M=aU(M),(P=co.get(P))&&hT(M,P),L=L.createElement("link"),Ie(L);var J=L;J._p=new Promise(function(pe,ze){J.onload=pe,J.onerror=ze}),ma(L,"link",M),_.instance=L}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(_,p),(p=_.state.preload)&&(_.state.loading&3)===0&&(h.count++,_=qv.bind(h),p.addEventListener("load",_),p.addEventListener("error",_))}}var mT=0;function wae(h,p){return h.stylesheets&&h.count===0&&Kv(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var M=setTimeout(function(){if(h.stylesheets&&Kv(h,h.stylesheets),h.unsuspend){var L=h.unsuspend;h.unsuspend=null,L()}},6e4+p);0<h.imgBytes&&mT===0&&(mT=62500*nae());var P=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&Kv(h,h.stylesheets),h.unsuspend)){var L=h.unsuspend;h.unsuspend=null,L()}},(h.imgBytes>mT?50:800)+p);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(M),clearTimeout(P)}}:null}function qv(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Kv(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var Wv=null;function Kv(h,p){h.stylesheets=null,h.unsuspend!==null&&(h.count++,Wv=new Map,p.forEach(Sae,h),Wv=null,qv.call(h))}function Sae(h,p){if(!(p.state.loading&4)){var _=Wv.get(h);if(_)var M=_.get(null);else{_=new Map,Wv.set(h,_);for(var P=h.querySelectorAll("link[data-precedence],style[data-precedence]"),L=0;L<P.length;L++){var J=P[L];(J.nodeName==="LINK"||J.getAttribute("media")!=="not all")&&(_.set(J.dataset.precedence,J),M=J)}M&&_.set(null,M)}P=p.instance,J=P.getAttribute("data-precedence"),L=_.get(J)||M,L===M&&_.set(null,P),_.set(J,P),this.count++,M=qv.bind(this),P.addEventListener("load",M),P.addEventListener("error",M),L?L.parentNode.insertBefore(P,L.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(P,h.firstChild)),p.state.loading|=4}}var Wx={$$typeof:S,Provider:null,Consumer:null,_currentValue:Z,_currentValue2:Z,_threadCount:0};function Nae(h,p,_,M,P,L,J,pe,ze){this.tag=1,this.containerInfo=h,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=jt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=jt(0),this.hiddenUpdates=jt(null),this.identifierPrefix=M,this.onUncaughtError=P,this.onCaughtError=L,this.onRecoverableError=J,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ze,this.incompleteTransitions=new Map}function uU(h,p,_,M,P,L,J,pe,ze,rt,xt,vt){return h=new Nae(h,p,_,J,ze,rt,xt,vt,pe),p=1,L===!0&&(p|=24),L=js(3,null,null,p),h.current=L,L.stateNode=h,p=WM(),p.refCount++,h.pooledCache=p,p.refCount++,L.memoizedState={element:M,isDehydrated:_,cache:p},QM(L),h}function dU(h){return h?(h=gm,h):gm}function hU(h,p,_,M,P,L){P=dU(P),M.context===null?M.context=P:M.pendingContext=P,M=ju(p),M.payload={element:_},L=L===void 0?null:L,L!==null&&(M.callback=L),_=Pu(h,M,p),_!==null&&(ds(_,h,p),Mx(_,h,p))}function fU(h,p){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<p?_:p}}function pT(h,p){fU(h,p),(h=h.alternate)&&fU(h,p)}function mU(h){if(h.tag===13||h.tag===31){var p=wh(h,67108864);p!==null&&ds(p,h,67108864),pT(h,67108864)}}function pU(h){if(h.tag===13||h.tag===31){var p=Ls();p=ur(p);var _=wh(h,p);_!==null&&ds(_,h,p),pT(h,p)}}var Xv=!0;function Mae(h,p,_,M){var P=Y.T;Y.T=null;var L=K.p;try{K.p=2,gT(h,p,_,M)}finally{K.p=L,Y.T=P}}function Eae(h,p,_,M){var P=Y.T;Y.T=null;var L=K.p;try{K.p=8,gT(h,p,_,M)}finally{K.p=L,Y.T=P}}function gT(h,p,_,M){if(Xv){var P=xT(M);if(P===null)nT(h,p,M,Yv,_),xU(h,M);else if(Cae(P,h,p,_,M))M.stopPropagation();else if(xU(h,M),p&4&&-1<Tae.indexOf(h)){for(;P!==null;){var L=ue(P);if(L!==null)switch(L.tag){case 3:if(L=L.stateNode,L.current.memoizedState.isDehydrated){var J=De(L.pendingLanes);if(J!==0){var pe=L;for(pe.pendingLanes|=2,pe.entangledLanes|=2;J;){var ze=1<<31-Le(J);pe.entanglements[1]|=ze,J&=~ze}yl(L),(Jn&6)===0&&(Pv=I()+500,Bx(0))}}break;case 31:case 13:pe=wh(L,2),pe!==null&&ds(pe,L,2),Dv(),pT(L,2)}if(L=xT(M),L===null&&nT(h,p,M,Yv,_),L===P)break;P=L}P!==null&&M.stopPropagation()}else nT(h,p,M,null,_)}}function xT(h){return h=ua(h),bT(h)}var Yv=null;function bT(h){if(Yv=null,h=Ct(h),h!==null){var p=s(h);if(p===null)h=null;else{var _=p.tag;if(_===13){if(h=o(p),h!==null)return h;h=null}else if(_===31){if(h=l(p),h!==null)return h;h=null}else if(_===3){if(p.stateNode.current.memoizedState.isDehydrated)return p.tag===3?p.stateNode.containerInfo:null;h=null}else p!==h&&(h=null)}}return Yv=h,null}function gU(h){switch(h){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(V()){case ie:return 2;case Se:return 8;case ye:case $e:return 32;case Ue:return 268435456;default:return 32}default:return 32}}var yT=!1,Hu=null,Vu=null,Gu=null,Kx=new Map,Xx=new Map,qu=[],Tae="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 xU(h,p){switch(h){case"focusin":case"focusout":Hu=null;break;case"dragenter":case"dragleave":Vu=null;break;case"mouseover":case"mouseout":Gu=null;break;case"pointerover":case"pointerout":Kx.delete(p.pointerId);break;case"gotpointercapture":case"lostpointercapture":Xx.delete(p.pointerId)}}function Yx(h,p,_,M,P,L){return h===null||h.nativeEvent!==L?(h={blockedOn:p,domEventName:_,eventSystemFlags:M,nativeEvent:L,targetContainers:[P]},p!==null&&(p=ue(p),p!==null&&mU(p)),h):(h.eventSystemFlags|=M,p=h.targetContainers,P!==null&&p.indexOf(P)===-1&&p.push(P),h)}function Cae(h,p,_,M,P){switch(p){case"focusin":return Hu=Yx(Hu,h,p,_,M,P),!0;case"dragenter":return Vu=Yx(Vu,h,p,_,M,P),!0;case"mouseover":return Gu=Yx(Gu,h,p,_,M,P),!0;case"pointerover":var L=P.pointerId;return Kx.set(L,Yx(Kx.get(L)||null,h,p,_,M,P)),!0;case"gotpointercapture":return L=P.pointerId,Xx.set(L,Yx(Xx.get(L)||null,h,p,_,M,P)),!0}return!1}function bU(h){var p=Ct(h.target);if(p!==null){var _=s(p);if(_!==null){if(p=_.tag,p===13){if(p=o(_),p!==null){h.blockedOn=p,jr(h.priority,function(){pU(_)});return}}else if(p===31){if(p=l(_),p!==null){h.blockedOn=p,jr(h.priority,function(){pU(_)});return}}else if(p===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function Qv(h){if(h.blockedOn!==null)return!1;for(var p=h.targetContainers;0<p.length;){var _=xT(h.nativeEvent);if(_===null){_=h.nativeEvent;var M=new _.constructor(_.type,_);rc=M,_.target.dispatchEvent(M),rc=null}else return p=ue(_),p!==null&&mU(p),h.blockedOn=_,!1;p.shift()}return!0}function yU(h,p,_){Qv(h)&&_.delete(p)}function Aae(){yT=!1,Hu!==null&&Qv(Hu)&&(Hu=null),Vu!==null&&Qv(Vu)&&(Vu=null),Gu!==null&&Qv(Gu)&&(Gu=null),Kx.forEach(yU),Xx.forEach(yU)}function Zv(h,p){h.blockedOn===p&&(h.blockedOn=null,yT||(yT=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Aae)))}var Jv=null;function vU(h){Jv!==h&&(Jv=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Jv===h&&(Jv=null);for(var p=0;p<h.length;p+=3){var _=h[p],M=h[p+1],P=h[p+2];if(typeof M!="function"){if(bT(M||_)===null)continue;break}var L=ue(_);L!==null&&(h.splice(p,3),p-=3,xE(L,{pending:!0,data:P,method:_.method,action:M},M,P))}}))}function zm(h){function p(ze){return Zv(ze,h)}Hu!==null&&Zv(Hu,h),Vu!==null&&Zv(Vu,h),Gu!==null&&Zv(Gu,h),Kx.forEach(p),Xx.forEach(p);for(var _=0;_<qu.length;_++){var M=qu[_];M.blockedOn===h&&(M.blockedOn=null)}for(;0<qu.length&&(_=qu[0],_.blockedOn===null);)bU(_),_.blockedOn===null&&qu.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(M=0;M<_.length;M+=3){var P=_[M],L=_[M+1],J=P[zn]||null;if(typeof L=="function")J||vU(_);else if(J){var pe=null;if(L&&L.hasAttribute("formAction")){if(P=L,J=L[zn]||null)pe=J.formAction;else if(bT(P)!==null)continue}else pe=J.action;typeof pe=="function"?_[M+1]=pe:(_.splice(M,3),M-=3),vU(_)}}}function _U(){function h(L){L.canIntercept&&L.info==="react-transition"&&L.intercept({handler:function(){return new Promise(function(J){return P=J})},focusReset:"manual",scroll:"manual"})}function p(){P!==null&&(P(),P=null),M||setTimeout(_,20)}function _(){if(!M&&!navigation.transition){var L=navigation.currentEntry;L&&L.url!=null&&navigation.navigate(L.url,{state:L.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var M=!1,P=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",p),navigation.addEventListener("navigateerror",p),setTimeout(_,100),function(){M=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",p),navigation.removeEventListener("navigateerror",p),P!==null&&(P(),P=null)}}}function vT(h){this._internalRoot=h}e_.prototype.render=vT.prototype.render=function(h){var p=this._internalRoot;if(p===null)throw Error(r(409));var _=p.current,M=Ls();hU(_,M,h,p,null,null)},e_.prototype.unmount=vT.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var p=h.containerInfo;hU(h.current,2,null,h,null,null),Dv(),p[Wn]=null}};function e_(h){this._internalRoot=h}e_.prototype.unstable_scheduleHydration=function(h){if(h){var p=wr();h={blockedOn:null,target:h,priority:p};for(var _=0;_<qu.length&&p!==0&&p<qu[_].priority;_++);qu.splice(_,0,h),_===0&&bU(h)}};var wU=e.version;if(wU!=="19.2.0")throw Error(r(527,wU,"19.2.0"));K.findDOMNode=function(h){var p=h._reactInternals;if(p===void 0)throw typeof h.render=="function"?Error(r(188)):(h=Object.keys(h).join(","),Error(r(268,h)));return h=u(p),h=h!==null?d(h):null,h=h===null?null:h.stateNode,h};var kae={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:Y,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var t_=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!t_.isDisabled&&t_.supportsFiber)try{Ye=t_.inject(kae),oe=t_}catch{}}return Zx.createRoot=function(h,p){if(!i(h))throw Error(r(299));var _=!1,M="",P=A5,L=k5,J=j5;return p!=null&&(p.unstable_strictMode===!0&&(_=!0),p.identifierPrefix!==void 0&&(M=p.identifierPrefix),p.onUncaughtError!==void 0&&(P=p.onUncaughtError),p.onCaughtError!==void 0&&(L=p.onCaughtError),p.onRecoverableError!==void 0&&(J=p.onRecoverableError)),p=uU(h,1,!1,null,null,_,M,null,P,L,J,_U),h[Wn]=p.current,tT(h),new vT(p)},Zx.hydrateRoot=function(h,p,_){if(!i(h))throw Error(r(299));var M=!1,P="",L=A5,J=k5,pe=j5,ze=null;return _!=null&&(_.unstable_strictMode===!0&&(M=!0),_.identifierPrefix!==void 0&&(P=_.identifierPrefix),_.onUncaughtError!==void 0&&(L=_.onUncaughtError),_.onCaughtError!==void 0&&(J=_.onCaughtError),_.onRecoverableError!==void 0&&(pe=_.onRecoverableError),_.formState!==void 0&&(ze=_.formState)),p=uU(h,1,!0,p,_??null,M,P,ze,L,J,pe,_U),p.context=dU(null),_=p.current,M=Ls(),M=ur(M),P=ju(M),P.callback=null,Pu(_,P,M),_=M,p.current.lanes=_,ln(p,_),yl(p),h[Wn]=p.current,tT(h),new e_(p)},Zx.version="19.2.0",Zx}var PU;function Bae(){if(PU)return ST.exports;PU=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(),ST.exports=zae(),ST.exports}var $ae=Bae();const un=t=>typeof t=="string",Jx=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},RU=t=>t==null?"":""+t,Hae=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Vae=/###/g,DU=t=>t&&t.indexOf("###")>-1?t.replace(Vae,"."):t,OU=t=>!t||un(t),Bb=(t,e,n)=>{const r=un(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(OU(t))return{};const s=DU(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return OU(t)?{}:{obj:t,k:DU(r[i])}},LU=(t,e,n)=>{const{obj:r,k:i}=Bb(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let s=e[e.length-1],o=e.slice(0,e.length-1),l=Bb(t,o,Object);for(;l.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),l=Bb(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${s}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${s}`]=n},Gae=(t,e,n,r)=>{const{obj:i,k:s}=Bb(t,e,Object);i[s]=i[s]||[],i[s].push(n)},fw=(t,e)=>{const{obj:n,k:r}=Bb(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},qae=(t,e,n)=>{const r=fw(t,n);return r!==void 0?r:fw(e,n)},lq=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?un(t[r])||t[r]instanceof String||un(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):lq(t[r],e[r],n):t[r]=e[r]);return t},Bm=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Wae={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const Kae=t=>un(t)?t.replace(/[&<>"'\/]/g,e=>Wae[e]):t;class Xae{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 Yae=[" ",",","?","!",";"],Qae=new Xae(20),Zae=(t,e,n)=>{e=e||"",n=n||"";const r=Yae.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=Qae.getRegExp(`(${r.map(o=>o==="?"?"\\?":o).join("|")})`);let s=!i.test(t);if(!s){const o=t.indexOf(n);o>0&&!i.test(t.substring(0,o))&&(s=!0)}return s},Aj=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let s=0;s<r.length;){if(!i||typeof i!="object")return;let o,l="";for(let c=s;c<r.length;++c)if(c!==s&&(l+=n),l+=r[c],o=i[l],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&c<r.length-1)continue;s+=c-s+1;break}i=o}return i},d0=t=>t?.replace("_","-"),Jae={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 mw{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||Jae,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:(un(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new mw(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new mw(this.logger,e)}}var jl=new mw;let j2=class{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,s])=>{for(let o=0;o<s;o++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,s])=>{for(let o=0;o<s;o++)i.apply(i,[e,...n])})}};class IU extends j2{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r,i={}){const s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,o=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;e.indexOf(".")>-1?l=e.split("."):(l=[e,n],r&&(Array.isArray(r)?l.push(...r):un(r)&&s?l.push(...r.split(s)):l.push(r)));const c=fw(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!o||!un(r)?c:Aj(this.data?.[e]?.[n],r,s)}addResource(e,n,r,i,s={silent:!1}){const o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let l=[e,n];r&&(l=l.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(l=e.split("."),i=n,n=l[1]),this.addNamespaces(n),LU(this.data,l,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const s in r)(un(r[s])||Array.isArray(r[s]))&&this.addResource(e,n,s,r[s],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,s,o={silent:!1,skipCopy:!1}){let l=[e,n];e.indexOf(".")>-1&&(l=e.split("."),i=r,r=n,n=l[1]),this.addNamespaces(n);let c=fw(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?lq(c,r,s):c={...c,...r},LU(this.data,l,c),o.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var cq={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{e=this.processors[s]?.process(e,n,r,i)??e}),e}};const uq=Symbol("i18next/PATH_KEY");function ese(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===uq?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function kj(t,e){const{[uq]:n}=t(ese());return n.join(e?.keySeparator??".")}const FU={},TT=t=>!un(t)&&typeof t!="boolean"&&typeof t!="number";class pw extends j2{constructor(e,n={}){super(),Hae(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=jl.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const r={...n};if(e==null)return!1;const i=this.resolve(e,r);if(i?.res===void 0)return!1;const s=TT(i.res);return!(r.returnObjects===!1&&s)}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const o=r&&e.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Zae(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:un(s)?[s]:s};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(s=u.shift()),e=u.join(i)}return{key:e,namespaces:un(s)?[s]:s}}translate(e,n,r){let i=typeof n=="object"?{...n}:n;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=kj(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const s=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:l,namespaces:c}=this.extractFromKey(e[e.length-1],i),u=c[c.length-1];let d=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const f=i.lng||this.language,m=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return m?s?{res:`${u}${d}${l}`,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${l}`:s?{res:l,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:l;const g=this.resolve(e,i);let x=g?.res;const y=g?.usedKey||l,b=g?.exactUsedKey||l,v=["[object Number]","[object Function]","[object RegExp]"],N=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,S=!this.i18nFormat||this.i18nFormat.handleAsObject,T=i.count!==void 0&&!un(i.count),E=pw.hasDefaultValue(i),k=T?this.pluralResolver.getSuffix(f,i.count,i):"",C=i.ordinal&&T?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",D=T&&!i.ordinal&&i.count===0,A=D&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${k}`]||i[`defaultValue${C}`]||i.defaultValue;let R=x;S&&!x&&E&&(R=A);const F=TT(R),O=Object.prototype.toString.apply(R);if(S&&R&&F&&v.indexOf(O)<0&&!(un(N)&&Array.isArray(R))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const q=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,R,{...i,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return s?(g.res=q,g.usedParams=this.getUsedParamsDetails(i),g):q}if(o){const q=Array.isArray(R),j=q?[]:{},G=q?b:y;for(const Y in R)if(Object.prototype.hasOwnProperty.call(R,Y)){const K=`${G}${o}${Y}`;E&&!x?j[Y]=this.translate(K,{...i,defaultValue:TT(A)?A[Y]:void 0,joinArrays:!1,ns:c}):j[Y]=this.translate(K,{...i,joinArrays:!1,ns:c}),j[Y]===K&&(j[Y]=R[Y])}x=j}}else if(S&&un(N)&&Array.isArray(x))x=x.join(N),x&&(x=this.extendTranslation(x,e,i,r));else{let q=!1,j=!1;!this.isValidLookup(x)&&E&&(q=!0,x=A),this.isValidLookup(x)||(j=!0,x=l);const Y=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&j?void 0:x,K=E&&A!==x&&this.options.updateMissing;if(j||q||K){if(this.logger.log(K?"updateKey":"missingKey",f,u,l,K?A:x),o){const z=this.resolve(l,{...i,keySeparator:!1});z&&z.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 te=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&te&&te[0])for(let z=0;z<te.length;z++)Z.push(te[z]);else this.options.saveMissingTo==="all"?Z=this.languageUtils.toResolveHierarchy(i.lng||this.language):Z.push(i.lng||this.language);const ne=(z,W,se)=>{const ae=E&&se!==x?se:Y;this.options.missingKeyHandler?this.options.missingKeyHandler(z,u,W,ae,K,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(z,u,W,ae,K,i),this.emit("missingKey",z,u,W,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&T?Z.forEach(z=>{const W=this.pluralResolver.getSuffixes(z,i);D&&i[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(se=>{ne([z],l+se,i[`defaultValue${se}`]||A)})}):ne(Z,l,A))}x=this.extendTranslation(x,e,i,g,r),j&&x===l&&this.options.appendNamespaceToMissingKey&&(x=`${u}${d}${l}`),(j||q)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,q?x:void 0,i))}return s?(g.res=x,g.usedParams=this.getUsedParamsDetails(i),g):x}extendTranslation(e,n,r,i,s){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=un(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(c){const f=e.match(this.interpolator.nestingRegexp);u=f&&f.length}let d=r.replace&&!un(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),e=this.interpolator.interpolate(e,d,r.lng||this.language||i.usedLng,r),c){const f=e.match(this.interpolator.nestingRegexp),m=f&&f.length;u<m&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...f)=>s?.[0]===f[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${n[0]}`),null):this.translate(...f,n),r)),r.interpolation&&this.interpolator.reset()}const o=r.postProcess||this.options.postProcess,l=un(o)?[o]:o;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=cq.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,s,o,l;return un(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),d=u.key;i=d;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const m=n.count!==void 0&&!un(n.count),g=m&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(un(n.context)||typeof n.context=="number")&&n.context!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(b=>{this.isValidLookup(r)||(l=b,!FU[`${y[0]}-${b}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(FU[`${y[0]}-${b}`]=!0,this.logger.warn(`key "${i}" for languages "${y.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),y.forEach(v=>{if(this.isValidLookup(r))return;o=v;const N=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(N,d,v,b,n);else{let T;m&&(T=this.pluralResolver.getSuffix(v,n.count,n));const E=`${this.options.pluralSeparator}zero`,k=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(n.ordinal&&T.indexOf(k)===0&&N.push(d+T.replace(k,this.options.pluralSeparator)),N.push(d+T),g&&N.push(d+E)),x){const C=`${d}${this.options.contextSeparator||"_"}${n.context}`;N.push(C),m&&(n.ordinal&&T.indexOf(k)===0&&N.push(C+T.replace(k,this.options.pluralSeparator)),N.push(C+T),g&&N.push(C+E))}}let S;for(;S=N.pop();)this.isValidLookup(r)||(s=S,r=this.getResource(v,b,S,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:o,usedNS:l}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!un(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const s of n)delete i[s]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class UU{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=jl.create("languageUtils")}getScriptPartFromCode(e){if(e=d0(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=d0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(un(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getScriptPartFromCode(r);if(this.isSupportedCode(i))return n=i;const s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return n=s;n=this.options.supportedLngs.find(o=>{if(o===s)return o;if(!(o.indexOf("-")<0&&s.indexOf("-")<0)&&(o.indexOf("-")>0&&s.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===s||o.indexOf(s)===0&&s.length>1))return o})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),un(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),i=[],s=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return un(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):un(e)&&s(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&s(this.formatLanguageCode(o))}),i}}const zU={zero:0,one:1,two:2,few:3,many:4,other:5},BU={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class tse{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=jl.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=d0(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:i});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let o;try{o=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),BU;if(!e.match(/-|_/))return BU;const c=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(c,n)}return this.pluralRulesCache[s]=o,o}needsPlural(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,r={}){return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,s)=>zU[i]-zU[s]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n,r={}){const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const $U=(t,e,n,r=".",i=!0)=>{let s=qae(t,e,n);return!s&&i&&un(n)&&(s=Aj(t,n,r),s===void 0&&(s=Aj(e,n,r))),s},CT=t=>t.replace(/\$/g,"$$$$");class nse{constructor(e={}){this.logger=jl.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:s,prefixEscaped:o,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:g,nestingSuffix:x,nestingSuffixEscaped:y,nestingOptionsSeparator:b,maxReplaces:v,alwaysFormat:N}=e.interpolation;this.escape=n!==void 0?n:Kae,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?Bm(s):o||"{{",this.suffix=l?Bm(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=m?Bm(m):g||Bm("$t("),this.nestingSuffix=x?Bm(x):y||Bm(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=v||1e3,this.alwaysFormat=N!==void 0?N:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,r,i){let s,o,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=g=>{if(g.indexOf(this.formatSeparator)<0){const v=$U(n,c,g,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(v,void 0,r,{...i,...n,interpolationkey:g}):v}const x=g.split(this.formatSeparator),y=x.shift().trim(),b=x.join(this.formatSeparator).trim();return this.format($U(n,c,y,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...i,...n,interpolationkey:y})};this.resetRegExp();const d=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:g=>CT(g)},{regex:this.regexp,safeValue:g=>this.escapeValue?CT(this.escape(g)):CT(g)}].forEach(g=>{for(l=0;s=g.regex.exec(e);){const x=s[1].trim();if(o=u(x),o===void 0)if(typeof d=="function"){const b=d(e,s,i);o=un(b)?b:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))o="";else if(f){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),o="";else!un(o)&&!this.useRawValueToEscape&&(o=RU(o));const y=g.safeValue(o);if(e=e.replace(s[0],y),f?(g.regex.lastIndex+=o.length,g.regex.lastIndex-=s[0].length):g.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,s,o;const l=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let m=`{${f[1]}`;c=f[0],m=this.interpolate(m,o);const g=m.match(/'/g),x=m.match(/"/g);((g?.length??0)%2===0&&!x||x.length%2!==0)&&(m=m.replace(/'/g,'"'));try{o=JSON.parse(m),u&&(o={...u,...o})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,y),`${c}${d}${m}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,c};for(;i=this.nestingRegexp.exec(e);){let c=[];o={...r},o=o.replace&&!un(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;const u=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(u!==-1&&(c=i[1].slice(u).split(this.formatSeparator).map(d=>d.trim()).filter(Boolean),i[1]=i[1].slice(0,u)),s=n(l.call(this,i[1].trim(),o),o),s&&i[0]===e&&!un(s))return s;un(s)||(s=RU(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),c.length&&(s=c.reduce((d,f)=>this.format(d,f,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const rse=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(o=>{if(o){const[l,...c]=o.split(":"),u=c.join(":").trim().replace(/^'+|'+$/g,""),d=l.trim();n[d]||(n[d]=u),u==="false"&&(n[d]=!1),u==="true"&&(n[d]=!0),isNaN(u)||(n[d]=parseInt(u,10))}})}return{formatName:e,formatOptions:n}},HU=t=>{const e={};return(n,r,i)=>{let s=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(s={...s,[i.interpolationkey]:void 0});const o=r+JSON.stringify(s);let l=e[o];return l||(l=t(d0(r),i),e[o]=l),l(n)}},ise=t=>(e,n,r)=>t(d0(n),r)(e);class ase{constructor(e={}){this.logger=jl.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?HU:ise;this.formats={number:r((i,s)=>{const o=new Intl.NumberFormat(i,{...s});return l=>o.format(l)}),currency:r((i,s)=>{const o=new Intl.NumberFormat(i,{...s,style:"currency"});return l=>o.format(l)}),datetime:r((i,s)=>{const o=new Intl.DateTimeFormat(i,{...s});return l=>o.format(l)}),relativetime:r((i,s)=>{const o=new Intl.RelativeTimeFormat(i,{...s});return l=>o.format(l,s.range||"day")}),list:r((i,s)=>{const o=new Intl.ListFormat(i,{...s});return l=>o.format(l)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=HU(n)}format(e,n,r,i={}){const s=n.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(l=>l.indexOf(")")>-1)){const l=s.findIndex(c=>c.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,l)].join(this.formatSeparator)}return s.reduce((l,c)=>{const{formatName:u,formatOptions:d}=rse(c);if(this.formats[u]){let f=l;try{const m=i?.formatParams?.[i.interpolationkey]||{},g=m.locale||m.lng||i.locale||i.lng||r;f=this.formats[u](l,g,{...d,...i,...m})}catch(m){this.logger.warn(m)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},e)}}const sse=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class ose extends j2{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=jl.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,i.backend,i)}queueLoad(e,n,r,i){const s={},o={},l={},c={};return e.forEach(u=>{let d=!0;n.forEach(f=>{const m=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?o[m]===void 0&&(o[m]=!0):(this.state[m]=1,d=!1,o[m]===void 0&&(o[m]=!0),s[m]===void 0&&(s[m]=!0),c[f]===void 0&&(c[f]=!0)))}),d||(l[u]=!0)}),(Object.keys(s).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(o),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(e,n,r){const i=e.split("|"),s=i[0],o=i[1];n&&this.emit("failedLoading",s,o,n),!n&&r&&this.store.addResourceBundle(s,o,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const l={};this.queue.forEach(c=>{Gae(c.loaded,[s],o),sse(c,e),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const d=c.loaded[u];d.length&&d.forEach(f=>{l[u][f]===void 0&&(l[u][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(e,n,r,i=0,s=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:s,callback:o});return}this.readingCalls++;const l=(u,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&d&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,s*2,o)},s);return}o(u,d)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(e,n);u&&typeof u.then=="function"?u.then(d=>l(null,d)).catch(l):l(null,u)}catch(u){l(u)}return}return c(e,n,l)}prepareLoading(e,n,r={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();un(e)&&(e=this.languageUtils.toResolveHierarchy(e)),un(n)&&(n=[n]);const s=this.queueLoad(e,n,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(o=>{this.loadOne(o)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e,n=""){const r=e.split("|"),i=r[0],s=r[1];this.read(i,s,"read",void 0,void 0,(o,l)=>{o&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,o),!o&&l&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,l),this.loaded(e,o,l)})}saveMissing(e,n,r,i,s,o={},l=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const c={...o,isUpdate:s},u=this.backend.create.bind(this.backend);if(u.length<6)try{let d;u.length===5?d=u(e,n,r,i,c):d=u(e,n,r,i),d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}else u(e,n,r,i,l,c)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const VU=()=>({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]),un(t[1])&&(e.defaultValue=t[1]),un(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}),GU=t=>(un(t.ns)&&(t.ns=[t.ns]),un(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),un(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),r_=()=>{},lse=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class $b extends j2{constructor(e={},n){if(super(),this.options=GU(e),this.services={},this.logger=jl,this.modules={external:[]},lse(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&&(un(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=VU();this.options={...r,...this.options,...GU(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const i=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?jl.init(i(this.modules.logger),this.options):jl.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=ase;const d=new UU(this.options);this.store=new IU(this.options.resources,this.options);const f=this.services;f.logger=jl,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new tse(d,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),u&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(f.formatter=i(u),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new nse(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new ose(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(g,...x)=>{this.emit(g,...x)}),this.modules.languageDetector&&(f.languageDetector=i(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=i(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new pw(this.services,this.options),this.translator.on("*",(g,...x)=>{this.emit(g,...x)}),this.modules.external.forEach(g=>{g.init&&g.init(this)})}if(this.format=this.options.interpolation.format,n||(n=r_),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(u=>{this[u]=(...d)=>this.store[u](...d)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=(...d)=>(this.store[u](...d),this)});const l=Jx(),c=()=>{const u=(d,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(f),n(d,f)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(e,n=r_){let r=n;const i=un(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const s=[],o=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(u=>{u!=="cimode"&&s.indexOf(u)<0&&s.push(u)})};i?o(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>o(c)),this.options.preload?.forEach?.(l=>o(l)),this.services.backendConnector.load(s,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(e,n,r){const i=Jx();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=r_),this.services.backendConnector.reload(e,n,s=>{i.resolve(),r(s)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&cq.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=Jx();this.emit("languageChanging",e);const i=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},s=(l,c)=>{c?this.isLanguageChangingTo===e&&(i(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve((...u)=>this.t(...u)),n&&n(l,(...u)=>this.t(...u))},o=l=>{!e&&!l&&this.services.languageDetector&&(l=[]);const c=un(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(un(l)?[l]:l);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector?.cacheUserLanguage?.(u)),this.loadResources(u,d=>{s(d,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e),r}getFixedT(e,n,r){const i=(s,o,...l)=>{let c;typeof o!="object"?c=this.options.overloadTranslationOptionHandler([s,o].concat(l)):c={...o},c.lng=c.lng||i.lng,c.lngs=c.lngs||i.lngs,c.ns=c.ns||i.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||i.keyPrefix);const u=this.options.keySeparator||".";let d;return c.keyPrefix&&Array.isArray(s)?d=s.map(f=>(typeof f=="function"&&(f=kj(f,{...this.options,...o})),`${c.keyPrefix}${u}${f}`)):(typeof s=="function"&&(s=kj(s,{...this.options,...o})),d=c.keyPrefix?`${c.keyPrefix}${u}${s}`:s),this.t(d,c)};return un(e)?i.lng=e:i.lngs=e,i.ns=n,i.keyPrefix=r,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const o=(l,c)=>{const u=this.services.backendConnector.state[`${l}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const l=n.precheck(this,o);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!i||o(s,e)))}loadNamespaces(e,n){const r=Jx();return this.options.ns?(un(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=Jx();un(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return s.length?(this.options.preload=i.concat(s),this.loadResources(o=>{r.resolve(),n&&n(o)}),r):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const s=i.getTextInfo();if(s&&s.direction)return s.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new UU(VU());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 $b(e,n);return r.createInstance=$b.createInstance,r}cloneInstance(e={},n=r_){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new $b(i);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(l=>{s[l]=this[l]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r){const l=Object.keys(this.store.data).reduce((c,u)=>(c[u]={...this.store.data[u]},c[u]=Object.keys(c[u]).reduce((d,f)=>(d[f]={...c[u][f]},d),c[u]),c),{});s.store=new IU(l,i),s.services.resourceStore=s.store}return s.translator=new pw(s.services,i),s.translator.on("*",(l,...c)=>{s.emit(l,...c)}),s.init(i,n),s.translator.options=i,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const is=$b.createInstance();is.createInstance;is.dir;is.init;is.loadResources;is.reloadResources;is.use;is.changeLanguage;is.getFixedT;is.t;is.exists;is.setDefaultNamespace;is.hasLoadedNamespace;is.loadNamespaces;is.loadLanguages;const cse=(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);jf(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},qU={},dq=(t,e,n,r)=>{jf(n)&&qU[n]||(jf(n)&&(qU[n]=new Date),cse(t,e,n,r))},hq=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},jj=(t,e,n)=>{t.loadNamespaces(e,hq(t,n))},WU=(t,e,n,r)=>{if(jf(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return jj(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,hq(t,r))},use=(t,e,n={})=>!e.languages||!e.languages.length?(dq(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}}),jf=t=>typeof t=="string",dse=t=>typeof t=="object"&&t!==null,hse=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,fse={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},mse=t=>fse[t],pse=t=>t.replace(hse,mse);let Pj={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:pse};const gse=(t={})=>{Pj={...Pj,...t}},xse=()=>Pj;let fq;const bse=t=>{fq=t},yse=()=>fq,vse={type:"3rdParty",init(t){gse(t.options.react),bse(t)}},_se=w.createContext();class wse{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var AT={exports:{}},kT={};var KU;function Sse(){if(KU)return kT;KU=1;var t=Ig();function e(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,s=t.useLayoutEffect,o=t.useDebugValue;function l(f,m){var g=m(),x=r({inst:{value:g,getSnapshot:m}}),y=x[0].inst,b=x[1];return s(function(){y.value=g,y.getSnapshot=m,c(y)&&b({inst:y})},[f,g,m]),i(function(){return c(y)&&b({inst:y}),f(function(){c(y)&&b({inst:y})})},[f]),o(g),g}function c(f){var m=f.getSnapshot;f=f.value;try{var g=m();return!n(f,g)}catch{return!0}}function u(f,m){return m()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:l;return kT.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,kT}var XU;function mq(){return XU||(XU=1,AT.exports=Sse()),AT.exports}var KR=mq();const Nse=(t,e)=>jf(e)?e:dse(e)&&jf(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,Mse={t:Nse,ready:!1},Ese=()=>()=>{},Fg=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=w.useContext(_se)||{},s=n||r||yse();s&&!s.reportNamespaces&&(s.reportNamespaces=new wse),s||dq(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=w.useMemo(()=>({...xse(),...s?.options?.react,...e}),[s,e]),{useSuspense:l,keyPrefix:c}=o,u=i||s?.options?.defaultNS,d=jf(u)?[u]:u||["translation"],f=w.useMemo(()=>d,d);s?.reportNamespaces?.addUsedNamespaces?.(f);const m=w.useRef(0),g=w.useCallback(A=>{if(!s)return Ese;const{bindI18n:R,bindI18nStore:F}=o,O=()=>{m.current+=1,A()};return R&&s.on(R,O),F&&s.store.on(F,O),()=>{R&&R.split(" ").forEach(q=>s.off(q,O)),F&&F.split(" ").forEach(q=>s.store.off(q,O))}},[s,o]),x=w.useRef(),y=w.useCallback(()=>{if(!s)return Mse;const A=!!(s.isInitialized||s.initializedStoreOnce)&&f.every(G=>use(G,s,o)),R=e.lng||s.language,F=m.current,O=x.current;if(O&&O.ready===A&&O.lng===R&&O.keyPrefix===c&&O.revision===F)return O;const j={t:s.getFixedT(R,o.nsMode==="fallback"?f:f[0],c),ready:A,lng:R,keyPrefix:c,revision:F};return x.current=j,j},[s,f,c,o,e.lng]),[b,v]=w.useState(0),{t:N,ready:S}=KR.useSyncExternalStore(g,y,y);w.useEffect(()=>{if(s&&!S&&!l){const A=()=>v(R=>R+1);e.lng?WU(s,e.lng,f,A):jj(s,f,A)}},[s,e.lng,f,S,l,b]);const T=s||{},E=w.useRef(null),k=w.useRef(),C=A=>{const R=Object.getOwnPropertyDescriptors(A);R.__original&&delete R.__original;const F=Object.create(Object.getPrototypeOf(A),R);if(!Object.prototype.hasOwnProperty.call(F,"__original"))try{Object.defineProperty(F,"__original",{value:A,writable:!1,enumerable:!1,configurable:!1})}catch{}return F},D=w.useMemo(()=>{const A=T,R=A?.language;let F=A;A&&(E.current&&E.current.__original===A?k.current!==R?(F=C(A),E.current=F,k.current=R):F=E.current:(F=C(A),E.current=F,k.current=R));const O=[N,F,S];return O.t=N,O.i18n=F,O.ready=S,O},[N,T,S,T.resolvedLanguage,T.language,T.languages]);if(s&&l&&!S)throw new Promise(A=>{const R=()=>A();e.lng?WU(s,e.lng,f,R):jj(s,f,R)});return D},{slice:Tse,forEach:Cse}=[];function Ase(t){return Cse.call(Tse.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function kse(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 YU=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,jse=function(t,e){const r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},i=encodeURIComponent(e);let s=`${t}=${i}`;if(r.maxAge>0){const o=r.maxAge-0;if(Number.isNaN(o))throw new Error("maxAge should be a Number");s+=`; Max-Age=${Math.floor(o)}`}if(r.domain){if(!YU.test(r.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${r.domain}`}if(r.path){if(!YU.test(r.path))throw new TypeError("option path is invalid");s+=`; Path=${r.path}`}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");s+=`; Expires=${r.expires.toUTCString()}`}if(r.httpOnly&&(s+="; HttpOnly"),r.secure&&(s+="; Secure"),r.sameSite)switch(typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite){case!0:s+="; SameSite=Strict";break;case"lax":s+="; SameSite=Lax";break;case"strict":s+="; SameSite=Strict";break;case"none":s+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return r.partitioned&&(s+="; Partitioned"),s},QU={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=jse(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 Pse={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return QU.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:s}=e;n&&typeof document<"u"&&QU.create(n,t,r,i,s)}},Rse={name:"querystring",lookup(t){let{lookupQuerystring:e}=t,n;if(typeof window<"u"){let{search:r}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));const s=r.substring(1).split("&");for(let o=0;o<s.length;o++){const l=s[o].indexOf("=");l>0&&s[o].substring(0,l)===e&&(n=s[o].substring(l+1))}}return n}},Dse={name:"hash",lookup(t){let{lookupHash:e,lookupFromHashIndex:n}=t,r;if(typeof window<"u"){const{hash:i}=window.location;if(i&&i.length>2){const s=i.substring(1);if(e){const o=s.split("&");for(let l=0;l<o.length;l++){const c=o[l].indexOf("=");c>0&&o[l].substring(0,c)===e&&(r=o[l].substring(c+1))}}if(r)return r;if(!r&&n>-1){const o=i.match(/\/([a-zA-Z-]*)/g);return Array.isArray(o)?o[typeof n=="number"?n:0]?.replace("/",""):void 0}}}return r}};let $m=null;const ZU=()=>{if($m!==null)return $m;try{if($m=typeof window<"u"&&window.localStorage!==null,!$m)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{$m=!1}return $m};var Ose={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&ZU())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&ZU()&&window.localStorage.setItem(n,t)}};let Hm=null;const JU=()=>{if(Hm!==null)return Hm;try{if(Hm=typeof window<"u"&&window.sessionStorage!==null,!Hm)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Hm=!1}return Hm};var Lse={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&JU())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&JU()&&window.sessionStorage.setItem(n,t)}},Ise={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:r,language:i}=navigator;if(n)for(let s=0;s<n.length;s++)e.push(n[s]);r&&e.push(r),i&&e.push(i)}return e.length>0?e:void 0}},Fse={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}},Use={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}},zse={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 pq=!1;try{document.cookie,pq=!0}catch{}const gq=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];pq||gq.splice(1,1);const Bse=()=>({order:gq,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class xq{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=Ase(n,this.options||{},Bse()),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(Pse),this.addDetector(Rse),this.addDetector(Ose),this.addDetector(Lse),this.addDetector(Ise),this.addDetector(Fse),this.addDetector(Use),this.addDetector(zse),this.addDetector(Dse)}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&&!kse(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)}))}}xq.type="languageDetector";const $se={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",projects:"Projects",files:"File Manager",settings:"Settings",system:"System",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",update:"Update",updateAvailable:"Update available: v{{version}}",viewOnGithub:"View on GitHub",keyboardShortcuts:"Keyboard shortcuts (?)",switchToLight:"Switch to light mode",switchToDark:"Switch to dark mode"},common:{save:"Save",cancel:"Cancel",delete:"Delete",edit:"Edit",add:"Add",close:"Close",confirm:"Confirm",loading:"Loading...",error:"Error",success:"Success",warning:"Warning",enabled:"Enabled",disabled:"Disabled",yes:"Yes",no:"No",on:"On",off:"Off",all:"All",none:"None",search:"Search",filter:"Filter",sort:"Sort",refresh:"Refresh",download:"Download",upload:"Upload",actions:"Actions",status:"Status",name:"Name",description:"Description",date:"Date",time:"Time",hours:"hours",minutes:"minutes",seconds:"seconds",noPrinters:"No printers configured",noData:"No data available",required:"Required",optional:"Optional"},printers:{title:"Printers",addPrinter:"Add Printer",editPrinter:"Edit Printer",deletePrinter:"Delete Printer",printerName:"Printer Name",serialNumber:"Serial Number",ipAddress:"IP Address",accessCode:"Access Code",model:"Model",nozzleCount:"Nozzle Count",autoArchive:"Auto Archive",status:{idle:"Idle",printing:"Printing",paused:"Paused",offline:"Offline",error:"Error",finished:"Finished",unknown:"Unknown"},temperatures:{nozzle:"Nozzle",bed:"Bed",chamber:"Chamber"},progress:"{{percent}}% complete",timeRemaining:"{{time}} remaining",deleteConfirm:'Are you sure you want to delete "{{name}}"?',maintenanceOk:"Maintenance OK",maintenanceWarning:"{{count}} warning",maintenanceWarning_plural:"{{count}} warnings",maintenanceDue:"{{count}} due",maintenanceDue_plural:"{{count}} due"},archives:{title:"Print Archives",searchPlaceholder:"Search archives...",filterByPrinter:"Filter by printer",filterByStatus:"Filter by status",sortBy:"Sort by",sortNewest:"Newest first",sortOldest:"Oldest first",sortName:"Name",sortDuration:"Duration",noArchives:"No archives found",printTime:"Print Time",filamentUsed:"Filament Used",cost:"Cost",reprint:"Reprint",preview:"Preview",deleteArchive:"Delete Archive",deleteConfirm:"Are you sure you want to delete this archive?",favorite:"Favorite",unfavorite:"Remove from favorites",viewDetails:"View Details",status:{completed:"Completed",failed:"Failed",stopped:"Stopped"}},queue:{title:"Print Queue",addToQueue:"Add to Queue",clearQueue:"Clear Queue",emptyQueue:"Queue is empty",position:"Position",scheduledTime:"Scheduled Time",moveUp:"Move Up",moveDown:"Move Down",remove:"Remove",startNow:"Start Now",status:{pending:"Pending",printing:"Printing",completed:"Completed",failed:"Failed",cancelled:"Cancelled"}},stats:{title:"Statistics",overview:"Overview",totalPrints:"Total Prints",successRate:"Success Rate",totalPrintTime:"Total Print Time",totalFilament:"Total Filament Used",totalCost:"Total Cost",averagePrintTime:"Average Print Time",printsPerDay:"Prints per Day",byPrinter:"By Printer",byMaterial:"By Material",byMonth:"By Month",last7Days:"Last 7 Days",last30Days:"Last 30 Days",last90Days:"Last 90 Days",allTime:"All Time"},profiles:{title:"Filament Profiles",addProfile:"Add Profile",editProfile:"Edit Profile",deleteProfile:"Delete Profile",material:"Material",brand:"Brand",color:"Color",diameter:"Diameter",density:"Density",costPerKg:"Cost per kg",spoolWeight:"Spool Weight",noProfiles:"No profiles configured",deleteConfirm:"Are you sure you want to delete this profile?"},maintenance:{title:"Maintenance",overview:"Overview",allOk:"All maintenance up to date",dueCount:"{{count}} item due",dueCount_plural:"{{count}} items due",warningCount:"{{count}} warning",warningCount_plural:"{{count}} warnings",totalPrintTime:"Total Print Time",nextMaintenance:"Next Maintenance",nothingDue:"Nothing due",tasks:"Tasks",lastPerformed:"Last performed",interval:"Interval",hoursRemaining:"{{hours}}h remaining",hoursOverdue:"{{hours}}h overdue",markDone:"Mark as Done",performMaintenance:"Perform Maintenance",history:"History",noHistory:"No maintenance history",editPrintHours:"Edit Print Hours",currentHours:"Current Hours",types:{lubricateRails:"Lubricate Linear Rails",cleanNozzle:"Clean Nozzle/Hotend",checkBelts:"Check Belt Tension",cleanBuildPlate:"Clean Build Plate",checkExtruder:"Check Extruder Gears",checkCooling:"Check Cooling Fans",generalInspection:"General Inspection"}},settings:{title:"Settings",general:"General",appearance:"Appearance",notifications:"Notifications",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Language",languageDescription:"Select your preferred language",theme:"Theme",themeLight:"Light",themeDark:"Dark",themeSystem:"System",defaultView:"Default View",defaultViewDescription:"Page to show when opening the app",checkForUpdates:"Check for Updates",autoUpdate:"Auto Update",currentVersion:"Current Version",latestVersion:"Latest Version",upToDate:"You are up to date",updateAvailable:"Update available",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?"}},Hse={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",projects:"Projekte",files:"Dateimanager",settings:"Einstellungen",system:"System",collapseSidebar:"Seitenleiste einklappen",expandSidebar:"Seitenleiste ausklappen",update:"Update",updateAvailable:"Update verfügbar: v{{version}}",viewOnGithub:"Auf GitHub ansehen",keyboardShortcuts:"Tastaturkürzel (?)",switchToLight:"Zum hellen Modus wechseln",switchToDark:"Zum dunklen Modus wechseln"},common:{save:"Speichern",cancel:"Abbrechen",delete:"Löschen",edit:"Bearbeiten",add:"Hinzufügen",close:"Schließen",confirm:"Bestätigen",loading:"Lädt...",error:"Fehler",success:"Erfolg",warning:"Warnung",enabled:"Aktiviert",disabled:"Deaktiviert",yes:"Ja",no:"Nein",on:"An",off:"Aus",all:"Alle",none:"Keine",search:"Suchen",filter:"Filtern",sort:"Sortieren",refresh:"Aktualisieren",download:"Herunterladen",upload:"Hochladen",actions:"Aktionen",status:"Status",name:"Name",description:"Beschreibung",date:"Datum",time:"Zeit",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden",noPrinters:"Keine Drucker konfiguriert",noData:"Keine Daten verfügbar",required:"Erforderlich",optional:"Optional"},printers:{title:"Drucker",addPrinter:"Drucker hinzufügen",editPrinter:"Drucker bearbeiten",deletePrinter:"Drucker löschen",printerName:"Druckername",serialNumber:"Seriennummer",ipAddress:"IP-Adresse",accessCode:"Zugangscode",model:"Modell",nozzleCount:"Düsenanzahl",autoArchive:"Automatische Archivierung",status:{idle:"Bereit",printing:"Druckt",paused:"Pausiert",offline:"Offline",error:"Fehler",finished:"Fertig",unknown:"Unbekannt"},temperatures:{nozzle:"Düse",bed:"Druckbett",chamber:"Kammer"},progress:"{{percent}}% abgeschlossen",timeRemaining:"Noch {{time}}",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',maintenanceOk:"Wartung OK",maintenanceWarning:"{{count}} Warnung",maintenanceWarning_plural:"{{count}} Warnungen",maintenanceDue:"{{count}} fällig",maintenanceDue_plural:"{{count}} fällig"},archives:{title:"Druckarchiv",searchPlaceholder:"Archiv durchsuchen...",filterByPrinter:"Nach Drucker filtern",filterByStatus:"Nach Status filtern",sortBy:"Sortieren nach",sortNewest:"Neueste zuerst",sortOldest:"Älteste zuerst",sortName:"Name",sortDuration:"Dauer",noArchives:"Keine Archive gefunden",printTime:"Druckzeit",filamentUsed:"Verbrauchtes Filament",cost:"Kosten",reprint:"Erneut drucken",preview:"Vorschau",deleteArchive:"Archiv löschen",deleteConfirm:"Möchten Sie dieses Archiv wirklich löschen?",favorite:"Favorit",unfavorite:"Aus Favoriten entfernen",viewDetails:"Details anzeigen",status:{completed:"Abgeschlossen",failed:"Fehlgeschlagen",stopped:"Gestoppt"}},queue:{title:"Druckwarteschlange",addToQueue:"Zur Warteschlange hinzufügen",clearQueue:"Warteschlange leeren",emptyQueue:"Warteschlange ist leer",position:"Position",scheduledTime:"Geplante Zeit",moveUp:"Nach oben",moveDown:"Nach unten",remove:"Entfernen",startNow:"Jetzt starten",status:{pending:"Ausstehend",printing:"Druckt",completed:"Abgeschlossen",failed:"Fehlgeschlagen",cancelled:"Abgebrochen"}},stats:{title:"Statistiken",overview:"Übersicht",totalPrints:"Gesamtdrucke",successRate:"Erfolgsrate",totalPrintTime:"Gesamtdruckzeit",totalFilament:"Gesamtverbrauch Filament",totalCost:"Gesamtkosten",averagePrintTime:"Durchschnittliche Druckzeit",printsPerDay:"Drucke pro Tag",byPrinter:"Nach Drucker",byMaterial:"Nach Material",byMonth:"Nach Monat",last7Days:"Letzte 7 Tage",last30Days:"Letzte 30 Tage",last90Days:"Letzte 90 Tage",allTime:"Gesamt"},profiles:{title:"Filament-Profile",addProfile:"Profil hinzufügen",editProfile:"Profil bearbeiten",deleteProfile:"Profil löschen",material:"Material",brand:"Marke",color:"Farbe",diameter:"Durchmesser",density:"Dichte",costPerKg:"Kosten pro kg",spoolWeight:"Spulengewicht",noProfiles:"Keine Profile konfiguriert",deleteConfirm:"Möchten Sie dieses Profil wirklich löschen?"},maintenance:{title:"Wartung",overview:"Übersicht",allOk:"Alle Wartungen aktuell",dueCount:"{{count}} Aufgabe fällig",dueCount_plural:"{{count}} Aufgaben fällig",warningCount:"{{count}} Warnung",warningCount_plural:"{{count}} Warnungen",totalPrintTime:"Gesamtdruckzeit",nextMaintenance:"Nächste Wartung",nothingDue:"Nichts fällig",tasks:"Aufgaben",lastPerformed:"Zuletzt durchgeführt",interval:"Intervall",hoursRemaining:"{{hours}}h verbleibend",hoursOverdue:"{{hours}}h überfällig",markDone:"Als erledigt markieren",performMaintenance:"Wartung durchführen",history:"Verlauf",noHistory:"Kein Wartungsverlauf",editPrintHours:"Druckstunden bearbeiten",currentHours:"Aktuelle Stunden",types:{lubricateRails:"Linearschienen schmieren",cleanNozzle:"Düse/Hotend reinigen",checkBelts:"Riemenspannung prüfen",cleanBuildPlate:"Druckbett reinigen",checkExtruder:"Extruderzahnräder prüfen",checkCooling:"Kühlungslüfter prüfen",generalInspection:"Allgemeine Inspektion"}},settings:{title:"Einstellungen",general:"Allgemein",appearance:"Erscheinungsbild",notifications:"Benachrichtigungen",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Sprache",languageDescription:"Wählen Sie Ihre bevorzugte Sprache",theme:"Design",themeLight:"Hell",themeDark:"Dunkel",themeSystem:"System",defaultView:"Standardansicht",defaultViewDescription:"Seite, die beim Öffnen der App angezeigt wird",checkForUpdates:"Nach Updates suchen",autoUpdate:"Automatische Updates",currentVersion:"Aktuelle Version",latestVersion:"Neueste Version",upToDate:"Sie sind auf dem neuesten Stand",updateAvailable:"Update verfügbar",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?"}},Vse={en:{translation:$se},de:{translation:Hse}};is.use(xq).use(vse).init({resources:Vse,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const ez=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var tz="popstate";function Gse(t={}){function e(r,i){let{pathname:s,search:o,hash:l}=r.location;return Rj("",{pathname:s,search:o,hash:l},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:h0(i)}return Wse(e,n,null,t)}function Vr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Zs(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function qse(){return Math.random().toString(36).substring(2,10)}function nz(t,e){return{usr:t.state,key:t.key,idx:e}}function Rj(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Ug(e):e,state:n,key:e&&e.key||r||qse()}}function h0({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 Ug(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 Wse(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:s=!1}=r,o=i.history,l="POP",c=null,u=d();u==null&&(u=0,o.replaceState({...o.state,idx:u},""));function d(){return(o.state||{idx:null}).idx}function f(){l="POP";let b=d(),v=b==null?null:b-u;u=b,c&&c({action:l,location:y.location,delta:v})}function m(b,v){l="PUSH";let N=Rj(y.location,b,v);u=d()+1;let S=nz(N,u),T=y.createHref(N);try{o.pushState(S,"",T)}catch(E){if(E instanceof DOMException&&E.name==="DataCloneError")throw E;i.location.assign(T)}s&&c&&c({action:l,location:y.location,delta:1})}function g(b,v){l="REPLACE";let N=Rj(y.location,b,v);u=d();let S=nz(N,u),T=y.createHref(N);o.replaceState(S,"",T),s&&c&&c({action:l,location:y.location,delta:0})}function x(b){return Kse(b)}let y={get action(){return l},get location(){return t(i,o)},listen(b){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(tz,f),c=b,()=>{i.removeEventListener(tz,f),c=null}},createHref(b){return e(i,b)},createURL:x,encodeLocation(b){let v=x(b);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:m,replace:g,go(b){return o.go(b)}};return y}function Kse(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Vr(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:h0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function bq(t,e,n="/"){return Xse(t,e,n,!1)}function Xse(t,e,n,r){let i=typeof e=="string"?Ug(e):e,s=su(i.pathname||"/",n);if(s==null)return null;let o=yq(t);Yse(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=ooe(s);l=aoe(o[c],u,r)}return l}function yq(t,e=[],n=[],r="",i=!1){let s=(o,l,c=i,u)=>{let d={relativePath:u===void 0?o.path||"":u,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(r)&&c)return;Vr(d.relativePath.startsWith(r),`Absolute route path "${d.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(r.length)}let f=Qc([r,d.relativePath]),m=n.concat(d);o.children&&o.children.length>0&&(Vr(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),yq(o.children,e,m,f,c)),!(o.path==null&&!o.index)&&e.push({path:f,score:roe(f,o.index),routesMeta:m})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))s(o,l);else for(let c of vq(o.path))s(o,l,!0,c)}),e}function vq(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,i=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return i?[s,""]:[s];let o=vq(r.join("/")),l=[];return l.push(...o.map(c=>c===""?s:[s,c].join("/"))),i&&l.push(...o),l.map(c=>t.startsWith("/")&&c===""?"/":c)}function Yse(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:ioe(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Qse=/^:[\w-]+$/,Zse=3,Jse=2,eoe=1,toe=10,noe=-2,rz=t=>t==="*";function roe(t,e){let n=t.split("/"),r=n.length;return n.some(rz)&&(r+=noe),e&&(r+=Jse),n.filter(i=>!rz(i)).reduce((i,s)=>i+(Qse.test(s)?Zse:s===""?eoe:toe),r)}function ioe(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 aoe(t,e,n=!1){let{routesMeta:r}=t,i={},s="/",o=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.length-1,d=s==="/"?e:e.slice(s.length)||"/",f=gw({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),m=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=gw({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),o.push({params:i,pathname:Qc([s,f.pathname]),pathnameBase:doe(Qc([s,f.pathnameBase])),route:m}),f.pathnameBase!=="/"&&(s=Qc([s,f.pathnameBase]))}return o}function gw(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=soe(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let s=i[0],o=s.replace(/(.)\/+$/,"$1"),l=i.slice(1);return{params:r.reduce((u,{paramName:d,isOptional:f},m)=>{if(d==="*"){let x=l[m]||"";o=s.slice(0,s.length-x.length).replace(/(.)\/+$/,"$1")}const g=l[m];return f&&!g?u[d]=void 0:u[d]=(g||"").replace(/%2F/g,"/"),u},{}),pathname:s,pathnameBase:o,pattern:t}}function soe(t,e=!1,n=!0){Zs(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let r=[],i="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c)=>(r.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(r.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function ooe(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Zs(!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 su(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 _q=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,loe=t=>_q.test(t);function coe(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Ug(t):t,s;if(n)if(loe(n))s=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Zs(!1,`Pathnames cannot have embedded double slashes - normalizing ${o} -> ${n}`)}n.startsWith("/")?s=iz(n.substring(1),"/"):s=iz(n,e)}else s=e;return{pathname:s,search:hoe(r),hash:foe(i)}}function iz(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 jT(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 uoe(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function XR(t){let e=uoe(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function YR(t,e,n,r=!1){let i;typeof t=="string"?i=Ug(t):(i={...t},Vr(!i.pathname||!i.pathname.includes("?"),jT("?","pathname","search",i)),Vr(!i.pathname||!i.pathname.includes("#"),jT("#","pathname","hash",i)),Vr(!i.search||!i.search.includes("#"),jT("#","search","hash",i)));let s=t===""||i.pathname==="",o=s?"/":i.pathname,l;if(o==null)l=n;else{let f=e.length-1;if(!r&&o.startsWith("..")){let m=o.split("/");for(;m[0]==="..";)m.shift(),f-=1;i.pathname=m.join("/")}l=f>=0?e[f]:"/"}let c=coe(i,l),u=o&&o!=="/"&&o.endsWith("/"),d=(s||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Qc=t=>t.join("/").replace(/\/\/+/g,"/"),doe=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),hoe=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,foe=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,moe=class{constructor(t,e,n,r=!1){this.status=t,this.statusText=e||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function poe(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function goe(t){return t.map(e=>e.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var wq=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Sq(t,e){let n=t;if(typeof n!="string"||!_q.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(wq)try{let s=new URL(window.location.href),o=n.startsWith("//")?new URL(s.protocol+n):new URL(n),l=su(o.pathname,e);o.origin===s.origin&&l!=null?n=l+o.search+o.hash:i=!0}catch{Zs(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Nq=["POST","PUT","PATCH","DELETE"];new Set(Nq);var xoe=["GET",...Nq];new Set(xoe);var zg=w.createContext(null);zg.displayName="DataRouter";var P2=w.createContext(null);P2.displayName="DataRouterState";var boe=w.createContext(!1),Mq=w.createContext({isTransitioning:!1});Mq.displayName="ViewTransition";var yoe=w.createContext(new Map);yoe.displayName="Fetchers";var voe=w.createContext(null);voe.displayName="Await";var to=w.createContext(null);to.displayName="Navigation";var sy=w.createContext(null);sy.displayName="Location";var zo=w.createContext({outlet:null,matches:[],isDataRoute:!1});zo.displayName="Route";var QR=w.createContext(null);QR.displayName="RouteError";var Eq="REACT_ROUTER_ERROR",_oe="REDIRECT",woe="ROUTE_ERROR_RESPONSE";function Soe(t){if(t.startsWith(`${Eq}:${_oe}:{`))try{let e=JSON.parse(t.slice(28));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.location=="string"&&typeof e.reloadDocument=="boolean"&&typeof e.replace=="boolean")return e}catch{}}function Noe(t){if(t.startsWith(`${Eq}:${woe}:{`))try{let e=JSON.parse(t.slice(40));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string")return new moe(e.status,e.statusText,e.data)}catch{}}function Moe(t,{relative:e}={}){Vr(Bg(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=w.useContext(to),{hash:i,pathname:s,search:o}=oy(t,{relative:e}),l=s;return n!=="/"&&(l=s==="/"?n:Qc([n,s])),r.createHref({pathname:l,search:o,hash:i})}function Bg(){return w.useContext(sy)!=null}function Yl(){return Vr(Bg(),"useLocation() may be used only in the context of a <Router> component."),w.useContext(sy).location}var Tq="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Cq(t){w.useContext(to).static||w.useLayoutEffect(t)}function fl(){let{isDataRoute:t}=w.useContext(zo);return t?zoe():Eoe()}function Eoe(){Vr(Bg(),"useNavigate() may be used only in the context of a <Router> component.");let t=w.useContext(zg),{basename:e,navigator:n}=w.useContext(to),{matches:r}=w.useContext(zo),{pathname:i}=Yl(),s=JSON.stringify(XR(r)),o=w.useRef(!1);return Cq(()=>{o.current=!0}),w.useCallback((c,u={})=>{if(Zs(o.current,Tq),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=YR(c,JSON.parse(s),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:Qc([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,s,i,t])}var Toe=w.createContext(null);function Coe(t){let e=w.useContext(zo).outlet;return w.useMemo(()=>e&&w.createElement(Toe.Provider,{value:t},e),[e,t])}function ZR(){let{matches:t}=w.useContext(zo),e=t[t.length-1];return e?e.params:{}}function oy(t,{relative:e}={}){let{matches:n}=w.useContext(zo),{pathname:r}=Yl(),i=JSON.stringify(XR(n));return w.useMemo(()=>YR(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function Aoe(t,e){return Aq(t,e)}function Aq(t,e,n,r,i){Vr(Bg(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=w.useContext(to),{matches:o}=w.useContext(zo),l=o[o.length-1],c=l?l.params:{},u=l?l.pathname:"/",d=l?l.pathnameBase:"/",f=l&&l.route;{let N=f&&f.path||"";jq(u,!f||N.endsWith("*")||N.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${N}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
- Please change the parent <Route path="${N}"> to <Route path="${N==="/"?"*":`${N}/*`}">.`)}let m=Yl(),g;if(e){let N=typeof e=="string"?Ug(e):e;Vr(d==="/"||N.pathname?.startsWith(d),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${N.pathname}" was given in the \`location\` prop.`),g=N}else g=m;let x=g.pathname||"/",y=x;if(d!=="/"){let N=d.replace(/^\//,"").split("/");y="/"+x.replace(/^\//,"").split("/").slice(N.length).join("/")}let b=bq(t,{pathname:y});Zs(f||b!=null,`No routes matched location "${g.pathname}${g.search}${g.hash}" `),Zs(b==null||b[b.length-1].route.element!==void 0||b[b.length-1].route.Component!==void 0||b[b.length-1].route.lazy!==void 0,`Matched leaf route at location "${g.pathname}${g.search}${g.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let v=Doe(b&&b.map(N=>Object.assign({},N,{params:Object.assign({},c,N.params),pathname:Qc([d,s.encodeLocation?s.encodeLocation(N.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:N.pathname]),pathnameBase:N.pathnameBase==="/"?d:Qc([d,s.encodeLocation?s.encodeLocation(N.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:N.pathnameBase])})),o,n,r,i);return e&&v?w.createElement(sy.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...g},navigationType:"POP"}},v):v}function koe(){let t=Uoe(),e=poe(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},s={padding:"2px 4px",backgroundColor:r},o=null;return console.error("Error handled by React Router default ErrorBoundary:",t),o=w.createElement(w.Fragment,null,w.createElement("p",null,"💿 Hey developer 👋"),w.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",w.createElement("code",{style:s},"ErrorBoundary")," or"," ",w.createElement("code",{style:s},"errorElement")," prop on your route.")),w.createElement(w.Fragment,null,w.createElement("h2",null,"Unexpected Application Error!"),w.createElement("h3",{style:{fontStyle:"italic"}},e),n?w.createElement("pre",{style:i},n):null,o)}var joe=w.createElement(koe,null),kq=class extends w.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,e){return e.location!==t.location||e.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:e.error,location:e.location,revalidation:t.revalidation||e.revalidation}}componentDidCatch(t,e){this.props.onError?this.props.onError(t,e):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const n=Noe(t.digest);n&&(t=n)}let e=t!==void 0?w.createElement(zo.Provider,{value:this.props.routeContext},w.createElement(QR.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?w.createElement(Poe,{error:t},e):e}};kq.contextType=boe;var PT=new WeakMap;function Poe({children:t,error:e}){let{basename:n}=w.useContext(to);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let r=Soe(e.digest);if(r){let i=PT.get(e);if(i)throw i;let s=Sq(r.location,n);if(wq&&!PT.get(e))if(s.isExternal||r.reloadDocument)window.location.href=s.absoluteURL||s.to;else{const o=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(s.to,{replace:r.replace}));throw PT.set(e,o),o}return w.createElement("meta",{httpEquiv:"refresh",content:`0;url=${s.absoluteURL||s.to}`})}}return t}function Roe({routeContext:t,match:e,children:n}){let r=w.useContext(zg);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),w.createElement(zo.Provider,{value:t},n)}function Doe(t,e=[],n=null,r=null,i=null){if(t==null){if(!n)return null;if(n.errors)t=n.matches;else if(e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let s=t,o=n?.errors;if(o!=null){let d=s.findIndex(f=>f.route.id&&o?.[f.route.id]!==void 0);Vr(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),s=s.slice(0,Math.min(s.length,d+1))}let l=!1,c=-1;if(n)for(let d=0;d<s.length;d++){let f=s[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(c=d),f.route.id){let{loaderData:m,errors:g}=n,x=f.route.loader&&!m.hasOwnProperty(f.route.id)&&(!g||g[f.route.id]===void 0);if(f.route.lazy||x){l=!0,c>=0?s=s.slice(0,c+1):s=[s[0]];break}}}let u=n&&r?(d,f)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:goe(n.matches),errorInfo:f})}:void 0;return s.reduceRight((d,f,m)=>{let g,x=!1,y=null,b=null;n&&(g=o&&f.route.id?o[f.route.id]:void 0,y=f.route.errorElement||joe,l&&(c<0&&m===0?(jq("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,b=null):c===m&&(x=!0,b=f.route.hydrateFallbackElement||null)));let v=e.concat(s.slice(0,m+1)),N=()=>{let S;return g?S=y:x?S=b:f.route.Component?S=w.createElement(f.route.Component,null):f.route.element?S=f.route.element:S=d,w.createElement(Roe,{match:f,routeContext:{outlet:d,matches:v,isDataRoute:n!=null},children:S})};return n&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?w.createElement(kq,{location:n.location,revalidation:n.revalidation,component:y,error:g,children:N(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:u}):N()},null)}function JR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ooe(t){let e=w.useContext(zg);return Vr(e,JR(t)),e}function Loe(t){let e=w.useContext(P2);return Vr(e,JR(t)),e}function Ioe(t){let e=w.useContext(zo);return Vr(e,JR(t)),e}function eD(t){let e=Ioe(t),n=e.matches[e.matches.length-1];return Vr(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function Foe(){return eD("useRouteId")}function Uoe(){let t=w.useContext(QR),e=Loe("useRouteError"),n=eD("useRouteError");return t!==void 0?t:e.errors?.[n]}function zoe(){let{router:t}=Ooe("useNavigate"),e=eD("useNavigate"),n=w.useRef(!1);return Cq(()=>{n.current=!0}),w.useCallback(async(i,s={})=>{Zs(n.current,Tq),n.current&&(typeof i=="number"?await t.navigate(i):await t.navigate(i,{fromRouteId:e,...s}))},[t,e])}var az={};function jq(t,e,n){!e&&!az[t]&&(az[t]=!0,Zs(!1,n))}w.memo(Boe);function Boe({routes:t,future:e,state:n,onError:r}){return Aq(t,void 0,n,r,e)}function xw({to:t,replace:e,state:n,relative:r}){Vr(Bg(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=w.useContext(to);Zs(!i,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:s}=w.useContext(zo),{pathname:o}=Yl(),l=fl(),c=YR(t,XR(s),o,r==="path"),u=JSON.stringify(c);return w.useEffect(()=>{l(JSON.parse(u),{replace:e,state:n,relative:r})},[l,u,r,e,n]),null}function $oe(t){return Coe(t.context)}function Yi(t){Vr(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Hoe({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:s=!1,unstable_useTransitions:o}){Vr(!Bg(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=t.replace(/^\/*/,"/"),c=w.useMemo(()=>({basename:l,navigator:i,static:s,unstable_useTransitions:o,future:{}}),[l,i,s,o]);typeof n=="string"&&(n=Ug(n));let{pathname:u="/",search:d="",hash:f="",state:m=null,key:g="default"}=n,x=w.useMemo(()=>{let y=su(u,l);return y==null?null:{location:{pathname:y,search:d,hash:f,state:m,key:g},navigationType:r}},[l,u,d,f,m,g,r]);return Zs(x!=null,`<Router basename="${l}"> is not able to match the URL "${u}${d}${f}" because it does not start with the basename, so the <Router> won't render anything.`),x==null?null:w.createElement(to.Provider,{value:c},w.createElement(sy.Provider,{children:e,value:x}))}function Voe({children:t,location:e}){return Aoe(Dj(t),e)}function Dj(t,e=[]){let n=[];return w.Children.forEach(t,(r,i)=>{if(!w.isValidElement(r))return;let s=[...e,i];if(r.type===w.Fragment){n.push.apply(n,Dj(r.props.children,s));return}Vr(r.type===Yi,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Vr(!r.props.index||!r.props.children,"An index route cannot have child routes.");let o={id:r.props.id||s.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=Dj(r.props.children,s)),n.push(o)}),n}var B1="get",$1="application/x-www-form-urlencoded";function R2(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function Goe(t){return R2(t)&&t.tagName.toLowerCase()==="button"}function qoe(t){return R2(t)&&t.tagName.toLowerCase()==="form"}function Woe(t){return R2(t)&&t.tagName.toLowerCase()==="input"}function Koe(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Xoe(t,e){return t.button===0&&(!e||e==="_self")&&!Koe(t)}function Oj(t=""){return new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,n)=>{let r=t[n];return e.concat(Array.isArray(r)?r.map(i=>[n,i]):[[n,r]])},[]))}function Yoe(t,e){let n=Oj(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(s=>{n.append(i,s)})}),n}var i_=null;function Qoe(){if(i_===null)try{new FormData(document.createElement("form"),0),i_=!1}catch{i_=!0}return i_}var Zoe=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function RT(t){return t!=null&&!Zoe.has(t)?(Zs(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${$1}"`),null):t}function Joe(t,e){let n,r,i,s,o;if(qoe(t)){let l=t.getAttribute("action");r=l?su(l,e):null,n=t.getAttribute("method")||B1,i=RT(t.getAttribute("enctype"))||$1,s=new FormData(t)}else if(Goe(t)||Woe(t)&&(t.type==="submit"||t.type==="image")){let l=t.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=t.getAttribute("formaction")||l.getAttribute("action");if(r=c?su(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||B1,i=RT(t.getAttribute("formenctype"))||RT(l.getAttribute("enctype"))||$1,s=new FormData(l,t),!Qoe()){let{name:u,type:d,value:f}=t;if(d==="image"){let m=u?`${u}.`:"";s.append(`${m}x`,"0"),s.append(`${m}y`,"0")}else u&&s.append(u,f)}}else{if(R2(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=B1,r=null,i=$1,o=t}return s&&i==="text/plain"&&(o=s,s=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:s,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function tD(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function ele(t,e,n,r){let i=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return n?i.pathname.endsWith("/")?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname==="/"?i.pathname=`_root.${r}`:e&&su(i.pathname,e)==="/"?i.pathname=`${e.replace(/\/$/,"")}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,"")}.${r}`,i}async function tle(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 nle(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 rle(t,e,n){let r=await Promise.all(t.map(async i=>{let s=e.routes[i.route.id];if(s){let o=await tle(s,n);return o.links?o.links():[]}return[]}));return ole(r.flat(1).filter(nle).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function sz(t,e,n,r,i,s){let o=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,l=(c,u)=>n[u].pathname!==c.pathname||n[u].route.path?.endsWith("*")&&n[u].params["*"]!==c.params["*"];return s==="assets"?e.filter((c,u)=>o(c,u)||l(c,u)):s==="data"?e.filter((c,u)=>{let d=r.routes[c.route.id];if(!d||!d.hasLoader)return!1;if(o(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let f=c.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function ile(t,e,{includeHydrateFallback:n}={}){return ale(t.map(r=>{let i=e.routes[r.route.id];if(!i)return[];let s=[i.module];return i.clientActionModule&&(s=s.concat(i.clientActionModule)),i.clientLoaderModule&&(s=s.concat(i.clientLoaderModule)),n&&i.hydrateFallbackModule&&(s=s.concat(i.hydrateFallbackModule)),i.imports&&(s=s.concat(i.imports)),s}).flat(1))}function ale(t){return[...new Set(t)]}function sle(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function ole(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let s=JSON.stringify(sle(i));return n.has(s)||(n.add(s),r.push({key:s,link:i})),r},[])}function Pq(){let t=w.useContext(zg);return tD(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function lle(){let t=w.useContext(P2);return tD(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var nD=w.createContext(void 0);nD.displayName="FrameworkContext";function Rq(){let t=w.useContext(nD);return tD(t,"You must render this element inside a <HydratedRouter> element"),t}function cle(t,e){let n=w.useContext(nD),[r,i]=w.useState(!1),[s,o]=w.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,m=w.useRef(null);w.useEffect(()=>{if(t==="render"&&o(!0),t==="viewport"){let y=v=>{v.forEach(N=>{o(N.isIntersecting)})},b=new IntersectionObserver(y,{threshold:.5});return m.current&&b.observe(m.current),()=>{b.disconnect()}}},[t]),w.useEffect(()=>{if(r){let y=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(y)}}},[r]);let g=()=>{i(!0)},x=()=>{i(!1),o(!1)};return n?t!=="intent"?[s,m,{}]:[s,m,{onFocus:eb(l,g),onBlur:eb(c,x),onMouseEnter:eb(u,g),onMouseLeave:eb(d,x),onTouchStart:eb(f,g)}]:[!1,m,{}]}function eb(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function ule({page:t,...e}){let{router:n}=Pq(),r=w.useMemo(()=>bq(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?w.createElement(hle,{page:t,matches:r,...e}):null}function dle(t){let{manifest:e,routeModules:n}=Rq(),[r,i]=w.useState([]);return w.useEffect(()=>{let s=!1;return rle(t,e,n).then(o=>{s||i(o)}),()=>{s=!0}},[t,e,n]),r}function hle({page:t,matches:e,...n}){let r=Yl(),{future:i,manifest:s,routeModules:o}=Rq(),{basename:l}=Pq(),{loaderData:c,matches:u}=lle(),d=w.useMemo(()=>sz(t,e,u,s,r,"data"),[t,e,u,s,r]),f=w.useMemo(()=>sz(t,e,u,s,r,"assets"),[t,e,u,s,r]),m=w.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let y=new Set,b=!1;if(e.forEach(N=>{let S=s.routes[N.route.id];!S||!S.hasLoader||(!d.some(T=>T.route.id===N.route.id)&&N.route.id in c&&o[N.route.id]?.shouldRevalidate||S.hasClientLoader?b=!0:y.add(N.route.id))}),y.size===0)return[];let v=ele(t,l,i.unstable_trailingSlashAwareDataRequests,"data");return b&&y.size>0&&v.searchParams.set("_routes",e.filter(N=>y.has(N.route.id)).map(N=>N.route.id).join(",")),[v.pathname+v.search]},[l,i.unstable_trailingSlashAwareDataRequests,c,r,s,d,e,t,o]),g=w.useMemo(()=>ile(f,s),[f,s]),x=dle(f);return w.createElement(w.Fragment,null,m.map(y=>w.createElement("link",{key:y,rel:"prefetch",as:"fetch",href:y,...n})),g.map(y=>w.createElement("link",{key:y,rel:"modulepreload",href:y,...n})),x.map(({key:y,link:b})=>w.createElement("link",{key:y,nonce:n.nonce,...b})))}function fle(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var mle=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{mle&&(window.__reactRouterVersion="7.12.0")}catch{}function ple({basename:t,children:e,unstable_useTransitions:n,window:r}){let i=w.useRef();i.current==null&&(i.current=Gse({window:r,v5Compat:!0}));let s=i.current,[o,l]=w.useState({action:s.action,location:s.location}),c=w.useCallback(u=>{n===!1?l(u):w.startTransition(()=>l(u))},[n]);return w.useLayoutEffect(()=>s.listen(c),[s,c]),w.createElement(Hoe,{basename:t,children:e,location:o.location,navigationType:o.action,navigator:s,unstable_useTransitions:n})}var Dq=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ps=w.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:s,replace:o,state:l,target:c,to:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:m,...g},x){let{basename:y,unstable_useTransitions:b}=w.useContext(to),v=typeof u=="string"&&Dq.test(u),N=Sq(u,y);u=N.to;let S=Moe(u,{relative:i}),[T,E,k]=cle(r,g),C=ble(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:f,unstable_defaultShouldRevalidate:m,unstable_useTransitions:b});function D(R){e&&e(R),R.defaultPrevented||C(R)}let A=w.createElement("a",{...g,...k,href:N.absoluteURL||S,onClick:N.isExternal||s?e:D,ref:fle(x,E),target:c,"data-discover":!v&&n==="render"?"true":void 0});return T&&!v?w.createElement(w.Fragment,null,A,w.createElement(ule,{page:S})):A});ps.displayName="Link";var Eb=w.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:s,to:o,viewTransition:l,children:c,...u},d){let f=oy(o,{relative:u.relative}),m=Yl(),g=w.useContext(P2),{navigator:x,basename:y}=w.useContext(to),b=g!=null&&Sle(f)&&l===!0,v=x.encodeLocation?x.encodeLocation(f).pathname:f.pathname,N=m.pathname,S=g&&g.navigation&&g.navigation.location?g.navigation.location.pathname:null;n||(N=N.toLowerCase(),S=S?S.toLowerCase():null,v=v.toLowerCase()),S&&y&&(S=su(S,y)||S);const T=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let E=N===v||!i&&N.startsWith(v)&&N.charAt(T)==="/",k=S!=null&&(S===v||!i&&S.startsWith(v)&&S.charAt(v.length)==="/"),C={isActive:E,isPending:k,isTransitioning:b},D=E?e:void 0,A;typeof r=="function"?A=r(C):A=[r,E?"active":null,k?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let R=typeof s=="function"?s(C):s;return w.createElement(ps,{...u,"aria-current":D,className:A,ref:d,style:R,to:o,viewTransition:l},typeof c=="function"?c(C):c)});Eb.displayName="NavLink";var gle=w.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:s,method:o=B1,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:m,...g},x)=>{let{unstable_useTransitions:y}=w.useContext(to),b=_le(),v=wle(l,{relative:u}),N=o.toLowerCase()==="get"?"get":"post",S=typeof l=="string"&&Dq.test(l),T=E=>{if(c&&c(E),E.defaultPrevented)return;E.preventDefault();let k=E.nativeEvent.submitter,C=k?.getAttribute("formmethod")||o,D=()=>b(k||E.currentTarget,{fetcherKey:e,method:C,navigate:n,replace:i,state:s,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:m});y&&n!==!1?w.startTransition(()=>D()):D()};return w.createElement("form",{ref:x,method:N,action:v,onSubmit:r?c:T,...g,"data-discover":!S&&t==="render"?"true":void 0})});gle.displayName="Form";function xle(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Oq(t){let e=w.useContext(zg);return Vr(e,xle(t)),e}function ble(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:s,viewTransition:o,unstable_defaultShouldRevalidate:l,unstable_useTransitions:c}={}){let u=fl(),d=Yl(),f=oy(t,{relative:s});return w.useCallback(m=>{if(Xoe(m,e)){m.preventDefault();let g=n!==void 0?n:h0(d)===h0(f),x=()=>u(t,{replace:g,state:r,preventScrollReset:i,relative:s,viewTransition:o,unstable_defaultShouldRevalidate:l});c?w.startTransition(()=>x()):x()}},[d,u,f,n,r,e,t,i,s,o,l,c])}function Lq(t){Zs(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let e=w.useRef(Oj(t)),n=w.useRef(!1),r=Yl(),i=w.useMemo(()=>Yoe(r.search,n.current?null:e.current),[r.search]),s=fl(),o=w.useCallback((l,c)=>{const u=Oj(typeof l=="function"?l(new URLSearchParams(i)):l);n.current=!0,s("?"+u,c)},[s,i]);return[i,o]}var yle=0,vle=()=>`__${String(++yle)}__`;function _le(){let{router:t}=Oq("useSubmit"),{basename:e}=w.useContext(to),n=Foe(),r=t.fetch,i=t.navigate;return w.useCallback(async(s,o={})=>{let{action:l,method:c,encType:u,formData:d,body:f}=Joe(s,e);if(o.navigate===!1){let m=o.fetcherKey||vle();await r(m,n,o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:f,formMethod:o.method||c,formEncType:o.encType||u,flushSync:o.flushSync})}else await i(o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:f,formMethod:o.method||c,formEncType:o.encType||u,replace:o.replace,state:o.state,fromRouteId:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[r,i,e,n])}function wle(t,{relative:e}={}){let{basename:n}=w.useContext(to),r=w.useContext(zo);Vr(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),s={...oy(t||".",{relative:e})},o=Yl();if(t==null){s.search=o.search;let l=new URLSearchParams(s.search),c=l.getAll("index");if(c.some(d=>d==="")){l.delete("index"),c.filter(f=>f).forEach(f=>l.append("index",f));let d=l.toString();s.search=d?`?${d}`:""}}return(!t||t===".")&&i.route.index&&(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(s.pathname=s.pathname==="/"?n:Qc([n,s.pathname])),h0(s)}function Sle(t,{relative:e}={}){let n=w.useContext(Mq);Vr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Oq("useViewTransitionState"),i=oy(t,{relative:e});if(!n.isTransitioning)return!1;let s=su(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=su(n.nextLocation.pathname,r)||n.nextLocation.pathname;return gw(i.pathname,o)!=null||gw(i.pathname,s)!=null}var Vc=oq();const Nle=Uo(Vc);var nm=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(){}},Mle={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Ele=class{#t=Mle;#e=!1;setTimeoutProvider(t){this.#t=t}setTimeout(t,e){return this.#t.setTimeout(t,e)}clearTimeout(t){this.#t.clearTimeout(t)}setInterval(t,e){return this.#t.setInterval(t,e)}clearInterval(t){this.#t.clearInterval(t)}},sf=new Ele;function Tle(t){setTimeout(t,0)}var Pf=typeof window>"u"||"Deno"in globalThis;function Oa(){}function Cle(t,e){return typeof t=="function"?t(e):t}function Lj(t){return typeof t=="number"&&t>=0&&t!==1/0}function Iq(t,e){return Math.max(t+(e||0)-Date.now(),0)}function jd(t,e){return typeof t=="function"?t(e):t}function yo(t,e){return typeof t=="function"?t(e):t}function oz(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==rD(o,e.options))return!1}else if(!f0(e.queryKey,o))return!1}if(n!=="all"){const c=e.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||i&&i!==e.state.fetchStatus||s&&!s(e))}function lz(t,e){const{exact:n,status:r,predicate:i,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(n){if(Rf(e.options.mutationKey)!==Rf(s))return!1}else if(!f0(e.options.mutationKey,s))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function rD(t,e){return(e?.queryKeyHashFn||Rf)(t)}function Rf(t){return JSON.stringify(t,(e,n)=>Ij(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function f0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>f0(t[n],e[n])):!1}var Ale=Object.prototype.hasOwnProperty;function iD(t,e){if(t===e)return t;const n=cz(t)&&cz(e);if(!n&&!(Ij(t)&&Ij(e)))return e;const i=(n?t:Object.keys(t)).length,s=n?e:Object.keys(e),o=s.length,l=n?new Array(o):{};let c=0;for(let u=0;u<o;u++){const d=n?u:s[u],f=t[d],m=e[d];if(f===m){l[d]=f,(n?u<i:Ale.call(t,d))&&c++;continue}if(f===null||m===null||typeof f!="object"||typeof m!="object"){l[d]=m;continue}const g=iD(f,m);l[d]=g,g===f&&c++}return i===o&&c===i?t:l}function m0(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 cz(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Ij(t){if(!uz(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!uz(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function uz(t){return Object.prototype.toString.call(t)==="[object Object]"}function kle(t){return new Promise(e=>{sf.setTimeout(e,t)})}function Fj(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?iD(t,e):e}function jle(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function Ple(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var aD=Symbol();function Fq(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===aD?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function Uq(t,e){return typeof t=="function"?t(...e):!!t}var Rle=class extends nm{#t;#e;#n;constructor(){super(),this.#n=t=>{if(!Pf&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#n=t,this.#e?.(),this.#e=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#t!==t&&(this.#t=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},sD=new Rle;function Uj(){let t,e;const n=new Promise((i,s)=>{t=i,e=s});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),t(i)},n.reject=i=>{r({status:"rejected",reason:i}),e(i)},n}var Dle=Tle;function Ole(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=Dle;const s=l=>{e?t.push(l):i(()=>{n(l)})},o=()=>{const l=t;t=[],l.length&&i(()=>{r(()=>{l.forEach(c=>{n(c)})})})};return{batch:l=>{let c;e++;try{c=l()}finally{e--,e||o()}return c},batchCalls:l=>(...c)=>{s(()=>{l(...c)})},schedule:s,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{i=l}}}var ai=Ole(),Lle=class extends nm{#t=!0;#e;#n;constructor(){super(),this.#n=t=>{if(!Pf&&window.addEventListener){const e=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#n=t,this.#e?.(),this.#e=t(this.setOnline.bind(this))}setOnline(t){this.#t!==t&&(this.#t=t,this.listeners.forEach(n=>{n(t)}))}isOnline(){return this.#t}},bw=new Lle;function Ile(t){return Math.min(1e3*2**t,3e4)}function zq(t){return(t??"online")==="online"?bw.isOnline():!0}var zj=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Bq(t){let e=!1,n=0,r;const i=Uj(),s=()=>i.status!=="pending",o=y=>{if(!s()){const b=new zj(y);m(b),t.onCancel?.(b)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>sD.isFocused()&&(t.networkMode==="always"||bw.isOnline())&&t.canRun(),d=()=>zq(t.networkMode)&&t.canRun(),f=y=>{s()||(r?.(),i.resolve(y))},m=y=>{s()||(r?.(),i.reject(y))},g=()=>new Promise(y=>{r=b=>{(s()||u())&&y(b)},t.onPause?.()}).then(()=>{r=void 0,s()||t.onContinue?.()}),x=()=>{if(s())return;let y;const b=n===0?t.initialPromise:void 0;try{y=b??t.fn()}catch(v){y=Promise.reject(v)}Promise.resolve(y).then(f).catch(v=>{if(s())return;const N=t.retry??(Pf?0:3),S=t.retryDelay??Ile,T=typeof S=="function"?S(n,v):S,E=N===!0||typeof N=="number"&&n<N||typeof N=="function"&&N(n,v);if(e||!E){m(v);return}n++,t.onFail?.(n,v),kle(T).then(()=>u()?void 0:g()).then(()=>{e?m(v):x()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?x():g().then(x),i)}}var $q=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Lj(this.gcTime)&&(this.#t=sf.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Pf?1/0:300*1e3))}clearGcTimeout(){this.#t&&(sf.clearTimeout(this.#t),this.#t=void 0)}},Fle=class extends $q{#t;#e;#n;#i;#r;#a;#o;constructor(t){super(),this.#o=!1,this.#a=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#i=t.client,this.#n=this.#i.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#t=hz(this.options),this.state=t.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(t){if(this.options={...this.#a,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=hz(this.options);e.data!==void 0&&(this.setState(dz(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=Fj(this.state.data,t,this.options);return this.#s({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#s({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#r?.promise;return this.#r?.cancel(t),e?e.then(Oa).catch(Oa):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(t=>yo(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===aD||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>jd(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:!Iq(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(t&&this.setOptions(t),!this.options.queryFn){const l=this.observers.find(c=>c.options.queryFn);l&&this.setOptions(l.options)}const n=new AbortController,r=l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{const l=Fq(this.options,e),u=(()=>{const d={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(d),d})();return this.#o=!1,this.options.persister?this.options.persister(l,u,this):l(u)},o=(()=>{const l={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(l),l})();this.options.behavior?.onFetch(o,this),this.#e=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#s({type:"fetch",meta:o.fetchOptions?.meta}),this.#r=Bq({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof zj&&l.revert&&this.setState({...this.#e,fetchStatus:"idle"}),n.abort()},onFail:(l,c)=>{this.#s({type:"failed",failureCount:l,error:c})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{const l=await this.#r.start();if(l===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(l),this.#n.config.onSuccess?.(l,this),this.#n.config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof zj){if(l.silent)return this.#r.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#s({type:"error",error:l}),this.#n.config.onError?.(l,this),this.#n.config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc()}}#s(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Hq(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...dz(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#e=t.manual?r:void 0,r;case"error":const i=t.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),ai.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function Hq(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:zq(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function dz(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function hz(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 oD=class extends nm{constructor(t,e){super(),this.options=e,this.#t=t,this.#s=null,this.#o=Uj(),this.bindMethods(),this.setOptions(e)}#t;#e=void 0;#n=void 0;#i=void 0;#r;#a;#o;#s;#f;#d;#h;#c;#u;#l;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),fz(this.#e,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Bj(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Bj(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#_(),this.#e.removeObserver(this)}setOptions(t){const e=this.options,n=this.#e;if(this.options=this.#t.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof yo(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#w(),this.#e.setOptions(this.options),e._defaulted&&!m0(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&mz(this.#e,n,this.options,e)&&this.#m(),this.updateResult(),r&&(this.#e!==n||yo(this.options.enabled,this.#e)!==yo(e.enabled,this.#e)||jd(this.options.staleTime,this.#e)!==jd(e.staleTime,this.#e))&&this.#g();const i=this.#x();r&&(this.#e!==n||yo(this.options.enabled,this.#e)!==yo(e.enabled,this.#e)||i!==this.#l)&&this.#b(i)}getOptimisticResult(t){const e=this.#t.getQueryCache().build(this.#t,t),n=this.createResult(e,t);return zle(this,n)&&(this.#i=n,this.#a=this.options,this.#r=this.#e.state),n}getCurrentResult(){return this.#i}trackResult(t,e){return new Proxy(t,{get:(n,r)=>(this.trackProp(r),e?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,r))})}trackProp(t){this.#p.add(t)}getCurrentQuery(){return this.#e}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#t.defaultQueryOptions(t),n=this.#t.getQueryCache().build(this.#t,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#m({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#m(t){this.#w();let e=this.#e.fetch(this.options,t);return t?.throwOnError||(e=e.catch(Oa)),e}#g(){this.#v();const t=jd(this.options.staleTime,this.#e);if(Pf||this.#i.isStale||!Lj(t))return;const n=Iq(this.#i.dataUpdatedAt,t)+1;this.#c=sf.setTimeout(()=>{this.#i.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(t){this.#_(),this.#l=t,!(Pf||yo(this.options.enabled,this.#e)===!1||!Lj(this.#l)||this.#l===0)&&(this.#u=sf.setInterval(()=>{(this.options.refetchIntervalInBackground||sD.isFocused())&&this.#m()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(sf.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(sf.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#e,r=this.options,i=this.#i,s=this.#r,o=this.#a,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},f=!1,m;if(e._optimisticResults){const D=this.hasListeners(),A=!D&&fz(t,e),R=D&&mz(t,n,e,r);(A||R)&&(d={...d,...Hq(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:g,errorUpdatedAt:x,status:y}=d;m=d.data;let b=!1;if(e.placeholderData!==void 0&&m===void 0&&y==="pending"){let D;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(D=i.data,b=!0):D=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,D!==void 0&&(y="success",m=Fj(i?.data,D,e),f=!0)}if(e.select&&m!==void 0&&!b)if(i&&m===s?.data&&e.select===this.#f)m=this.#d;else try{this.#f=e.select,m=e.select(m),m=Fj(i?.data,m,e),this.#d=m,this.#s=null}catch(D){this.#s=D}this.#s&&(g=this.#s,m=this.#d,x=Date.now(),y="error");const v=d.fetchStatus==="fetching",N=y==="pending",S=y==="error",T=N&&v,E=m!==void 0,C={status:y,fetchStatus:d.fetchStatus,isPending:N,isSuccess:y==="success",isError:S,isInitialLoading:T,isLoading:T,data:m,dataUpdatedAt:d.dataUpdatedAt,error:g,errorUpdatedAt:x,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:v,isRefetching:v&&!N,isLoadingError:S&&!E,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:S&&E,isStale:lD(t,e),refetch:this.refetch,promise:this.#o,isEnabled:yo(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const D=F=>{C.status==="error"?F.reject(C.error):C.data!==void 0&&F.resolve(C.data)},A=()=>{const F=this.#o=C.promise=Uj();D(F)},R=this.#o;switch(R.status){case"pending":t.queryHash===n.queryHash&&D(R);break;case"fulfilled":(C.status==="error"||C.data!==R.value)&&A();break;case"rejected":(C.status!=="error"||C.error!==R.reason)&&A();break}}return C}updateResult(){const t=this.#i,e=this.createResult(this.#e,this.options);if(this.#r=this.#e.state,this.#a=this.options,this.#r.data!==void 0&&(this.#h=this.#e),m0(e,t))return;this.#i=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#p.size)return!0;const s=new Set(i??this.#p);return this.options.throwOnError&&s.add("error"),Object.keys(this.#i).some(o=>{const l=o;return this.#i[l]!==t[l]&&s.has(l)})};this.#S({listeners:n()})}#w(){const t=this.#t.getQueryCache().build(this.#t,this.options);if(t===this.#e)return;const e=this.#e;this.#e=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#S(t){ai.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function Ule(t,e){return yo(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function fz(t,e){return Ule(t,e)||t.state.data!==void 0&&Bj(t,e,e.refetchOnMount)}function Bj(t,e,n){if(yo(e.enabled,t)!==!1&&jd(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&lD(t,e)}return!1}function mz(t,e,n,r){return(t!==e||yo(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&lD(t,n)}function lD(t,e){return yo(e.enabled,t)!==!1&&t.isStaleByTime(jd(e.staleTime,t))}function zle(t,e){return!m0(t.getCurrentResult(),e)}function pz(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,s=e.state.data?.pages||[],o=e.state.data?.pageParams||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let d=!1;const f=x=>{Object.defineProperty(x,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},m=Fq(e.options,e.fetchOptions),g=async(x,y,b)=>{if(d)return Promise.reject();if(y==null&&x.pages.length)return Promise.resolve(x);const N=(()=>{const k={client:e.client,queryKey:e.queryKey,pageParam:y,direction:b?"backward":"forward",meta:e.options.meta};return f(k),k})(),S=await m(N),{maxPages:T}=e.options,E=b?Ple:jle;return{pages:E(x.pages,S,T),pageParams:E(x.pageParams,y,T)}};if(i&&s.length){const x=i==="backward",y=x?Ble:gz,b={pages:s,pageParams:o},v=y(r,b);l=await g(b,v,x)}else{const x=t??s.length;do{const y=c===0?o[0]??r.initialPageParam:gz(r,l);if(c>0&&y==null)break;l=await g(l,y),c++}while(c<x)}return l};e.options.persister?e.fetchFn=()=>e.options.persister?.(u,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=u}}}function gz(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 Ble(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var $le=class extends $q{#t;#e;#n;#i;constructor(t){super(),this.#t=t.client,this.mutationId=t.mutationId,this.#n=t.mutationCache,this.#e=[],this.state=t.state||Vq(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#e.includes(t)||(this.#e.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#e=this.#e.filter(e=>e!==t),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#i?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#r({type:"continue"})},n={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=Bq({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(s,o)=>{this.#r({type:"failed",failureCount:s,error:o})},onPause:()=>{this.#r({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const r=this.state.status==="pending",i=!this.#i.canStart();try{if(r)e();else{this.#r({type:"pending",variables:t,isPaused:i}),await this.#n.config.onMutate?.(t,this,n);const o=await this.options.onMutate?.(t,n);o!==this.state.context&&this.#r({type:"pending",context:o,variables:t,isPaused:i})}const s=await this.#i.start();return await this.#n.config.onSuccess?.(s,t,this.state.context,this,n),await this.options.onSuccess?.(s,t,this.state.context,n),await this.#n.config.onSettled?.(s,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(s,null,t,this.state.context,n),this.#r({type:"success",data:s}),s}catch(s){try{throw await this.#n.config.onError?.(s,t,this.state.context,this,n),await this.options.onError?.(s,t,this.state.context,n),await this.#n.config.onSettled?.(void 0,s,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(void 0,s,t,this.state.context,n),s}finally{this.#r({type:"error",error:s})}}finally{this.#n.runNext(this)}}#r(t){const e=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),ai.batch(()=>{this.#e.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function Vq(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Hle=class extends nm{constructor(t={}){super(),this.config=t,this.#t=new Set,this.#e=new Map,this.#n=0}#t;#e;#n;build(t,e,n){const r=new $le({client:t,mutationCache:this,mutationId:++this.#n,options:t.defaultMutationOptions(e),state:n});return this.add(r),r}add(t){this.#t.add(t);const e=a_(t);if(typeof e=="string"){const n=this.#e.get(e);n?n.push(t):this.#e.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#t.delete(t)){const e=a_(t);if(typeof e=="string"){const n=this.#e.get(e);if(n)if(n.length>1){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}else n[0]===t&&this.#e.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=a_(t);if(typeof e=="string"){const r=this.#e.get(e)?.find(i=>i.state.status==="pending");return!r||r===t}else return!0}runNext(t){const e=a_(t);return typeof e=="string"?this.#e.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ai.batch(()=>{this.#t.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(t){const e={exact:!0,...t};return this.getAll().find(n=>lz(e,n))}findAll(t={}){return this.getAll().filter(e=>lz(t,e))}notify(t){ai.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return ai.batch(()=>Promise.all(t.map(e=>e.continue().catch(Oa))))}};function a_(t){return t.options.scope?.id}var Vle=class extends nm{#t;#e=void 0;#n;#i;constructor(e,n){super(),this.#t=e,this.setOptions(n),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const n=this.options;this.options=this.#t.defaultMutationOptions(e),m0(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&Rf(n.mutationKey)!==Rf(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#r(),this.#a(e)}getCurrentResult(){return this.#e}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#r(),this.#a()}mutate(e,n){return this.#i=n,this.#n?.removeObserver(this),this.#n=this.#t.getMutationCache().build(this.#t,this.options),this.#n.addObserver(this),this.#n.execute(e)}#r(){const e=this.#n?.state??Vq();this.#e={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#a(e){ai.batch(()=>{if(this.#i&&this.hasListeners()){const n=this.#e.variables,r=this.#e.context,i={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};e?.type==="success"?(this.#i.onSuccess?.(e.data,n,r,i),this.#i.onSettled?.(e.data,null,n,r,i)):e?.type==="error"&&(this.#i.onError?.(e.error,n,r,i),this.#i.onSettled?.(void 0,e.error,n,r,i))}this.listeners.forEach(n=>{n(this.#e)})})}};function xz(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function Gle(t,e,n){const r=t.slice(0);return r[e]=n,r}var qle=class extends nm{#t;#e;#n;#i;#r;#a;#o;#s;#f=[];constructor(t,e,n){super(),this.#t=t,this.#i=n,this.#n=[],this.#r=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#r.forEach(t=>{t.subscribe(e=>{this.#u(t,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#r.forEach(t=>{t.destroy()})}setQueries(t,e){this.#n=t,this.#i=e,ai.batch(()=>{const n=this.#r,r=this.#c(this.#n);this.#f=r,r.forEach(d=>d.observer.setOptions(d.defaultedQueryOptions));const i=r.map(d=>d.observer),s=i.map(d=>d.getCurrentResult()),o=n.length!==i.length,l=i.some((d,f)=>d!==n[f]),c=o||l,u=c?!0:s.some((d,f)=>{const m=this.#e[f];return!m||!m0(d,m)});!c&&!u||(c&&(this.#r=i),this.#e=s,this.hasListeners()&&(c&&(xz(n,i).forEach(d=>{d.destroy()}),xz(i,n).forEach(d=>{d.subscribe(f=>{this.#u(d,f)})})),this.#l()))})}getCurrentResult(){return this.#e}getQueries(){return this.#r.map(t=>t.getCurrentQuery())}getObservers(){return this.#r}getOptimisticResult(t,e){const n=this.#c(t),r=n.map(i=>i.observer.getOptimisticResult(i.defaultedQueryOptions));return[r,i=>this.#h(i??r,e),()=>this.#d(r,n)]}#d(t,e){return e.map((n,r)=>{const i=t[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,s=>{e.forEach(o=>{o.observer.trackProp(s)})})})}#h(t,e){return e?((!this.#a||this.#e!==this.#s||e!==this.#o)&&(this.#o=e,this.#s=this.#e,this.#a=iD(this.#a,e(t))),this.#a):t}#c(t){const e=new Map;this.#r.forEach(r=>{const i=r.options.queryHash;if(!i)return;const s=e.get(i);s?s.push(r):e.set(i,[r])});const n=[];return t.forEach(r=>{const i=this.#t.defaultQueryOptions(r),o=e.get(i.queryHash)?.shift()??new oD(this.#t,i);n.push({defaultedQueryOptions:i,observer:o})}),n}#u(t,e){const n=this.#r.indexOf(t);n!==-1&&(this.#e=Gle(this.#e,n,e),this.#l())}#l(){if(this.hasListeners()){const t=this.#a,e=this.#d(this.#e,this.#f),n=this.#h(e,this.#i?.combine);t!==n&&ai.batch(()=>{this.listeners.forEach(r=>{r(this.#e)})})}}},Wle=class extends nm{constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,n){const r=e.queryKey,i=e.queryHash??rD(r,e);let s=this.get(i);return s||(s=new Fle({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(s)),s}add(t){this.#t.has(t.queryHash)||(this.#t.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#t.get(t.queryHash);e&&(t.destroy(),e===t&&this.#t.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ai.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#t.get(t)}getAll(){return[...this.#t.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(n=>oz(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>oz(t,n)):e}notify(t){ai.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){ai.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ai.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Kle=class{#t;#e;#n;#i;#r;#a;#o;#s;constructor(t={}){this.#t=t.queryCache||new Wle,this.#e=t.mutationCache||new Hle,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=sD.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=bw.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(t){return this.#t.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#e.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#t.build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(jd(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#t.findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),s=this.#t.get(r.queryHash)?.state.data,o=Cle(e,s);if(o!==void 0)return this.#t.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return ai.batch(()=>this.#t.findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state}removeQueries(t){const e=this.#t;ai.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#t;return ai.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=ai.batch(()=>this.#t.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Oa).catch(Oa)}invalidateQueries(t,e={}){return ai.batch(()=>(this.#t.findAll(t).forEach(n=>{n.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const n={...e,cancelRefetch:e.cancelRefetch??!0},r=ai.batch(()=>this.#t.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let s=i.fetch(void 0,n);return n.throwOnError||(s=s.catch(Oa)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(Oa)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#t.build(this,e);return n.isStaleByTime(jd(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Oa).catch(Oa)}fetchInfiniteQuery(t){return t.behavior=pz(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Oa).catch(Oa)}ensureInfiniteQueryData(t){return t.behavior=pz(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return bw.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#n}setDefaultOptions(t){this.#n=t}setQueryDefaults(t,e){this.#i.set(Rf(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{f0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(Rf(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{f0(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=rD(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===aD&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#n.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},Gq=w.createContext(void 0),an=t=>{const e=w.useContext(Gq);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Xle=({client:t,children:e})=>(w.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),a.jsx(Gq.Provider,{value:t,children:e})),qq=w.createContext(!1),Wq=()=>w.useContext(qq);qq.Provider;function Yle(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Qle=w.createContext(Yle()),Kq=()=>w.useContext(Qle),Xq=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Yq=t=>{w.useEffect(()=>{t.clearReset()},[t])},Qq=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||Uq(n,[t.error,r])),Zq=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))}},Jq=(t,e)=>t.isLoading&&t.isFetching&&!e,$j=(t,e)=>t?.suspense&&e.isPending,yw=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function eW({queries:t,...e},n){const r=an(),i=Wq(),s=Kq(),o=w.useMemo(()=>t.map(y=>{const b=r.defaultQueryOptions(y);return b._optimisticResults=i?"isRestoring":"optimistic",b}),[t,r,i]);o.forEach(y=>{Zq(y),Xq(y,s)}),Yq(s);const[l]=w.useState(()=>new qle(r,o,e)),[c,u,d]=l.getOptimisticResult(o,e.combine),f=!i&&e.subscribed!==!1;w.useSyncExternalStore(w.useCallback(y=>f?l.subscribe(ai.batchCalls(y)):Oa,[l,f]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),w.useEffect(()=>{l.setQueries(o,e)},[o,e,l]);const g=c.some((y,b)=>$j(o[b],y))?c.flatMap((y,b)=>{const v=o[b];if(v){const N=new oD(r,v);if($j(v,y))return yw(v,N,s);Jq(y,i)&&yw(v,N,s)}return[]}):[];if(g.length>0)throw Promise.all(g);const x=c.find((y,b)=>{const v=o[b];return v&&Qq({result:y,errorResetBoundary:s,throwOnError:v.throwOnError,query:r.getQueryCache().get(v.queryHash),suspense:v.suspense})});if(x?.error)throw x.error;return u(d())}function Zle(t,e,n){const r=Wq(),i=Kq(),s=an(),o=s.defaultQueryOptions(t);s.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?"isRestoring":"optimistic",Zq(o),Xq(o,i),Yq(i);const l=!s.getQueryCache().get(o.queryHash),[c]=w.useState(()=>new e(s,o)),u=c.getOptimisticResult(o),d=!r&&t.subscribed!==!1;if(w.useSyncExternalStore(w.useCallback(f=>{const m=d?c.subscribe(ai.batchCalls(f)):Oa;return c.updateResult(),m},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),w.useEffect(()=>{c.setOptions(o)},[o,c]),$j(o,u))throw yw(o,c,i);if(Qq({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw u.error;return s.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!Pf&&Jq(u,r)&&(l?yw(o,c,i):s.getQueryCache().get(o.queryHash)?.promise)?.catch(Oa).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?u:c.trackResult(u)}function ct(t,e){return Zle(t,oD)}function ht(t,e){const n=an(),[r]=w.useState(()=>new Vle(n,t));w.useEffect(()=>{r.setOptions(t)},[r,t]);const i=w.useSyncExternalStore(w.useCallback(o=>r.subscribe(ai.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=w.useCallback((o,l)=>{r.mutate(o,l).catch(Oa)},[r]);if(i.error&&Uq(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}const Jle=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ece=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),bz=t=>{const e=ece(t);return e.charAt(0).toUpperCase()+e.slice(1)},tW=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),tce=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var nce={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 rce=w.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...l},c)=>w.createElement("svg",{ref:c,...nce,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:tW("lucide",i),...!s&&!tce(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,d])=>w.createElement(u,d)),...Array.isArray(s)?s:[s]]));const Qe=(t,e)=>{const n=w.forwardRef(({className:r,...i},s)=>w.createElement(rce,{ref:s,iconNode:e,className:tW(`lucide-${Jle(bz(t))}`,`lucide-${t}`,r),...i}));return n.displayName=bz(t),n};const ice=[["path",{d:"M18 17.5a2.5 2.5 0 1 1-4 2.03V12",key:"yd12zl"}],["path",{d:"M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"larmp2"}],["path",{d:"M6 8h12",key:"6g4wlu"}],["path",{d:"M6.6 15.572A2 2 0 1 0 10 17v-5",key:"1x1kqn"}]],ace=Qe("air-vent",ice);const sce=[["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"}]],Qa=Qe("archive",sce);const oce=[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]],lce=Qe("arrow-down-wide-narrow",oce);const cce=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],p0=Qe("arrow-down",cce);const uce=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],nW=Qe("arrow-left",uce);const dce=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Hj=Qe("arrow-right",dce);const hce=[["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"}]],rW=Qe("arrow-up-down",hce);const fce=[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]],mce=Qe("arrow-up-narrow-wide",fce);const pce=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],og=Qe("arrow-up",pce);const gce=[["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"}]],gf=Qe("bell",gce);const xce=[["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"}]],bce=Qe("bold",xce);const yce=[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]],vce=Qe("book",yce);const _ce=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],wce=Qe("bookmark",_ce);const Sce=[["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"}]],Hs=Qe("box",Sce);const Nce=[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]],iW=Qe("briefcase",Nce);const Mce=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],D2=Qe("bug",Mce);const Ece=[["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"}]],Tce=Qe("cable",Ece);const Cce=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]],Ace=Qe("calculator",Cce);const kce=[["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"}]],jce=Qe("calendar-days",kce);const Pce=[["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"}]],si=Qe("calendar",Pce);const Rce=[["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"}]],Df=Qe("camera",Rce);const Dce=[["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"}]],Oce=Qe("chart-column",Dce);const Lce=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ua=Qe("check",Lce);const Ice=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Br=Qe("chevron-down",Ice);const Fce=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ms=Qe("chevron-right",Fce);const Uce=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Vd=Qe("chevron-left",Uce);const zce=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],ou=Qe("chevron-up",zce);const Bce=[["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"}]],Ei=Qe("circle-alert",Bce);const $ce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],DT=Qe("circle-arrow-up",$ce);const Hce=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Fn=Qe("circle-check-big",Hce);const Vce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],O2=Qe("circle-check",Vce);const Gce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],qce=Qe("circle-dot",Gce);const Wce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Kce=Qe("circle-stop",Wce);const Xce=[["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"}]],aa=Qe("circle-x",Xce);const Yce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Vj=Qe("circle",Yce);const Qce=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],qn=Qe("clock",Qce);const Zce=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],L2=Qe("cloud",Zce);const Jce=[["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"}]],eue=Qe("code-xml",Jce);const tue=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],aW=Qe("code",tue);const nue=[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]],rue=Qe("coffee",nue);const iue=[["path",{d:"M11 10.27 7 3.34",key:"16pf9h"}],["path",{d:"m11 13.73-4 6.93",key:"794ttg"}],["path",{d:"M12 22v-2",key:"1osdcq"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"m17 20.66-1-1.73",key:"eq3orb"}],["path",{d:"m17 3.34-1 1.73",key:"2wel8s"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"m20.66 17-1.73-1",key:"sg0v6f"}],["path",{d:"m20.66 7-1.73 1",key:"1ow05n"}],["path",{d:"m3.34 17 1.73-1",key:"nuk764"}],["path",{d:"m3.34 7 1.73 1",key:"1ulond"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}]],aue=Qe("cog",iue);const sue=[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],oue=Qe("compass",sue);const lue=[["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"}]],ll=Qe("copy",lue);const cue=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],s_=Qe("cpu",cue);const uue=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],due=Qe("cylinder",uue);const hue=[["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"}]],Zc=Qe("database",hue);const fue=[["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"}]],Gj=Qe("dollar-sign",fue);const mue=[["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"}]],Gr=Qe("download",mue);const pue=[["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"}]],cD=Qe("droplet",pue);const gue=[["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"}]],uD=Qe("droplets",gue);const xue=[["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"}]],Pd=Qe("ellipsis-vertical",xue);const bue=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],OT=Qe("equal",bue);const yue=[["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"}]],$r=Qe("external-link",yue);const vue=[["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"}]],I2=Qe("eye-off",vue);const _ue=[["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"}]],lu=Qe("eye",_ue);const wue=[["path",{d:"M10.827 16.379a6.082 6.082 0 0 1-8.618-7.002l5.412 1.45a6.082 6.082 0 0 1 7.002-8.618l-1.45 5.412a6.082 6.082 0 0 1 8.618 7.002l-5.412-1.45a6.082 6.082 0 0 1-7.002 8.618l1.45-5.412Z",key:"484a7f"}],["path",{d:"M12 12v.01",key:"u5ubse"}]],sW=Qe("fan",wue);const Sue=[["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"}]],xf=Qe("file-box",Sue);const Nue=[["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"}]],vw=Qe("file-code",Nue);const Mue=[["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"}]],Eue=Qe("file-exclamation-point",Mue);const Tue=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],_w=Qe("file-spreadsheet",Tue);const Cue=[["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"}]],Ka=Qe("file-text",Cue);const Aue=[["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"}]],F2=Qe("file",Aue);const kue=[["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"}]],Rd=Qe("film",kue);const jue=[["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"}]],Pue=Qe("flame",jue);const Rue=[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]],Ma=Qe("folder-kanban",Rue);const Due=[["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"}]],cl=Qe("folder-open",Due);const Oue=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Lue=Qe("folder-plus",Oue);const Iue=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],Fue=Qe("folder-tree",Iue);const Uue=[["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"}]],oW=Qe("folder",Uue);const zue=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1",key:"vys8me"}]],Bue=Qe("fullscreen",zue);const $ue=[["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"}]],U2=Qe("funnel",$ue);const Hue=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],z2=Qe("gauge",Hue);const Vue=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],Gue=Qe("gift",Vue);const que=[["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"}]],qp=Qe("git-compare",que);const Wue=[["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"}]],qj=Qe("github",Wue);const Kue=[["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"}]],Dd=Qe("globe",Kue);const Xue=[["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"}]],lg=Qe("grip-vertical",Xue);const Yue=[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]],lW=Qe("hand",Yue);const Que=[["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"}]],B2=Qe("hard-drive",Que);const Zue=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Jue=Qe("hash",Zue);const ede=[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]],tde=Qe("headphones",ede);const nde=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],rde=Qe("heart",nde);const ide=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],g0=Qe("history",ide);const ade=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],$2=Qe("house",ade);const sde=[["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"}]],cu=Qe("image",sde);const ode=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Ul=Qe("info",ode);const lde=[["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"}]],cde=Qe("italic",lde);const ude=[["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"}]],of=Qe("key",ude);const dde=[["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"}]],Wj=Qe("keyboard",dde);const hde=[["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"}]],ul=Qe("layers",hde);const fde=[["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"}]],H2=Qe("layout-grid",fde);const mde=[["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"}]],pde=Qe("link-2-off",mde);const gde=[["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"}]],Ol=Qe("link-2",gde);const xde=[["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"}]],$g=Qe("link",xde);const bde=[["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"}]],cW=Qe("list-ordered",bde);const yde=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],Kj=Qe("list-todo",yde);const vde=[["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"}]],V2=Qe("list",vde);const _de=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ut=Qe("loader-circle",_de);const wde=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],yz=Qe("lock-open",wde);const Sde=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],LT=Qe("lock",Sde);const Nde=[["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"}]],vz=Qe("log-in",Nde);const Mde=[["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"}]],Xj=Qe("log-out",Mde);const Ede=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],Tde=Qe("mail",Ede);const Cde=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],Ade=Qe("map",Cde);const kde=[["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"}]],uW=Qe("maximize-2",kde);const jde=[["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"}]],Pde=Qe("maximize",jde);const Rde=[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]],Dde=Qe("memory-stick",Rde);const Ode=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Lde=Qe("menu",Ode);const Ide=[["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"}]],dW=Qe("minimize-2",Ide);const Fde=[["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"}]],hW=Qe("minimize",Fde);const Ude=[["path",{d:"M5 12h14",key:"1ays0h"}]],Yj=Qe("minus",Ude);const zde=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Bde=Qe("monitor",zde);const $de=[["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"}]],ww=Qe("moon",$de);const Hde=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],Vde=Qe("move-right",Hde);const Gde=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],Qj=Qe("music",Gde);const qde=[["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"}]],zl=Qe("package",qde);const Wde=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],dD=Qe("palette",Wde);const Kde=[["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"}]],hD=Qe("pause",Kde);const Xde=[["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"}]],Of=Qe("pen-line",Xde);const Yde=[["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"}]],G2=Qe("pen",Yde);const Qde=[["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"}]],Oi=Qe("pencil",Qde);const Zde=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],Jde=Qe("phone",Zde);const ehe=[["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"}]],vs=Qe("play",ehe);const the=[["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"}]],Ws=Qe("plug",the);const nhe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],rr=Qe("plus",nhe);const rhe=[["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"}]],q2=Qe("power-off",rhe);const ihe=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],yu=Qe("power",ihe);const ahe=[["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"}]],Ar=Qe("printer",ahe);const she=[["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"}]],fW=Qe("qr-code",she);const ohe=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],fD=Qe("radio",ohe);const lhe=[["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"}]],vr=Qe("refresh-cw",lhe);const che=[["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"}]],rm=Qe("rotate-ccw",che);const uhe=[["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"}]],dhe=Qe("ruler",uhe);const hhe=[["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"}]],bs=Qe("save",hhe);const fhe=[["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"}]],Sw=Qe("scan-search",fhe);const mhe=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],phe=Qe("scissors",mhe);const ghe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],na=Qe("search",ghe);const xhe=[["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"}]],mD=Qe("send",xhe);const bhe=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Wh=Qe("server",bhe);const yhe=[["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"}]],Gd=Qe("settings-2",yhe);const vhe=[["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"}]],ly=Qe("settings",vhe);const _he=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Zj=Qe("shield",_he);const whe=[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]],mW=Qe("shopping-cart",whe);const She=[["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"}]],Nhe=Qe("signal",She);const Mhe=[["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"}]],Ehe=Qe("skip-back",Mhe);const The=[["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"}]],x0=Qe("skip-forward",The);const Che=[["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"}]],_z=Qe("sliders-vertical",Che);const Ahe=[["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"}]],b0=Qe("sparkles",Ahe);const khe=[["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"}]],Do=Qe("square-check-big",khe);const jhe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]],Phe=Qe("square-minus",jhe);const Rhe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Oo=Qe("square",Rhe);const Dhe=[["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"}]],Lf=Qe("star",Dhe);const Ohe=[["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"}]],pW=Qe("sticky-note",Ohe);const Lhe=[["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"}]],wz=Qe("sun",Lhe);const Ihe=[["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"}]],qd=Qe("tag",Ihe);const Fhe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],gW=Qe("target",Fhe);const Uhe=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],xW=Qe("terminal",Uhe);const zhe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Bhe=Qe("text-align-center",zhe);const $he=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Hhe=Qe("text-align-end",$he);const Vhe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Ghe=Qe("text-align-start",Vhe);const qhe=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],W2=Qe("thermometer",qhe);const Whe=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],Sd=Qe("timer",Whe);const Khe=[["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"}]],on=Qe("trash-2",Khe);const Xhe=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],bW=Qe("trending-down",Xhe);const Yhe=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Jj=Qe("trending-up",Yhe);const Qhe=[["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"}]],xn=Qe("triangle-alert",Qhe);const Zhe=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Jhe=Qe("underline",Zhe);const efe=[["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"}]],pD=Qe("unlink",efe);const tfe=[["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"}]],fi=Qe("upload",tfe);const nfe=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],e3=Qe("user",nfe);const rfe=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],Nd=Qe("users",rfe);const ife=[["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"}]],gD=Qe("video",ife);const afe=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],sfe=Qe("volume-2",afe);const ofe=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],lfe=Qe("volume-x",ofe);const cfe=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],ufe=Qe("wand-sparkles",cfe);const dfe=[["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"}]],If=Qe("wifi-off",dfe);const hfe=[["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"}]],Wp=Qe("wifi",hfe);const ffe=[["path",{d:"M12.8 19.6A2 2 0 1 0 14 16H2",key:"148xed"}],["path",{d:"M17.5 8a2.5 2.5 0 1 1 2 4H2",key:"1u4tom"}],["path",{d:"M9.8 4.4A2 2 0 1 1 11 8H2",key:"75valh"}]],yW=Qe("wind",ffe);const mfe=[["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"}]],Wd=Qe("wrench",mfe);const pfe=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ot=Qe("x",pfe);const gfe=[["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"}]],xD=Qe("zoom-in",gfe);const xfe=[["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"}]],Kd=Qe("zap",xfe);const bfe=[["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"}]],bD=Qe("zoom-out",bfe),fn="/api/v1";let Nw=localStorage.getItem("auth_token");function Tb(t){Nw=t,t?localStorage.setItem("auth_token",t):localStorage.removeItem("auth_token")}function Sz(){return Nw}async function Re(t,e={}){const n={"Content-Type":"application/json",...e.headers};Nw&&(n.Authorization=`Bearer ${Nw}`);const r=await fetch(`${fn}${t}`,{...e,cache:"no-store",headers:n});if(!r.ok){r.status===401&&Tb(null);const s=(await r.json().catch(()=>({}))).detail,o=typeof s=="string"?s:s?JSON.stringify(s):`HTTP ${r.status}`;throw new Error(o)}return await r.json()}const he={getAuthStatus:()=>Re("/auth/status"),setupAuth:t=>Re("/auth/setup",{method:"POST",body:JSON.stringify(t)}),login:t=>Re("/auth/login",{method:"POST",body:JSON.stringify(t)}),logout:()=>Re("/auth/logout",{method:"POST"}),getCurrentUser:()=>Re("/auth/me"),disableAuth:()=>Re("/auth/disable",{method:"POST"}),getUsers:()=>Re("/users/"),getUser:t=>Re(`/users/${t}`),createUser:t=>Re("/users/",{method:"POST",body:JSON.stringify(t)}),updateUser:(t,e)=>Re(`/users/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteUser:t=>Re(`/users/${t}`,{method:"DELETE"}),getPrinters:()=>Re("/printers/"),getPrinter:t=>Re(`/printers/${t}`),createPrinter:t=>Re("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>Re(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>Re(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>Re(`/printers/${t}/status`),refreshPrinterStatus:t=>Re(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>Re(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>Re(`/printers/${t}/disconnect`,{method:"POST"}),testExternalCamera:(t,e,n)=>Re(`/printers/${t}/camera/external/test?url=${encodeURIComponent(e)}&camera_type=${encodeURIComponent(n)}`,{method:"POST"}),stopPrint:t=>Re(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>Re(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>Re(`/printers/${t}/print/resume`,{method:"POST"}),setChamberLight:(t,e)=>Re(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>Re(`/printers/${t}/print/objects`),skipObjects:(t,e)=>Re(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>Re(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>Re(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>Re(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>Re(`/printers/${t}/logging`),clearMQTTLogs:t=>Re(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>Re(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${fn}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,downloadPrinterFilesAsZip:async(t,e)=>{const n=await fetch(`${fn}/printers/${t}/files/download-zip`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:e})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.detail||`HTTP ${n.status}`)}return n.blob()},deletePrinterFile:(t,e)=>Re(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>Re(`/printers/${t}/storage`),getArchives:(t,e,n=50,r=0)=>{const i=new URLSearchParams;return t&&i.set("printer_id",String(t)),e&&i.set("project_id",String(e)),i.set("limit",String(n)),i.set("offset",String(r)),Re(`/archives/?${i}`)},getArchive:t=>Re(`/archives/${t}`),searchArchives:(t,e)=>{const n=new URLSearchParams;return n.set("q",t),e?.printerId&&n.set("printer_id",String(e.printerId)),e?.projectId&&n.set("project_id",String(e.projectId)),e?.status&&n.set("status",e.status),e?.limit&&n.set("limit",String(e.limit)),e?.offset&&n.set("offset",String(e.offset)),Re(`/archives/search?${n}`)},rebuildSearchIndex:()=>Re("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>Re(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>Re(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>Re(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>Re("/archives/stats"),getTags:()=>Re("/archives/tags"),renameTag:(t,e)=>Re(`/archives/tags/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({new_name:e})}),deleteTag:t=>Re(`/archives/tags/${encodeURIComponent(t)}`,{method:"DELETE"}),recalculateCosts:()=>Re("/archives/recalculate-costs",{method:"POST"}),getFailureAnalysis:t=>{const e=new URLSearchParams;return t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),Re(`/archives/analysis/failures?${e}`)},compareArchives:t=>Re(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>Re(`/archives/${t}/similar?limit=${e}`),exportArchives:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.fields&&e.set("fields",t.fields.join(",")),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),t?.status&&e.set("status",t.status),t?.dateFrom&&e.set("date_from",t.dateFrom),t?.dateTo&&e.set("date_to",t.dateTo),t?.search&&e.set("search",t.search);const n=await fetch(`${fn}/archives/export?${e}`);if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"archives_export.xlsx":"archives_export.csv";if(r){const o=r.match(/filename="?([^"]+)"?/);o&&(i=o[1])}return{blob:await n.blob(),filename:i}},exportStats:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId));const n=await fetch(`${fn}/archives/stats/export?${e}`);if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"stats_export.xlsx":"stats_export.csv";if(r){const o=r.match(/filename="?([^"]+)"?/);o&&(i=o[1])}return{blob:await n.blob(),filename:i}},getArchiveDuplicates:t=>Re(`/archives/${t}/duplicates`),backfillContentHashes:()=>Re("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${fn}/archives/${t}/thumbnail?v=${Date.now()}`,getArchivePlateThumbnail:(t,e)=>`${fn}/archives/${t}/plate-thumbnail/${e}`,getArchiveDownload:t=>`${fn}/archives/${t}/download`,getArchiveGcode:t=>`${fn}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${fn}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${fn}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>Re(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>Re(`/archives/${t}/timelapse/select?filename=${encodeURIComponent(e)}`,{method:"POST"}),uploadArchiveTimelapse:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${fn}/archives/${t}/timelapse/upload`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},getTimelapseInfo:t=>Re(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>Re(`/archives/${t}/timelapse/thumbnails?count=${e}`),processTimelapse:async(t,e,n)=>{const r=new FormData;r.append("trim_start",String(e.trimStart??0)),e.trimEnd!==void 0&&r.append("trim_end",String(e.trimEnd)),r.append("speed",String(e.speed??1)),r.append("save_mode",e.saveMode),e.outputFilename&&r.append("output_filename",e.outputFilename),n&&r.append("audio",n);const i=await fetch(`${fn}/archives/${t}/timelapse/process`,{method:"POST",body:r});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},getArchivePhotoUrl:(t,e)=>`${fn}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${fn}/archives/${t}/photos`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteArchivePhoto:(t,e)=>Re(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${fn}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${fn}/archives/${t}/source/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,uploadSource3mf:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${fn}/archives/${t}/source`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteSource3mf:t=>Re(`/archives/${t}/source`,{method:"DELETE"}),getF3dDownloadUrl:t=>`${fn}/archives/${t}/f3d`,uploadF3d:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${fn}/archives/${t}/f3d`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteF3d:t=>Re(`/archives/${t}/f3d`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${fn}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>Re(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>Re(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>Re(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${fn}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${fn}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,getArchivePlates:t=>Re(`/archives/${t}/plates`),getArchiveFilamentRequirements:(t,e)=>Re(`/archives/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),reprintArchive:(t,e,n)=>Re(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST",headers:n?{"Content-Type":"application/json"}:void 0,body:n?JSON.stringify(n):void 0}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${fn}/archives/upload?printer_id=${e}`:`${fn}/archives/upload`,i=await fetch(r,{method:"POST",body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(s=>n.append("files",s));const r=e?`${fn}/archives/upload-bulk?printer_id=${e}`:`${fn}/archives/upload-bulk`,i=await fetch(r,{method:"POST",body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},getSettings:()=>Re("/settings/"),updateSettings:t=>Re("/settings/",{method:"PUT",body:JSON.stringify(t)}),getMQTTStatus:()=>Re("/settings/mqtt/status"),resetSettings:()=>Re("/settings/reset",{method:"POST"}),exportBackup:async t=>{const e=new URLSearchParams;t&&(t.settings!==void 0&&e.set("include_settings",String(t.settings)),t.notifications!==void 0&&e.set("include_notifications",String(t.notifications)),t.templates!==void 0&&e.set("include_templates",String(t.templates)),t.smart_plugs!==void 0&&e.set("include_smart_plugs",String(t.smart_plugs)),t.external_links!==void 0&&e.set("include_external_links",String(t.external_links)),t.printers!==void 0&&e.set("include_printers",String(t.printers)),t.plate_calibration!==void 0&&e.set("include_plate_calibration",String(t.plate_calibration)),t.filaments!==void 0&&e.set("include_filaments",String(t.filaments)),t.maintenance!==void 0&&e.set("include_maintenance",String(t.maintenance)),t.archives!==void 0&&e.set("include_archives",String(t.archives)),t.projects!==void 0&&e.set("include_projects",String(t.projects)),t.pending_uploads!==void 0&&e.set("include_pending_uploads",String(t.pending_uploads)),t.access_codes!==void 0&&e.set("include_access_codes",String(t.access_codes)),t.api_keys!==void 0&&e.set("include_api_keys",String(t.api_keys)));const n=`${fn}/settings/backup${e.toString()?"?"+e.toString():""}`,r=await fetch(n);if(!r.ok){const l=await r.text();throw new Error(l||`Backup failed with status ${r.status}`)}const i=r.headers.get("Content-Disposition");let s="bambuddy-backup.json";if(i){const l=i.match(/filename=([^;]+)/);l&&(s=l[1].trim())}return{blob:await r.blob(),filename:s}},importBackup:async(t,e=!1)=>{const n=new FormData;n.append("file",t);const r=`${fn}/settings/restore${e?"?overwrite=true":""}`;return(await fetch(r,{method:"POST",body:n})).json()},checkFfmpeg:()=>Re("/settings/check-ffmpeg"),getCloudStatus:()=>Re("/cloud/status"),cloudLogin:(t,e,n="global")=>Re("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>Re("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>Re("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>Re("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>Re(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>Re(`/cloud/settings/${t}`),createCloudSetting:t=>Re("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>Re(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>Re(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>Re("/cloud/devices"),getCloudFields:t=>Re(`/cloud/fields/${t}`),getAllCloudFields:()=>Re("/cloud/fields"),getFilamentInfo:t=>Re("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>Re("/smart-plugs/"),getSmartPlug:t=>Re(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>Re(`/smart-plugs/by-printer/${t}`),getScriptPlugsByPrinter:t=>Re(`/smart-plugs/by-printer/${t}/scripts`),createSmartPlug:t=>Re("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>Re(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>Re(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>Re(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>Re(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>Re("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>fetch(`${fn}/smart-plugs/discover/scan`,{method:"POST"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.detail||`HTTP ${t.status}`)})),getTasmotaScanStatus:()=>Re("/smart-plugs/discover/status"),stopTasmotaScan:()=>fetch(`${fn}/smart-plugs/discover/stop`,{method:"POST"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.detail||`HTTP ${t.status}`)})),getDiscoveredTasmotaDevices:()=>Re("/smart-plugs/discover/devices"),testHAConnection:(t,e)=>Re("/smart-plugs/ha/test-connection",{method:"POST",body:JSON.stringify({url:t,token:e})}),getHAEntities:t=>{const e=t?`?search=${encodeURIComponent(t)}`:"";return Re(`/smart-plugs/ha/entities${e}`)},getHASensorEntities:()=>Re("/smart-plugs/ha/sensors"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),Re(`/queue/?${n}`)},getQueueItem:t=>Re(`/queue/${t}`),addToQueue:t=>Re("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>Re(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>Re(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>Re("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>Re(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>Re(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>Re(`/queue/${t}/start`,{method:"POST"}),bulkUpdateQueue:t=>Re("/queue/bulk",{method:"PATCH",body:JSON.stringify(t)}),getKProfiles:(t,e="0.4")=>Re(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>Re(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>Re(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>Re(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>Re(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>Re(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>Re(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>Re(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>Re(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>Re(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>Re(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),configureAmsSlot:(t,e,n,r)=>{const i=new URLSearchParams({tray_info_idx:r.tray_info_idx,tray_type:r.tray_type,tray_sub_brands:r.tray_sub_brands,tray_color:r.tray_color,nozzle_temp_min:r.nozzle_temp_min.toString(),nozzle_temp_max:r.nozzle_temp_max.toString(),cali_idx:r.cali_idx.toString(),nozzle_diameter:r.nozzle_diameter});return r.setting_id&&i.set("setting_id",r.setting_id),r.kprofile_filament_id&&i.set("kprofile_filament_id",r.kprofile_filament_id),r.kprofile_setting_id&&i.set("kprofile_setting_id",r.kprofile_setting_id),r.k_value!==void 0&&r.k_value>0&&i.set("k_value",r.k_value.toString()),Re(`/printers/${t}/slots/${e}/${n}/configure?${i}`,{method:"POST"})},resetAmsSlot:(t,e,n)=>Re(`/printers/${t}/ams/${e}/tray/${n}/reset`,{method:"POST"}),listFilaments:()=>Re("/filaments/"),getFilament:t=>Re(`/filaments/${t}`),getFilamentsByType:t=>Re(`/filaments/by-type/${t}`),getNotificationProviders:()=>Re("/notifications/"),getNotificationProvider:t=>Re(`/notifications/${t}`),createNotificationProvider:t=>Re("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>Re(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>Re(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>Re(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>Re("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>Re("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>Re("/notification-templates"),getNotificationTemplate:t=>Re(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>Re(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>Re(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>Re("/notification-templates/variables"),previewTemplate:t=>Re("/notification-templates/preview",{method:"POST",body:JSON.stringify(t)}),getNotificationLogs:t=>{const e=new URLSearchParams;return t?.limit&&e.set("limit",String(t.limit)),t?.offset&&e.set("offset",String(t.offset)),t?.provider_id&&e.set("provider_id",String(t.provider_id)),t?.event_type&&e.set("event_type",t.event_type),t?.success!==void 0&&e.set("success",String(t.success)),t?.days&&e.set("days",String(t.days)),Re(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>Re(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>Re(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>Re("/spoolman/status"),connectSpoolman:()=>Re("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>Re("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>Re(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>Re("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>Re("/spoolman/spools"),getSpoolmanFilaments:()=>Re("/spoolman/filaments"),getUnlinkedSpools:()=>Re("/spoolman/spools/unlinked"),linkSpool:(t,e)=>Re(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getVersion:()=>Re("/updates/version"),checkForUpdates:()=>Re("/updates/check"),applyUpdate:()=>Re("/updates/apply",{method:"POST"}),getUpdateStatus:()=>Re("/updates/status"),getMaintenanceTypes:()=>Re("/maintenance/types"),createMaintenanceType:t=>Re("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>Re(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>Re(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>Re("/maintenance/overview"),getPrinterMaintenance:t=>Re(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>Re(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>Re(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>Re(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>Re("/maintenance/summary"),setPrinterHours:(t,e)=>Re(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>Re(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>Re(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${fn}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${fn}/printers/${t}/camera/snapshot`,testCameraConnection:t=>Re(`/printers/${t}/camera/test`),checkPlateEmpty:(t,e)=>{const n=new URLSearchParams;return n.set("use_external",String(e?.useExternal??!1)),n.set("include_debug_image",String(e?.includeDebugImage??!1)),Re(`/printers/${t}/camera/check-plate?${n.toString()}`)},getPlateDetectionStatus:t=>Re(`/printers/${t}/camera/plate-detection/status`),calibratePlateDetection:(t,e)=>{const n=new URLSearchParams;return e?.label&&n.set("label",e.label),n.set("use_external",String(e?.useExternal??!1)),Re(`/printers/${t}/camera/plate-detection/calibrate?${n.toString()}`,{method:"POST"})},deletePlateCalibration:t=>Re(`/printers/${t}/camera/plate-detection/calibrate`,{method:"DELETE"}),getPlateReferences:t=>Re(`/printers/${t}/camera/plate-detection/references`),getPlateReferenceThumbnailUrl:(t,e)=>`${fn}/printers/${t}/camera/plate-detection/references/${e}/thumbnail`,updatePlateReferenceLabel:(t,e,n)=>{const r=new URLSearchParams;return r.set("label",n),Re(`/printers/${t}/camera/plate-detection/references/${e}?${r.toString()}`,{method:"PUT"})},deletePlateReference:(t,e)=>Re(`/printers/${t}/camera/plate-detection/references/${e}`,{method:"DELETE"}),getExternalLinks:()=>Re("/external-links/"),getExternalLink:t=>Re(`/external-links/${t}`),createExternalLink:t=>Re("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>Re(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>Re(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>Re("/external-links/reorder",{method:"PUT",body:JSON.stringify({ids:t})}),uploadExternalLinkIcon:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${fn}/external-links/${t}/icon`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteExternalLinkIcon:t=>Re(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${fn}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),Re(`/projects/?${e}`)},getProject:t=>Re(`/projects/${t}`),createProject:t=>Re("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>Re(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>Re(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>Re(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>Re(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>Re(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>Re(`/projects/${t}/add-queue`,{method:"POST",body:JSON.stringify({queue_item_ids:e})}),uploadProjectAttachment:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${fn}/projects/${t}/attachments`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},getProjectAttachmentUrl:(t,e)=>`${fn}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>Re(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>Re(`/projects/${t}/bom`),createBOMItem:(t,e)=>Re(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>Re(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>Re(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>Re("/projects/templates/"),createTemplateFromProject:t=>Re(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>Re(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>Re(`/projects/${t}/timeline?limit=${e}`),exportProjectJson:t=>Re(`/projects/${t}/export?format=json`),importProject:t=>Re("/projects/import",{method:"POST",body:JSON.stringify(t)}),getAPIKeys:()=>Re("/api-keys/"),createAPIKey:t=>Re("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>Re(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>Re(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>Re(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>Re("/system/info"),getLibraryFolders:()=>Re("/library/folders"),createLibraryFolder:t=>Re("/library/folders",{method:"POST",body:JSON.stringify(t)}),updateLibraryFolder:(t,e)=>Re(`/library/folders/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFolder:t=>Re(`/library/folders/${t}`,{method:"DELETE"}),getLibraryFoldersByProject:t=>Re(`/library/folders/by-project/${t}`),getLibraryFoldersByArchive:t=>Re(`/library/folders/by-archive/${t}`),getLibraryFiles:(t,e=!0)=>{const n=new URLSearchParams;return t!=null&&n.set("folder_id",String(t)),n.set("include_root",String(e)),Re(`/library/files?${n}`)},getLibraryFile:t=>Re(`/library/files/${t}`),uploadLibraryFile:async(t,e,n=!0)=>{const r=new FormData;r.append("file",t);const i=new URLSearchParams;e&&i.set("folder_id",String(e)),i.set("generate_stl_thumbnails",String(n));const s=await fetch(`${fn}/library/files?${i}`,{method:"POST",body:r});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${s.status}`)}return s.json()},extractZipFile:async(t,e,n=!0,r=!1,i=!0)=>{const s=new FormData;s.append("file",t);const o=new URLSearchParams;e&&o.set("folder_id",String(e)),o.set("preserve_structure",String(n)),o.set("create_folder_from_zip",String(r)),o.set("generate_stl_thumbnails",String(i));const l=await fetch(`${fn}/library/files/extract-zip?${o}`,{method:"POST",body:s});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.detail||`HTTP ${l.status}`)}return l.json()},updateLibraryFile:(t,e)=>Re(`/library/files/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFile:t=>Re(`/library/files/${t}`,{method:"DELETE"}),getLibraryFileDownloadUrl:t=>`${fn}/library/files/${t}/download`,getLibraryFileThumbnailUrl:t=>`${fn}/library/files/${t}/thumbnail`,getLibraryFilePlateThumbnail:(t,e)=>`${fn}/library/files/${t}/plate-thumbnail/${e}`,getLibraryFileGcodeUrl:t=>`${fn}/library/files/${t}/gcode`,moveLibraryFiles:(t,e)=>Re("/library/files/move",{method:"POST",body:JSON.stringify({file_ids:t,folder_id:e})}),bulkDeleteLibrary:(t,e)=>Re("/library/bulk-delete",{method:"POST",body:JSON.stringify({file_ids:t,folder_ids:e})}),getLibraryStats:()=>Re("/library/stats"),batchGenerateStlThumbnails:t=>Re("/library/generate-stl-thumbnails",{method:"POST",body:JSON.stringify(t)}),addLibraryFilesToQueue:t=>Re("/library/files/add-to-queue",{method:"POST",body:JSON.stringify({file_ids:t})}),printLibraryFile:(t,e,n)=>Re(`/library/files/${t}/print?printer_id=${e}`,{method:"POST",body:n?JSON.stringify(n):void 0}),getLibraryFilePlates:t=>Re(`/library/files/${t}/plates`),getLibraryFileFilamentRequirements:(t,e)=>Re(`/library/files/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),getGitHubBackupConfig:()=>Re("/github-backup/config"),saveGitHubBackupConfig:t=>Re("/github-backup/config",{method:"POST",body:JSON.stringify(t)}),updateGitHubBackupConfig:t=>Re("/github-backup/config",{method:"PATCH",body:JSON.stringify(t)}),deleteGitHubBackupConfig:()=>Re("/github-backup/config",{method:"DELETE"}),testGitHubConnection:(t,e)=>Re(`/github-backup/test?repo_url=${encodeURIComponent(t)}&token=${encodeURIComponent(e)}`,{method:"POST"}),testGitHubStoredConnection:()=>Re("/github-backup/test-stored",{method:"POST"}),triggerGitHubBackup:()=>Re("/github-backup/run",{method:"POST"}),getGitHubBackupStatus:()=>Re("/github-backup/status"),getGitHubBackupLogs:(t=50)=>Re(`/github-backup/logs?limit=${t}`),clearGitHubBackupLogs:(t=10)=>Re(`/github-backup/logs?keep_last=${t}`,{method:"DELETE"})},vl={getInfo:()=>Re("/discovery/info"),getStatus:()=>Re("/discovery/status"),startDiscovery:(t=10)=>Re(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>Re("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>Re("/discovery/printers"),startSubnetScan:(t,e=1)=>Re("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>Re("/discovery/scan/status"),stopSubnetScan:()=>Re("/discovery/scan/stop",{method:"POST"})},H1={getSettings:()=>Re("/settings/virtual-printer"),getModels:()=>Re("/settings/virtual-printer/models"),updateSettings:t=>{const e=new URLSearchParams;return t.enabled!==void 0&&e.set("enabled",String(t.enabled)),t.access_code!==void 0&&e.set("access_code",t.access_code),t.mode!==void 0&&e.set("mode",t.mode),t.model!==void 0&&e.set("model",t.model),Re(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},Pp={list:()=>Re("/pending-uploads/"),getCount:()=>Re("/pending-uploads/count"),get:t=>Re(`/pending-uploads/${t}`),archive:(t,e)=>Re(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>Re(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>Re("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>Re("/pending-uploads/discard-all",{method:"DELETE"})},V1={checkUpdates:()=>Re("/firmware/updates"),checkPrinterUpdate:t=>Re(`/firmware/updates/${t}`),prepareUpload:t=>Re(`/firmware/updates/${t}/prepare`),startUpload:t=>Re(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>Re(`/firmware/updates/${t}/upload/status`)},Kp={getDebugLoggingState:()=>Re("/support/debug-logging"),setDebugLogging:t=>Re("/support/debug-logging",{method:"POST",body:JSON.stringify({enabled:t})}),downloadSupportBundle:async()=>{const t=await fetch(`${fn}/support/bundle`);if(!t.ok){const l=await t.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${t.status}`)}const n=t.headers.get("Content-Disposition")?.match(/filename=(.+)/),r=n?n[1]:"bambuddy-support.zip",i=await t.blob(),s=window.URL.createObjectURL(i),o=document.createElement("a");o.href=s,o.download=r,document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(s)},getLogs:t=>{const e=new URLSearchParams;t?.limit&&e.set("limit",t.limit.toString()),t?.level&&e.set("level",t.level),t?.search&&e.set("search",t.search);const n=e.toString();return Re(`/support/logs${n?`?${n}`:""}`)},clearLogs:()=>Re("/support/logs",{method:"DELETE"})},vW=w.createContext(void 0);function yfe({children:t}){const[e,n]=w.useState(()=>{const C=localStorage.getItem("theme-mode"),D=localStorage.getItem("theme");return C||D||"dark"}),[r,i]=w.useState(()=>localStorage.getItem("dark-style")||"classic"),[s,o]=w.useState(()=>localStorage.getItem("dark-background")||"neutral"),[l,c]=w.useState(()=>localStorage.getItem("dark-accent")||"green"),[u,d]=w.useState(()=>localStorage.getItem("light-style")||"classic"),[f,m]=w.useState(()=>localStorage.getItem("light-background")||"neutral"),[g,x]=w.useState(()=>localStorage.getItem("light-accent")||"green");w.useEffect(()=>{he.getSettings().then(C=>{C.dark_style&&(i(C.dark_style),localStorage.setItem("dark-style",C.dark_style)),C.dark_background&&(o(C.dark_background),localStorage.setItem("dark-background",C.dark_background)),C.dark_accent&&(c(C.dark_accent),localStorage.setItem("dark-accent",C.dark_accent)),C.light_style&&(d(C.light_style),localStorage.setItem("light-style",C.light_style)),C.light_background&&(m(C.light_background),localStorage.setItem("light-background",C.light_background)),C.light_accent&&(x(C.light_accent),localStorage.setItem("light-accent",C.light_accent))}).catch(()=>{})},[]),w.useEffect(()=>{const C=document.documentElement;C.classList.remove("dark","style-classic","style-glow","style-vibrant","bg-neutral","bg-warm","bg-cool","bg-oled","bg-slate","bg-forest","accent-green","accent-teal","accent-blue","accent-orange","accent-purple","accent-red"),e==="dark"?(C.classList.add("dark"),C.classList.add(`style-${r}`),C.classList.add(`bg-${s}`),C.classList.add(`accent-${l}`)):(C.classList.add(`style-${u}`),C.classList.add(`bg-${f}`),C.classList.add(`accent-${g}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,s,l,u,f,g]);const y=()=>n(C=>C==="dark"?"light":"dark"),b=C=>n(C),v=C=>{i(C),localStorage.setItem("dark-style",C),he.updateSettings({dark_style:C}).catch(()=>{})},N=C=>{o(C),localStorage.setItem("dark-background",C),he.updateSettings({dark_background:C}).catch(()=>{})},S=C=>{c(C),localStorage.setItem("dark-accent",C),he.updateSettings({dark_accent:C}).catch(()=>{})},T=C=>{d(C),localStorage.setItem("light-style",C),he.updateSettings({light_style:C}).catch(()=>{})},E=C=>{m(C),localStorage.setItem("light-background",C),he.updateSettings({light_background:C}).catch(()=>{})},k=C=>{x(C),localStorage.setItem("light-accent",C),he.updateSettings({light_accent:C}).catch(()=>{})};return a.jsx(vW.Provider,{value:{mode:e,darkStyle:r,darkBackground:s,darkAccent:l,lightStyle:u,lightBackground:f,lightAccent:g,toggleMode:y,setMode:b,setDarkStyle:v,setDarkBackground:N,setDarkAccent:S,setLightStyle:T,setLightBackground:E,setLightAccent:k},children:t})}function lh(){const t=w.useContext(vW);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function _t({children:t,className:e="",onClick:n,onContextMenu:r,...i}){return a.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary card-shadow ${e}`,onClick:n,onContextMenu:r,...i,children:t})}function tr({children:t,className:e=""}){return a.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function St({children:t,className:e=""}){return a.jsx("div",{className:`p-6 ${e}`,children:t})}function vfe(t,e,n){return[{category:"Navigation",items:t?t.slice(0,9).map((i,s)=>({keys:[String(s+1)],description:i.type==="external"?`Open ${i.label}`:`Go to ${i.labelKey?n(i.labelKey):i.label}`,isExternal:i.type==="external"})):e?e.map((i,s)=>({keys:[String(s+1)],description:`Go to ${n(i.labelKey)}`,isExternal:!1})):[{keys:["1"],description:"Go to Printers",isExternal:!1},{keys:["2"],description:"Go to Archives",isExternal:!1},{keys:["3"],description:"Go to Queue",isExternal:!1},{keys:["4"],description:"Go to Statistics",isExternal:!1},{keys:["5"],description:"Go to Cloud Profiles",isExternal:!1},{keys:["6"],description:"Go to Settings",isExternal:!1}]},{category:"Archives",items:[{keys:["/"],description:"Focus search",isExternal:!1},{keys:["U"],description:"Open upload modal",isExternal:!1},{keys:["Esc"],description:"Clear selection / blur input",isExternal:!1},{keys:["Right-click"],description:"Context menu on cards",isExternal:!1}]},{category:"K-Profiles",items:[{keys:["R"],description:"Refresh profiles",isExternal:!1},{keys:["N"],description:"New profile",isExternal:!1},{keys:["Esc"],description:"Exit selection mode",isExternal:!1}]},{category:"General",items:[{keys:["?"],description:"Show this help",isExternal:!1}]}]}function Nz({children:t}){return a.jsx("kbd",{className:"px-2 py-1 text-xs font-mono bg-bambu-dark border border-bambu-dark-tertiary rounded text-white",children:t})}function _fe({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Fg(),i=vfe(n,e,r);return w.useEffect(()=>{const s=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:a.jsx(_t,{className:"w-full max-w-md",onClick:s=>s.stopPropagation(),children:a.jsxs(St,{className:"p-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Wj,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(s=>a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:s.category}),a.jsx("div",{className:"space-y-2",children:s.items.map(o=>a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[o.description,o.isExternal&&a.jsx($r,{className:"w-3 h-3 text-bambu-gray"})]}),a.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>a.jsx(Nz,{children:l},l))})]},o.description))})]},s.category))}),a.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:a.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",a.jsx(Nz,{children:"Esc"})," or click outside to close"]})})]})})})}function Te({variant:t="primary",size:e="md",className:n="",children:r,...i}){const s="inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 disabled:cursor-not-allowed",o={primary:"bg-bambu-green hover:bg-bambu-green-light text-white focus:ring-bambu-green",secondary:"bg-bambu-dark-tertiary hover:bg-bambu-gray-dark text-white focus:ring-bambu-gray",danger:"bg-red-600 hover:bg-red-700 text-white focus:ring-red-500",ghost:"bg-transparent hover:bg-bambu-dark-tertiary text-bambu-gray-light hover:text-white"},l={sm:"px-3 py-1.5 text-sm gap-1.5 min-h-[44px] md:min-h-0",md:"px-4 py-2 text-sm gap-2 min-h-[44px] md:min-h-0",lg:"px-6 py-3 text-base gap-2 min-h-[48px] md:min-h-0"};return a.jsx("button",{className:`${s} ${o[t]} ${l[e]} ${n}`,...i,children:r})}function Hn({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",isLoading:s=!1,loadingText:o,onConfirm:l,onCancel:c}){w.useEffect(()=>{const f=m=>{m.key==="Escape"&&!s&&c()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[c,s]);const d={danger:{icon:"text-red-400",button:"bg-red-500 hover:bg-red-600"},warning:{icon:"text-yellow-400",button:"bg-yellow-500 hover:bg-yellow-600"},default:{icon:"text-bambu-green",button:"bg-bambu-green hover:bg-bambu-green-dark"}}[i];return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:s?void 0:c,children:a.jsx(_t,{className:"w-full max-w-md",onClick:f=>f.stopPropagation(),children:a.jsxs(St,{className:"p-6",children:[a.jsxs("div",{className:"flex items-start gap-4",children:[a.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${d.icon}`,children:a.jsx(xn,{className:"w-6 h-6"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),a.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),a.jsxs("div",{className:"flex gap-3 mt-6",children:[a.jsx(Te,{variant:"secondary",onClick:c,className:"flex-1",disabled:s,children:r}),a.jsx(Te,{onClick:l,className:`flex-1 ${d.button}`,disabled:s,children:s?a.jsxs(a.Fragment,{children:[a.jsx(ut,{className:"w-4 h-4 mr-2 animate-spin"}),o||"Processing..."]}):n})]})]})})})}function wfe({plug:t}){const e=an(),[n,r]=w.useState(null),{data:i,isLoading:s}=ct({queryKey:["smart-plug-status",t.id],queryFn:()=>he.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=ht({mutationFn:g=>he.controlSmartPlug(t.id,g),onSuccess:()=>{e.invalidateQueries({queryKey:["smart-plug-status",t.id]})}}),l=i?.state==="ON",c=t.plug_type==="mqtt"&&i?.energy?.power!==null&&i?.energy?.power!==void 0,u=(i?.reachable??!1)||c,d=o.isPending,f=t.plug_type==="mqtt",m=()=>{n&&(o.mutate(n),r(null))};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between py-2 px-3 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`p-1.5 rounded ${f?u?"bg-teal-500/20":"bg-red-500/20":u?l?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:f?a.jsx(fD,{className:`w-4 h-4 ${u?"text-teal-400":"text-red-400"}`}):a.jsx(Ws,{className:`w-4 h-4 ${u?l?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white font-medium",children:t.name}),a.jsx("div",{className:"flex items-center gap-1 text-xs",children:s?a.jsx(ut,{className:"w-3 h-3 text-bambu-gray animate-spin"}):f?u?a.jsxs(a.Fragment,{children:[a.jsx(Kd,{className:"w-3 h-3 text-teal-400"}),a.jsxs("span",{className:"text-teal-400",children:[Math.round(i?.energy?.power??0),"W"]}),a.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),a.jsx(lu,{className:"w-3 h-3 text-bambu-gray"}),a.jsx("span",{className:"text-bambu-gray",children:"Monitor"})]}):a.jsxs(a.Fragment,{children:[a.jsx(If,{className:"w-3 h-3 text-status-error"}),a.jsx("span",{className:"text-status-error",children:"Waiting"})]}):u?a.jsxs(a.Fragment,{children:[a.jsx(Wp,{className:"w-3 h-3 text-status-ok"}),a.jsx("span",{className:l?"text-status-ok":"text-bambu-gray",children:i?.state||"Unknown"}),i?.energy?.power!==null&&i?.energy?.power!==void 0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),a.jsx(Kd,{className:"w-3 h-3 text-yellow-400"}),a.jsxs("span",{className:"text-yellow-400",children:[Math.round(i.energy.power),"W"]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx(If,{className:"w-3 h-3 text-status-error"}),a.jsx("span",{className:"text-status-error",children:"Offline"})]})})]})]}),!f&&a.jsxs("div",{className:"flex gap-1",children:[a.jsx("button",{onClick:()=>r("on"),disabled:!u||d,className:`p-1.5 rounded transition-colors ${l?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn On",children:d?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(yu,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>r("off"),disabled:!u||d,className:`p-1.5 rounded transition-colors ${!l&&u?"bg-bambu-dark-tertiary text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn Off",children:d?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(q2,{className:"w-4 h-4"})})]})]}),n&&a.jsx(Hn,{title:`Turn ${n==="on"?"On":"Off"} Smart Plug`,message:`Are you sure you want to turn ${n==="on"?"on":"off"} "${t.name}"?`,confirmText:n==="on"?"Turn On":"Turn Off",variant:n==="off"?"warning":"default",onConfirm:m,onCancel:()=>r(null)})]})}function Mz({onClose:t}){const{data:e,isLoading:n}=ct({queryKey:["smart-plugs"],queryFn:he.getSmartPlugs}),r=e?.filter(i=>i.show_in_switchbar)||[];return a.jsxs("div",{className:"absolute bottom-full left-0 mb-2 w-72 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-xl z-50",onMouseLeave:t,children:[a.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary",children:a.jsxs("h3",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[a.jsx(Ws,{className:"w-4 h-4 text-bambu-green"}),"Smart Switches"]})}),a.jsx("div",{className:"p-2 max-h-80 overflow-y-auto",children:n?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(ut,{className:"w-6 h-6 text-bambu-gray animate-spin"})}):r.length===0?a.jsxs("div",{className:"text-center py-6 px-4",children:[a.jsx(Ws,{className:"w-8 h-8 text-bambu-gray mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"No switches in switchbar"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:'Enable "Show in Switchbar" in Settings > Smart Plugs'})]}):a.jsx("div",{className:"space-y-1",children:r.map(i=>a.jsx(wfe,{plug:i},i.id))})})]})}const _W=[{name:"globe",icon:Dd},{name:"link",icon:$g},{name:"external-link",icon:$r},{name:"book",icon:vce},{name:"file-text",icon:Ka},{name:"home",icon:$2},{name:"star",icon:Lf},{name:"heart",icon:rde},{name:"bookmark",icon:wce},{name:"shopping-cart",icon:mW},{name:"music",icon:Qj},{name:"video",icon:gD},{name:"image",icon:cu},{name:"camera",icon:Df},{name:"map",icon:Ade},{name:"compass",icon:oue},{name:"coffee",icon:rue},{name:"gift",icon:Gue},{name:"wrench",icon:Wd},{name:"zap",icon:Kd},{name:"cloud",icon:L2},{name:"database",icon:Zc},{name:"folder",icon:oW},{name:"mail",icon:Tde},{name:"phone",icon:Jde},{name:"user",icon:e3},{name:"users",icon:Nd},{name:"server",icon:Wh},{name:"terminal",icon:xW},{name:"code",icon:aW}];function K2(t){return _W.find(n=>n.name===t)?.icon||$g}function Sfe({value:t,onChange:e}){const[n,r]=w.useState(!1),i=K2(t);return a.jsxs("div",{className:"relative",children:[a.jsxs("button",{type:"button",onClick:()=>r(!n),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white hover:border-bambu-gray focus:border-bambu-green focus:outline-none w-full",children:[a.jsx(i,{className:"w-5 h-5"}),a.jsx("span",{className:"text-sm text-bambu-gray flex-1 text-left",children:t})]}),n&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),a.jsx("div",{className:"absolute z-50 mt-1 w-full max-h-64 overflow-y-auto bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg",children:a.jsx("div",{className:"grid grid-cols-5 gap-1 p-2",children:_W.map(({name:s,icon:o})=>a.jsx("button",{type:"button",onClick:()=>{e(s),r(!1)},className:`p-2 rounded-lg transition-colors flex items-center justify-center ${t===s?"bg-bambu-green text-white":"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:s,children:a.jsx(o,{className:"w-5 h-5"})},s))})})]})]})}const Ez=768;function yD(){const[t,e]=w.useState(()=>typeof window<"u"?window.innerWidth<Ez:!1);return w.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Ez-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const wW=w.createContext(void 0);function Nfe({children:t}){const[e,n]=w.useState(null),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(!0),u=w.useRef(!1),d=w.useRef(!0),f=async()=>{try{const b=await he.getAuthStatus();if(!d.current)return;if(i(b.auth_enabled),o(b.requires_setup),b.auth_enabled)if(Sz())try{const N=await he.getCurrentUser();if(!d.current)return;n(N)}catch{if(Tb(null),!d.current)return;n(null)}else n(null);else n(null)}catch{if(!d.current)return;i(!1),n(null)}finally{d.current&&c(!1)}};w.useEffect(()=>(d.current=!0,f(),()=>{d.current=!1}),[]),w.useEffect(()=>{if(!l&&s&&!r){const b=window.location.pathname;b!=="/setup"&&!b.startsWith("/camera/")&&!u.current&&(u.current=!0,window.location.href="/setup")}else s||(u.current=!1)},[l,s,r]);const m=async(b,v)=>{const N=await he.login({username:b,password:v});Tb(N.access_token),n(N.user)},g=()=>{Tb(null),n(null),he.logout().catch(()=>{}),window.location.href="/login"},x=async()=>{if(r&&Sz())try{const b=await he.getCurrentUser();d.current&&n(b)}catch{Tb(null),d.current&&n(null)}},y=async()=>{await f()};return a.jsx(wW.Provider,{value:{user:e,authEnabled:r,requiresSetup:s,loading:l,login:m,logout:g,refreshUser:x,refreshAuth:y},children:t})}function ch(){const t=w.useContext(wW);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const y0=[{id:"printers",to:"/",icon:Ar,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:Qa,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:si,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:Oce,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:L2,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:Wd,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:Ma,labelKey:"nav.projects"},{id:"files",to:"/files",icon:cl,labelKey:"nav.files"},{id:"settings",to:"/settings",icon:ly,labelKey:"nav.settings"}];function Mfe(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return y0.map(e=>e.id)}return y0.map(e=>e.id)}function Efe(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function IT(t){return t.startsWith("ext-")}function SW(){return localStorage.getItem("defaultView")||"/"}function Tfe(t){localStorage.setItem("defaultView",t)}function Cfe(){const t=fl(),e=Yl(),{mode:n,toggleMode:r}=lh(),{t:i}=Fg(),s=yD(),{user:o,authEnabled:l,logout:c}=ch(),[u,d]=w.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[f,m]=w.useState(!1),[g,x]=w.useState(!1),[y,b]=w.useState(!1),[v,N]=w.useState(Mfe),[S,T]=w.useState(null),[E,k]=w.useState(null),C=w.useRef(!1),[D,A]=w.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),[R,F]=w.useState(null),{data:O}=ct({queryKey:["version"],queryFn:he.getVersion,staleTime:1/0}),{data:q}=ct({queryKey:["settings"],queryFn:he.getSettings,staleTime:300*1e3}),{data:j}=ct({queryKey:["updateCheck"],queryFn:he.checkForUpdates,enabled:q?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:G}=ct({queryKey:["external-links"],queryFn:he.getExternalLinks}),{data:Y}=ct({queryKey:["smart-plugs"],queryFn:he.getSmartPlugs,staleTime:30*1e3}),K=Y?.some(X=>X.show_in_switchbar)??!1,{data:Z}=ct({queryKey:["debugLogging"],queryFn:Kp.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),{data:te}=ct({queryKey:["queue","pending"],queryFn:()=>he.getQueue(void 0,"pending"),staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),ne=te?.length??0,{data:z}=ct({queryKey:["pending-uploads","count"],queryFn:Pp.getCount,staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),W=z?.count??0,[se,ae]=w.useState(null);w.useEffect(()=>{if(!Z?.enabled||!Z.enabled_at){ae(null);return}const X=new Date(Z.enabled_at).getTime(),U=()=>{ae(Math.floor((Date.now()-X)/1e3))};U();const Q=setInterval(U,1e3);return()=>clearInterval(Q)},[Z?.enabled,Z?.enabled_at]);const de=w.useMemo(()=>new Map(y0.map(X=>[X.id,X])),[]),me=w.useMemo(()=>new Map((G||[]).map(X=>[`ext-${X.id}`,X])),[G]),xe=(()=>{const X=[],U=new Set,Q=l&&o?.role==="user";for(const le of v)Q&&le==="settings"||(de.has(le)||me.has(le))&&(X.push(le),U.add(le));for(const le of y0)Q&&le.id==="settings"||U.has(le.id)||(X.push(le.id),U.add(le.id));for(const le of G||[]){const Pe=`ext-${le.id}`;U.has(Pe)||(X.push(Pe),U.add(Pe))}return X})(),be=(X,U)=>{T(U),X.dataTransfer.effectAllowed="move",X.dataTransfer.setData("text/plain",U)},fe=(X,U)=>{X.preventDefault(),X.dataTransfer.dropEffect="move",k(U)},Ce=()=>{k(null)},Ne=(X,U)=>{if(X.preventDefault(),S===null||S===U){T(null),k(null);return}const Q=[...xe],le=Q.indexOf(S),Pe=Q.indexOf(U);if(le===-1||Pe===-1){T(null),k(null);return}Q.splice(le,1),Q.splice(Pe,0,S),N(Q),Efe(Q),T(null),k(null)},re=()=>{T(null),k(null)},He=j?.update_available&&j.latest_version&&j.latest_version!==D,H=()=>{j?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",j.latest_version),A(j.latest_version))};w.useEffect(()=>{if(!C.current&&e.pathname==="/"){const X=SW();X!=="/"&&(C.current=!0,t(X,{replace:!0}))}},[e.pathname,t]),w.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(u))},[u]),w.useEffect(()=>{s&&m(!1)},[e.pathname,s]),w.useEffect(()=>{const X=U=>{const Q=U.detail;F({printer_id:Q.printer_id,printer_name:Q.printer_name,message:Q.message})};return window.addEventListener("plate-not-empty",X),()=>window.removeEventListener("plate-not-empty",X)},[]);const B=w.useCallback(X=>{const U=X.target;if(!(U.tagName==="INPUT"||U.tagName==="TEXTAREA"||U.isContentEditable)&&!X.metaKey&&!X.ctrlKey&&!X.altKey){const Q=parseInt(X.key);if(Q>=1&&Q<=xe.length&&Q<=9){const le=xe[Q-1];if(X.preventDefault(),IT(le)){const Pe=le.replace("ext-","");t(`/external/${Pe}`)}else{const Pe=de.get(le);Pe&&t(Pe.to)}return}switch(X.key){case"?":X.preventDefault(),x(!0);break;case"Escape":x(!1);break}}},[t,xe,de]);return w.useEffect(()=>(document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)),[B]),a.jsxs("div",{className:"flex min-h-screen",children:[s&&a.jsxs("header",{className:"fixed top-0 left-0 right-0 z-40 h-14 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary flex items-center px-4",children:[a.jsx("button",{onClick:()=>m(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:a.jsx(Lde,{className:"w-6 h-6 text-white"})}),a.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-8 ml-3"})]}),s&&f&&a.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>m(!1)}),a.jsxs("aside",{className:`bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col transition-all duration-300 ${s?`fixed inset-y-0 left-0 z-50 w-72 transform ${f?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${u?"w-64":"w-16"}`}`,children:[a.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${s||u?"p-4":"p-2"}`,children:a.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:s||u?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),a.jsx("nav",{className:"flex-1 p-2",children:a.jsx("ul",{className:"space-y-2",children:xe.map(X=>{if(IT(X)){const Q=me.get(X);if(!Q)return null;const le=Q.custom_icon?null:K2(Q.icon);return a.jsx("li",{draggable:!0,onDragStart:Pe=>be(Pe,X),onDragOver:Pe=>fe(Pe,X),onDragLeave:Ce,onDrop:Pe=>Ne(Pe,X),onDragEnd:re,className:`relative ${S===X?"opacity-50":""} ${E===X&&S!==X?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:a.jsxs(Eb,{to:`/external/${Q.id}`,className:({isActive:Pe})=>`flex items-center ${s||u?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${Pe?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!s&&!u?Q.name:void 0,children:[u&&!s&&a.jsx(lg,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),Q.custom_icon?a.jsx("img",{src:`/api/v1/external-links/${Q.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):le&&a.jsx(le,{className:"w-5 h-5 flex-shrink-0"}),(s||u)&&a.jsx("span",{children:Q.name})]})},X)}else{const Q=de.get(X);if(!Q)return null;const{to:le,icon:Pe,labelKey:Oe}=Q,je=X==="queue"&&ne>0,$=X==="archives"&&W>0,I=je?ne:$?W:0,V=je||$;return a.jsx("li",{draggable:!0,onDragStart:ie=>be(ie,X),onDragOver:ie=>fe(ie,X),onDragLeave:Ce,onDrop:ie=>Ne(ie,X),onDragEnd:re,className:`relative ${S===X?"opacity-50":""} ${E===X&&S!==X?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:a.jsxs(Eb,{to:le,className:({isActive:ie})=>`flex items-center ${s||u?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${ie?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!s&&!u?i(Oe):void 0,children:[u&&!s&&a.jsx(lg,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),a.jsxs("div",{className:"relative",children:[a.jsx(Pe,{className:"w-5 h-5 flex-shrink-0"}),V&&a.jsx("span",{className:`absolute -top-1.5 -right-1.5 min-w-[18px] h-[18px] px-1 flex items-center justify-center text-[10px] font-bold rounded-full ${$?"bg-blue-500 text-white":"bg-yellow-500 text-black"}`,children:I>99?"99+":I})]}),(s||u)&&a.jsx("span",{children:i(Oe)})]})},X)}})})}),!s&&a.jsx("button",{onClick:()=>d(!u),className:"p-2 mx-2 mb-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white flex items-center justify-center",title:i(u?"nav.collapseSidebar":"nav.expandSidebar"),children:u?a.jsx(Vd,{className:"w-5 h-5"}):a.jsx(Ms,{className:"w-5 h-5"})}),a.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:s||u?a.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[a.jsxs("div",{className:"flex items-center justify-center gap-1",children:[K&&a.jsxs("div",{className:"relative",children:[a.jsx("button",{onMouseEnter:()=>b(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${y?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:a.jsx(Ws,{className:"w-5 h-5"})}),y&&a.jsx(Mz,{onClose:()=>b(!1)})]}),a.jsx(Eb,{to:"/system",className:({isActive:X})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${X?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:a.jsx(Ul,{className:"w-5 h-5"})}),a.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:a.jsx(qj,{className:"w-5 h-5"})}),a.jsx("button",{onClick:()=>x(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:a.jsx(Wj,{className:"w-5 h-5"})}),a.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?a.jsx(wz,{className:"w-5 h-5"}):a.jsx(ww,{className:"w-5 h-5"})}),l&&o&&a.jsx("button",{onClick:c,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.logout",{defaultValue:"Logout"}),children:a.jsx(Xj,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[a.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",O?.version||"..."]}),j?.update_available&&a.jsxs("button",{onClick:()=>t("/settings"),className:"flex items-center gap-1 text-xs text-bambu-green hover:text-bambu-green/80 transition-colors",title:i("nav.updateAvailable",{version:j.latest_version}),children:[a.jsx(DT,{className:"w-4 h-4"}),a.jsx("span",{children:i("nav.update")})]})]})]}):a.jsxs("div",{className:"flex flex-col items-center gap-1",children:[j?.update_available&&a.jsx("button",{onClick:()=>t("/settings"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-green hover:text-bambu-green/80",title:i("nav.updateAvailable",{version:j.latest_version}),children:a.jsx(DT,{className:"w-5 h-5"})}),K&&a.jsxs("div",{className:"relative",children:[a.jsx("button",{onMouseEnter:()=>b(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${y?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:a.jsx(Ws,{className:"w-5 h-5"})}),y&&a.jsx(Mz,{onClose:()=>b(!1)})]}),a.jsx(Eb,{to:"/system",className:({isActive:X})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${X?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:a.jsx(Ul,{className:"w-5 h-5"})}),a.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:a.jsx(qj,{className:"w-5 h-5"})}),a.jsx("button",{onClick:()=>x(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:a.jsx(Wj,{className:"w-5 h-5"})}),a.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?a.jsx(wz,{className:"w-5 h-5"}):a.jsx(ww,{className:"w-5 h-5"})}),l&&o&&a.jsx("button",{onClick:c,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.logout",{defaultValue:"Logout"}),children:a.jsx(Xj,{className:"w-5 h-5"})})]})})]}),a.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${s?"mt-14":u?"ml-64":"ml-16"}`,children:[Z?.enabled&&a.jsx("div",{className:"bg-amber-500/20 border-b border-amber-500/30 px-4 py-2 flex items-center justify-between",children:a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(D2,{className:"w-4 h-4 text-amber-500 animate-pulse"}),a.jsxs("span",{className:"text-amber-200",children:[i("support.debugLoggingActive",{defaultValue:"Debug logging is active"}),se!==null&&a.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(se/60),"m ",se%60,"s)"]})]}),a.jsx("button",{onClick:()=>t("/system"),className:"text-amber-400 hover:text-amber-300 font-medium underline ml-2",children:i("support.manageLogs",{defaultValue:"Manage"})})]})}),He&&a.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(DT,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{children:i("nav.updateAvailableBanner",{version:j?.latest_version,defaultValue:`Version ${j?.latest_version} is available!`})}),a.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),a.jsx("button",{onClick:H,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:a.jsx(Ot,{className:"w-4 h-4"})})]}),a.jsx($oe,{})]}),g&&a.jsx(_fe,{onClose:()=>x(!1),sidebarItems:xe.map(X=>{if(IT(X)){const U=me.get(X);return U?{type:"external",label:U.name}:null}else{const U=de.get(X);return U?{type:"nav",label:U.labelKey,labelKey:U.labelKey}:null}}).filter(Boolean)}),R&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[100] p-4",children:a.jsx("div",{className:"bg-bambu-dark-secondary border-2 border-yellow-500 rounded-xl shadow-2xl max-w-md w-full animate-in fade-in zoom-in duration-200",children:a.jsxs("div",{className:"p-6 text-center",children:[a.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-yellow-500/20 flex items-center justify-center",children:a.jsx("svg",{className:"w-10 h-10 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),a.jsx("h2",{className:"text-xl font-bold text-yellow-400 mb-2",children:"Print Paused!"}),a.jsx("p",{className:"text-lg text-white mb-2",children:R.printer_name}),a.jsx("p",{className:"text-bambu-gray mb-6",children:"Objects detected on build plate. The print has been automatically paused. Please clear the plate and resume the print."}),a.jsx("button",{onClick:()=>F(null),className:"w-full py-3 px-6 bg-yellow-500 hover:bg-yellow-600 text-black font-semibold rounded-lg transition-colors",children:"I Understand"})]})})})]})}function Hb(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function wi(t){return t?t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(t+"Z"):null}function cg(t,e){const n=wi(t);if(!n)return"";const r={year:"numeric",month:"short",day:"numeric"};return n.toLocaleDateString(void 0,e??r)}function ug(t,e="system",n){const r=wi(t);if(!r)return"";const s=Hb(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,s)}function Afe(t,e="system",n){const i=Hb({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}const NW=w.createContext(void 0);function Gn(){const t=w.useContext(NW);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const kfe={success:a.jsx(Fn,{className:"w-5 h-5 text-green-400"}),error:a.jsx(aa,{className:"w-5 h-5 text-red-400"}),warning:a.jsx(Ei,{className:"w-5 h-5 text-yellow-400"}),info:a.jsx(Ul,{className:"w-5 h-5 text-blue-400"}),loading:a.jsx(ut,{className:"w-5 h-5 text-bambu-green animate-spin"})},jfe={success:"bg-green-500/10 border-green-500/30",error:"bg-red-500/10 border-red-500/30",warning:"bg-yellow-500/10 border-yellow-500/30",info:"bg-blue-500/10 border-blue-500/30",loading:"bg-bambu-green/10 border-bambu-green/30"};function Pfe({children:t}){const[e,n]=w.useState([]),r=w.useCallback((o,l="success")=>{const c=Math.random().toString(36).substr(2,9);n(u=>[...u,{id:c,message:o,type:l}]),setTimeout(()=>{n(u=>u.filter(d=>d.id!==c))},3e3)},[]),i=w.useCallback((o,l,c="info")=>{n(u=>u.find(f=>f.id===o)?u.map(f=>f.id===o?{...f,message:l,type:c,persistent:!0}:f):[...u,{id:o,message:l,type:c,persistent:!0}])},[]),s=w.useCallback(o=>{n(l=>l.filter(c=>c.id!==o))},[]);return a.jsxs(NW.Provider,{value:{showToast:r,showPersistentToast:i,dismissToast:s},children:[t,a.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(o=>a.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${jfe[o.type]}`,children:[kfe[o.type],a.jsx("span",{className:"text-white text-sm",children:o.message}),a.jsx("button",{onClick:()=>s(o.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ot,{className:"w-4 h-4"})})]},o.id))})]})}function Rfe(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 Tz(t){if(t===0)return"0 GB";const e=t/(1024*1024*1024);return e>=1?`${e.toFixed(1)} GB`:`${(t/(1024*1024)).toFixed(0)} MB`}function Dfe(t,e){if(e)return oW;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return xf;case"gcode":return Ka;case"mp4":case"avi":return Rd;case"png":case"jpg":case"jpeg":return cu;default:return F2}}const Ofe=[{value:"name-asc",label:"Name (A-Z)"},{value:"name-desc",label:"Name (Z-A)"},{value:"size-asc",label:"Size (smallest)"},{value:"size-desc",label:"Size (largest)"},{value:"date-asc",label:"Date (oldest)"},{value:"date-desc",label:"Date (newest)"}];function Lfe({printerId:t,printerName:e,onClose:n}){const{showToast:r}=Gn(),i=an(),[s,o]=w.useState("/"),[l,c]=w.useState(new Set),[u,d]=w.useState(""),[f,m]=w.useState([]),[g,x]=w.useState("name-asc"),[y,b]=w.useState(null);w.useEffect(()=>{const j=G=>{G.key==="Escape"&&n()};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[n]);const{data:v,isLoading:N,refetch:S}=ct({queryKey:["printerFiles",t,s],queryFn:()=>he.getPrinterFiles(t,s)}),{data:T}=ct({queryKey:["printerStorage",t],queryFn:()=>he.getPrinterStorage(t),staleTime:3e4}),E=ht({mutationFn:async j=>{for(const G of j)await he.deletePrinterFile(t,G)},onSuccess:()=>{r(`Deleted ${f.length} file${f.length>1?"s":""}`),i.invalidateQueries({queryKey:["printerFiles",t]}),c(new Set),m([])},onError:j=>{r(`Delete failed: ${j.message}`,"error")}}),k=j=>{o(j),c(new Set)},C=()=>{if(s==="/")return;const j=s.split("/").filter(Boolean);j.pop(),o(j.length?"/"+j.join("/"):"/"),c(new Set)},D=(j,G)=>{G.stopPropagation(),c(Y=>{const K=new Set(Y);return K.has(j)?K.delete(j):K.add(j),K})},A=()=>{if(!v?.files)return;const j=v.files.filter(G=>!G.is_directory&&(!u||G.name.toLowerCase().includes(u.toLowerCase()))).map(G=>G.path);c(new Set(j))},R=()=>{c(new Set)},F=async()=>{if(l.size===0)return;const j=Array.from(l);if(j.length===1){window.open(he.getPrinterFileDownloadUrl(t,j[0]),"_blank"),c(new Set);return}b({current:0,total:j.length});try{const G=await he.downloadPrinterFilesAsZip(t,j),Y=URL.createObjectURL(G),K=document.createElement("a");K.href=Y,K.download=`${e.replace(/[^a-zA-Z0-9]/g,"_")}-files.zip`,document.body.appendChild(K),K.click(),document.body.removeChild(K),URL.revokeObjectURL(Y),r(`Downloaded ${j.length} files as ZIP`),c(new Set)}catch(G){r(`Download failed: ${G instanceof Error?G.message:"Unknown error"}`,"error")}finally{b(null)}},O=()=>{l.size!==0&&m(Array.from(l))},q=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[a.jsxs("div",{className:"w-full max-w-3xl max-h-[85vh] flex flex-col bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden",onClick:j=>j.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(B2,{className:"w-5 h-5 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),a.jsxs("div",{className:"flex items-center gap-4",children:[T&&(T.used_bytes!=null||T.free_bytes!=null)&&a.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[T.used_bytes!=null&&a.jsxs("span",{children:["Used: ",Tz(T.used_bytes)]}),T.used_bytes!=null&&T.free_bytes!=null&&a.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),T.free_bytes!=null&&a.jsxs("span",{children:["Free: ",Tz(T.free_bytes)]})]}),a.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ot,{className:"w-5 h-5"})})]})]}),a.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[q.map(j=>a.jsx("button",{onClick:()=>{k(j.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${s===j.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:j.label},j.path)),a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"relative",children:[a.jsx(na,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:"Filter files...",value:u,onChange:j=>d(j.target.value),className:"w-40 pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"relative flex items-center gap-1",children:[a.jsx(rW,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("select",{value:g,onChange:j=>x(j.target.value),className:"appearance-none bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm py-1.5 pl-2 pr-6 focus:border-bambu-green focus:outline-none cursor-pointer",children:Ofe.map(j=>a.jsx("option",{value:j.value,children:j.label},j.value))})]}),a.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>S(),disabled:N,children:a.jsx(vr,{className:`w-4 h-4 ${N?"animate-spin":""}`})})]}),a.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[a.jsx("button",{onClick:C,disabled:s==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:a.jsx(Vd,{className:"w-4 h-4"})}),a.jsx("span",{className:"text-bambu-gray font-mono",children:s})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:N?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(ut,{className:"w-8 h-8 text-bambu-green animate-spin"})}):v?.files?.length?a.jsx("div",{className:"space-y-1",children:[...v.files].filter(j=>!u||j.name.toLowerCase().includes(u.toLowerCase())).sort((j,G)=>{if(j.is_directory&&!G.is_directory)return-1;if(!j.is_directory&&G.is_directory)return 1;switch(g){case"name-asc":return j.name.localeCompare(G.name);case"name-desc":return G.name.localeCompare(j.name);case"size-asc":return j.size-G.size;case"size-desc":return G.size-j.size;case"date-asc":{const Y=j.mtime?new Date(j.mtime).getTime():0,K=G.mtime?new Date(G.mtime).getTime():0;return Y-K}case"date-desc":{const Y=j.mtime?new Date(j.mtime).getTime():0;return(G.mtime?new Date(G.mtime).getTime():0)-Y}default:return j.name.localeCompare(G.name)}}).map(j=>{const G=Dfe(j.name,j.is_directory),Y=l.has(j.path);return a.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${Y?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{j.is_directory&&k(j.path)},children:[j.is_directory?null:a.jsx("button",{onClick:K=>D(j.path,K),className:"flex-shrink-0 text-bambu-gray hover:text-white",children:Y?a.jsx(Do,{className:"w-5 h-5 text-bambu-green"}):a.jsx(Oo,{className:"w-5 h-5"})}),a.jsx(G,{className:`w-5 h-5 flex-shrink-0 ${j.is_directory?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("span",{className:"flex-1 text-white truncate",children:j.name}),!j.is_directory&&a.jsx("span",{className:"text-sm text-bambu-gray",children:Rfe(j.size)}),j.is_directory&&a.jsx(Vd,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},j.path)})}):a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),a.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("div",{className:"text-sm text-bambu-gray",children:l.size>0?`${l.size} selected`:u?`${v?.files?.filter(j=>j.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${v?.files?.length||0} items`:`${v?.files?.length||0} items`}),v?.files?.some(j=>!j.is_directory)&&a.jsx("div",{className:"flex items-center gap-2",children:l.size>0?a.jsxs("button",{onClick:R,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[a.jsx(Phe,{className:"w-4 h-4"}),"Deselect All"]}):a.jsxs("button",{onClick:A,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[a.jsx(Do,{className:"w-4 h-4"}),"Select All"]})})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Te,{variant:"secondary",disabled:l.size===0||y!==null,onClick:F,children:y?a.jsxs(a.Fragment,{children:[a.jsx(ut,{className:"w-4 h-4 animate-spin"}),y.current,"/",y.total]}):a.jsxs(a.Fragment,{children:[a.jsx(Gr,{className:"w-4 h-4"}),"Download",l.size>1?` (${l.size})`:""]})}),a.jsxs(Te,{variant:"secondary",disabled:l.size===0||E.isPending,onClick:O,className:"text-red-400 hover:text-red-300",children:[E.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(on,{className:"w-4 h-4"}),"Delete",l.size>1?` (${l.size})`:""]})]})]})]}),f.length>0&&a.jsx(Hn,{title:f.length>1?`Delete ${f.length} Files`:"Delete File",message:f.length>1?`Delete ${f.length} selected files? This cannot be undone.`:`Delete "${f[0].split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{E.mutate(f)},onCancel:()=>m([])})]})}const Ife="embeddedCameraState_",Cz=5,Ffe=2e3,Ufe=3e4,zfe=5e3,FT={x:window.innerWidth-420,y:20,width:400,height:300};function Bfe({printerId:t,printerName:e,viewerIndex:n=0,onClose:r}){const i=`${Ife}${t}`,s=()=>{try{const ve=localStorage.getItem(i);if(ve){const Le=JSON.parse(ve);return{x:Math.min(Math.max(0,Le.x),window.innerWidth-100),y:Math.min(Math.max(0,Le.y),window.innerHeight-100),width:Math.max(200,Math.min(Le.width,window.innerWidth-20)),height:Math.max(150,Math.min(Le.height,window.innerHeight-20))}}}catch{}const oe=n*30;return{...FT,x:Math.max(0,FT.x-oe),y:Math.max(0,FT.y+oe)}},[o,l]=w.useState(s),[c,u]=w.useState(!1),[d,f]=w.useState(!1),[m,g]=w.useState({x:0,y:0}),[x,y]=w.useState(!1),[b,v]=w.useState(!1),[N,S]=w.useState(1),[T,E]=w.useState({x:0,y:0}),[k,C]=w.useState(!1),[D,A]=w.useState({x:0,y:0}),[R,F]=w.useState(null),[O,q]=w.useState(null),[j,G]=w.useState(!1),[Y,K]=w.useState(!0),[Z,te]=w.useState(Date.now()),[ne,z]=w.useState(0),[W,se]=w.useState(!1),[ae,de]=w.useState(0),me=w.useRef(null),xe=w.useRef(null),be=w.useRef(null),fe=w.useRef(null),Ce=w.useRef(null),{data:Ne}=ct({queryKey:["printer",t],queryFn:()=>he.getPrinter(t),enabled:t>0});w.useEffect(()=>{const oe=setTimeout(()=>{localStorage.setItem(i,JSON.stringify(o))},500);return()=>clearTimeout(oe)},[o,i]);const re=w.useRef(!1);w.useEffect(()=>{re.current=!1;const oe=`/api/v1/printers/${t}/camera/stop`,ve=()=>{t>0&&!re.current&&(re.current=!0,navigator.sendBeacon(oe))},Le=xe.current;return()=>{Le&&(Le.src=""),ve(),be.current&&clearTimeout(be.current),fe.current&&clearInterval(fe.current),Ce.current&&clearInterval(Ce.current)}},[t]),w.useEffect(()=>{if(Y){const oe=setTimeout(()=>K(!1),3e3);return()=>clearTimeout(oe)}},[Y,Z]);const He=w.useCallback(()=>{if(ne>=Cz){se(!1),G(!0);return}const oe=Math.min(Ffe*Math.pow(2,ne),Ufe);se(!0),de(Math.ceil(oe/1e3)),fe.current=setInterval(()=>{de(ve=>ve<=1?(fe.current&&clearInterval(fe.current),0):ve-1)},1e3),be.current=setTimeout(()=>{z(ve=>ve+1),se(!1),K(!0),G(!1),xe.current&&(xe.current.src=""),te(Date.now())},oe)},[ne]);w.useEffect(()=>{if(Y||W||x){Ce.current&&(clearInterval(Ce.current),Ce.current=null);return}return Ce.current=setInterval(async()=>{try{const oe=await fetch(`/api/v1/printers/${t}/camera/status`);if(oe.ok){const ve=await oe.json();(ve.stalled||!ve.active&&!j)&&(Ce.current&&(clearInterval(Ce.current),Ce.current=null),K(!1),He())}}catch{}},zfe),()=>{Ce.current&&(clearInterval(Ce.current),Ce.current=null)}},[Y,j,W,x,t,He]),w.useEffect(()=>{const oe=()=>{const ve=!!document.fullscreenElement;v(ve),ve||(S(1),E({x:0,y:0}))};return document.addEventListener("fullscreenchange",oe),()=>document.removeEventListener("fullscreenchange",oe)},[]);const H=()=>{me.current&&(document.fullscreenElement?document.exitFullscreen():me.current.requestFullscreen())},B=()=>{S(oe=>Math.min(oe+.5,4))},X=()=>{S(oe=>{const ve=Math.max(oe-.5,1);return ve===1&&E({x:0,y:0}),ve})},U=oe=>{oe.preventDefault(),oe.deltaY<0?B():X()},Q=oe=>{N>1&&(oe.preventDefault(),C(!0),A({x:oe.clientX-T.x,y:oe.clientY-T.y}))},le=w.useCallback(()=>{if(!me.current||!xe.current)return{x:200,y:150};const oe=me.current.getBoundingClientRect(),ve=oe.width*(N-1)/2,Le=oe.height*(N-1)/2;return{x:Math.max(50,ve),y:Math.max(50,Le)}},[N]),Pe=oe=>{if(k&&N>1){const ve=oe.clientX-D.x,Le=oe.clientY-D.y,Ke=le();E({x:Math.max(-Ke.x,Math.min(Ke.x,ve)),y:Math.max(-Ke.y,Math.min(Ke.y,Le))})}},Oe=()=>{C(!1)},je=oe=>{if(oe.length<2)return 0;const ve=oe[0].clientX-oe[1].clientX,Le=oe[0].clientY-oe[1].clientY;return Math.sqrt(ve*ve+Le*Le)},$=oe=>oe.length<2?{x:oe[0].clientX,y:oe[0].clientY}:{x:(oe[0].clientX+oe[1].clientX)/2,y:(oe[0].clientY+oe[1].clientY)/2},I=oe=>{oe.touches.length===2?(oe.preventDefault(),F(je(oe.touches)),q($(oe.touches))):oe.touches.length===1&&N>1&&(oe.preventDefault(),C(!0),A({x:oe.touches[0].clientX-T.x,y:oe.touches[0].clientY-T.y}))},V=oe=>{if(oe.touches.length===2&&R!==null){oe.preventDefault();const ve=je(oe.touches),Le=ve/R;S(lt=>{const _e=Math.max(1,Math.min(4,lt*Le));return _e===1&&E({x:0,y:0}),_e}),F(ve);const Ke=$(oe.touches);if(O){const lt=le();E(_e=>({x:Math.max(-lt.x,Math.min(lt.x,_e.x+(Ke.x-O.x))),y:Math.max(-lt.y,Math.min(lt.y,_e.y+(Ke.y-O.y)))}))}q(Ke)}else if(oe.touches.length===1&&k&&N>1){oe.preventDefault();const ve=oe.touches[0].clientX-D.x,Le=oe.touches[0].clientY-D.y,Ke=le();E({x:Math.max(-Ke.x,Math.min(Ke.x,ve)),y:Math.max(-Ke.y,Math.min(Ke.y,Le))})}},ie=oe=>{oe.touches.length<2&&(F(null),q(null)),oe.touches.length===0&&C(!1)},Se=()=>{S(1),E({x:0,y:0})},ye=()=>{K(!1),ne<Cz?He():G(!0)},$e=()=>{K(!1),G(!1),z(0),se(!1),be.current&&clearTimeout(be.current),fe.current&&clearInterval(fe.current)},Ue=()=>{K(!0),G(!1),z(0),se(!1),be.current&&clearTimeout(be.current),fe.current&&clearInterval(fe.current),fetch(`/api/v1/printers/${t}/camera/stop`).catch(()=>{}),xe.current&&(xe.current.src=""),setTimeout(()=>te(Date.now()),100)},Ge=oe=>{oe.target.closest(".no-drag")||(u(!0),g({x:oe.clientX-o.x,y:oe.clientY-o.y}))},We=oe=>{oe.stopPropagation(),f(!0)};w.useEffect(()=>{const oe=Le=>{if(c)l(Ke=>({...Ke,x:Math.max(0,Math.min(Le.clientX-m.x,window.innerWidth-Ke.width)),y:Math.max(0,Math.min(Le.clientY-m.y,window.innerHeight-Ke.height))}));else if(d&&me.current){const Ke=me.current.getBoundingClientRect();l(lt=>({...lt,width:Math.max(200,Math.min(Le.clientX-Ke.left,window.innerWidth-lt.x-10)),height:Math.max(150,Math.min(Le.clientY-Ke.top,window.innerHeight-lt.y-10))}))}},ve=()=>{u(!1),f(!1)};if(c||d)return document.addEventListener("mousemove",oe),document.addEventListener("mouseup",ve),()=>{document.removeEventListener("mousemove",oe),document.removeEventListener("mouseup",ve)}},[c,d,m]);const Ye=`/api/v1/printers/${t}/camera/stream?fps=10&t=${Z}`;return a.jsxs("div",{ref:me,className:`${b?"fixed inset-0 z-[100]":"fixed z-50 rounded-lg shadow-2xl border border-bambu-dark-tertiary"} bg-bambu-dark-secondary overflow-hidden`,style:b?void 0:{left:o.x,top:o.y,width:x?200:o.width,height:x?40:o.height,cursor:c?"grabbing":"default"},children:[a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-bambu-dark border-b border-bambu-dark-tertiary cursor-grab active:cursor-grabbing",onMouseDown:Ge,children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-white truncate",children:[a.jsx(lg,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"truncate",children:Ne?.name||e})]}),a.jsxs("div",{className:"flex items-center gap-1 no-drag",children:[a.jsx("button",{onClick:Ue,disabled:Y||W,className:"p-1 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:"Refresh stream",children:a.jsx(vr,{className:`w-3.5 h-3.5 text-bambu-gray ${Y?"animate-spin":""}`})}),a.jsx("button",{onClick:H,className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:b?"Exit fullscreen":"Fullscreen",children:b?a.jsx(hW,{className:"w-3.5 h-3.5 text-bambu-gray"}):a.jsx(Bue,{className:"w-3.5 h-3.5 text-bambu-gray"})}),a.jsx("button",{onClick:()=>y(!x),className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:x?"Expand":"Minimize",children:x?a.jsx(uW,{className:"w-3.5 h-3.5 text-bambu-gray"}):a.jsx(dW,{className:"w-3.5 h-3.5 text-bambu-gray"})}),a.jsx("button",{onClick:r,className:"p-1 hover:bg-red-500/20 rounded",title:"Close",children:a.jsx(Ot,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-red-400"})})]})]}),!x&&a.jsxs("div",{className:"relative w-full bg-black flex items-center justify-center overflow-hidden h-[calc(100%-40px)]",onWheel:U,onMouseMove:Pe,onMouseUp:Oe,onMouseLeave:Oe,onTouchStart:I,onTouchMove:V,onTouchEnd:ie,style:{touchAction:"none"},children:[Y&&!W&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:a.jsx(vr,{className:"w-6 h-6 text-bambu-gray animate-spin"})}),W&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:a.jsxs("div",{className:"text-center p-2",children:[a.jsx(If,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Reconnecting in ",ae,"s..."]})]})}),j&&!W&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:a.jsxs("div",{className:"text-center p-2",children:[a.jsx(xn,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Camera unavailable"}),a.jsx("button",{onClick:Ue,className:"px-2 py-1 text-xs bg-bambu-green text-white rounded hover:bg-bambu-green/80",children:"Retry"})]})}),a.jsx("img",{ref:xe,src:Ye,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${N}) translate(${T.x/N}px, ${T.y/N}px)`,cursor:N>1?k?"grabbing":"grab":"default"},onError:ye,onLoad:$e,onMouseDown:Q,draggable:!1},Z),a.jsxs("div",{className:"absolute bottom-2 left-2 flex items-center gap-1 bg-black/60 rounded px-1.5 py-1 no-drag",children:[a.jsx("button",{onClick:X,disabled:N<=1,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:a.jsx(bD,{className:"w-3.5 h-3.5 text-white"})}),a.jsxs("button",{onClick:Se,className:"px-1.5 py-0.5 text-xs text-white hover:bg-white/10 rounded min-w-[32px]",title:"Reset zoom",children:[Math.round(N*100),"%"]}),a.jsx("button",{onClick:B,disabled:N>=4,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:a.jsx(xD,{className:"w-3.5 h-3.5 text-white"})})]}),!b&&a.jsx("div",{className:"absolute bottom-0 right-0 w-6 h-6 cursor-se-resize no-drag hover:bg-white/10 rounded-tl transition-colors",onMouseDown:We,title:"Drag to resize",children:a.jsx("svg",{className:"w-6 h-6 text-bambu-gray/70 hover:text-bambu-gray",viewBox:"0 0 24 24",fill:"currentColor",children:a.jsx("path",{d:"M22 22H20V20H22V22ZM22 18H20V16H22V18ZM18 22H16V20H18V22ZM22 14H20V12H22V14ZM18 18H16V16H18V18ZM14 22H12V20H14V22ZM22 10H20V8H22V10ZM18 14H16V12H18V14ZM14 18H12V16H14V18ZM10 22H8V20H10V22Z"})})})]})]})}function $fe({printerId:t,printerName:e,onClose:n}){const r=an(),[i,s]=w.useState(!0),[o,l]=w.useState(new Set),[c,u]=w.useState(""),[d,f]=w.useState("all"),m=w.useRef(null),{data:g,isLoading:x,refetch:y}=ct({queryKey:["mqtt-logs",t],queryFn:()=>he.getMQTTLogs(t),refetchInterval:1e3}),b=ht({mutationFn:()=>he.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),v=ht({mutationFn:()=>he.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),N=ht({mutationFn:()=>he.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});w.useEffect(()=>{const A=R=>{R.key==="Escape"&&n()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[n]),w.useEffect(()=>{i&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[g?.logs,i]);const S=A=>{l(R=>{const F=new Set(R);return F.has(A)?F.delete(A):F.add(A),F})},T=A=>new Date(A).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),E=(A,R)=>{if(A==null)return"<empty>";const F=typeof A=="string"?JSON.parse(A):A,O=JSON.stringify(F,null,R?2:0);return!R&&O.length>100?O.substring(0,100)+"...":O},k=g?.logging_enabled??!1,C=w.useMemo(()=>g?.logs??[],[g?.logs]),D=w.useMemo(()=>C.filter(A=>{if(d!=="all"&&A.direction!==d)return!1;if(c.trim()){const R=c.toLowerCase(),F=A.topic.toLowerCase().includes(R),q=JSON.stringify(A.payload).toLowerCase().includes(R);return F||q}return!0}),[C,c,d]);return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),a.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[k?a.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>v.mutate(),disabled:v.isPending,children:[a.jsx(Oo,{className:"w-4 h-4"}),"Stop"]}):a.jsxs(Te,{size:"sm",onClick:()=>b.mutate(),disabled:b.isPending,children:[a.jsx(vs,{className:"w-4 h-4"}),"Start Logging"]}),a.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>N.mutate(),disabled:N.isPending||C.length===0,children:[a.jsx(on,{className:"w-4 h-4"}),"Clear"]}),a.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>y(),disabled:x,children:a.jsx(vr,{className:`w-4 h-4 ${x?"animate-spin":""}`})}),a.jsx("div",{className:"flex-1"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:i,onChange:A=>s(A.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[D.length,"/",C.length]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(na,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:"Search topic or payload...",value:c,onChange:A=>u(A.target.value),className:"w-full pl-8 pr-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),c&&a.jsx("button",{onClick:()=>u(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Ot,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>f("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${d==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),a.jsxs("button",{onClick:()=>f("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${d==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[a.jsx(p0,{className:"w-3 h-3"}),"In"]}),a.jsxs("button",{onClick:()=>f("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${d==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[a.jsx(og,{className:"w-3 h-3"}),"Out"]})]})]})]}),a.jsx("div",{ref:m,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:C.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!k&&a.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):D.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:"No messages match your filter"}),a.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):a.jsx("div",{className:"space-y-1",children:D.map((A,R)=>{const F=o.has(R),O=A.direction==="in";return a.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${F?"bg-bambu-dark-secondary":""}`,onClick:()=>S(R),children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("span",{className:"text-bambu-gray shrink-0",children:T(A.timestamp)}),a.jsx("span",{className:`shrink-0 ${O?"text-blue-400":"text-green-400"}`,title:O?"Incoming":"Outgoing",children:O?a.jsx(p0,{className:"w-3 h-3"}):a.jsx(og,{className:"w-3 h-3"})}),a.jsx("span",{className:"text-purple-400 shrink-0",children:A.topic})]}),F?a.jsx("pre",{className:"mt-2 p-3 bg-gray-900 border border-gray-700 rounded text-green-400 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto text-xs",children:E(A.payload,!0)}):a.jsx("pre",{className:"mt-1 text-white/80 truncate",children:E(A.payload,!1)})]},R)})})}),a.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-sm text-bambu-gray",children:k?a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):a.jsx("span",{children:"Logging stopped"})}),a.jsx(Te,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const t3={"0300_4000":"Z axis homing failed; the task has been stopped.","0300_4001":"The printer timed out waiting for the nozzle to cool down before homing.","0300_4002":"Auto Bed Leveling failed; the task has been stopped.","0300_4005":"The hotend cooling fan speed is abnormal.","0300_4006":"The nozzle is clogged.","0300_4008":"The AMS failed to change filament.","0300_4009":"Homing XY axis failed.","0300_400A":"Mechanical resonance frequency identification failed.","0300_400B":"Internal communication exception","0300_400C":"The task was canceled.","0300_400D":"Resume failed after power loss.","0300_400E":"The motor self-check failed.","0300_400F":"The power supply voltage does not match the printer.","0300_4010":"Nozzle offset calibration failed.","0300_4011":"Flow Dynamics Calibration failed; please reinitiate printing or calibration.","0300_4013":"Printing cannot be initiated while AMS is drying.","0300_4014":"Homing Z axis failed: temperature control abnormality.","0300_4015":"Nozzle clumping detection calibration failed. Please go to 'Assistant' for troubleshooting.","0300_4016":"Nozzle cleaning failed. Please click the Assistant for troubleshooting.","0300_401F":"The hotend is not installed, and the toolhead cannot perform homing. Please install the hotend and then continue.","0300_4020":"The nozzle presence detection failed. Please check the Assistant for details.","0300_4021":"Nozzle offset calibration sensor signal abnormality detected. Please check the sensor and retry.","0300_4042":"The Laser Safety Window is not properly installed. The task has been stopped.","0300_4044":"The Flame Sensor is abnormal. The sensor may be short-circuited. Please troubleshoot the issue before starting a print job.","0300_404B":"Task aborted because the front door or top cover is open.","0300_404D":"The current temperature of the hotend, heatbed, or chamber is too high. Please wait for it to cool down to room temperature before restarting the task.","0300_4050":"Liveview Camera calibration timeout; please restart the printer.","0300_4052":"Blade Z-axis homing failed","0300_4057":"Z-axis step loss detected. The task has stopped. Please check if there are any obstructions beneath the heatbed.","0300_4066":"Calibration of motion precision failed.","0300_4067":"Calibration result is over the threshold.","0300_4068":"Step loss occurred during the motion accuracy enhancement process. Please try again.","0300_8000":"Printing was paused for unknown reason. You can select 'Resume' to resume the print job.","0300_8001":"Printing was paused by the user. You can select 'Resume' to continue printing.","0300_8002":"First layer defects were detected by the Micro Lidar. Please check the quality of the printed model before continuing your print.","0300_8003":"Spaghetti defects were detected by the AI Print Monitoring. Please check the quality of the printed model before continuing your print.","0300_8004":"Filament ran out. Please load new filament.","0300_8005":"Toolhead front cover fell off. Please remount the front cover and check to make sure your print is going okay.","0300_8006":"The build plate marker was not detected. Please confirm the build plate is correctly positioned on the heatbed with all four corners aligned, and the marker is visible.","0300_8007":"There was an unfinished print job when the printer lost power. If the model is still adhered to the build plate, you can try resuming the print job.","0300_8008":"Nozzle temperature malfunction","0300_8009":"Heatbed temperature malfunction","0300_800A":"A Filament pile-up was detected by AI Print Monitoring. Please clean filament from the waste chute.","0300_800B":"The cutter is stuck. Please make sure the cutter handle is out and check the filament sensor cable connection.","0300_800C":"Skipped step detected: auto-recover complete; please resume print and check if there are any layer shift problems.","0300_800D":"Detected that the extruder is not extruding normally. If the defects are acceptable, select 'Resume' to resume the print job.","0300_800E":"The print file is not available. Please check to see if the storage media has been removed.","0300_800F":"The door seems to be open, so printing was paused.","0300_8010":"The hotend cooling fan speed is abnormal.","0300_8011":"Detected build plate is not the same as the Gcode file. Please adjust slicer settings or use the correct plate.","0300_8013":"Printing paused due to the pause command added to the printing file.","0300_8014":"The nozzle is covered with filament, or the build plate is installed incorrectly. Please cancel this print and clean the nozzle or adjust the build plate according to the actual status. You can als...","0300_8015":"The filament on external spool has run out; please load new filament. If the filament is loaded, please select 'Resume'.","0300_8016":"The nozzle is clogged with filament. Please cancel this print and clean the nozzle or select 'Resume' to resume the print job.","0300_8017":"Foreign objects detected on heatbed. Please check and clean the heatbed. Then, select 'Resume' to resume the print job.","0300_8018":"Chamber temperature malfunction.","0300_8019":"No build plate is placed.","0300_801A":"Filament extrusion error; please check the assistant for troubleshooting. After resolving the issue, decide whether to cancel or resume the print job based on the actual print status.","0300_801B":"Nozzle temperature problem detected. Refer to Assistant to re-connect the hotend connector. POWER OFF the printer before this operation to avoid short circuits.","0300_801C":"The extrusion resistance is abnormal. The extruder may be clogged; please refer to the assistant. After trouble shooting, you can select 'Resume' to resume the print job.","0300_801D":"The extruder servo motor position sensor is malfunctioning. Please power off the printer first and check if the connection cable is loose.","0300_801E":"The extrusion motor is overloaded, please check the Assistant for details.","0300_8021":"The nozzle may not be installed or not properly installed. Please ensure the nozzle is correctly installed before proceeding.","0300_8022":"The heatbed may be obstructed while moving downward. Please clear any objects beneath the heatbed and check for any resistance or jamming during its movement.","0300_8028":"Nozzle offset calibration sensor error. If using a single hotend or the calibration function is disabled, you may ignore this and continue printing; otherwise, it is recommended to check the sensor...","0300_8041":"Platform detection timeout: please restart the printer.","0300_8042":"Task paused because the door is open.","0300_8043":"The laser module is abnormal.","0300_8044":"Fire was detected inside the chamber.","0300_8045":"Material detection timeout: please restart the printer.","0300_8046":"Foreign object detect timeout: please restart the printer.","0300_8047":"Quick-release lever detection time out: please restart the printer.","0300_8048":"Laser Module unlock has timed out, and the task cannot proceed. Please restart the printer and try again.","0300_8049":"The current plate is invalid.","0300_804A":"Emergency stop button improperly installed. Please reinstall according to the Wiki before proceeding.","0300_804B":"Task paused. The Laser Safety Window is open.","0300_804E":"This is a printing task. Please detach the Laser/Cutting Module from the Toolhead.","0300_804F":"The loading/unloading process is currently ongoing. Please stop the process or remove the laser/cutting module.","0300_8050":"This device does not support the 40W Laser Module. Please remove it or replace it with a 10W Laser Module.","0300_8051":"The cutting module has dropped or the cutting module cable is disconnected; please check the module.","0300_8053":"Laser module detected. Please install the right nozzle correctly to ensure proper Laser Module Mounting Calibration.","0300_8054":"Please place the paper required for Print Then Cut.","0300_8055":"The module mounted on the toolhead does not match the task. Please install the correct module.","0300_8057":"The rotary attachment is disconnected. Please ensure it is properly installed and the cable is securely plugged in.","0300_8058":"The rotary attachment is detected. Please remove it before continuing.","0300_8061":"The mode of Airflow System failed to activate; check the air door condition.","0300_8062":"The chamber temperature is too high. It may be due to high environmental temperature.","0300_8063":"The chamber temperature is too high. Please open the top cover and front door to cool down.","0300_8064":"The chamber temperature is too high. Please open the top cover and front door to cool down. (Open door detection for this print job will be set to 'Notification' level)","0300_8065":"The temperature of the MC module is too high. Please check the Wiki for possible explanations.","0300_8071":"The Toolhead Enhanced Cooling Fan module is malfunctioning.","0300_807D":"Fire Extinguisher not detected, the automatic extinguishing function will be unavailable.","0300_807E":"Fire Extinguisher not detected, the automatic extinguishing function will be unavailable.","0300_807F":"Fire Extinguisher is malfunctioning.","0300_8080":"Fire extinguisher motor reset failed.","0300_8081":"Fire extinguisher cylinder not installed. Please confirm on the extinguisher page.","0300_8082":"The Fire Extinguisher Gas Cylinder is empty.","0300_C012":"Please heat the nozzle to above 170°C.","0300_C056":"A minor fire was detected inside the chamber, and the Auto Fire Extinguishing process has been aborted.","0300_C070":"The fire extinguisher has been detected and is ready for use after the laser module is connected.","0500_4001":"Failed to connect to Bambu Cloud. Please check your network connection.","0500_4002":"Unsupported print file path or name. Please resend the print job.","0500_4003":"Printing stopped because the printer was unable to parse the file. Please resend your print job.","0500_4004":"Device is busy and cannot start new task. Please wait for current task to complete before sending new task.","0500_4005":"Print jobs are not allowed to be sent while updating firmware.","0500_4006":"There is not enough free storage space for the print job. Restoring to factory settings can free up available space.","0500_4007":"The device requires a repair upgrade, and printing is currently unavailable.","0500_4008":"Starting printing failed; please power cycle the printer and resend the print job.","0500_4009":"Print jobs are not allowed to be sent while updating logs.","0500_400A":"The file name is not supported. Please rename and restart the print job.","0500_400B":"There was a problem downloading a file. Please check your network connection and resend the print job.","0500_400C":"Please insert a MicroSD card and restart the print job.","0500_400D":"Please run a self-test and restart the print job.","0500_400E":"Printing was cancelled.","0500_400F":"AMS is initializing and cannot be upgraded at the moment. Please try again later.","0500_4010":"AMS is drying and cannot be upgraded at the moment. Please try again later.","0500_4011":"The printer is loading or unloading filament and cannot be upgraded at the moment. Please try again later.","0500_4012":"The device is printing and cannot be upgraded at the moment. Please try again later.","0500_4013":"AMS is in operation and cannot be upgraded at the moment. Please try again when it is idle.","0500_4014":"Slicing for the print job failed. Please check your settings and restart the print job.","0500_4015":"There is not enough free storage space for the print job. Please format or clear files from the MicroSD card to free up space.","0500_4016":"The MicroSD Card is write-protected. Please replace the MicroSD Card.","0500_4017":"Binding failed. Please retry or restart the printer and retry.","0500_4018":"Binding configuration information parsing failed; please try again.","0500_4019":"The printer has already been bound. Please unbind it and try again.","0500_401A":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0500_401B":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_401C":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_401D":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_401E":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_401F":"Authorization timed out. Please make sure that your phone or PC has access to the internet, and ensure that the Bambu Studio/Bambu Handy APP is running in the foreground during the binding operation.","0500_4020":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4021":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_4022":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4023":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4024":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0500_4025":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4026":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4027":"Cloud access failed; this may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_4028":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4029":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_402A":"Failed to connect to the router, which may be caused by wireless interference or being too far away from the router. Please try again or move the printer closer to the router and try again.","0500_402B":"Router connection failed due to incorrect password. Please check the password and try again.","0500_402C":"Failed to obtain IP address, which may be caused by wireless interference resulting in data transmission failure or the DHCP address pool of the router being full. Please move the printer closer to...","0500_402D":"System exception","0500_402E":"System does not support the file system currently used by the USB flash drive. Please replace or format the USB flash drive to FAT32.","0500_402F":"The MicroSD card sector data is damaged. Please use the SD card repair tool to repair or format it. If it still cannot be identified, please replace the MicroSD card.","0500_4030":"The device is currently upgrading. Please try again when it is idle.","0500_4031":"The accessory firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4033":"The AMS firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4034":"The Laser Module firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4035":"The BirdsEye Camera is malfunctioning. Please try restarting the device. If the issue persists after multiple restarts, check the camera connection status or contact customer support.","0500_4037":"Your sliced file is not compatible with current printer model. This file can't be printed on this printer.","0500_4038":"The nozzle diameter in sliced file is not consistent with the current nozzle setting. This file can't be printed.","0500_4039":"The current task does not allow the installation of the laser/cutting module, and the task has been halted.","0500_403A":"The current temperature is too low. In order to protect you and your printer, printing tasks, moving an axis and other operations are disabled. Please move the printer to an environment above 10 de...","0500_403B":"Laser/cutting tasks cannot be initiated on the machine at the moment. Please use the computer software to start the task.","0500_403C":"The current nozzle setting does not match the slicing file. Continuing to print may affect print quality. It is recommended to re-slice before starting the print.","0500_403D":"The toolhead module is not set up. Please set it up before initiating the task.","0500_403E":"The current tool head does not support initialization.","0500_403F":"Failed to download print job; please check your network connection.","0500_4040":"The printer has reached its power limit. Please connect a dedicated power adapter to this AMS to enable drying.","0500_4041":"The AMS drying cannot be started during printing.","0500_4042":"Due to power limitations, starting AMS drying will pause current operations such as nozzle heating and fan running. Do you want to proceed with drying?","0500_4043":"Due to power limitations, only one AMS is allowed to use the device's power for drying.","0500_4044":"BirdsEye Camera malfunction: please contact customer support.","0500_4045":"Hotend check in progress. This operation is temporarily unavailable. Please wait.","0500_4050":"Error detected on the print board.","0500_4052":"Error detected on the hot end.","0500_4054":"Error detected on the mat.","0500_405D":"Laser module Serial Number error: unable to calibrate or make project.","0500_4065":"The task requires a Laser Platform, but the current one is a Cutting Platform. Please replace it, measure the material thickness in the software, and then restart the task.","0500_4070":"The laser or cutter module is connected, so the device cannot initiate a 3D printing task.","0500_4075":"No Laser Platform was detected, which may affect thickness measurement accuracy. Please place the laser platform correctly and ensure the rear markers are not blocked, then restart the thickness me...","0500_4076":"Please place the Laser Platform correctly and ensure the rear markers are not blocked, then restart the thickness measurement in the software before initiating the task.","0500_4097":"The device cannot detect the Laser Module. Please reconnect the module cable or restart the printer.","0500_4098":"The device cannot detect AMS A. Please reconnect the AMS cable or restart the printer.","0500_4099":"The firmware of Cutting Module does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409A":"The firmware of the Air Pump does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409B":"The firmware of the Laser Module does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409D":"The firmware of AMS A does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0500_409E":"The device cannot detect the Cutting Module. Please reconnect the module cable or restart the printer.","0500_409F":"The device cannot detect the Air Pump. Please reconnect the module cable or restart the printer.","0500_40A0":"The Rotary Attachment module is not detected. Please reconnect the cable or restart the printer.","0500_40A1":"The Auto Fire Extinguishing System is not detected. Please reconnect the module cable or restart the printer.","0500_40A3":"AMS(or AMS lite) A communication is abnormal. Please reconnect the module cable or restart the printer.","0500_40A4":"The current firmware only supports 1 AMS Lite. Please remove all AMS units before reconnecting the supported AMS Lite device.","0500_40A5":"The current firmware only supports AMS/AMS 2 Pro/AMS HT, with a maximum of 4 units. Please remove all AMS units before reconnecting the supported one.","0500_8013":"The print file is not available. Please check to see if the storage media has been removed.","0500_8036":"Your sliced file is not consistent with the current printer model. Continue?","0500_803C":"The current nozzle setting does not match the slicing file. Continuing to print may affect print quality. It is recommended to re-slice before starting the print.","0500_8040":"Toolhead front cover is detached. Moving the toolhead may damage the printer. Do you want to continue?","0500_8041":"The filament in hotend is too cold. Extrusion may damage the extruder. Still feeding in/out the filament?","0500_8048":"The module on the toolhead is not calibrated. Please cancel the task to perform calibration or switch to a calibrated module.","0500_8051":"Detected build plate is not the same as the Gcode file. Please adjust slicer settings or use the correct plate.","0500_8053":"Nozzle mismatch was detected during printing. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","0500_8055":"Laser module is installed, but a Cutting Platform is detected. Please place a Laser Platform and perform laser calibration.","0500_8056":"Cutting module is installed, but the laser platform is detected. Please place the cutting platform for calibration.","0500_8058":"Please place the light grip cutting mat correctly and ensure the marker is exposed.","0500_8059":"Cutting platform base is not correctly aligned. Please ensure that the four corners of the platform are aligned with the heatbed.","0500_805A":"Please place the cutting mat on cutting protection base.","0500_805B":"The cutting mat type is unknown; please replace it with the correct cutting mat.","0500_805C":"The grip cutting mat type does not match; please place a LightGrip cutting mat.","0500_805E":"Cutting module Serial Number error: unable to calibrate or make project.","0500_8060":"The current module on toolhead does not meet requirements. Please replace the module as per the on-screen instructions.","0500_8061":"No print plate detected. Please make sure it is placed correctly.","0500_8062":"The print plate marker was not detected. Please confirm the print plate is correctly positioned on the heatbed with all four corners aligned, and the marker is visible. If strong light is shining o...","0500_8063":"The platform is not detected during calibration; please make sure the Laser Platform is properly placed.","0500_8064":"Please place the Laser Platform correctly and ensure the rear markers are not blocked for laser calibration.","0500_8066":"The task requires a Cutting Platform, but the current one is a Laser Platform. Please replace it with a Cutting Platform (Cutting Protection Base + LightGrip cutting mat).","0500_8067":"Please place a LightGrip cutting mat on the cutting protection base.","0500_8068":"Please place the strong grip cutting mat correctly and ensure the marker is exposed.","0500_8069":"Unable to recognize the left and right hotends. They might be third party hotends, or the hotend marks may be dirty. Please manually set the hotend types.","0500_806A":"Unable to recognize the left and right hotends. They might be third party hotends, or the hotend marks may be dirty. Please set hotend types on printer screen before next print.","0500_806B":"Quick-release Lever is not locked. Please press down the external toolhead module to ensure it is properly seated, then push down the level to lock it in place.","0500_806C":"Please place the cutting platform correctly and ensure the marker is exposed.","0500_806D":"Material not detected. Please confirm placement and continue.","0500_806E":"Foreign objects detected on heatbed; please check and clean up the heatbed.","0500_806F":"The grip cutting mat type does not match; please place a StrongGrip cutting mat.","0500_8071":"No cutting platform was detected. Please confirm that it has been correctly placed.","0500_8072":"Live View camera is blocked","0500_8073":"Heatbed limit block is obstructed or contaminated. Please clean and ensure the limit block is visible, otherwise platform position offset detection may be inaccurate.","0500_8074":"The Laser Platform is offset. Please ensure that the four corners of the platform are aligned with the heatbed, and the marker is not obstructed.","0500_8077":"The visual marker was not detected. Please ensure the paper is properly placed.","0500_8078":"Current material does not match the sliced file settings. Please load the correct material and ensure the QR code on the material is not damaged or dirty.","0500_8079":"Please place the Laser Test Material (350g paperboard) and position support strips underneath to prevent material warping.","0500_807A":"The foreign object detection function is not working. You can continue the task or check the assistant for troubleshooting.","0500_807B":"Please place the cutting platform (cutting protection base + LightGrip cutting mat).","0500_807C":"Please place the cutting platform (cutting protection base + StrongGrip cutting mat).","0500_807D":"This task requires a Cutting Platform, but the current one is a Laser Platform. Please replace it with a Cutting Platform (Cutting Protection Base + StrongGrip Cutting Mat).","0500_807E":"Please place a StrongGrip cutting mat on the cutting protection base.","0500_8080":"The left and right hotends are not installed.","0500_8081":"The left and right hotends are not installed.","0500_8082":"Please remove the protective film on the Opaque Glossy Acrylic before processing","0500_8083":"Material is not allowed in Mounting Calibration. Please remove the material from the platform.","0500_8084":"The Live View Camera is dirty; please clean it and continue.","0500_8085":"Toolhead camera is obstructed","0500_8086":"Toolhead Camera is dirty, which affects the AI function; please clean the lens surface.","0500_8087":"BirdsEye camera is obstructed","0500_8088":"The Birdseye Camera is dirty","0500_8089":"Task paused due to Presence Check failed. Please check the printer to continue.","0500_808A":"The BirdsEye Camera is installed offset. Please refer to the assistant to reinstall it.","0500_808B":"The BirdsEye Camera setup failed. Please remove all objects and the mat on the heatbed to ensure the heatbed markers are visible. Meanwhile, please ensure the BirdsEye Camera is installed correctly...","0500_808C":"Detected build plate offset. Please align the build plate with the heatbed, and then continue.","0500_808D":"The Cutting Module offset calibration failed, which may result in inaccurate cuts. Please ensure the cutting material is properly positioned and check whether the cutting blade tip is worn.","0500_808E":"BirdsEye Camera initialization failed. The toolhead camera did not detect the Heatbed features. Please clean the Heatbed, remove all objects and pads, and ensure the bed markings are visible. Check...","0500_808F":"Nozzle camera lens is dirty, affecting AI monitoring. Clean the lens with a non-woven cloth and a small amount of alcohol. Beware of hotend heat; wait for it to cool before handling.","0500_8090":"Please attach the 80g White Printing Paper to the center area of the platform.","0500_8091":"The Cutting Module offset calibration failed, which may result in inaccurate cuts. Please ensure the 80g white printer paper(letter paper thickness) is properly positioned and check whether the cut...","0500_8092":"Toolhead Camera initialization failed. This print can still continue, but some AI functions will be disabled. If you encounter this issue again after restarting, please contact customer support.","0500_8093":"The nozzle silicone sleeve is not installed; there is a risk of temperature control failure. Please install it correctly and try again.","0500_80A0":"The visual encoder board was not detected. Please check if the board is properly placed and aligned at all four corners, and ensure the positioning markings are clear and free from wear.","0500_C010":"MicroSD Card read/write exception: please reinsert or replace the MicroSD Card.","0500_C032":"Laser/Cutting module connected to the toolhead. The drying process has been automatically stopped.","0500_C036":"This is a printing task. Please detach the Laser/Cutting Module from the Toolhead.","0500_C07F":"Device is busy and cannot perform this operation. To proceed, please pause or stop the current task.","0501_4017":"Binding failed. Please retry or restart the printer and retry.","0501_4018":"Binding configuration information parsing failed; please try again.","0501_4019":"The printer has already been bound. Please unbind it and try again.","0501_401A":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0501_401B":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_401C":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_401D":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_401E":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_401F":"Authorization timed out. Please make sure that your phone or PC has access to the internet, and ensure that the Bambu Studio/Bambu Handy APP is running in the foreground during the binding operation.","0501_4020":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4021":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_4022":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4023":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4024":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0501_4025":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4026":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4027":"Cloud access failed; this may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_4028":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4029":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4031":"Device discovery binding is in progress, and the QR code cannot be displayed on the screen. You can wait for the binding to finish or abort the device discovery binding process in the APP/Studio an...","0501_4032":"QR code binding is in progress, so device discovery binding cannot be performed. You can scan the QR code on the screen for binding or exit the QR code display page on screen and try device discove...","0501_4033":"Your APP region does not match with your printer; please download the APP in the corresponding region and register your account again.","0501_4034":"The slicing progress has not been updated for a long time, and the printing task has exited. Please confirm the parameters and reinitiate printing.","0501_4035":"The device is in the process of binding and cannot respond to new binding requests.","0501_4038":"The regional settings do not match the printer; please check the printer's regional settings.","0501_4039":"Device login has expired; please try to bind again.","0501_4098":"The device cannot detect AMS B. Please reconnect the AMS cable or restart the printer.","0501_409D":"The firmware of AMS B does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0501_40A3":"AMS(or AMS lite) B communication is abnormal. Please reconnect the module cable or restart the printer.","0502_4001":"Current filament will be used in this print job. Settings cannot be changed.","0502_4002":"Please go to “Settings > Calibration” to run the Motion Accuracy Enhancement Calibration before turning on Motion Accuracy Enhancement mode.","0502_4003":"The printer is currently printing and the motion accuracy enhancement feature cannot be turned on or off.","0502_4004":"Some features are not supported by the current device. Please check the Studio feature settings or update the firmware to the latest version.","0502_4005":"The AMS has not been calibrated yet, so printing cannot be initiated.","0502_4006":"Unknown module detected; please try updating the firmware to the latest version.","0502_400D":"Failed to start a new task: filament loading/unloading not completed.","0502_400E":"Failed to start a new task: The nozzle cold pull was not completed.","0502_4013":"This device is not compatible with the 40W laser module. Please replace it with a 10W laser module or remove it.","0502_4098":"The device cannot detect AMS C. Please reconnect the AMS cable or restart the printer.","0502_409D":"The firmware of AMS C does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0502_40A3":"AMS(or AMS lite) C communication is abnormal. Please reconnect the module cable or restart the printer.","0502_C00F":"The device is busy and cannot perform nozzle identification.","0502_C010":"Due to printer power limitations, printing, calibration, controls and other actions cannot be performed during AMS drying. Please stop the drying process before proceeding with any other operation.","0502_C011":"Currently in 2D production mode. Please continue the operation on the printer","0502_C012":"The task cannot be paused.","0502_C014":"The AMS Remaining Filament Estimation is enabled by default and cannot be disabled.","0502_C024":"The flow dynamic calibration records have exceeded the storage limit. Please delete some historical records in the slicer software before adding new calibration data.","0503_4098":"The device cannot detect AMS D. Please reconnect the AMS cable or restart the printer.","0503_409D":"The firmware of AMS D does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0503_40A3":"AMS(or AMS lite) D communication is abnormal. Please reconnect the module cable or restart the printer.","0580_4096":"The device cannot detect AMS-HT A. Please reconnect the AMS-HT cable or restart the printer.","0580_409C":"The firmware of AMS-HT A does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0580_40A2":"AMS-HT A communication is abnormal. Please reconnect the module cable or restart the printer.","0581_4096":"The device cannot detect AMS-HT B. Please reconnect the AMS-HT cable or restart the printer.","0581_409C":"The firmware of AMS-HT B does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0581_40A2":"AMS-HT B communication is abnormal. Please reconnect the module cable or restart the printer.","0582_4096":"The device cannot detect AMS-HT C. Please reconnect the AMS-HT cable or restart the printer.","0582_409C":"The firmware of AMS-HT C does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0582_40A2":"AMS-HT C communication is abnormal. Please reconnect the module cable or restart the printer.","0583_4096":"The device cannot detect AMS-HT D. Please reconnect the AMS-HT cable or restart the printer.","0583_409C":"The firmware of AMS-HT D does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0583_40A2":"AMS-HT D communication is abnormal. Please reconnect the module cable or restart the printer.","0584_4096":"The device cannot detect AMS-HT F. Please reconnect the AMS-HT cable or restart the printer.","0584_409C":"The firmware of AMS-HT E does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0584_40A2":"AMS-HT E communication is abnormal. Please reconnect the module cable or restart the printer.","0585_4096":"The device cannot detect AMS-HT E. Please reconnect the AMS-HT cable or restart the printer.","0585_409C":"The firmware of AMS-HT F does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0585_40A2":"AMS-HT F communication is abnormal. Please reconnect the module cable or restart the printer.","0586_4096":"The device cannot detect AMS-HT G. Please reconnect the AMS-HT cable or restart the printer.","0586_409C":"The firmware of AMS-HT G does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0586_40A2":"AMS-HT G communication is abnormal. Please reconnect the module cable or restart the printer.","0587_4096":"The device cannot detect AMS-HT H. Please reconnect the AMS-HT cable or restart the printer.","0587_409C":"The firmware of AMS-HT H does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0587_40A2":"AMS-HT H communication is abnormal. Please reconnect the module cable or restart the printer.","05FE_8053":"The left nozzle is not matched with slicing file. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","05FE_8069":"Unable to recognize the left hotend. It might be a third party hotend, or the hotend mark may be dirty. Please manually set the hotend type.","05FE_806A":"Unable to recognize the left hotend. It might be a third party hotend, or the hotend mark may be dirty. Please set hotend type on printer screen before next print.","05FE_8080":"The left hotend is not installed.","05FE_8081":"The left hotend is not installed.","05FF_8053":"The right nozzle is not matched with slicing file. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","05FF_8069":"Unable to recognize the right hotend. It might be a third party hotend, or the hotend mark may be dirty. Please manually set the hotend type.","05FF_806A":"Unable to recognize the right hotend. It might be a third party hotend, or the hotend mark may be dirty. Please set hotend type on printer screen before next print.","05FF_8080":"The right hotend is not installed.","05FF_8081":"The right hotend is not installed.","0700_4001":"The AMS has been disabled for a print, but it still has filament loaded. Please unload the AMS filament and switch to the spool holder filament for printing.","0700_4025":"Failed to read the filament information.","0700_8001":"Failed to cut the filament. Please check the cutter.","0700_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0700_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0700_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0700_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0700_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0700_8007":"Extruding filament failed. The extruder might be clogged.","0700_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS A to the extruder is properly connected.","0700_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0700_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0700_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0700_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0700_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0700_8017":"AMS A is drying. Please stop drying process before loading/unloading material.","0700_8021":"AMS setup failed; please refer to the assistant.","0700_8023":"AMS A cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0700_C069":"An error occurred during AMS A drying. Please go to Assistant for more details.","0700_C06A":"AMS A is reading RFID. Unable to start drying. Please try again later.","0700_C06B":"AMS A is changing filament. Unable to start drying. Please try again later.","0700_C06C":"AMS A is in Feed Assist Mode. Unable to start drying. Please try again later.","0700_C06D":"AMS A is assisting in filament insertion. Unable to start drying. Please try again later.","0700_C06E":"AMS A motor is performing self-test. Unable to start drying. Please try again later.","0701_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0701_4025":"Failed to read the filament information.","0701_8001":"Failed to cut the filament. Please check the cutter.","0701_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0701_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0701_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0701_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0701_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0701_8007":"Extruding filament failed. The extruder might be clogged.","0701_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS B to the extruder is properly connected.","0701_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0701_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0701_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0701_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0701_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0701_8017":"AMS B is drying. Please stop drying process before loading/unloading material.","0701_8021":"AMS setup failed; please refer to the assistant.","0701_8023":"AMS B cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0701_C069":"An error occurred during AMS B drying. Please go to Assistant for more details.","0701_C06A":"AMS B is reading RFID. Unable to start drying. Please try again later.","0701_C06B":"AMS B is changing filament. Unable to start drying. Please try again later.","0701_C06C":"AMS B is in Feed Assist Mode. Unable to start drying. Please try again later.","0701_C06D":"AMS B is assisting in filament insertion. Unable to start drying. Please try again later.","0701_C06E":"AMS B motor is performing self-test. Unable to start drying. Please try again later.","0702_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0702_4025":"Failed to read the filament information.","0702_8001":"Failed to cut the filament. Please check the cutter.","0702_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0702_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0702_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0702_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0702_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0702_8007":"Extruding filament failed. The extruder might be clogged.","0702_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS C to the extruder is properly connected.","0702_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0702_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0702_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0702_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0702_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0702_8017":"AMS C is drying. Please stop drying process before loading/unloading material.","0702_8021":"AMS setup failed; please refer to the assistant.","0702_8023":"AMS C cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0702_C069":"An error occurred during AMS C drying. Please go to Assistant for more details.","0702_C06A":"AMS C is reading RFID. Unable to start drying. Please try again later.","0702_C06B":"AMS C is changing filament. Unable to start drying. Please try again later.","0702_C06C":"AMS C is in Feed Assist Mode. Unable to start drying. Please try again later.","0702_C06D":"AMS C is assisting in filament insertion. Unable to start drying. Please try again later.","0702_C06E":"AMS C motor is performing self-test. Unable to start drying. Please try again later.","0703_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0703_4025":"Failed to read the filament information.","0703_8001":"Failed to cut the filament. Please check the cutter.","0703_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0703_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0703_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0703_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0703_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0703_8007":"Extruding filament failed. The extruder might be clogged.","0703_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS D to the extruder is properly connected.","0703_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0703_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0703_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0703_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0703_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0703_8017":"AMS D is drying. Please stop drying process before loading/unloading material.","0703_8021":"AMS setup failed; please refer to the assistant.","0703_8023":"AMS D cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0703_C069":"An error occurred during AMS D drying. Please go to Assistant for more details.","0703_C06A":"AMS D is reading RFID. Unable to start drying. Please try again later.","0703_C06B":"AMS D is changing filament. Unable to start drying. Please try again later.","0703_C06C":"AMS D is in Feed Assist Mode. Unable to start drying. Please try again later.","0703_C06D":"AMS D is assisting in filament insertion. Unable to start drying. Please try again later.","0703_C06E":"AMS D motor is performing self-test. Unable to start drying. Please try again later.","0704_4025":"Failed to read the filament information.","0704_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0704_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0704_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0704_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0704_8007":"Extruding filament failed. The extruder might be clogged.","0704_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS E to the extruder is properly connected.","0704_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0704_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0704_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0704_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0704_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0704_8021":"AMS setup failed; please refer to the assistant.","0704_8023":"AMS E cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0705_4025":"Failed to read the filament information.","0705_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0705_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0705_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0705_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0705_8007":"Extruding filament failed. The extruder might be clogged.","0705_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS F to the extruder is properly connected.","0705_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0705_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0705_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0705_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0705_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0705_8021":"AMS setup failed; please refer to the assistant.","0705_8023":"AMS F cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0706_4025":"Failed to read the filament information.","0706_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0706_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0706_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0706_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0706_8007":"Extruding filament failed. The extruder might be clogged.","0706_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS G to the extruder is properly connected.","0706_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0706_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0706_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0706_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0706_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0706_8021":"AMS setup failed; please refer to the assistant.","0706_8023":"AMS G cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0707_4025":"Failed to read the filament information.","0707_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0707_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0707_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0707_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0707_8007":"Extruding filament failed. The extruder might be clogged.","0707_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS H to the extruder is properly connected.","0707_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0707_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0707_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0707_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0707_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0707_8021":"AMS setup failed; please refer to the assistant.","0707_8023":"AMS H cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","07FE_8001":"Failed to cut the filament of the left extruder. Please check the cutter.","07FE_8002":"The cutter of the left extruder is stuck. Please pull out the cutter handle.","07FE_8003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are ab...","07FE_8004":"Failed to pull back the filament from the left extruder. Please check whether the filament is stuck inside the extruder.","07FE_8005":"Failed to feed the filament outside the AMS. Please clip the end of the filament flat and check to see if the spool is stuck.","07FE_8006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_8007":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","07FE_8010":"Check if the left external filament spool or filament is stuck.","07FE_8011":"The external filament connected to the left extruder has run out; please load a new filament.","07FE_8012":"Failed to get mapping table; please select 'Resume' to retry.","07FE_8013":"Timeout purging old filament of the left extruder: Please check if the filament is stuck or the extruder is clogged.","07FE_8020":"Extruder change failed; please refer to the assistant.","07FE_8021":"AMS setup failed; please refer to the assistant.","07FE_8024":"Extruder position calibration failed; please refer to the assistant.","07FE_8025":"Cold pull timed out. Please promptly operate or check whether the filament is broken inside the extruder, and click the Assistant for details.","07FE_8030":"The filament specified in the slicer has been used up. Printing is paused. Please go to the machine to replace the material and resume printing.","07FE_C003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","07FE_C006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_C008":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","07FE_C009":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_C00A":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","07FE_C010":"Insert the filament (over 30cm long) until it stops. You might see slight smoke during flushing. After insertion, close the front door and top cover.","07FE_C011":"Please manually and slowly pull out the filament from the extruder. Then click “Continue”.","07FE_C012":"Press the black PTFE tube coupler and unplug the PTFE tube. After completing the operation, click 'Continue.'","07FF_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","07FF_8001":"Failed to cut the filament of the right extruder. Please check the cutter.","07FF_8002":"The cutter is stuck. Please make sure the cutter handle is out.","07FF_8003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are a...","07FF_8004":"Failed to pull back the filament from the right extruder. Please check whether the filament is stuck inside the extruder.","07FF_8005":"Failed to feed the filament outside the AMS. Please clip the end of the filament flat and check to see if the spool is stuck.","07FF_8006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_8007":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","07FF_8010":"Check if the external filament spool or filament is stuck.","07FF_8011":"External filament has run out; please load a new filament.","07FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","07FF_8013":"Timeout purging old filament of the right extruder: Please check if the filament is stuck or the extruder is clogged.","07FF_8020":"Extruder change failed; please refer to the assistant.","07FF_8021":"AMS setup failed; please refer to the assistant.","07FF_8024":"Extruder position calibration failed; please refer to the assistant.","07FF_8025":"Cold pull timed out. Please promptly operate or check whether the filament is broken inside the extruder, and click the Assistant for details.","07FF_8030":"The filament specified in the slicer has been used up. Printing is paused. Please go to the machine to replace the material and resume printing.","07FF_C003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","07FF_C006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_C008":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","07FF_C009":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_C00A":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","07FF_C010":"Insert the filament (over 30cm long) until it stops. You might see slight smoke during flushing. After insertion, close the front door and top cover.","07FF_C011":"Hold the driven wheel bracket, slowly pull the filament from the extruder, then press 'Continue'.","07FF_C012":"Press the black PTFE tube coupler and unplug the PTFE tube. After completing the operation, click 'Continue.'","0C00_4020":"The setup of BirdsEye Camera failed. Please clear all objects and remove the mat. Make sure the marker is not obstructed. Meanwhile, clean both the BirdsEye Camera and Toolhead Camera, and remove a...","0C00_4021":"The setup of BirdsEye Camera failed; please reboot the printer.","0C00_4022":"The setup of BirdsEye Camera failed. Please check if the laser module is working properly.","0C00_4024":"The Birdseye Camera is installed offset. Please refer to the assistant to reinstall it.","0C00_4025":"The Birdseye Camera is dirty. Please clean it and restart the process.","0C00_4026":"The Live View Camera initialization failed; please reboot the printer.","0C00_4027":"The Live View Camera calibration failed. Please refer to the assistant for details and recalibrate the camera after processing.","0C00_4029":"Material not detected. Please confirm placement and continue.","0C00_402A":"The visual marker was not detected. Please re-paste the paper in the correct position.","0C00_402C":"Device data link error. Please reboot the printer","0C00_402D":"The toolhead camera is not working properly; please reboot the device.","0C00_403D":"The vision encoder plate was not detected. Please confirm it is correctly positioned on the heatbed.","0C00_403E":"The high-precision nozzle offset calibration has failed, possibly due to a damaged pattern or the similarity of the colors of the two selected filaments. Please clear the printed pattern and replac...","0C00_4041":"Toolhead camera calibration failed. Please ensure the Calibration Marker on the heatbed or Height Calibration Marker on the homing area is clean and undamaged, then re-run the calibration process.","0C00_8001":"First layer defects were detected. If the defects are acceptable, select 'Resume' to resume the print job.","0C00_8005":"Purged filament has piled up in the waste chute, which may cause a tool head collision.","0C00_8009":"Build plate localization marker was not found.","0C00_800B":"The heatbed marker was not detected. Please clear all objects and remove the mat. Make sure the marker is not obstructed.","0C00_8015":"Objects detected on the platform; please clean them up in a timely manner.","0C00_8016":"The foreign object detection function is not working. You can continue the task or check assistant for solutions.","0C00_8017":"Foreign objects detected on the platform; please clean them up on time.","0C00_8018":"The foreign object detection function is not working. You can continue the task or view the assistant for troubleshooting.","0C00_8033":"Quick-release Lever is not locked. Please push it down to secure.","0C00_8034":"Liveview Camera initialization failed. This print can still continue, but some AI functions will be disabled. If you encounter this issue again after restarting, please contact customer support.","0C00_803F":"AI detected nozzle clumping. Please check the nozzle condition. Refer to assistant for solutions.","0C00_8040":"AI detected air-printing defect. Please check the hotend extrusion status. Refer to assistant for solutions.","0C00_8042":"The AI print monitor has detected a spaghetti defect. Please check the print and take the necessary action.","0C00_8043":"AI detected nozzle clumping. Please check the nozzle condition. Refer to assistant for solutions.","0C00_C003":"Possible defects were detected in the first layer.","0C00_C004":"Possible spaghetti failure was detected.","0C00_C006":"Purged filament may have piled up in the waste chute.","1000_C001":"High bed temperature may lead to filament clogging in the nozzle. You may open the chamber door.","1000_C002":"Printing CF material with stainless steel may cause nozzle damage.","1000_C003":"Enabling Timelapse in traditional mode may cause defects; please activate this feature as needed.","1001_4001":"Timelapse is not supported as Spiral Vase mode is enabled in slicing presets.","1001_4002":"Timelapse is not supported as the Print sequence is set to 'By object'.","1001_8003":"The time-lapse mode is set to Traditional in the slicing file. This may cause surface defects. Would you like to enable it?","1001_8004":"Prime Tower is not enabled and time-lapse mode is set to Smooth in slicing file. This may cause surface defects. Would you like to enable it?","1200_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1200_8001":"Cutting the filament failed. Please check to see if the cutter is stuck. Refer to the Assistant for solutions.","1200_8002":"The cutter is stuck. Please pull out the cutter handle.","1200_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1200_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1200_8005":"The filament is not inserted. Please insert the filament.","1200_8006":"Unable to feed filament into the extruder. This could be due to tangled filament or a stuck spool. If not, please check if the AMS PTFE tube is connected.","1200_8007":"Failed to extrude the filament. This might be caused by clogged extruder or stuck filament. Refer to the Assistant for solutions.","1200_8010":"Filament or spool may be stuck.","1200_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1200_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1200_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1200_8014":"The filament location in the toolhead was not found. Refer to the Assistant for solutions.","1200_8015":"Failed to pull out the filament from the toolhead. Please check if the filament is stuck, or if it is broken inside the extruder or PTFE tube.","1200_8016":"The extruder is not extruding normally. Refer to the Assistant for troubleshooting. There may be defects in this layer, but you may resume if the defects are acceptable.","1201_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1201_8001":"Failed to cut the filament. Please check the cutter.","1201_8002":"The cutter is stuck. Please pull out the cutter handle.","1201_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1201_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1201_8005":"Failed to feed the filament. Please load the filament and then select 'Retry'.","1201_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1201_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1201_8010":"Please check if the spool or filament is stuck.","1201_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1201_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1201_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1201_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1201_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or the filament is broken inside the extruder.","1201_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","1202_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1202_8001":"Failed to cut the filament. Please check the cutter.","1202_8002":"The cutter is stuck. Please pull out the cutter handle.","1202_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1202_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1202_8005":"The filament is not inserted. Please insert the filament.","1202_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1202_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1202_8010":"Please check if the spool or filament is stuck.","1202_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1202_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1202_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1202_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1202_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or is broken inside the extruder.","1202_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","1203_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1203_8001":"Failed to cut the filament. Please check the cutter.","1203_8002":"The cutter is stuck. Please pull out the cutter handle.","1203_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1203_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1203_8005":"The filament is not inserted. Please insert the filament.","1203_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1203_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1203_8010":"Please check if the spool or filament is stuck.","1203_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1203_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1203_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1203_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1203_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or is broken inside the extruder.","1203_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","12FF_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","12FF_8001":"Failed to cut the filament. Please check the cutter.","12FF_8002":"The cutter is stuck. Please pull out the cutter handle.","12FF_8003":"Please pull out the filament on the spool holder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube if you are about to us...","12FF_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","12FF_8005":"The filament is not inserted. Please insert the filament.","12FF_8006":"Please feed filament into the PTFE tube until it can not be pushed any farther.","12FF_8007":"Check nozzle. Select 'Done' if filament was extruded, otherwise push filament forward slightly and select 'Retry.'","12FF_8010":"Please check if the filament or the spool is stuck.","12FF_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","12FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","12FF_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","12FF_C003":"Please pull out the filament on the spool holder. If this message persists, please check to see if there is filament broken in the extruder or PTFE Tube. (Connect a PTFE tube if you are about to us...","12FF_C006":"Please feed filament into the PTFE tube until it can not be pushed any farther.","1800_4025":"Failed to read the filament information.","1800_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1800_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1800_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1800_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1800_8007":"Extruding filament failed. The extruder might be clogged.","1800_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT A to the extruder is properly connected.","1800_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1800_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1800_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1800_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1800_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1800_8017":"AMS-HT A is drying. Please stop drying process before loading/unloading material.","1800_8021":"AMS setup failed; please refer to the assistant.","1800_8023":"AMS-HT A cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1800_C069":"An error occurred during AMS-HT A drying. Please go to Assistant for more details.","1800_C06A":"AMS-HT A is reading RFID. Unable to start drying. Please try again later.","1800_C06B":"AMS-HT A is changing filament. Unable to start drying. Please try again later.","1800_C06C":"AMS-HT A is in Feed Assist Mode. Unable to start drying. Please try again later.","1800_C06D":"AMS-HT A is assisting in filament insertion. Unable to start drying. Please try again later.","1800_C06E":"AMS-HT A motor is performing self-test. Unable to start drying. Please try again later.","1801_4025":"Failed to read the filament information.","1801_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1801_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1801_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1801_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1801_8007":"Extruding filament failed. The extruder might be clogged.","1801_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT B to the extruder is properly connected.","1801_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1801_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1801_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1801_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1801_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1801_8017":"AMS-HT B is drying. Please stop drying process before loading/unloading material.","1801_8021":"AMS setup failed; please refer to the assistant.","1801_8023":"AMS-HT B cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1801_C069":"An error occurred during AMS-HT B drying. Please go to Assistant for more details.","1801_C06A":"AMS-HT B is reading RFID. Unable to start drying. Please try again later.","1801_C06B":"AMS-HT B is changing filament. Unable to start drying. Please try again later.","1801_C06C":"AMS-HT B is in Feed Assist Mode. Unable to start drying. Please try again later.","1801_C06D":"AMS-HT B is assisting in filament insertion. Unable to start drying. Please try again later.","1801_C06E":"AMS-HT B motor is performing self-test. Unable to start drying. Please try again later.","1802_4025":"Failed to read the filament information.","1802_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1802_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1802_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1802_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1802_8007":"Extruding filament failed. The extruder might be clogged.","1802_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT C to the extruder is properly connected.","1802_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1802_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1802_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1802_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1802_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1802_8017":"AMS-HT C is drying. Please stop drying process before loading/unloading material.","1802_8021":"AMS setup failed; please refer to the assistant.","1802_8023":"AMS-HT C cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1802_C069":"An error occurred during AMS-HT C drying. Please go to Assistant for more details.","1802_C06A":"AMS-HT C is reading RFID. Unable to start drying. Please try again later.","1802_C06B":"AMS-HT C is changing filament. Unable to start drying. Please try again later.","1802_C06C":"AMS-HT C is in Feed Assist Mode. Unable to start drying. Please try again later.","1802_C06D":"AMS-HT C is assisting in filament insertion. Unable to start drying. Please try again later.","1802_C06E":"AMS-HT C motor is performing self-test. Unable to start drying. Please try again later.","1803_4025":"Failed to read the filament information.","1803_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1803_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1803_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1803_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1803_8007":"Extruding filament failed. The extruder might be clogged.","1803_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT D to the extruder is properly connected.","1803_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1803_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1803_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1803_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1803_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1803_8017":"AMS-HT D is drying. Please stop drying process before loading/unloading material.","1803_8021":"AMS setup failed; please refer to the assistant.","1803_8023":"AMS-HT D cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1803_C069":"An error occurred during AMS-HT D drying. Please go to Assistant for more details.","1803_C06A":"AMS-HT D is reading RFID. Unable to start drying. Please try again later.","1803_C06B":"AMS-HT D is changing filament. Unable to start drying. Please try again later.","1803_C06C":"AMS-HT D is in Feed Assist Mode. Unable to start drying. Please try again later.","1803_C06D":"AMS-HT D is assisting in filament insertion. Unable to start drying. Please try again later.","1803_C06E":"AMS-HT D motor is performing self-test. Unable to start drying. Please try again later.","1804_4025":"Failed to read the filament information.","1804_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1804_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1804_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1804_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1804_8007":"Extruding filament failed. The extruder might be clogged.","1804_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT E to the extruder is properly connected.","1804_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1804_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1804_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1804_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1804_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1804_8021":"AMS setup failed; please refer to the assistant.","1804_8023":"AMS-HT E cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1804_C069":"An error occurred during AMS-HT E drying. Please go to Assistant for more details.","1804_C06A":"AMS-HT E is reading RFID. Unable to start drying. Please try again later.","1804_C06B":"AMS-HT E is changing filament. Unable to start drying. Please try again later.","1804_C06C":"AMS-HT E is in Feed Assist Mode. Unable to start drying. Please try again later.","1804_C06D":"AMS-HT E is assisting in filament insertion. Unable to start drying. Please try again later.","1804_C06E":"AMS-HT E motor is performing self-test. Unable to start drying. Please try again later.","1805_4025":"Failed to read the filament information.","1805_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1805_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1805_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1805_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1805_8007":"Extruding filament failed. The extruder might be clogged.","1805_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT F to the extruder is properly connected.","1805_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1805_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1805_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1805_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1805_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1805_8021":"AMS setup failed; please refer to the assistant.","1805_8023":"AMS-HT F cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1805_C069":"An error occurred during AMS-HT F drying. Please go to Assistant for more details.","1805_C06A":"AMS-HT F is reading RFID. Unable to start drying. Please try again later.","1805_C06B":"AMS-HT F is changing filament. Unable to start drying. Please try again later.","1805_C06C":"AMS-HT F is in Feed Assist Mode. Unable to start drying. Please try again later.","1805_C06D":"AMS-HT F is assisting in filament insertion. Unable to start drying. Please try again later.","1805_C06E":"AMS-HT F motor is performing self-test. Unable to start drying. Please try again later.","1806_4025":"Failed to read the filament information.","1806_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1806_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1806_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1806_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1806_8007":"Extruding filament failed. The extruder might be clogged.","1806_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT G to the extruder is properly connected.","1806_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1806_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1806_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1806_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1806_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1806_8021":"AMS setup failed; please refer to the assistant.","1806_8023":"AMS-HT G cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1806_C069":"An error occurred during AMS-HT G drying. Please go to Assistant for more details.","1806_C06A":"AMS-HT G is reading RFID. Unable to start drying. Please try again later.","1806_C06B":"AMS-HT G is changing filament. Unable to start drying. Please try again later.","1806_C06C":"AMS-HT G is in Feed Assist Mode. Unable to start drying. Please try again later.","1806_C06D":"AMS-HT G is assisting in filament insertion. Unable to start drying. Please try again later.","1806_C06E":"AMS-HT G motor is performing self-test. Unable to start drying. Please try again later.","1807_4025":"Failed to read the filament information.","1807_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1807_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1807_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1807_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1807_8007":"Extruding filament failed. The extruder might be clogged.","1807_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT H to the extruder is properly connected.","1807_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1807_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1807_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1807_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1807_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1807_8021":"AMS setup failed; please refer to the assistant.","1807_8023":"AMS-HT H cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1807_C069":"An error occurred during AMS-HT H drying. Please go to Assistant for more details.","1807_C06A":"AMS-HT H is reading RFID. Unable to start drying. Please try again later.","1807_C06B":"AMS-HT H is changing filament. Unable to start drying. Please try again later.","1807_C06C":"AMS-HT H is in Feed Assist Mode. Unable to start drying. Please try again later.","1807_C06D":"AMS-HT H is assisting in filament insertion. Unable to start drying. Please try again later.","1807_C06E":"AMS-HT H motor is performing self-test. Unable to start drying. Please try again later.","18FE_8001":"Failed to cut the filament of the left extruder. Please check the cutter.","18FE_8002":"The cutter of the left extruder is stuck. Please pull out the cutter handle.","18FE_8003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are ab...","18FE_8004":"Failed to pull back the filament from the left extruder. Please check whether the filament is stuck inside the extruder.","18FE_8005":"Failed to feed the filament outside the AMS-HT. Please clip the end of the filament flat and check to see if the spool is stuck.","18FE_8006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_8007":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","18FE_8011":"The external filament connected to the left extruder has run out; please load a new filament.","18FE_8012":"Failed to get mapping table; please select 'Resume' to retry.","18FE_8013":"Timeout purging old filament of the left extruder: Please check if the filament is stuck or the extruder is clogged.","18FE_8020":"Extruder change failed; please refer to the assistant.","18FE_8021":"AMS setup failed; please refer to the assistant.","18FE_8024":"Extruder position calibration failed; please refer to the assistant.","18FE_C003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","18FE_C006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_C008":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","18FE_C009":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_C00A":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","18FF_8001":"Failed to cut the filament of the right extruder. Please check the cutter.","18FF_8002":"The cutter of the right extruder is stuck. Please pull out the cutter handle.","18FF_8003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are a...","18FF_8004":"Failed to pull back the filament from the right extruder. Please check whether the filament is stuck inside the extruder.","18FF_8005":"Failed to feed the filament outside the AMS-HT. Please clip the end of the filament flat and check to see if the spool is stuck.","18FF_8006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_8007":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","18FF_8011":"The external filament connected to the right extruder has run out; please load a new filament.","18FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","18FF_8013":"Timeout purging old filament of the right extruder: Please check if the filament is stuck or the extruder is clogged.","18FF_8020":"Extruder change failed; please refer to the assistant.","18FF_8021":"AMS setup failed; please refer to the assistant.","18FF_8024":"Extruder position calibration failed; please refer to the assistant.","18FF_C003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","18FF_C006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_C008":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","18FF_C009":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_C00A":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'."};function Hfe(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:xn};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:xn};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:Ei};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:Ul}}}function n3(t,e){const n=t>>16&65535||(t>>8&255)<<8|t&255,r=e&65535;return`${n.toString(16).padStart(4,"0").toUpperCase()}_${r.toString(16).padStart(4,"0").toUpperCase()}`}function Vfe(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=n3(e.attr,n);return t3[r]!==void 0})}function Gfe(){return"https://wiki.bambulab.com/en/hms/home"}function qfe({printerName:t,errors:e,onClose:n}){console.log("HMSErrorModal errors:",JSON.stringify(e,null,2));const r=e.filter(i=>{const s=parseInt(i.code.replace("0x",""),16)||0,o=n3(i.attr,s);return t3[o]!==void 0});return w.useEffect(()=>{const i=s=>{s.key==="Escape"&&n()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[n]),a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(xn,{className:"w-5 h-5 text-orange-400"}),a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Errors - ",t]})]}),a.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Ot,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r.length===0?a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(Ei,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{children:"No errors"})]}):a.jsx("div",{className:"space-y-3",children:r.map((i,s)=>{const{label:o,color:l,bgColor:c,Icon:u}=Hfe(i.severity),d=parseInt(i.code.replace("0x",""),16)||0,f=n3(i.attr,d),m=t3[f],g=Gfe(),x=f.replace("_","-");return a.jsx("div",{className:`p-4 rounded-lg ${c} border border-white/10`,children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(u,{className:`w-5 h-5 ${l} flex-shrink-0 mt-0.5`}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsxs("span",{className:`font-mono text-sm ${l}`,children:["[",x,"]"]}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${c} ${l}`,children:o})]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:m}),a.jsxs("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[a.jsx($r,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${i.code}-${s}`)})})}),a.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:a.jsx("p",{className:"text-xs text-bambu-gray",children:"Clear errors on the printer to dismiss them here."})})]})})}function Wfe(t){if(!t)return"ASAP";const e=wi(t);if(!e)return"ASAP";const n=new Date,r=e.getTime()-n.getTime();return r<0?"Now":r<6e4?"In <1 min":r<36e5?`In ${Math.round(r/6e4)} min`:r<864e5?`In ${Math.round(r/36e5)}h`:e.toLocaleDateString()}function Kfe({printerId:t}){const{data:e}=ct({queryKey:["queue",t,"pending"],queryFn:()=>he.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:a.jsx(ps,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx(si,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),a.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[a.jsx(qn,{className:"w-3 h-3"}),Wfe(n?.scheduled_time||null)]}),r>1&&a.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),a.jsx(Ms,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function MW(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=MW(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Vn(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=MW(t))&&(r&&(r+=" "),r+=e);return r}var Xfe=["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 vD(t){if(typeof t!="string")return!1;var e=Xfe;return e.includes(t)}var Yfe=["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"],Qfe=new Set(Yfe);function EW(t){return typeof t!="string"?!1:Qfe.has(t)}function TW(t){return typeof t=="string"&&t.startsWith("data-")}function Ja(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(EW(n)||TW(n))&&(e[n]=t[n]);return e}function Ff(t){if(t==null)return null;if(w.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Ja(e)}return typeof t=="object"&&!Array.isArray(t)?Ja(t):null}function Ea(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(EW(n)||TW(n)||vD(n))&&(e[n]=t[n]);return e}function Zfe(t){return t==null?null:w.isValidElement(t)?Ea(t.props):typeof t=="object"&&!Array.isArray(t)?Ea(t):null}var Jfe=["children","width","height","viewBox","className","style","title","desc"];function r3(){return r3=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},r3.apply(null,arguments)}function eme(t,e){if(t==null)return{};var n,r,i=tme(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function tme(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 _D=w.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:s,className:o,style:l,title:c,desc:u}=t,d=eme(t,Jfe),f=s||{width:r,height:i,x:0,y:0},m=Vn("recharts-surface",o);return w.createElement("svg",r3({},Ea(d),{className:m,width:r,height:i,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),w.createElement("title",null,c),w.createElement("desc",null,u),n)}),nme=["children","className"];function i3(){return i3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},i3.apply(null,arguments)}function rme(t,e){if(t==null)return{};var n,r,i=ime(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function ime(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 Kr=w.forwardRef((t,e)=>{var{children:n,className:r}=t,i=rme(t,nme),s=Vn("recharts-layer",r);return w.createElement("g",i3({className:s},Ea(i),{ref:e}),n)}),CW=w.createContext(null),ame=()=>w.useContext(CW);function Cr(t){return function(){return t}}const AW=Math.cos,Mw=Math.sin,ml=Math.sqrt,Ew=Math.PI,X2=2*Ew,a3=Math.PI,s3=2*a3,Kh=1e-6,sme=s3-Kh;function kW(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function ome(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return kW;const n=10**e;return function(r){this._+=r[0];for(let i=1,s=r.length;i<s;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class lme{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?kW:ome(e)}moveTo(e,n){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,n){this._append`L${this._x1=+e},${this._y1=+n}`}quadraticCurveTo(e,n,r,i){this._append`Q${+e},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(e,n,r,i,s,o){this._append`C${+e},${+n},${+r},${+i},${this._x1=+s},${this._y1=+o}`}arcTo(e,n,r,i,s){if(e=+e,n=+n,r=+r,i=+i,s=+s,s<0)throw new Error(`negative radius: ${s}`);let o=this._x1,l=this._y1,c=r-e,u=i-n,d=o-e,f=l-n,m=d*d+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(m>Kh)if(!(Math.abs(f*c-u*d)>Kh)||!s)this._append`L${this._x1=e},${this._y1=n}`;else{let g=r-o,x=i-l,y=c*c+u*u,b=g*g+x*x,v=Math.sqrt(y),N=Math.sqrt(m),S=s*Math.tan((a3-Math.acos((y+m-b)/(2*v*N)))/2),T=S/N,E=S/v;Math.abs(T-1)>Kh&&this._append`L${e+T*d},${n+T*f}`,this._append`A${s},${s},0,0,${+(f*g>d*x)},${this._x1=e+E*c},${this._y1=n+E*u}`}}arc(e,n,r,i,s,o){if(e=+e,n=+n,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let l=r*Math.cos(i),c=r*Math.sin(i),u=e+l,d=n+c,f=1^o,m=o?i-s:s-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>Kh||Math.abs(this._y1-d)>Kh)&&this._append`L${u},${d}`,r&&(m<0&&(m=m%s3+s3),m>sme?this._append`A${r},${r},0,1,${f},${e-l},${n-c}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:m>Kh&&this._append`A${r},${r},0,${+(m>=a3)},${f},${this._x1=e+r*Math.cos(s)},${this._y1=n+r*Math.sin(s)}`)}rect(e,n,r,i){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function wD(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 lme(e)}function SD(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function jW(t){this._context=t}jW.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 Y2(t){return new jW(t)}function PW(t){return t[0]}function RW(t){return t[1]}function DW(t,e){var n=Cr(!0),r=null,i=Y2,s=null,o=wD(l);t=typeof t=="function"?t:t===void 0?PW:Cr(t),e=typeof e=="function"?e:e===void 0?RW:Cr(e);function l(c){var u,d=(c=SD(c)).length,f,m=!1,g;for(r==null&&(s=i(g=o())),u=0;u<=d;++u)!(u<d&&n(f=c[u],u,c))===m&&((m=!m)?s.lineStart():s.lineEnd()),m&&s.point(+t(f,u,c),+e(f,u,c));if(g)return s=null,g+""||null}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:Cr(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:Cr(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:Cr(!!c),l):n},l.curve=function(c){return arguments.length?(i=c,r!=null&&(s=i(r)),l):i},l.context=function(c){return arguments.length?(c==null?r=s=null:s=i(r=c),l):r},l}function o_(t,e,n){var r=null,i=Cr(!0),s=null,o=Y2,l=null,c=wD(u);t=typeof t=="function"?t:t===void 0?PW:Cr(+t),e=typeof e=="function"?e:Cr(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?RW:Cr(+n);function u(f){var m,g,x,y=(f=SD(f)).length,b,v=!1,N,S=new Array(y),T=new Array(y);for(s==null&&(l=o(N=c())),m=0;m<=y;++m){if(!(m<y&&i(b=f[m],m,f))===v)if(v=!v)g=m,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),x=m-1;x>=g;--x)l.point(S[x],T[x]);l.lineEnd(),l.areaEnd()}v&&(S[m]=+t(b,m,f),T[m]=+e(b,m,f),l.point(r?+r(b,m,f):S[m],n?+n(b,m,f):T[m]))}if(N)return l=null,N+""||null}function d(){return DW().defined(i).curve(o).context(s)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Cr(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Cr(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Cr(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:Cr(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:Cr(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Cr(+f),u):n},u.lineX0=u.lineY0=function(){return d().x(t).y(e)},u.lineY1=function(){return d().x(t).y(n)},u.lineX1=function(){return d().x(r).y(e)},u.defined=function(f){return arguments.length?(i=typeof f=="function"?f:Cr(!!f),u):i},u.curve=function(f){return arguments.length?(o=f,s!=null&&(l=o(s)),u):o},u.context=function(f){return arguments.length?(f==null?s=l=null:l=o(s=f),u):s},u}class OW{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 cme(t){return new OW(t,!0)}function ume(t){return new OW(t,!1)}const ND={draw(t,e){const n=ml(e/Ew);t.moveTo(n,0),t.arc(0,0,n,0,X2)}},dme={draw(t,e){const n=ml(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()}},LW=ml(1/3),hme=LW*2,fme={draw(t,e){const n=ml(e/hme),r=n*LW;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},mme={draw(t,e){const n=ml(e),r=-n/2;t.rect(r,r,n,n)}},pme=.8908130915292852,IW=Mw(Ew/10)/Mw(7*Ew/10),gme=Mw(X2/10)*IW,xme=-AW(X2/10)*IW,bme={draw(t,e){const n=ml(e*pme),r=gme*n,i=xme*n;t.moveTo(0,-n),t.lineTo(r,i);for(let s=1;s<5;++s){const o=X2*s/5,l=AW(o),c=Mw(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},UT=ml(3),yme={draw(t,e){const n=-ml(e/(UT*3));t.moveTo(0,n*2),t.lineTo(-UT*n,-n),t.lineTo(UT*n,-n),t.closePath()}},uo=-.5,ho=ml(3)/2,o3=1/ml(12),vme=(o3/2+1)*3,_me={draw(t,e){const n=ml(e/vme),r=n/2,i=n*o3,s=r,o=n*o3+n,l=-s,c=o;t.moveTo(r,i),t.lineTo(s,o),t.lineTo(l,c),t.lineTo(uo*r-ho*i,ho*r+uo*i),t.lineTo(uo*s-ho*o,ho*s+uo*o),t.lineTo(uo*l-ho*c,ho*l+uo*c),t.lineTo(uo*r+ho*i,uo*i-ho*r),t.lineTo(uo*s+ho*o,uo*o-ho*s),t.lineTo(uo*l+ho*c,uo*c-ho*l),t.closePath()}};function wme(t,e){let n=null,r=wD(i);t=typeof t=="function"?t:Cr(t||ND),e=typeof e=="function"?e:Cr(e===void 0?64:+e);function i(){let s;if(n||(n=s=r()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),s)return n=null,s+""||null}return i.type=function(s){return arguments.length?(t=typeof s=="function"?s:Cr(s),i):t},i.size=function(s){return arguments.length?(e=typeof s=="function"?s:Cr(+s),i):e},i.context=function(s){return arguments.length?(n=s??null,i):n},i}function Tw(){}function Cw(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 FW(t){this._context=t}FW.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Cw(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:Cw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Sme(t){return new FW(t)}function UW(t){this._context=t}UW.prototype={areaStart:Tw,areaEnd:Tw,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:Cw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Nme(t){return new UW(t)}function zW(t){this._context=t}zW.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:Cw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Mme(t){return new zW(t)}function BW(t){this._context=t}BW.prototype={areaStart:Tw,areaEnd:Tw,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 Eme(t){return new BW(t)}function Az(t){return t<0?-1:1}function kz(t,e,n){var r=t._x1-t._x0,i=e-t._x1,s=(t._y1-t._y0)/(r||i<0&&-0),o=(n-t._y1)/(i||r<0&&-0),l=(s*i+o*r)/(r+i);return(Az(s)+Az(o))*Math.min(Math.abs(s),Math.abs(o),.5*Math.abs(l))||0}function jz(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function zT(t,e,n){var r=t._x0,i=t._y0,s=t._x1,o=t._y1,l=(s-r)/3;t._context.bezierCurveTo(r+l,i+l*e,s-l,o-l*n,s,o)}function Aw(t){this._context=t}Aw.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:zT(this,this._t0,jz(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,zT(this,jz(this,n=kz(this,t,e)),n);break;default:zT(this,this._t0,n=kz(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function $W(t){this._context=new HW(t)}($W.prototype=Object.create(Aw.prototype)).point=function(t,e){Aw.prototype.point.call(this,e,t)};function HW(t){this._context=t}HW.prototype={moveTo:function(t,e){this._context.moveTo(e,t)},closePath:function(){this._context.closePath()},lineTo:function(t,e){this._context.lineTo(e,t)},bezierCurveTo:function(t,e,n,r,i,s){this._context.bezierCurveTo(e,t,r,n,s,i)}};function Tme(t){return new Aw(t)}function Cme(t){return new $W(t)}function VW(t){this._context=t}VW.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=Pz(t),i=Pz(e),s=0,o=1;o<n;++s,++o)this._context.bezierCurveTo(r[0][s],i[0][s],r[1][s],i[1][s],t[o],e[o]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(t,e){this._x.push(+t),this._y.push(+e)}};function Pz(t){var e,n=t.length-1,r,i=new Array(n),s=new Array(n),o=new Array(n);for(i[0]=0,s[0]=2,o[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,s[e]=4,o[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,s[n-1]=7,o[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/s[e-1],s[e]-=r,o[e]-=r*o[e-1];for(i[n-1]=o[n-1]/s[n-1],e=n-2;e>=0;--e)i[e]=(o[e]-i[e+1])/s[e];for(s[n-1]=(t[n]+i[n-1])/2,e=0;e<n-1;++e)s[e]=2*t[e+1]-i[e+1];return[i,s]}function Ame(t){return new VW(t)}function Q2(t,e){this._context=t,this._t=e}Q2.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 kme(t){return new Q2(t,.5)}function jme(t){return new Q2(t,0)}function Pme(t){return new Q2(t,1)}function dg(t,e){if((o=t.length)>1)for(var n=1,r,i,s=t[e[0]],o,l=s.length;n<o;++n)for(i=s,s=t[e[n]],r=0;r<l;++r)s[r][1]+=s[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function l3(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function Rme(t,e){return t[e]}function Dme(t){const e=[];return e.key=t,e}function Ome(){var t=Cr([]),e=l3,n=dg,r=Rme;function i(s){var o=Array.from(t.apply(this,arguments),Dme),l,c=o.length,u=-1,d;for(const f of s)for(l=0,++u;l<c;++l)(o[l][u]=[0,+r(f,o[l].key,u,s)]).data=f;for(l=0,d=SD(e(o));l<c;++l)o[d[l]].index=l;return n(o,d),o}return i.keys=function(s){return arguments.length?(t=typeof s=="function"?s:Cr(Array.from(s)),i):t},i.value=function(s){return arguments.length?(r=typeof s=="function"?s:Cr(+s),i):r},i.order=function(s){return arguments.length?(e=s==null?l3:typeof s=="function"?s:Cr(Array.from(s)),i):e},i.offset=function(s){return arguments.length?(n=s??dg,i):n},i}function Lme(t,e){if((r=t.length)>0){for(var n,r,i=0,s=t[0].length,o;i<s;++i){for(o=n=0;n<r;++n)o+=t[n][i][1]||0;if(o)for(n=0;n<r;++n)t[n][i][1]/=o}dg(t,e)}}function Ime(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,s=r.length;n<s;++n){for(var o=0,l=0;o<i;++o)l+=t[o][n][1]||0;r[n][1]+=r[n][0]=-l/2}dg(t,e)}}function Fme(t,e){if(!(!((o=t.length)>0)||!((s=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,s,o;r<s;++r){for(var l=0,c=0,u=0;l<o;++l){for(var d=t[e[l]],f=d[r][1]||0,m=d[r-1][1]||0,g=(f-m)/2,x=0;x<l;++x){var y=t[e[x]],b=y[r][1]||0,v=y[r-1][1]||0;g+=b-v}c+=f,u+=g*f}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,dg(t,e)}}var BT={},$T={},Rz;function Ume(){return Rz||(Rz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})($T)),$T}var HT={},Dz;function GW(){return Dz||(Dz=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})(HT)),HT}var VT={},Oz;function MD(){return Oz||(Oz=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})(VT)),VT}var GT={},qT={},Lz;function zme(){return Lz||(Lz=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})(qT)),qT}var Iz;function ED(){return Iz||(Iz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=zme(),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 s=[],o=i.length;if(o===0)return s;let l=0,c="",u="",d=!1;for(i.charCodeAt(0)===46&&(s.push(""),l++);l<o;){const f=i[l];u?f==="\\"&&l+1<o?(l++,c+=i[l]):f===u?u="":c+=f:d?f==='"'||f==="'"?u=f:f==="]"?(d=!1,s.push(c),c=""):c+=f:f==="["?(d=!0,c&&(s.push(c),c="")):f==="."?c&&(s.push(c),c=""):c+=f,l++}return c&&s.push(c),s}t.toPath=r})(GT)),GT}var Fz;function TD(){return Fz||(Fz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ume(),n=GW(),r=MD(),i=ED();function s(l,c,u){if(l==null)return u;switch(typeof c){case"string":{if(e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?n.isDeepKey(c)?s(l,i.toPath(c),u):u:d}case"number":case"symbol":{typeof c=="number"&&(c=r.toKey(c));const d=l[c];return d===void 0?u:d}default:{if(Array.isArray(c))return o(l,c,u);if(Object.is(c?.valueOf(),-0)?c="-0":c=String(c),e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?u:d}}}function o(l,c,u){if(c.length===0)return u;let d=l;for(let f=0;f<c.length;f++){if(d==null||e.isUnsafeProperty(c[f]))return u;d=d[c[f]]}return d===void 0?u:d}t.get=s})(BT)),BT}var WT,Uz;function Bme(){return Uz||(Uz=1,WT=TD().get),WT}var $me=Bme();const Uf=Uo($me);var ra=t=>t===0?0:t>0?1:-1,Es=t=>typeof t=="number"&&t!=+t,uu=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Ut=t=>(typeof t=="number"||t instanceof Number)&&!Es(t),Lo=t=>Ut(t)||typeof t=="string",Hme=0,v0=t=>{var e=++Hme;return"".concat(t||"").concat(e)},Fa=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(!Ut(e)&&typeof e!="string")return r;var s;if(uu(e)){if(n==null)return r;var o=e.indexOf("%");s=n*parseFloat(e.slice(0,o))/100}else s=+e;return Es(s)&&(s=r),i&&n!=null&&s>n&&(s=n),s},qW=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 nr(t,e,n){return Ut(t)&&Ut(e)?t+n*(e-t):e}function WW(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Uf(r,e))===n)}var Ir=t=>t===null||typeof t>"u",cy=t=>Ir(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function Vme(t){return t!=null}function uy(){}var Gme=["type","size","sizeType"];function c3(){return c3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},c3.apply(null,arguments)}function zz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Bz(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?zz(Object(n),!0).forEach(function(r){qme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):zz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function qme(t,e,n){return(e=Wme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Wme(t){var e=Kme(t,"string");return typeof e=="symbol"?e:e+""}function Kme(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Xme(t,e){if(t==null)return{};var n,r,i=Yme(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Yme(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var KW={symbolCircle:ND,symbolCross:dme,symbolDiamond:fme,symbolSquare:mme,symbolStar:bme,symbolTriangle:yme,symbolWye:_me},Qme=Math.PI/180,Zme=t=>{var e="symbol".concat(cy(t));return KW[e]||ND},Jme=(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*Qme;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}},epe=(t,e)=>{KW["symbol".concat(cy(t))]=e},CD=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=Xme(t,Gme),s=Bz(Bz({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var m=Zme(o),g=wme().type(m).size(Jme(n,r,o)),x=g();if(x!==null)return x},{className:c,cx:u,cy:d}=s,f=Ea(s);return Ut(u)&&Ut(d)&&Ut(n)?w.createElement("path",c3({},f,{className:Vn("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};CD.registerSymbol=epe;var XW=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,AD=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(w.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{vD(i)&&(r[i]=(s=>n[i](n,s)))}),r},tpe=(t,e,n)=>r=>(t(e,n,r),null),dy=(t,e,n)=>{if(t===null||typeof t!="object"&&typeof t!="function")return null;var r=null;return Object.keys(t).forEach(i=>{var s=t[i];vD(i)&&typeof s=="function"&&(r||(r={}),r[i]=tpe(s,e,n))}),r};function $z(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function npe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$z(Object(n),!0).forEach(function(r){rpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$z(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rpe(t,e,n){return(e=ipe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ipe(t){var e=ape(t,"string");return typeof e=="symbol"?e:e+""}function ape(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Xr(t,e){var n=npe({},t),r=e,i=Object.keys(e),s=i.reduce((o,l)=>(o[l]===void 0&&r[l]!==void 0&&(o[l]=r[l]),o),n);return s}function kw(){return kw=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},kw.apply(null,arguments)}function Hz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function spe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Hz(Object(n),!0).forEach(function(r){ope(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Hz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ope(t,e,n){return(e=lpe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lpe(t){var e=cpe(t,"string");return typeof e=="symbol"?e:e+""}function cpe(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 xo=32,upe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function dpe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=xo/2,s=xo/6,o=xo/3,l=e.inactive?r:e.color,c=n??e.type;if(c==="none")return null;if(c==="plainline"){var u;return w.createElement("line",{strokeWidth:4,fill:"none",stroke:l,strokeDasharray:(u=e.payload)===null||u===void 0?void 0:u.strokeDasharray,x1:0,y1:i,x2:xo,y2:i,className:"recharts-legend-icon"})}if(c==="line")return w.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(i,"h").concat(o,`
- A`).concat(s,",").concat(s,",0,1,1,").concat(2*o,",").concat(i,`
- H`).concat(xo,"M").concat(2*o,",").concat(i,`
- A`).concat(s,",").concat(s,",0,1,1,").concat(o,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return w.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(xo/8,"h").concat(xo,"v").concat(xo*3/4,"h").concat(-xo,"z"),className:"recharts-legend-icon"});if(w.isValidElement(e.legendIcon)){var d=spe({},e);return delete d.legendIcon,w.cloneElement(e.legendIcon,d)}return w.createElement(CD,{fill:l,cx:i,cy:i,size:xo,sizeType:"diameter",type:c})}function hpe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:s,iconType:o}=t,l={x:0,y:0,width:xo,height:xo},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,f)=>{var m=d.formatter||i,g=Vn({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var x=d.inactive?s:d.color,y=m?m(d.value,d,f):d.value;return w.createElement("li",kw({className:g,style:c,key:"legend-item-".concat(f)},dy(t,d,f)),w.createElement(_D,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(y," legend icon")},w.createElement(dpe,{data:d,iconType:o,inactiveColor:s})),w.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},y))})}var fpe=t=>{var e=Xr(t,upe),{payload:n,layout:r,align:i}=e;if(!n||!n.length)return null;var s={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return w.createElement("ul",{className:"recharts-default-legend",style:s},w.createElement(hpe,kw({},e,{payload:n})))},KT={},XT={},Vz;function mpe(){return Vz||(Vz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){const i=new Map;for(let s=0;s<n.length;s++){const o=n[s],l=r(o);i.has(l)||i.set(l,o)}return Array.from(i.values())}t.uniqBy=e})(XT)),XT}var YT={},Gz;function YW(){return Gz||(Gz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(YT)),YT}var QT={},ZT={},JT={},qz;function ppe(){return qz||(qz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(JT)),JT}var Wz;function kD(){return Wz||(Wz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ppe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(ZT)),ZT}var eC={},Kz;function gpe(){return Kz||(Kz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(eC)),eC}var Xz;function xpe(){return Xz||(Xz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=kD(),n=gpe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(QT)),QT}var tC={},nC={},Yz;function bpe(){return Yz||(Yz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=TD();function n(r){return function(i){return e.get(i,r)}}t.property=n})(nC)),nC}var rC={},iC={},aC={},sC={},Qz;function QW(){return Qz||(Qz=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})(sC)),sC}var oC={},Zz;function ZW(){return Zz||(Zz=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})(oC)),oC}var lC={},Jz;function JW(){return Jz||(Jz=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})(lC)),lC}var eB;function ype(){return eB||(eB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=QW(),n=ZW(),r=JW();function i(d,f,m){return typeof m!="function"?i(d,f,()=>{}):s(d,f,function g(x,y,b,v,N,S){const T=m(x,y,b,v,N,S);return T!==void 0?!!T:s(x,y,g,S)},new Map)}function s(d,f,m,g){if(f===d)return!0;switch(typeof f){case"object":return o(d,f,m,g);case"function":return Object.keys(f).length>0?s(d,{...f},m,g):r.eq(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:r.eq(d,f)}}function o(d,f,m,g){if(f==null)return!0;if(Array.isArray(f))return c(d,f,m,g);if(f instanceof Map)return l(d,f,m,g);if(f instanceof Set)return u(d,f,m,g);const x=Object.keys(f);if(d==null)return x.length===0;if(x.length===0)return!0;if(g?.has(f))return g.get(f)===d;g?.set(f,d);try{for(let y=0;y<x.length;y++){const b=x[y];if(!n.isPrimitive(d)&&!(b in d)||f[b]===void 0&&d[b]!==void 0||f[b]===null&&d[b]!==null||!m(d[b],f[b],b,d,f,g))return!1}return!0}finally{g?.delete(f)}}function l(d,f,m,g){if(f.size===0)return!0;if(!(d instanceof Map))return!1;for(const[x,y]of f.entries()){const b=d.get(x);if(m(b,y,x,d,f,g)===!1)return!1}return!0}function c(d,f,m,g){if(f.length===0)return!0;if(!Array.isArray(d))return!1;const x=new Set;for(let y=0;y<f.length;y++){const b=f[y];let v=!1;for(let N=0;N<d.length;N++){if(x.has(N))continue;const S=d[N];let T=!1;if(m(S,b,y,d,f,g)&&(T=!0),T){x.add(N),v=!0;break}}if(!v)return!1}return!0}function u(d,f,m,g){return f.size===0?!0:d instanceof Set?c([...d],[...f],m,g):!1}t.isMatchWith=i,t.isSetMatch=u})(aC)),aC}var tB;function eK(){return tB||(tB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ype();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(iC)),iC}var cC={},uC={},dC={},nB;function vpe(){return nB||(nB=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})(dC)),dC}var hC={},rB;function tK(){return rB||(rB=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})(hC)),hC}var fC={},iB;function nK(){return iB||(iB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",s="[object Arguments]",o="[object Symbol]",l="[object Date]",c="[object Map]",u="[object Set]",d="[object Array]",f="[object Function]",m="[object ArrayBuffer]",g="[object Object]",x="[object Error]",y="[object DataView]",b="[object Uint8Array]",v="[object Uint8ClampedArray]",N="[object Uint16Array]",S="[object Uint32Array]",T="[object BigUint64Array]",E="[object Int8Array]",k="[object Int16Array]",C="[object Int32Array]",D="[object BigInt64Array]",A="[object Float32Array]",R="[object Float64Array]";t.argumentsTag=s,t.arrayBufferTag=m,t.arrayTag=d,t.bigInt64ArrayTag=D,t.bigUint64ArrayTag=T,t.booleanTag=i,t.dataViewTag=y,t.dateTag=l,t.errorTag=x,t.float32ArrayTag=A,t.float64ArrayTag=R,t.functionTag=f,t.int16ArrayTag=k,t.int32ArrayTag=C,t.int8ArrayTag=E,t.mapTag=c,t.numberTag=r,t.objectTag=g,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=o,t.uint16ArrayTag=N,t.uint32ArrayTag=S,t.uint8ArrayTag=b,t.uint8ClampedArrayTag=v})(fC)),fC}var mC={},aB;function _pe(){return aB||(aB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(mC)),mC}var sB;function rK(){return sB||(sB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=vpe(),n=tK(),r=nK(),i=ZW(),s=_pe();function o(d,f){return l(d,void 0,d,new Map,f)}function l(d,f,m,g=new Map,x=void 0){const y=x?.(d,f,m,g);if(y!==void 0)return y;if(i.isPrimitive(d))return d;if(g.has(d))return g.get(d);if(Array.isArray(d)){const b=new Array(d.length);g.set(d,b);for(let v=0;v<d.length;v++)b[v]=l(d[v],v,m,g,x);return Object.hasOwn(d,"index")&&(b.index=d.index),Object.hasOwn(d,"input")&&(b.input=d.input),b}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const b=new RegExp(d.source,d.flags);return b.lastIndex=d.lastIndex,b}if(d instanceof Map){const b=new Map;g.set(d,b);for(const[v,N]of d)b.set(v,l(N,v,m,g,x));return b}if(d instanceof Set){const b=new Set;g.set(d,b);for(const v of d)b.add(l(v,void 0,m,g,x));return b}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(s.isTypedArray(d)){const b=new(Object.getPrototypeOf(d)).constructor(d.length);g.set(d,b);for(let v=0;v<d.length;v++)b[v]=l(d[v],v,m,g,x);return b}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const b=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return g.set(d,b),c(b,d,m,g,x),b}if(typeof File<"u"&&d instanceof File){const b=new File([d],d.name,{type:d.type});return g.set(d,b),c(b,d,m,g,x),b}if(typeof Blob<"u"&&d instanceof Blob){const b=new Blob([d],{type:d.type});return g.set(d,b),c(b,d,m,g,x),b}if(d instanceof Error){const b=new d.constructor;return g.set(d,b),b.message=d.message,b.name=d.name,b.stack=d.stack,b.cause=d.cause,c(b,d,m,g,x),b}if(d instanceof Boolean){const b=new Boolean(d.valueOf());return g.set(d,b),c(b,d,m,g,x),b}if(d instanceof Number){const b=new Number(d.valueOf());return g.set(d,b),c(b,d,m,g,x),b}if(d instanceof String){const b=new String(d.valueOf());return g.set(d,b),c(b,d,m,g,x),b}if(typeof d=="object"&&u(d)){const b=Object.create(Object.getPrototypeOf(d));return g.set(d,b),c(b,d,m,g,x),b}return d}function c(d,f,m=d,g,x){const y=[...Object.keys(f),...e.getSymbols(f)];for(let b=0;b<y.length;b++){const v=y[b],N=Object.getOwnPropertyDescriptor(d,v);(N==null||N.writable)&&(d[v]=l(f[v],v,m,g,x))}}function u(d){switch(n.getTag(d)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=o,t.cloneDeepWithImpl=l,t.copyProperties=c})(uC)),uC}var oB;function wpe(){return oB||(oB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rK();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(cC)),cC}var lB;function Spe(){return lB||(lB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eK(),n=wpe();function r(i){return i=n.cloneDeep(i),s=>e.isMatch(s,i)}t.matches=r})(rC)),rC}var pC={},gC={},xC={},cB;function Npe(){return cB||(cB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rK(),n=nK();function r(i,s){return e.cloneDeepWith(i,(o,l,c,u)=>{const d=s?.(o,l,c,u);if(d!==void 0)return d;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const f=new i.constructor(i?.valueOf());return e.copyProperties(f,i),f}case n.argumentsTag:{const f={};return e.copyProperties(f,i),f.length=i.length,f[Symbol.iterator]=i[Symbol.iterator],f}default:return}})}t.cloneDeepWith=r})(xC)),xC}var uB;function Mpe(){return uB||(uB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Npe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(gC)),gC}var bC={},yC={},dB;function iK(){return dB||(dB=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})(yC)),yC}var vC={},hB;function Epe(){return hB||(hB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tK();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(vC)),vC}var fB;function Tpe(){return fB||(fB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=GW(),n=iK(),r=Epe(),i=ED();function s(o,l){let c;if(Array.isArray(l)?c=l:typeof l=="string"&&e.isDeepKey(l)&&o?.[l]==null?c=i.toPath(l):c=[l],c.length===0)return!1;let u=o;for(let d=0;d<c.length;d++){const f=c[d];if((u==null||!Object.hasOwn(u,f))&&!((Array.isArray(u)||r.isArguments(u))&&n.isIndex(f)&&f<u.length))return!1;u=u[f]}return!0}t.has=s})(bC)),bC}var mB;function Cpe(){return mB||(mB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eK(),n=MD(),r=Mpe(),i=TD(),s=Tpe();function o(l,c){switch(typeof l){case"object":{Object.is(l?.valueOf(),-0)&&(l="-0");break}case"number":{l=n.toKey(l);break}}return c=r.cloneDeep(c),function(u){const d=i.get(u,l);return d===void 0?s.has(u,l):c===void 0?d===void 0:e.isMatch(d,c)}}t.matchesProperty=o})(pC)),pC}var pB;function Ape(){return pB||(pB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=YW(),n=bpe(),r=Spe(),i=Cpe();function s(o){if(o==null)return e.identity;switch(typeof o){case"function":return o;case"object":return Array.isArray(o)&&o.length===2?i.matchesProperty(o[0],o[1]):r.matches(o);case"string":case"symbol":case"number":return n.property(o)}}t.iteratee=s})(tC)),tC}var gB;function kpe(){return gB||(gB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mpe(),n=YW(),r=xpe(),i=Ape();function s(o,l=n.identity){return r.isArrayLikeObject(o)?e.uniqBy(Array.from(o),i.iteratee(l)):[]}t.uniqBy=s})(KT)),KT}var _C,xB;function jpe(){return xB||(xB=1,_C=kpe().uniqBy),_C}var Ppe=jpe();const bB=Uo(Ppe);function aK(t,e,n){return e===!0?bB(t,n):typeof e=="function"?bB(t,e):t}var wC={exports:{}},SC={};var yB;function Rpe(){if(yB)return SC;yB=1;var t=Ig(),e=mq();function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,s=t.useRef,o=t.useEffect,l=t.useMemo,c=t.useDebugValue;return SC.useSyncExternalStoreWithSelector=function(u,d,f,m,g){var x=s(null);if(x.current===null){var y={hasValue:!1,value:null};x.current=y}else y=x.current;x=l(function(){function v(k){if(!N){if(N=!0,S=k,k=m(k),g!==void 0&&y.hasValue){var C=y.value;if(g(C,k))return T=C}return T=k}if(C=T,r(S,k))return C;var D=m(k);return g!==void 0&&g(C,D)?(S=k,C):(S=k,T=D)}var N=!1,S,T,E=f===void 0?null:f;return[function(){return v(d())},E===null?void 0:function(){return v(E())}]},[d,f,m,g]);var b=i(u,x[0],x[1]);return o(function(){y.hasValue=!0,y.value=b},[b]),c(b),b},SC}var vB;function Dpe(){return vB||(vB=1,wC.exports=Rpe()),wC.exports}var sK=Dpe(),jD=w.createContext(null),Ope=t=>t,Er=()=>{var t=w.useContext(jD);return t?t.store.dispatch:Ope},G1=()=>{},Lpe=()=>G1,Ipe=(t,e)=>t===e;function It(t){var e=w.useContext(jD);return sK.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:Lpe,e?e.store.getState:G1,e?e.store.getState:G1,e?t:G1,Ipe)}function Fpe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function Upe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function zpe(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 _B=t=>Array.isArray(t)?t:[t];function Bpe(t){const e=Array.isArray(t[0])?t[0]:t;return zpe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function $pe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var Hpe=class{constructor(t){this.value=t}deref(){return this.value}},Vpe=typeof WeakRef<"u"?WeakRef:Hpe,Gpe=0,wB=1;function l_(){return{s:Gpe,v:void 0,o:null,p:null}}function oK(t,e={}){let n=l_();const{resultEqualityCheck:r}=e;let i,s=0;function o(){let l=n;const{length:c}=arguments;for(let f=0,m=c;f<m;f++){const g=arguments[f];if(typeof g=="function"||typeof g=="object"&&g!==null){let x=l.o;x===null&&(l.o=x=new WeakMap);const y=x.get(g);y===void 0?(l=l_(),x.set(g,l)):l=y}else{let x=l.p;x===null&&(l.p=x=new Map);const y=x.get(g);y===void 0?(l=l_(),x.set(g,l)):l=y}}const u=l;let d;if(l.s===wB)d=l.v;else if(d=t.apply(null,arguments),s++,r){const f=i?.deref?.()??i;f!=null&&r(f,d)&&(d=f,s!==0&&s--),i=typeof d=="object"&&d!==null||typeof d=="function"?new Vpe(d):d}return u.s=wB,u.v=d,d}return o.clearCache=()=>{n=l_(),o.resetResultsCount()},o.resultsCount=()=>s,o.resetResultsCount=()=>{s=0},o}function qpe(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let s=0,o=0,l,c={},u=i.pop();typeof u=="object"&&(c=u,u=i.pop()),Fpe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:m=[],argsMemoize:g=oK,argsMemoizeOptions:x=[]}=d,y=_B(m),b=_B(x),v=Bpe(i),N=f(function(){return s++,u.apply(null,arguments)},...y),S=g(function(){o++;const E=$pe(v,arguments);return l=N.apply(null,E),l},...b);return Object.assign(S,{resultFunc:u,memoizedResultFunc:N,dependencies:v,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:f,argsMemoize:g})};return Object.assign(r,{withTypes:()=>r}),r}var tt=qpe(oK),Wpe=Object.assign((t,e=tt)=>{Upe(t,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof t}`);const n=Object.keys(t),r=n.map(s=>t[s]);return e(r,(...s)=>s.reduce((o,l,c)=>(o[n[c]]=l,o),{}))},{withTypes:()=>Wpe}),NC={},MC={},EC={},SB;function Kpe(){return SB||(SB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(r){return typeof r=="symbol"?1:r===null?2:r===void 0?3:r!==r?4:0}const n=(r,i,s)=>{if(r!==i){const o=e(r),l=e(i);if(o===l&&o===0){if(r<i)return s==="desc"?1:-1;if(r>i)return s==="desc"?-1:1}return s==="desc"?l-o:o-l}return 0};t.compareValues=n})(EC)),EC}var TC={},CC={},NB;function lK(){return NB||(NB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(CC)),CC}var MB;function Xpe(){return MB||(MB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lK(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(s,o){return Array.isArray(s)?!1:typeof s=="number"||typeof s=="boolean"||s==null||e.isSymbol(s)?!0:typeof s=="string"&&(r.test(s)||!n.test(s))||o!=null&&Object.hasOwn(o,s)}t.isKey=i})(TC)),TC}var EB;function Ype(){return EB||(EB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Kpe(),n=Xpe(),r=ED();function i(s,o,l,c){if(s==null)return[];l=c?void 0:l,Array.isArray(s)||(s=Object.values(s)),Array.isArray(o)||(o=o==null?[null]:[o]),o.length===0&&(o=[null]),Array.isArray(l)||(l=l==null?[]:[l]),l=l.map(g=>String(g));const u=(g,x)=>{let y=g;for(let b=0;b<x.length&&y!=null;++b)y=y[x[b]];return y},d=(g,x)=>x==null||g==null?x:typeof g=="object"&&"key"in g?Object.hasOwn(x,g.key)?x[g.key]:u(x,g.path):typeof g=="function"?g(x):Array.isArray(g)?u(x,g):typeof x=="object"?x[g]:x,f=o.map(g=>(Array.isArray(g)&&g.length===1&&(g=g[0]),g==null||typeof g=="function"||Array.isArray(g)||n.isKey(g)?g:{key:g,path:r.toPath(g)}));return s.map(g=>({original:g,criteria:f.map(x=>d(x,g))})).slice().sort((g,x)=>{for(let y=0;y<f.length;y++){const b=e.compareValues(g.criteria[y],x.criteria[y],l[y]);if(b!==0)return b}return 0}).map(g=>g.original)}t.orderBy=i})(MC)),MC}var AC={},TB;function Qpe(){return TB||(TB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],s=Math.floor(r),o=(l,c)=>{for(let u=0;u<l.length;u++){const d=l[u];Array.isArray(d)&&c<s?o(d,c+1):i.push(d)}};return o(n,0),i}t.flatten=e})(AC)),AC}var kC={},CB;function cK(){return CB||(CB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=iK(),n=kD(),r=QW(),i=JW();function s(o,l,c){return r.isObject(c)&&(typeof l=="number"&&n.isArrayLike(c)&&e.isIndex(l)&&l<c.length||typeof l=="string"&&l in c)?i.eq(c[l],o):!1}t.isIterateeCall=s})(kC)),kC}var AB;function Zpe(){return AB||(AB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ype(),n=Qpe(),r=cK();function i(s,...o){const l=o.length;return l>1&&r.isIterateeCall(s,o[0],o[1])?o=[]:l>2&&r.isIterateeCall(o[0],o[1],o[2])&&(o=[o[0]]),e.orderBy(s,n.flatten(o),["asc"])}t.sortBy=i})(NC)),NC}var jC,kB;function Jpe(){return kB||(kB=1,jC=Zpe().sortBy),jC}var ege=Jpe();const Z2=Uo(ege);var uK=t=>t.legend.settings,tge=t=>t.legend.size,nge=t=>t.legend.payload,rge=tt([nge,uK],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?Z2(r,n):r});function ige(){return It(rge)}var c_=1;function dK(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=w.useState({height:0,left:0,top:0,width:0}),r=w.useCallback(i=>{if(i!=null){var s=i.getBoundingClientRect(),o={height:s.height,left:s.left,top:s.top,width:s.width};(Math.abs(o.height-e.height)>c_||Math.abs(o.left-e.left)>c_||Math.abs(o.top-e.top)>c_||Math.abs(o.width-e.width)>c_)&&n({height:o.height,left:o.left,top:o.top,width:o.width})}},[e.width,e.height,e.top,e.left,...t]);return[e,r]}function ba(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 age=typeof Symbol=="function"&&Symbol.observable||"@@observable",jB=age,PC=()=>Math.random().toString(36).substring(7).split("").join("."),sge={INIT:`@@redux/INIT${PC()}`,REPLACE:`@@redux/REPLACE${PC()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${PC()}`},jw=sge;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(ba(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(ba(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(ba(1));return n(hK)(t,e)}let r=t,i=e,s=new Map,o=s,l=0,c=!1;function u(){o===s&&(o=new Map,s.forEach((b,v)=>{o.set(v,b)}))}function d(){if(c)throw new Error(ba(3));return i}function f(b){if(typeof b!="function")throw new Error(ba(4));if(c)throw new Error(ba(5));let v=!0;u();const N=l++;return o.set(N,b),function(){if(v){if(c)throw new Error(ba(6));v=!1,u(),o.delete(N),s=null}}}function m(b){if(!PD(b))throw new Error(ba(7));if(typeof b.type>"u")throw new Error(ba(8));if(typeof b.type!="string")throw new Error(ba(17));if(c)throw new Error(ba(9));try{c=!0,i=r(i,b)}finally{c=!1}return(s=o).forEach(N=>{N()}),b}function g(b){if(typeof b!="function")throw new Error(ba(10));r=b,m({type:jw.REPLACE})}function x(){const b=f;return{subscribe(v){if(typeof v!="object"||v===null)throw new Error(ba(11));function N(){const T=v;T.next&&T.next(d())}return N(),{unsubscribe:b(N)}},[jB](){return this}}}return m({type:jw.INIT}),{dispatch:m,subscribe:f,getState:d,replaceReducer:g,[jB]:x}}function oge(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:jw.INIT})>"u")throw new Error(ba(12));if(typeof n(void 0,{type:jw.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(ba(13))})}function fK(t){const e=Object.keys(t),n={};for(let s=0;s<e.length;s++){const o=e[s];typeof t[o]=="function"&&(n[o]=t[o])}const r=Object.keys(n);let i;try{oge(n)}catch(s){i=s}return function(o={},l){if(i)throw i;let c=!1;const u={};for(let d=0;d<r.length;d++){const f=r[d],m=n[f],g=o[f],x=m(g,l);if(typeof x>"u")throw l&&l.type,new Error(ba(14));u[f]=x,c=c||x!==g}return c=c||r.length!==Object.keys(o).length,c?u:o}}function Pw(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function lge(...t){return e=>(n,r)=>{const i=e(n,r);let s=()=>{throw new Error(ba(15))};const o={getState:i.getState,dispatch:(c,...u)=>s(c,...u)},l=t.map(c=>c(o));return s=Pw(...l)(i.dispatch),{...i,dispatch:s}}}function mK(t){return PD(t)&&"type"in t&&typeof t.type=="string"}var pK=Symbol.for("immer-nothing"),PB=Symbol.for("immer-draftable"),es=Symbol.for("immer-state");function Zo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var qs=Object,hg=qs.getPrototypeOf,Rw="constructor",J2="prototype",u3="configurable",Dw="enumerable",q1="writable",_0="value",du=t=>!!t&&!!t[es];function dl(t){return t?gK(t)||eN(t)||!!t[PB]||!!t[Rw]?.[PB]||tN(t)||nN(t):!1}var cge=qs[J2][Rw].toString(),RB=new WeakMap;function gK(t){if(!t||!RD(t))return!1;const e=hg(t);if(e===null||e===qs[J2])return!0;const n=qs.hasOwnProperty.call(e,Rw)&&e[Rw];if(n===Object)return!0;if(!Rp(n))return!1;let r=RB.get(n);return r===void 0&&(r=Function.toString.call(n),RB.set(n,r)),r===cge}function hy(t,e,n=!0){fy(t)===0?(n?Reflect.ownKeys(t):qs.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function fy(t){const e=t[es];return e?e.type_:eN(t)?1:tN(t)?2:nN(t)?3:0}var DB=(t,e,n=fy(t))=>n===2?t.has(e):qs[J2].hasOwnProperty.call(t,e),d3=(t,e,n=fy(t))=>n===2?t.get(e):t[e],Ow=(t,e,n,r=fy(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function uge(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var eN=Array.isArray,tN=t=>t instanceof Map,nN=t=>t instanceof Set,RD=t=>typeof t=="object",Rp=t=>typeof t=="function",RC=t=>typeof t=="boolean",Uc=t=>t.copy_||t.base_,DD=t=>t.modified_?t.copy_:t.base_;function h3(t,e){if(tN(t))return new Map(t);if(nN(t))return new Set(t);if(eN(t))return Array[J2].slice.call(t);const n=gK(t);if(e===!0||e==="class_only"&&!n){const r=qs.getOwnPropertyDescriptors(t);delete r[es];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const o=i[s],l=r[o];l[q1]===!1&&(l[q1]=!0,l[u3]=!0),(l.get||l.set)&&(r[o]={[u3]:!0,[q1]:!0,[Dw]:l[Dw],[_0]:t[o]})}return qs.create(hg(t),r)}else{const r=hg(t);if(r!==null&&n)return{...t};const i=qs.create(r);return qs.assign(i,t)}}function OD(t,e=!1){return rN(t)||du(t)||!dl(t)||(fy(t)>1&&qs.defineProperties(t,{set:u_,add:u_,clear:u_,delete:u_}),qs.freeze(t),e&&hy(t,(n,r)=>{OD(r,!0)},!1)),t}function dge(){Zo(2)}var u_={[_0]:dge};function rN(t){return t===null||!RD(t)?!0:qs.isFrozen(t)}var Lw="MapSet",f3="Patches",xK={};function fg(t){const e=xK[t];return e||Zo(0,t),e}var hge=t=>!!xK[t],w0,bK=()=>w0,fge=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:hge(Lw)?fg(Lw):void 0});function OB(t,e){e&&(t.patchPlugin_=fg(f3),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function m3(t){p3(t),t.drafts_.forEach(mge),t.drafts_=null}function p3(t){t===w0&&(w0=t.parent_)}var LB=t=>w0=fge(w0,t);function mge(t){const e=t[es];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function IB(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[es].modified_&&(m3(e),Zo(4)),dl(t)&&(t=FB(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[es].base_,t,e)}else t=FB(e,n);return pge(e,t,!0),m3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==pK?t:void 0}function FB(t,e){if(rN(e))return e;const n=e[es];if(!n)return LD(e,t.handledSet_,t);if(!iN(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);_K(n,t)}return n.copy_}function pge(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&OD(e,n)}function yK(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var iN=(t,e)=>t.scope_===e,gge=[];function vK(t,e,n,r){const i=Uc(t),s=t.type_;if(r!==void 0&&d3(i,r,s)===e){Ow(i,r,n,s);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;hy(i,(c,u)=>{if(du(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const o=t.draftLocations_.get(e)??gge;for(const l of o)Ow(i,l,n,s)}function xge(t,e,n){t.callbacks_.push(function(i){const s=e;if(!s||!iN(s,i))return;i.mapSetPlugin_?.fixSetContents(s);const o=DD(s);vK(t,s.draft_??s,o,n),_K(s,i)})}function _K(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)}yK(t)}}function bge(t,e,n){const{scope_:r}=t;if(du(n)){const i=n[es];iN(i,r)&&i.callbacks_.push(function(){W1(t);const o=DD(i);vK(t,n,o,e)})}else dl(n)&&t.callbacks_.push(function(){const s=Uc(t);d3(s,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&LD(d3(t.copy_,e,t.type_),r.handledSet_,r)})}function LD(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||du(t)||e.has(t)||!dl(t)||rN(t)||(e.add(t),hy(t,(r,i)=>{if(du(i)){const s=i[es];if(iN(s,n)){const o=DD(s);Ow(t,r,o,t.type_),yK(s)}}else dl(i)&&LD(i,e,n)})),t}function yge(t,e){const n=eN(t),r={type_:n?1:0,scope_:e?e.scope_:bK(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,s=ID;n&&(i=[r],s=S0);const{revoke:o,proxy:l}=Proxy.revocable(i,s);return r.draft_=l,r.revoke_=o,[l,r]}var ID={get(t,e){if(e===es)return t;const n=Uc(t);if(!DB(n,e,t.type_))return vge(t,n,e);const r=n[e];if(t.finalized_||!dl(r))return r;if(r===DC(t.base_,e)){W1(t);const i=t.type_===1?+e:e,s=x3(t.scope_,r,t,i);return t.copy_[i]=s}return r},has(t,e){return e in Uc(t)},ownKeys(t){return Reflect.ownKeys(Uc(t))},set(t,e,n){const r=wK(Uc(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=DC(Uc(t),e),s=i?.[es];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(uge(n,i)&&(n!==void 0||DB(t.base_,e,t.type_)))return!0;W1(t),g3(t)}return t.copy_[e]===n&&(n!==void 0||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_.set(e,!0),bge(t,e,n)),!0},deleteProperty(t,e){return W1(t),DC(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),g3(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Uc(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[q1]:!0,[u3]:t.type_!==1||e!=="length",[Dw]:r[Dw],[_0]:n[e]}},defineProperty(){Zo(11)},getPrototypeOf(t){return hg(t.base_)},setPrototypeOf(){Zo(12)}},S0={};hy(ID,(t,e)=>{S0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});S0.deleteProperty=function(t,e){return S0.set.call(this,t,e,void 0)};S0.set=function(t,e,n){return ID.set.call(this,t[0],e,n,t[0])};function DC(t,e){const n=t[es];return(n?Uc(n):t)[e]}function vge(t,e,n){const r=wK(e,n);return r?_0 in r?r[_0]:r.get?.call(t.draft_):void 0}function wK(t,e){if(!(e in t))return;let n=hg(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=hg(n)}}function g3(t){t.modified_||(t.modified_=!0,t.parent_&&g3(t.parent_))}function W1(t){t.copy_||(t.assigned_=new Map,t.copy_=h3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var _ge=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(Rp(n)&&!Rp(r)){const o=r;r=n;const l=this;return function(u=o,...d){return l.produce(u,f=>r.call(this,f,...d))}}Rp(r)||Zo(6),i!==void 0&&!Rp(i)&&Zo(7);let s;if(dl(n)){const o=LB(this),l=x3(o,n,void 0);let c=!0;try{s=r(l),c=!1}finally{c?m3(o):p3(o)}return OB(o,i),IB(s,o)}else if(!n||!RD(n)){if(s=r(n),s===void 0&&(s=n),s===pK&&(s=void 0),this.autoFreeze_&&OD(s,!0),i){const o=[],l=[];fg(f3).generateReplacementPatches_(n,s,{patches_:o,inversePatches_:l}),i(o,l)}return s}else Zo(1,n)},this.produceWithPatches=(n,r)=>{if(Rp(n))return(l,...c)=>this.produceWithPatches(l,u=>n(u,...c));let i,s;return[this.produce(n,r,(l,c)=>{i=l,s=c}),i,s]},RC(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),RC(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),RC(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){dl(e)||Zo(8),du(e)&&(e=sl(e));const n=LB(this),r=x3(n,e,void 0);return r[es].isManual_=!0,p3(n),r}finishDraft(e,n){const r=e&&e[es];(!r||!r.isManual_)&&Zo(9);const{scope_:i}=r;return OB(i,n),IB(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,n){let r;for(r=n.length-1;r>=0;r--){const s=n[r];if(s.path.length===0&&s.op==="replace"){e=s.value;break}}r>-1&&(n=n.slice(r+1));const i=fg(f3).applyPatches_;return du(e)?i(e,n):this.produce(e,s=>i(s,n))}};function x3(t,e,n,r){const[i,s]=tN(e)?fg(Lw).proxyMap_(e,n):nN(e)?fg(Lw).proxySet_(e,n):yge(e,n);return(n?.scope_??bK()).drafts_.push(i),s.callbacks_=n?.callbacks_??[],s.key_=r,n&&r!==void 0?xge(n,s,r):s.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(s);const{patchPlugin_:u}=c;s.modified_&&u&&u.generatePatches_(s,[],c)}),i}function sl(t){return du(t)||Zo(10,t),SK(t)}function SK(t){if(!dl(t)||rN(t))return t;const e=t[es];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=h3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=h3(t,!0);return hy(n,(i,s)=>{Ow(n,i,SK(s))},r),e&&(e.finalized_=!1),n}var wge=new _ge,NK=wge.produce;function MK(t){return({dispatch:n,getState:r})=>i=>s=>typeof s=="function"?s(n,r,t):i(s)}var Sge=MK(),Nge=MK,Mge=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Pw:Pw.apply(null,arguments)};function Io(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(Ks(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=>mK(r)&&r.type===t,n}var EK=class Cb extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Cb.prototype)}static get[Symbol.species](){return Cb}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new Cb(...e[0].concat(this)):new Cb(...e.concat(this))}};function UB(t){return dl(t)?NK(t,()=>{}):t}function d_(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function Ege(t){return typeof t=="boolean"}var Tge=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:s=!0}=e??{};let o=new EK;return n&&(Ege(n)?o.push(Sge):o.push(Nge(n.extraArgument))),o},TK="RTK_autoBatch",Ur=()=>t=>({payload:t,meta:{[TK]:!0}}),zB=t=>e=>{setTimeout(e,t)},CK=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,s=!1,o=!1;const l=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:zB(10):t.type==="callback"?t.queueNotification:zB(t.timeout),u=()=>{o=!1,s&&(s=!1,l.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const f=()=>i&&d(),m=r.subscribe(f);return l.add(d),()=>{m(),l.delete(d)}},dispatch(d){try{return i=!d?.meta?.[TK],s=!i,s&&(o||(o=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},Cge=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new EK(t);return r&&i.push(CK(typeof r=="object"?r:void 0)),i};function Age(t){const e=Tge(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:s=void 0,enhancers:o=void 0}=t||{};let l;if(typeof n=="function")l=n;else if(PD(n))l=fK(n);else throw new Error(Ks(1));let c;typeof r=="function"?c=r(e):c=e();let u=Pw;i&&(u=Mge({trace:!1,...typeof i=="object"&&i}));const d=lge(...c),f=Cge(d);let m=typeof o=="function"?o(f):f();const g=u(...m);return hK(l,s,g)}function AK(t){const e={},n=[];let r;const i={addCase(s,o){const l=typeof s=="string"?s:s.type;if(!l)throw new Error(Ks(28));if(l in e)throw new Error(Ks(29));return e[l]=o,i},addAsyncThunk(s,o){return o.pending&&(e[s.pending.type]=o.pending),o.rejected&&(e[s.rejected.type]=o.rejected),o.fulfilled&&(e[s.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:s.settled,reducer:o.settled}),i},addMatcher(s,o){return n.push({matcher:s,reducer:o}),i},addDefaultCase(s){return r=s,i}};return t(i),[e,n,r]}function kge(t){return typeof t=="function"}function jge(t,e){let[n,r,i]=AK(e),s;if(kge(t))s=()=>UB(t());else{const l=UB(t);s=()=>l}function o(l=s(),c){let u=[n[c.type],...r.filter(({matcher:d})=>d(c)).map(({reducer:d})=>d)];return u.filter(d=>!!d).length===0&&(u=[i]),u.reduce((d,f)=>{if(f)if(du(d)){const g=f(d,c);return g===void 0?d:g}else{if(dl(d))return NK(d,m=>f(m,c));{const m=f(d,c);if(m===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return m}}return d},l)}return o.getInitialState=s,o}var Pge="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Rge=(t=21)=>{let e="",n=t;for(;n--;)e+=Pge[Math.random()*64|0];return e},Dge=Symbol.for("rtk-slice-createasyncthunk");function Oge(t,e){return`${t}/${e}`}function Lge({creators:t}={}){const e=t?.asyncThunk?.[Dge];return function(r){const{name:i,reducerPath:s=i}=r;if(!i)throw new Error(Ks(11));const o=(typeof r.reducers=="function"?r.reducers(Fge()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(S,T){const E=typeof S=="string"?S:S.type;if(!E)throw new Error(Ks(12));if(E in c.sliceCaseReducersByType)throw new Error(Ks(13));return c.sliceCaseReducersByType[E]=T,u},addMatcher(S,T){return c.sliceMatchers.push({matcher:S,reducer:T}),u},exposeAction(S,T){return c.actionCreators[S]=T,u},exposeCaseReducer(S,T){return c.sliceCaseReducersByName[S]=T,u}};l.forEach(S=>{const T=o[S],E={reducerName:S,type:Oge(i,S),createNotation:typeof r.reducers=="function"};zge(T)?$ge(E,T,u,e):Uge(E,T,u)});function d(){const[S={},T=[],E=void 0]=typeof r.extraReducers=="function"?AK(r.extraReducers):[r.extraReducers],k={...S,...c.sliceCaseReducersByType};return jge(r.initialState,C=>{for(let D in k)C.addCase(D,k[D]);for(let D of c.sliceMatchers)C.addMatcher(D.matcher,D.reducer);for(let D of T)C.addMatcher(D.matcher,D.reducer);E&&C.addDefaultCase(E)})}const f=S=>S,m=new Map,g=new WeakMap;let x;function y(S,T){return x||(x=d()),x(S,T)}function b(){return x||(x=d()),x.getInitialState()}function v(S,T=!1){function E(C){let D=C[S];return typeof D>"u"&&T&&(D=d_(g,E,b)),D}function k(C=f){const D=d_(m,T,()=>new WeakMap);return d_(D,C,()=>{const A={};for(const[R,F]of Object.entries(r.selectors??{}))A[R]=Ige(F,C,()=>d_(g,C,b),T);return A})}return{reducerPath:S,getSelectors:k,get selectors(){return k(E)},selectSlice:E}}const N={name:i,reducer:y,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:b,...v(s),injectInto(S,{reducerPath:T,...E}={}){const k=T??s;return S.inject({reducerPath:k,reducer:y},E),{...N,...v(k,!0)}}};return N}}function Ige(t,e,n,r){function i(s,...o){let l=e(s);return typeof l>"u"&&r&&(l=n()),t(l,...o)}return i.unwrapped=t,i}var Ts=Lge();function Fge(){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 Uge({type:t,reducerName:e,createNotation:n},r,i){let s,o;if("reducer"in r){if(n&&!Bge(r))throw new Error(Ks(17));s=r.reducer,o=r.prepare}else s=r;i.addCase(t,s).exposeCaseReducer(e,s).exposeAction(e,o?Io(t,o):Io(t))}function zge(t){return t._reducerDefinitionType==="asyncThunk"}function Bge(t){return t._reducerDefinitionType==="reducerWithPrepare"}function $ge({type:t,reducerName:e},n,r,i){if(!i)throw new Error(Ks(18));const{payloadCreator:s,fulfilled:o,pending:l,rejected:c,settled:u,options:d}=n,f=i(t,s,d);r.exposeAction(e,f),o&&r.addCase(f.fulfilled,o),l&&r.addCase(f.pending,l),c&&r.addCase(f.rejected,c),u&&r.addMatcher(f.settled,u),r.exposeCaseReducer(e,{fulfilled:o||h_,pending:l||h_,rejected:c||h_,settled:u||h_})}function h_(){}var Hge="task",kK="listener",jK="completed",FD="cancelled",Vge=`task-${FD}`,Gge=`task-${jK}`,b3=`${kK}-${FD}`,qge=`${kK}-${jK}`,aN=class{constructor(t){this.code=t,this.message=`${Hge} ${FD} (reason: ${t})`}name="TaskAbortError";message},UD=(t,e)=>{if(typeof t!="function")throw new TypeError(Ks(32))},Iw=()=>{},PK=(t,e=Iw)=>(t.catch(e),t),RK=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),bf=(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))},yf=t=>{if(t.aborted){const{reason:e}=t;throw new aN(e)}};function DK(t,e){let n=Iw;return new Promise((r,i)=>{const s=()=>i(new aN(t.reason));if(t.aborted){s();return}n=RK(t,s),e.finally(()=>n()).then(r,i)}).finally(()=>{n=Iw})}var Wge=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof aN?"cancelled":"rejected",error:n}}finally{e?.()}},Fw=t=>e=>PK(DK(t,e).then(n=>(yf(t),n))),OK=t=>{const e=Fw(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:Xp}=Object,BB={},sN="listenerMiddleware",Kge=(t,e)=>{const n=r=>RK(t,()=>bf(r,t.reason));return(r,i)=>{UD(r);const s=new AbortController;n(s);const o=Wge(async()=>{yf(t),yf(s.signal);const l=await r({pause:Fw(s.signal),delay:OK(s.signal),signal:s.signal});return yf(s.signal),l},()=>bf(s,Gge));return i?.autoJoin&&e.push(o.catch(Iw)),{result:Fw(t)(o),cancel(){bf(s,Vge)}}}},Xge=(t,e)=>{const n=async(r,i)=>{yf(e);let s=()=>{};const l=[new Promise((c,u)=>{let d=t({predicate:r,effect:(f,m)=>{m.unsubscribe(),c([f,m.getState(),m.getOriginalState()])}});s=()=>{d(),u()}})];i!=null&&l.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await DK(e,Promise.race(l));return yf(e),c}finally{s()}};return(r,i)=>PK(n(r,i))},LK=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:s}=t;if(e)i=Io(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(Ks(21));return UD(s),{predicate:i,type:e,effect:s}},IK=Xp(t=>{const{type:e,predicate:n,effect:r}=LK(t);return{id:Rge(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(Ks(22))}}},{withTypes:()=>IK}),$B=(t,e)=>{const{type:n,effect:r,predicate:i}=LK(e);return Array.from(t.values()).find(s=>(typeof n=="string"?s.type===n:s.predicate===i)&&s.effect===r)},y3=t=>{t.pending.forEach(e=>{bf(e,b3)})},Yge=(t,e)=>()=>{for(const n of e.keys())y3(n);t.clear()},HB=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},FK=Xp(Io(`${sN}/add`),{withTypes:()=>FK}),Qge=Io(`${sN}/removeAll`),UK=Xp(Io(`${sN}/remove`),{withTypes:()=>UK}),Zge=(...t)=>{console.error(`${sN}/error`,...t)},my=(t={})=>{const e=new Map,n=new Map,r=g=>{const x=n.get(g)??0;n.set(g,x+1)},i=g=>{const x=n.get(g)??1;x===1?n.delete(g):n.set(g,x-1)},{extra:s,onError:o=Zge}=t;UD(o);const l=g=>(g.unsubscribe=()=>e.delete(g.id),e.set(g.id,g),x=>{g.unsubscribe(),x?.cancelActive&&y3(g)}),c=g=>{const x=$B(e,g)??IK(g);return l(x)};Xp(c,{withTypes:()=>c});const u=g=>{const x=$B(e,g);return x&&(x.unsubscribe(),g.cancelActive&&y3(x)),!!x};Xp(u,{withTypes:()=>u});const d=async(g,x,y,b)=>{const v=new AbortController,N=Xge(c,v.signal),S=[];try{g.pending.add(v),r(g),await Promise.resolve(g.effect(x,Xp({},y,{getOriginalState:b,condition:(T,E)=>N(T,E).then(Boolean),take:N,delay:OK(v.signal),pause:Fw(v.signal),extra:s,signal:v.signal,fork:Kge(v.signal,S),unsubscribe:g.unsubscribe,subscribe:()=>{e.set(g.id,g)},cancelActiveListeners:()=>{g.pending.forEach((T,E,k)=>{T!==v&&(bf(T,b3),k.delete(T))})},cancel:()=>{bf(v,b3),g.pending.delete(v)},throwIfCancelled:()=>{yf(v.signal)}})))}catch(T){T instanceof aN||HB(o,T,{raisedBy:"effect"})}finally{await Promise.all(S),bf(v,qge),i(g),g.pending.delete(v)}},f=Yge(e,n);return{middleware:g=>x=>y=>{if(!mK(y))return x(y);if(FK.match(y))return c(y.payload);if(Qge.match(y)){f();return}if(UK.match(y))return u(y.payload);let b=g.getState();const v=()=>{if(b===BB)throw new Error(Ks(23));return b};let N;try{if(N=x(y),e.size>0){const S=g.getState(),T=Array.from(e.values());for(const E of T){let k=!1;try{k=E.predicate(y,S,b)}catch(C){k=!1,HB(o,C,{raisedBy:"predicate"})}k&&d(E,y,g,v)}}}finally{b=BB}return N},startListening:c,stopListening:u,clearListeners:f}};function Ks(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 Jge={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},zK=Ts({name:"chartLayout",initialState:Jge,reducers:{setLayout(t,e){t.layoutType=e.payload},setChartSize(t,e){t.width=e.payload.width,t.height=e.payload.height},setMargin(t,e){var n,r,i,s;t.margin.top=(n=e.payload.top)!==null&&n!==void 0?n:0,t.margin.right=(r=e.payload.right)!==null&&r!==void 0?r:0,t.margin.bottom=(i=e.payload.bottom)!==null&&i!==void 0?i:0,t.margin.left=(s=e.payload.left)!==null&&s!==void 0?s:0},setScale(t,e){t.scale=e.payload}}}),{setMargin:exe,setLayout:txe,setChartSize:nxe,setScale:rxe}=zK.actions,ixe=zK.reducer;function BK(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function VB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function zp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?VB(Object(n),!0).forEach(function(r){axe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):VB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function axe(t,e,n){return(e=sxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sxe(t){var e=oxe(t,"string");return typeof e=="symbol"?e:e+""}function oxe(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 lr(t,e,n){return Ir(t)||Ir(e)?n:Lo(e)?Uf(t,e,n):typeof e=="function"?e(t):n}var lxe=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:s,verticalAlign:o,layout:l}=e;if((l==="vertical"||l==="horizontal"&&o==="middle")&&s!=="center"&&Ut(t[s]))return zp(zp({},t),{},{[s]:t[s]+(r||0)});if((l==="horizontal"||l==="vertical"&&s==="center")&&o!=="middle"&&Ut(t[o]))return zp(zp({},t),{},{[o]:t[o]+(i||0)})}return t},Ql=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",$K=(t,e,n,r)=>{if(r)return t.map(l=>l.coordinate);var i,s,o=t.map(l=>(l.coordinate===e&&(i=!0),l.coordinate===n&&(s=!0),l.coordinate));return i||o.push(e),s||o.push(n),o},HK=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:s,scale:o,realScaleType:l,isCategorical:c,categoricalDomain:u,tickCount:d,ticks:f,niceTicks:m,axisType:g}=t;if(!o)return null;var x=l==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,y=i==="category"&&o.bandwidth?o.bandwidth()/x:0;if(y=g==="angleAxis"&&s&&s.length>=2?ra(s[0]-s[1])*2*y:y,f||m){var b=(f||m||[]).map((v,N)=>{var S=r?r.indexOf(v):v;return{coordinate:o(S)+y,value:v,offset:y,index:N}});return b.filter(v=>!Es(v.coordinate))}return c&&u?u.map((v,N)=>({coordinate:o(v)+y,value:v,index:N,offset:y})):o.ticks&&d!=null?o.ticks(d).map((v,N)=>({coordinate:o(v)+y,value:v,offset:y,index:N})):o.domain().map((v,N)=>({coordinate:o(v)+y,value:r?r[v]:v,index:N,offset:y}))},GB=1e-4,cxe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-GB,s=Math.max(r[0],r[1])+GB,o=t(e[0]),l=t(e[n-1]);(o<i||o>s||l<i||l>s)&&t.domain([e[0],e[n-1]])}},uxe=(t,e)=>{if(!e||e.length!==2||!Ut(e[0])||!Ut(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(!Ut(t[0])||t[0]<n)&&(i[0]=n),(!Ut(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},dxe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,s=0,o=0;o<e;++o){var l=Es(t[o][n][1])?t[o][n][0]:t[o][n][1];l>=0?(t[o][n][0]=i,t[o][n][1]=i+l,i=t[o][n][1]):(t[o][n][0]=s,t[o][n][1]=s+l,s=t[o][n][1])}},hxe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,s=0;s<e;++s){var o=Es(t[s][n][1])?t[s][n][0]:t[s][n][1];o>=0?(t[s][n][0]=i,t[s][n][1]=i+o,i=t[s][n][1]):(t[s][n][0]=0,t[s][n][1]=0)}},fxe={sign:dxe,expand:Lme,none:dg,silhouette:Ime,wiggle:Fme,positive:hxe},mxe=(t,e,n)=>{var r=fxe[n],i=Ome().keys(e).value((s,o)=>Number(lr(s,o,0))).order(l3).offset(r);return i(t)};function VK(t){return t==null?void 0:String(t)}function Uw(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:s,dataKey:o}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!Ir(i[e.dataKey])){var l=WW(n,"value",i[e.dataKey]);if(l)return l.coordinate+r/2}return n[s]?n[s].coordinate+r/2:null}var c=lr(i,Ir(o)?e.dataKey:o);return Ir(c)?null:e.scale(c)}var qB=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:s,index:o}=t;if(e.type==="category")return n[o]?n[o].coordinate+r:null;var l=lr(s,e.dataKey,e.scale.domain()[o]);return Ir(l)?null:e.scale(l)-i/2+r},pxe=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]},gxe=t=>{var e=t.flat(2).filter(Ut);return[Math.min(...e),Math.max(...e)]},xxe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],bxe=(t,e,n)=>{if(t!=null)return xxe(Object.keys(t).reduce((r,i)=>{var s=t[i],{stackedData:o}=s,l=o.reduce((c,u)=>{var d=BK(u,e,n),f=gxe(d);return[Math.min(c[0],f[0]),Math.max(c[1],f[1])]},[1/0,-1/0]);return[Math.min(l[0],r[0]),Math.max(l[1],r[1])]},[1/0,-1/0]))},WB=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,KB=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Xd=(t,e,n)=>{if(t&&t.scale&&t.scale.bandwidth){var r=t.scale.bandwidth();if(!n||r>0)return r}if(t&&e&&e.length>=2){for(var i=Z2(e,d=>d.coordinate),s=1/0,o=1,l=i.length;o<l;o++){var c=i[o],u=i[o-1];s=Math.min((c.coordinate||0)-(u.coordinate||0),s)}return s===1/0?0:s}return n?void 0:0};function XB(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:s}=t;return zp(zp({},e),{},{dataKey:n,payload:r,value:i,name:s})}function uh(t,e){if(t)return String(t);if(typeof e=="string")return e}var yxe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},vxe=(t,e)=>e==="centric"?t.angle:t.radius,vu=t=>t.layout.width,_u=t=>t.layout.height,_xe=t=>t.layout.scale,GK=t=>t.layout.margin,oN=tt(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),lN=tt(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),qK="data-recharts-item-index",WK="data-recharts-item-data-key",py=60;function YB(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 f_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?YB(Object(n),!0).forEach(function(r){wxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):YB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function wxe(t,e,n){return(e=Sxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Sxe(t){var e=Nxe(t,"string");return typeof e=="symbol"?e:e+""}function Nxe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Mxe=t=>t.brush.height;function Exe(t){var e=lN(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:py;return n+i}return n},0)}function Txe(t){var e=lN(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:py;return n+i}return n},0)}function Cxe(t){var e=oN(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function Axe(t){var e=oN(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var zi=tt([vu,_u,GK,Mxe,Exe,Txe,Cxe,Axe,uK,tge],(t,e,n,r,i,s,o,l,c,u)=>{var d={left:(n.left||0)+i,right:(n.right||0)+s},f={top:(n.top||0)+o,bottom:(n.bottom||0)+l},m=f_(f_({},f),d),g=m.bottom;m.bottom+=r,m=lxe(m,c,u);var x=t-m.left-m.right,y=e-m.top-m.bottom;return f_(f_({brushBottom:g},m),{},{width:Math.max(x,0),height:Math.max(y,0)})}),kxe=tt(zi,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),zD=tt(vu,_u,(t,e)=>({x:0,y:0,width:t,height:e})),jxe=w.createContext(null),Bi=()=>w.useContext(jxe)!=null,cN=t=>t.brush,uN=tt([cN,zi,GK],(t,e,n)=>({height:t.height,x:Ut(t.x)?t.x:e.left,y:Ut(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Ut(t.width)?t.width:e.width})),OC={},LC={},IC={},QB;function Pxe(){return QB||(QB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:s}={}){let o,l=null;const c=s!=null&&s.includes("leading"),u=s==null||s.includes("trailing"),d=()=>{l!==null&&(n.apply(o,l),o=void 0,l=null)},f=()=>{u&&d(),y()};let m=null;const g=()=>{m!=null&&clearTimeout(m),m=setTimeout(()=>{m=null,f()},r)},x=()=>{m!==null&&(clearTimeout(m),m=null)},y=()=>{x(),o=void 0,l=null},b=()=>{d()},v=function(...N){if(i?.aborted)return;o=this,l=N;const S=m==null;g(),c&&S&&d()};return v.schedule=g,v.cancel=y,v.flush=b,i?.addEventListener("abort",y,{once:!0}),v}t.debounce=e})(IC)),IC}var ZB;function Rxe(){return ZB||(ZB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Pxe();function n(r,i=0,s={}){typeof s!="object"&&(s={});const{leading:o=!1,trailing:l=!0,maxWait:c}=s,u=Array(2);o&&(u[0]="leading"),l&&(u[1]="trailing");let d,f=null;const m=e.debounce(function(...y){d=r.apply(this,y),f=null},i,{edges:u}),g=function(...y){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(d=r.apply(this,y),f=Date.now(),m.cancel(),m.schedule(),d):(m.apply(this,y),d)},x=()=>(m.flush(),d);return g.cancel=m.cancel,g.flush=x,g}t.debounce=n})(LC)),LC}var JB;function Dxe(){return JB||(JB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Rxe();function n(r,i=0,s={}){const{leading:o=!0,trailing:l=!0}=s;return e.debounce(r,i,{leading:o,maxWait:i,trailing:l})}t.throttle=n})(OC)),OC}var FC,e8;function Oxe(){return e8||(e8=1,FC=Dxe().throttle),FC}var Lxe=Oxe();const Ixe=Uo(Lxe);var zw=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];if(typeof console<"u"&&console.warn&&(n===void 0&&console.warn("LogUtils requires an error message argument"),!e))if(n===void 0)console.warn("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var o=0;console.warn(n.replace(/%s/g,()=>i[o++]))}},KK=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:s,maxHeight:o}=n,l=uu(r)?t:Number(r),c=uu(i)?e:Number(i);return s&&s>0&&(l?c=l/s:c&&(l=c*s),o&&c!=null&&c>o&&(c=o)),{calculatedWidth:l,calculatedHeight:c}},Fxe={width:0,height:0,overflow:"visible"},Uxe={width:0,overflowX:"visible"},zxe={height:0,overflowY:"visible"},Bxe={},$xe=t=>{var{width:e,height:n}=t,r=uu(e),i=uu(n);return r&&i?Fxe:r?Uxe:i?zxe:Bxe};function Hxe(t){var{width:e,height:n,aspect:r}=t,i=e,s=n;return i===void 0&&s===void 0?(i="100%",s="100%"):i===void 0?i=r&&r>0?void 0:"100%":s===void 0&&(s=r&&r>0?void 0:"100%"),{width:i,height:s}}function cr(t){return Number.isFinite(t)}function Bl(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function v3(){return v3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},v3.apply(null,arguments)}function t8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function n8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?t8(Object(n),!0).forEach(function(r){Vxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):t8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Vxe(t,e,n){return(e=Gxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Gxe(t){var e=qxe(t,"string");return typeof e=="symbol"?e:e+""}function qxe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var XK=w.createContext({width:-1,height:-1});function Wxe(t){return Bl(t.width)&&Bl(t.height)}function YK(t){var{children:e,width:n,height:r}=t,i=w.useMemo(()=>({width:n,height:r}),[n,r]);return Wxe(i)?w.createElement(XK.Provider,{value:i},e):null}var BD=()=>w.useContext(XK),Kxe=w.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:s,minWidth:o=0,minHeight:l,maxHeight:c,children:u,debounce:d=0,id:f,className:m,onResize:g,style:x={}}=t,y=w.useRef(null),b=w.useRef();b.current=g,w.useImperativeHandle(e,()=>y.current);var[v,N]=w.useState({containerWidth:r.width,containerHeight:r.height}),S=w.useCallback((D,A)=>{N(R=>{var F=Math.round(D),O=Math.round(A);return R.containerWidth===F&&R.containerHeight===O?R:{containerWidth:F,containerHeight:O}})},[]);w.useEffect(()=>{if(y.current==null||typeof ResizeObserver>"u")return uy;var D=O=>{var q,{width:j,height:G}=O[0].contentRect;S(j,G),(q=b.current)===null||q===void 0||q.call(b,j,G)};d>0&&(D=Ixe(D,d,{trailing:!0,leading:!1}));var A=new ResizeObserver(D),{width:R,height:F}=y.current.getBoundingClientRect();return S(R,F),A.observe(y.current),()=>{A.disconnect()}},[S,d]);var{containerWidth:T,containerHeight:E}=v;zw(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:k,calculatedHeight:C}=KK(T,E,{width:i,height:s,aspect:n,maxHeight:c});return zw(k!=null&&k>0||C!=null&&C>0,`The width(%s) and height(%s) of chart should be greater than 0,
- please check the style of container, or the props width(%s) and height(%s),
- or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
- height and width.`,k,C,i,s,o,l,n),w.createElement("div",{id:f?"".concat(f):void 0,className:Vn("recharts-responsive-container",m),style:n8(n8({},x),{},{width:i,height:s,minWidth:o,minHeight:l,maxHeight:c}),ref:y},w.createElement("div",{style:$xe({width:i,height:s})},w.createElement(YK,{width:k,height:C},u)))}),K1=w.forwardRef((t,e)=>{var n=BD();if(Bl(n.width)&&Bl(n.height))return t.children;var{width:r,height:i}=Hxe({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:s,calculatedHeight:o}=KK(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Ut(s)&&Ut(o)?w.createElement(YK,{width:s,height:o},t.children):w.createElement(Kxe,v3({},t,{width:r,height:i,ref:e}))});function QK(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 gy=()=>{var t,e=Bi(),n=It(kxe),r=It(uN),i=(t=It(cN))===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}},Xxe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},ZK=()=>{var t;return(t=It(zi))!==null&&t!==void 0?t:Xxe},$D=()=>It(vu),HD=()=>It(_u),Yxe=()=>It(t=>t.layout.margin),Dn=t=>t.layout.layoutType,im=()=>It(Dn),Qxe=()=>{var t=im();if(t==="horizontal"||t==="vertical")return t},Zxe=()=>{var t=im();return t!==void 0},dN=t=>{var e=Er(),n=Bi(),{width:r,height:i}=t,s=BD(),o=r,l=i;return s&&(o=s.width>0?s.width:r,l=s.height>0?s.height:i),w.useEffect(()=>{!n&&Bl(o)&&Bl(l)&&e(nxe({width:o,height:l}))},[e,n,o,l]),null},JK=Symbol.for("immer-nothing"),r8=Symbol.for("immer-draftable"),Js=Symbol.for("immer-state");function Jo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var N0=Object.getPrototypeOf;function mg(t){return!!t&&!!t[Js]}function zf(t){return t?eX(t)||Array.isArray(t)||!!t[r8]||!!t.constructor?.[r8]||xy(t)||fN(t):!1}var Jxe=Object.prototype.constructor.toString(),i8=new WeakMap;function eX(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=i8.get(n);return r===void 0&&(r=Function.toString.call(n),i8.set(n,r)),r===Jxe}function Bw(t,e,n=!0){hN(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 hN(t){const e=t[Js];return e?e.type_:Array.isArray(t)?1:xy(t)?2:fN(t)?3:0}function _3(t,e){return hN(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function tX(t,e,n){const r=hN(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function ebe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function xy(t){return t instanceof Map}function fN(t){return t instanceof Set}function Xh(t){return t.copy_||t.base_}function w3(t,e){if(xy(t))return new Map(t);if(fN(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=eX(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Js];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const o=i[s],l=r[o];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(r[o]={configurable:!0,writable:!0,enumerable:l.enumerable,value:t[o]})}return Object.create(N0(t),r)}else{const r=N0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function VD(t,e=!1){return mN(t)||mg(t)||!zf(t)||(hN(t)>1&&Object.defineProperties(t,{set:m_,add:m_,clear:m_,delete:m_}),Object.freeze(t),e&&Object.values(t).forEach(n=>VD(n,!0))),t}function tbe(){Jo(2)}var m_={value:tbe};function mN(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var nbe={};function Bf(t){const e=nbe[t];return e||Jo(0,t),e}var M0;function nX(){return M0}function rbe(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function a8(t,e){e&&(Bf("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function S3(t){N3(t),t.drafts_.forEach(ibe),t.drafts_=null}function N3(t){t===M0&&(M0=t.parent_)}function s8(t){return M0=rbe(M0,t)}function ibe(t){const e=t[Js];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function o8(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Js].modified_&&(S3(e),Jo(4)),zf(t)&&(t=$w(e,t),e.parent_||Hw(e,t)),e.patches_&&Bf("Patches").generateReplacementPatches_(n[Js].base_,t,e.patches_,e.inversePatches_)):t=$w(e,n,[]),S3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==JK?t:void 0}function $w(t,e,n){if(mN(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Js];if(!i)return Bw(e,(s,o)=>l8(t,i,e,s,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return Hw(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const s=i.copy_;let o=s,l=!1;i.type_===3&&(o=new Set(s),s.clear(),l=!0),Bw(o,(c,u)=>l8(t,i,s,c,u,n,l),r),Hw(t,s,!1),n&&t.patches_&&Bf("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function l8(t,e,n,r,i,s,o){if(i==null||typeof i!="object"&&!o)return;const l=mN(i);if(!(l&&!o)){if(mg(i)){const c=s&&e&&e.type_!==3&&!_3(e.assigned_,r)?s.concat(r):void 0,u=$w(t,i,c);if(tX(n,r,u),mg(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(zf(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;$w(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(xy(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&Hw(t,i)}}}function Hw(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&VD(e,n)}function abe(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:nX(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,s=GD;n&&(i=[r],s=E0);const{revoke:o,proxy:l}=Proxy.revocable(i,s);return r.draft_=l,r.revoke_=o,l}var GD={get(t,e){if(e===Js)return t;const n=Xh(t);if(!_3(n,e))return sbe(t,n,e);const r=n[e];return t.finalized_||!zf(r)?r:r===UC(t.base_,e)?(zC(t),t.copy_[e]=E3(r,t)):r},has(t,e){return e in Xh(t)},ownKeys(t){return Reflect.ownKeys(Xh(t))},set(t,e,n){const r=rX(Xh(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=UC(Xh(t),e),s=i?.[Js];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(ebe(n,i)&&(n!==void 0||_3(t.base_,e)))return!0;zC(t),M3(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 UC(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,zC(t),M3(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Xh(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Jo(11)},getPrototypeOf(t){return N0(t.base_)},setPrototypeOf(){Jo(12)}},E0={};Bw(GD,(t,e)=>{E0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});E0.deleteProperty=function(t,e){return E0.set.call(this,t,e,void 0)};E0.set=function(t,e,n){return GD.set.call(this,t[0],e,n,t[0])};function UC(t,e){const n=t[Js];return(n?Xh(n):t)[e]}function sbe(t,e,n){const r=rX(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function rX(t,e){if(!(e in t))return;let n=N0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=N0(n)}}function M3(t){t.modified_||(t.modified_=!0,t.parent_&&M3(t.parent_))}function zC(t){t.copy_||(t.copy_=w3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var obe=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,n,r)=>{if(typeof e=="function"&&typeof n!="function"){const s=n;n=e;const o=this;return function(c=s,...u){return o.produce(c,d=>n.call(this,d,...u))}}typeof n!="function"&&Jo(6),r!==void 0&&typeof r!="function"&&Jo(7);let i;if(zf(e)){const s=s8(this),o=E3(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?S3(s):N3(s)}return a8(s,r),o8(i,s)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===JK&&(i=void 0),this.autoFreeze_&&VD(i,!0),r){const s=[],o=[];Bf("Patches").generateReplacementPatches_(e,i,s,o),r(s,o)}return i}else Jo(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(o,...l)=>this.produceWithPatches(o,c=>e(c,...l));let r,i;return[this.produce(e,n,(o,l)=>{r=o,i=l}),r,i]},typeof t?.autoFreeze=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof t?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),typeof t?.useStrictIteration=="boolean"&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){zf(t)||Jo(8),mg(t)&&(t=lbe(t));const e=s8(this),n=E3(t,void 0);return n[Js].isManual_=!0,N3(e),n}finishDraft(t,e){const n=t&&t[Js];(!n||!n.isManual_)&&Jo(9);const{scope_:r}=n;return a8(r,e),o8(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=Bf("Patches").applyPatches_;return mg(t)?r(t,e):this.produce(t,i=>r(i,e))}};function E3(t,e){const n=xy(t)?Bf("MapSet").proxyMap_(t,e):fN(t)?Bf("MapSet").proxySet_(t,e):abe(t,e);return(e?e.scope_:nX()).drafts_.push(n),n}function lbe(t){return mg(t)||Jo(10,t),iX(t)}function iX(t){if(!zf(t)||mN(t))return t;const e=t[Js];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=w3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=w3(t,!0);return Bw(n,(i,s)=>{tX(n,i,iX(s))},r),e&&(e.finalized_=!1),n}var cbe=new obe;cbe.produce;var ube={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},aX=Ts({name:"legend",initialState:ube,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:Ur()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=sl(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:Ur()},removeLegendPayload:{reducer(t,e){var n=sl(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:Ur()}}}),{setLegendSize:c8,setLegendSettings:dbe,addLegendPayload:sX,replaceLegendPayload:oX,removeLegendPayload:lX}=aX.actions,hbe=aX.reducer,fbe=["contextPayload"];function T3(){return T3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},T3.apply(null,arguments)}function u8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function pg(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){mbe(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 mbe(t,e,n){return(e=pbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pbe(t){var e=gbe(t,"string");return typeof e=="symbol"?e:e+""}function gbe(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=bbe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function 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){return t.value}function vbe(t){var{contextPayload:e}=t,n=xbe(t,fbe),r=aK(e,t.payloadUniqBy,ybe),i=pg(pg({},n),{},{payload:r});return w.isValidElement(t.content)?w.cloneElement(t.content,i):typeof t.content=="function"?w.createElement(t.content,i):w.createElement(fpe,i)}function _be(t,e,n,r,i,s){var{layout:o,align:l,verticalAlign:c}=e,u,d;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(l==="center"&&o==="vertical"?u={left:((r||0)-s.width)/2}:u=l==="right"?{right:n&&n.right||0}:{left:n&&n.left||0}),(!t||(t.top===void 0||t.top===null)&&(t.bottom===void 0||t.bottom===null))&&(c==="middle"?d={top:((i||0)-s.height)/2}:d=c==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),pg(pg({},u),d)}function wbe(t){var e=Er();return w.useEffect(()=>{e(dbe(t))},[e,t]),null}function Sbe(t){var e=Er();return w.useEffect(()=>(e(c8(t)),()=>{e(c8({width:0,height:0}))}),[e,t]),null}function Nbe(t,e,n,r){return t==="vertical"&&Ut(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var Mbe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function qD(t){var e=Xr(t,Mbe),n=ige(),r=ame(),i=Yxe(),{width:s,height:o,wrapperStyle:l,portal:c}=e,[u,d]=dK([n]),f=$D(),m=HD();if(f==null||m==null)return null;var g=f-(i?.left||0)-(i?.right||0),x=Nbe(e.layout,o,s,g),y=c?l:pg(pg({position:"absolute",width:x?.width||s||"auto",height:x?.height||o||"auto"},_be(l,e,i,f,m,u)),l),b=c??r;if(b==null||n==null)return null;var v=w.createElement("div",{className:"recharts-legend-wrapper",style:y,ref:d},w.createElement(wbe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&w.createElement(Sbe,{width:u.width,height:u.height}),w.createElement(vbe,T3({},e,x,{margin:i,chartWidth:f,chartHeight:m,contextPayload:n})));return Vc.createPortal(v,b)}qD.displayName="Legend";function C3(){return C3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},C3.apply(null,arguments)}function d8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function BC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?d8(Object(n),!0).forEach(function(r){Ebe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):d8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ebe(t,e,n){return(e=Tbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Tbe(t){var e=Cbe(t,"string");return typeof e=="symbol"?e:e+""}function Cbe(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 Abe(t){return Array.isArray(t)&&Lo(t[0])&&Lo(t[1])?t.join(" ~ "):t}var kbe=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:s,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:m=!1}=t,g=()=>{if(s&&s.length){var E={padding:0,margin:0},k=(l?Z2(s,l):s).map((C,D)=>{if(C.type==="none")return null;var A=C.formatter||o||Abe,{value:R,name:F}=C,O=R,q=F;if(A){var j=A(R,F,C,D,s);if(Array.isArray(j))[O,q]=j;else if(j!=null)O=j;else return null}var G=BC({display:"block",paddingTop:4,paddingBottom:4,color:C.color||"#000"},r);return w.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(D),style:G},Lo(q)?w.createElement("span",{className:"recharts-tooltip-item-name"},q):null,Lo(q)?w.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,w.createElement("span",{className:"recharts-tooltip-item-value"},O),w.createElement("span",{className:"recharts-tooltip-item-unit"},C.unit||""))});return w.createElement("ul",{className:"recharts-tooltip-item-list",style:E},k)}return null},x=BC({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),y=BC({margin:0},i),b=!Ir(d),v=b?d:"",N=Vn("recharts-default-tooltip",c),S=Vn("recharts-tooltip-label",u);b&&f&&s!==void 0&&s!==null&&(v=f(d,s));var T=m?{role:"status","aria-live":"assertive"}:{};return w.createElement("div",C3({className:N,style:x},T),w.createElement("p",{className:S,style:y},w.isValidElement(v)?v:"".concat(v)),g())},tb="recharts-tooltip-wrapper",jbe={visibility:"hidden"};function Pbe(t){var{coordinate:e,translateX:n,translateY:r}=t;return Vn(tb,{["".concat(tb,"-right")]:Ut(n)&&e&&Ut(e.x)&&n>=e.x,["".concat(tb,"-left")]:Ut(n)&&e&&Ut(e.x)&&n<e.x,["".concat(tb,"-bottom")]:Ut(r)&&e&&Ut(e.y)&&r>=e.y,["".concat(tb,"-top")]:Ut(r)&&e&&Ut(e.y)&&r<e.y})}function h8(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:s,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(s&&Ut(s[r]))return s[r];var d=n[r]-l-(i>0?i:0),f=n[r]+i;if(e[r])return o[r]?d:f;var m=c[r];if(m==null)return 0;if(o[r]){var g=d,x=m;return g<x?Math.max(f,m):Math.max(d,m)}if(u==null)return 0;var y=f+l,b=m+u;return y>b?Math.max(d,m):Math.max(f,m)}function Rbe(t){var{translateX:e,translateY:n,useTranslate3d:r}=t;return{transform:r?"translate3d(".concat(e,"px, ").concat(n,"px, 0)"):"translate(".concat(e,"px, ").concat(n,"px)")}}function Dbe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:s,tooltipBox:o,useTranslate3d:l,viewBox:c}=t,u,d,f;return o.height>0&&o.width>0&&n?(d=h8({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),f=h8({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),u=Rbe({translateX:d,translateY:f,useTranslate3d:l})):u=jbe,{cssProperties:u,cssClasses:Pbe({translateX:d,translateY:f,coordinate:n})}}function f8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function p_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?f8(Object(n),!0).forEach(function(r){A3(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):f8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function A3(t,e,n){return(e=Obe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Obe(t){var e=Lbe(t,"string");return typeof e=="symbol"?e:e+""}function Lbe(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 Ibe extends w.PureComponent{constructor(){super(...arguments),A3(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),A3(this,"handleKeyDown",e=>{if(e.key==="Escape"){var n,r,i,s;this.setState({dismissed:!0,dismissedAtCoordinate:{x:(n=(r=this.props.coordinate)===null||r===void 0?void 0:r.x)!==null&&n!==void 0?n:0,y:(i=(s=this.props.coordinate)===null||s===void 0?void 0:s.y)!==null&&i!==void 0?i:0}})}})}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}componentDidUpdate(){var e,n;this.state.dismissed&&(((e=this.props.coordinate)===null||e===void 0?void 0:e.x)!==this.state.dismissedAtCoordinate.x||((n=this.props.coordinate)===null||n===void 0?void 0:n.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:e,allowEscapeViewBox:n,animationDuration:r,animationEasing:i,children:s,coordinate:o,hasPayload:l,isAnimationActive:c,offset:u,position:d,reverseDirection:f,useTranslate3d:m,viewBox:g,wrapperStyle:x,lastBoundingBox:y,innerRef:b,hasPortalFromProps:v}=this.props,{cssClasses:N,cssProperties:S}=Dbe({allowEscapeViewBox:n,coordinate:o,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:y.height,width:y.width},useTranslate3d:m,viewBox:g}),T=v?{}:p_(p_({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},S),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&l?"visible":"hidden",position:"absolute",top:0,left:0}),E=p_(p_({},T),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},x);return w.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:N,style:E,ref:b},s)}}var cX=()=>{var t;return(t=It(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function k3(){return k3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},k3.apply(null,arguments)}function m8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function p8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?m8(Object(n),!0).forEach(function(r){Fbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):m8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Fbe(t,e,n){return(e=Ube(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ube(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 g8={curveBasisClosed:Nme,curveBasisOpen:Mme,curveBasis:Sme,curveBumpX:cme,curveBumpY:ume,curveLinearClosed:Eme,curveLinear:Y2,curveMonotoneX:Tme,curveMonotoneY:Cme,curveNatural:Ame,curveStep:kme,curveStepAfter:Pme,curveStepBefore:jme},Vw=t=>cr(t.x)&&cr(t.y),x8=t=>t.base!=null&&Vw(t.base)&&Vw(t),nb=t=>t.x,rb=t=>t.y,Bbe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(cy(t));return(n==="curveMonotone"||n==="curveBump")&&e?g8["".concat(n).concat(e==="vertical"?"Y":"X")]:g8[n]||Y2},$be=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:s=!1}=t,o=Bbe(e,i),l=s?n.filter(Vw):n,c;if(Array.isArray(r)){var u=n.map((g,x)=>p8(p8({},g),{},{base:r[x]}));i==="vertical"?c=o_().y(rb).x1(nb).x0(g=>g.base.x):c=o_().x(nb).y1(rb).y0(g=>g.base.y);var d=c.defined(x8).curve(o),f=s?u.filter(x8):u;return d(f)}i==="vertical"&&Ut(r)?c=o_().y(rb).x1(nb).x0(r):Ut(r)?c=o_().x(nb).y1(rb).y0(r):c=DW().x(nb).y(rb);var m=c.defined(Vw).curve(o);return m(l)},Yp=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var s=n&&n.length?$be(t):r;return w.createElement("path",k3({},Ja(t),AD(t),{className:Vn("recharts-curve",e),d:s===null?void 0:s,ref:i}))},Hbe=["x","y","top","left","width","height","className"];function j3(){return j3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},j3.apply(null,arguments)}function b8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Vbe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?b8(Object(n),!0).forEach(function(r){Gbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):b8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Gbe(t,e,n){return(e=qbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qbe(t){var e=Wbe(t,"string");return typeof e=="symbol"?e:e+""}function Wbe(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 Kbe(t,e){if(t==null)return{};var n,r,i=Xbe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Xbe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var Ybe=(t,e,n,r,i,s)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(s,",").concat(e,"h").concat(n),Qbe=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:s=0,height:o=0,className:l}=t,c=Kbe(t,Hbe),u=Vbe({x:e,y:n,top:r,left:i,width:s,height:o},c);return!Ut(e)||!Ut(n)||!Ut(s)||!Ut(o)||!Ut(r)||!Ut(i)?null:w.createElement("path",j3({},Ea(u),{className:Vn("recharts-cross",l),d:Ybe(e,n,s,o,r,i)}))};function Zbe(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 y8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function v8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?y8(Object(n),!0).forEach(function(r){Jbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Jbe(t,e,n){return(e=e0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function e0e(t){var e=t0e(t,"string");return typeof e=="symbol"?e:e+""}function t0e(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 n0e=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),uX=(t,e,n)=>t.map(r=>"".concat(n0e(r)," ").concat(e,"ms ").concat(n)).join(","),r0e=(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)=>v8(v8({},n),{},{[r]:t(r,e[r])}),{});function _8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ri(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?_8(Object(n),!0).forEach(function(r){i0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function i0e(t,e,n){return(e=a0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a0e(t){var e=s0e(t,"string");return typeof e=="symbol"?e:e+""}function s0e(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 Gw=(t,e,n)=>t+(e-t)*n,P3=t=>{var{from:e,to:n}=t;return e!==n},dX=(t,e,n)=>{var r=T0((i,s)=>{if(P3(s)){var[o,l]=t(s.from,s.to,s.velocity);return Ri(Ri({},s),{},{from:o,velocity:l})}return s},e);return n<1?T0((i,s)=>P3(s)?Ri(Ri({},s),{},{velocity:Gw(s.velocity,r[i].velocity,n),from:Gw(s.from,r[i].from,n)}):s,e):dX(t,r,n-1)};function o0e(t,e,n,r,i,s){var o,l=r.reduce((m,g)=>Ri(Ri({},m),{},{[g]:{from:t[g],velocity:0,to:e[g]}}),{}),c=()=>T0((m,g)=>g.from,l),u=()=>!Object.values(l).filter(P3).length,d=null,f=m=>{o||(o=m);var g=m-o,x=g/n.dt;l=dX(n,l,x),i(Ri(Ri(Ri({},t),e),c())),o=m,u()||(d=s.setTimeout(f))};return()=>(d=s.setTimeout(f),()=>{var m;(m=d)===null||m===void 0||m()})}function l0e(t,e,n,r,i,s,o){var l=null,c=i.reduce((f,m)=>Ri(Ri({},f),{},{[m]:[t[m],e[m]]}),{}),u,d=f=>{u||(u=f);var m=(f-u)/r,g=T0((y,b)=>Gw(...b,n(m)),c);if(s(Ri(Ri(Ri({},t),e),g)),m<1)l=o.setTimeout(d);else{var x=T0((y,b)=>Gw(...b,n(1)),c);s(Ri(Ri(Ri({},t),e),x))}};return()=>(l=o.setTimeout(d),()=>{var f;(f=l)===null||f===void 0||f()})}const c0e=(t,e,n,r,i,s)=>{var o=r0e(t,e);return n==null?()=>(i(Ri(Ri({},t),e)),()=>{}):n.isStepper===!0?o0e(t,e,n,o,i,s):l0e(t,e,n,r,o,i,s)};var qw=1e-4,hX=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],fX=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),w8=(t,e)=>n=>{var r=hX(t,e);return fX(r,n)},u0e=(t,e)=>n=>{var r=hX(t,e),i=[...r.map((s,o)=>s*o).slice(1),0];return fX(i,n)},d0e=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(n.length===1)switch(n[0]){case"linear":return[0,0,1,1];case"ease":return[.25,.1,.25,1];case"ease-in":return[.42,0,1,1];case"ease-out":return[.42,0,.58,1];case"ease-in-out":return[0,0,.58,1];default:{var i,s=n[0].split("(");if(s[0]==="cubic-bezier"&&((i=s[1])===null||i===void 0?void 0:i.split(")")[0].split(",").length)===4){var o=s[1].split(")")[0].split(",").map(l=>parseFloat(l));return[o[0],o[1],o[2],o[3]]}}}return n.length===4?n:[0,0,1,1]},h0e=(t,e,n,r)=>{var i=w8(t,n),s=w8(e,r),o=u0e(t,n),l=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,f=d,m=0;m<8;++m){var g=i(f)-d,x=o(f);if(Math.abs(g-d)<qw||x<qw)return s(f);f=l(f-g/x)}return s(f)};return c.isStepper=!1,c},S8=function(){return h0e(...d0e(...arguments))},f0e=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,s=(o,l,c)=>{var u=-(o-l)*n,d=c*r,f=c+(u-d)*i/1e3,m=c*i/1e3+o;return Math.abs(m-l)<qw&&Math.abs(f)<qw?[l,0]:[m,f]};return s.isStepper=!0,s.dt=i,s},m0e=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return S8(t);case"spring":return f0e();default:if(t.split("(")[0]==="cubic-bezier")return S8(t)}return typeof t=="function"?t:null};function p0e(t){var e,n=()=>null,r=!1,i=null,s=o=>{if(!r){if(Array.isArray(o)){if(!o.length)return;var l=o,[c,...u]=l;if(typeof c=="number"){i=t.setTimeout(s.bind(null,u),c);return}s(c),i=t.setTimeout(s.bind(null,u));return}typeof o=="string"&&(e=o,n(e)),typeof o=="object"&&(e=o,n(e)),typeof o=="function"&&o()}};return{stop:()=>{r=!0},start:o=>{r=!1,i&&(i(),i=null),s(o)},subscribe:o=>(n=o,()=>{n=()=>null}),getTimeoutController:()=>t}}class g0e{setTimeout(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,s=o=>{o-r>=n?e(o):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(s))};return i=requestAnimationFrame(s),()=>{i!=null&&cancelAnimationFrame(i)}}}function x0e(){return p0e(new g0e)}var b0e=w.createContext(x0e);function y0e(t,e){var n=w.useContext(b0e);return w.useMemo(()=>e??n(t),[t,e,n])}var v0e=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Hg={devToolsEnabled:!1,isSsr:v0e()},_0e={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},N8={t:0},$C={t:1};function Vg(t){var e=Xr(t,_0e),{isActive:n,canBegin:r,duration:i,easing:s,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!Hg.isSsr:n,f=y0e(e.animationId,e.animationManager),[m,g]=w.useState(d?N8:$C),x=w.useRef(null);return w.useEffect(()=>{d||g($C)},[d]),w.useEffect(()=>{if(!d||!r)return uy;var y=c0e(N8,$C,m0e(s),i,g,f.getTimeoutController()),b=()=>{x.current=y()};return f.start([c,o,b,i,l]),()=>{f.stop(),x.current&&x.current(),l()}},[d,r,i,s,o,c,l,f]),u(m.t)}function Gg(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=w.useRef(v0(e)),r=w.useRef(t);return r.current!==t&&(n.current=v0(e),r.current=t),n.current}var w0e=["radius"],S0e=["radius"];function M8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function E8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?M8(Object(n),!0).forEach(function(r){N0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):M8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function N0e(t,e,n){return(e=M0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function M0e(t){var e=E0e(t,"string");return typeof e=="symbol"?e:e+""}function E0e(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 Ww(){return Ww=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},Ww.apply(null,arguments)}function T8(t,e){if(t==null)return{};var n,r,i=T0e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function T0e(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 C8=(t,e,n,r,i)=>{var s=Math.min(Math.abs(n)/2,Math.abs(r)/2),o=r>=0?1:-1,l=n>=0?1:-1,c=r>=0&&n>=0||r<0&&n<0?1:0,u;if(s>0&&i instanceof Array){for(var d=[0,0,0,0],f=0,m=4;f<m;f++)d[f]=i[f]>s?s:i[f];u="M".concat(t,",").concat(e+o*d[0]),d[0]>0&&(u+="A ".concat(d[0],",").concat(d[0],",0,0,").concat(c,",").concat(t+l*d[0],",").concat(e)),u+="L ".concat(t+n-l*d[1],",").concat(e),d[1]>0&&(u+="A ".concat(d[1],",").concat(d[1],",0,0,").concat(c,`,
- `).concat(t+n,",").concat(e+o*d[1])),u+="L ".concat(t+n,",").concat(e+r-o*d[2]),d[2]>0&&(u+="A ".concat(d[2],",").concat(d[2],",0,0,").concat(c,`,
- `).concat(t+n-l*d[2],",").concat(e+r)),u+="L ".concat(t+l*d[3],",").concat(e+r),d[3]>0&&(u+="A ".concat(d[3],",").concat(d[3],",0,0,").concat(c,`,
- `).concat(t,",").concat(e+r-o*d[3])),u+="Z"}else if(s>0&&i===+i&&i>0){var g=Math.min(s,i);u="M ".concat(t,",").concat(e+o*g,`
- A `).concat(g,",").concat(g,",0,0,").concat(c,",").concat(t+l*g,",").concat(e,`
- L `).concat(t+n-l*g,",").concat(e,`
- A `).concat(g,",").concat(g,",0,0,").concat(c,",").concat(t+n,",").concat(e+o*g,`
- L `).concat(t+n,",").concat(e+r-o*g,`
- A `).concat(g,",").concat(g,",0,0,").concat(c,",").concat(t+n-l*g,",").concat(e+r,`
- L `).concat(t+l*g,",").concat(e+r,`
- A `).concat(g,",").concat(g,",0,0,").concat(c,",").concat(t,",").concat(e+r-o*g," Z")}else u="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return u},A8={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},mX=t=>{var e=Xr(t,A8),n=w.useRef(null),[r,i]=w.useState(-1);w.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var K=n.current.getTotalLength();K&&i(K)}catch{}},[]);var{x:s,y:o,width:l,height:c,radius:u,className:d}=e,{animationEasing:f,animationDuration:m,animationBegin:g,isAnimationActive:x,isUpdateAnimationActive:y}=e,b=w.useRef(l),v=w.useRef(c),N=w.useRef(s),S=w.useRef(o),T=w.useMemo(()=>({x:s,y:o,width:l,height:c,radius:u}),[s,o,l,c,u]),E=Gg(T,"rectangle-");if(s!==+s||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var k=Vn("recharts-rectangle",d);if(!y){var C=Ea(e),{radius:D}=C,A=T8(C,w0e);return w.createElement("path",Ww({},A,{radius:typeof u=="number"?u:void 0,className:k,d:C8(s,o,l,c,u)}))}var R=b.current,F=v.current,O=N.current,q=S.current,j="0px ".concat(r===-1?1:r,"px"),G="".concat(r,"px 0px"),Y=uX(["strokeDasharray"],m,typeof f=="string"?f:A8.animationEasing);return w.createElement(Vg,{animationId:E,key:E,canBegin:r>0,duration:m,easing:f,isActive:y,begin:g},K=>{var Z=nr(R,l,K),te=nr(F,c,K),ne=nr(O,s,K),z=nr(q,o,K);n.current&&(b.current=Z,v.current=te,N.current=ne,S.current=z);var W;x?K>0?W={transition:Y,strokeDasharray:G}:W={strokeDasharray:j}:W={strokeDasharray:G};var se=Ea(e),{radius:ae}=se,de=T8(se,S0e);return w.createElement("path",Ww({},de,{radius:typeof u=="number"?u:void 0,className:k,d:C8(ne,z,Z,te,u),ref:n,style:E8(E8({},W),e.style)}))})};function k8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function j8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?k8(Object(n),!0).forEach(function(r){C0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):k8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function C0e(t,e,n){return(e=A0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function A0e(t){var e=k0e(t,"string");return typeof e=="symbol"?e:e+""}function k0e(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 Kw=Math.PI/180,j0e=t=>t*180/Math.PI,Ni=(t,e,n,r)=>({x:t+Math.cos(-Kw*r)*n,y:e+Math.sin(-Kw*r)*n}),pX=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},P0e=(t,e)=>{var{x:n,y:r}=t,{x:i,y:s}=e;return Math.sqrt((n-i)**2+(r-s)**2)},R0e=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:s}=e,o=P0e({x:n,y:r},{x:i,y:s});if(o<=0)return{radius:o,angle:0};var l=(n-i)/o,c=Math.acos(l);return r>s&&(c=2*Math.PI-c),{radius:o,angle:j0e(c),angleInRadian:c}},D0e=t=>{var{startAngle:e,endAngle:n}=t,r=Math.floor(e/360),i=Math.floor(n/360),s=Math.min(r,i);return{startAngle:e-s*360,endAngle:n-s*360}},O0e=(t,e)=>{var{startAngle:n,endAngle:r}=e,i=Math.floor(n/360),s=Math.floor(r/360),o=Math.min(i,s);return t+o*360},L0e=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:s}=R0e({x:n,y:r},e),{innerRadius:o,outerRadius:l}=e;if(i<o||i>l||i===0)return null;var{startAngle:c,endAngle:u}=D0e(e),d=s,f;if(c<=u){for(;d>u;)d-=360;for(;d<c;)d+=360;f=d>=c&&d<=u}else{for(;d>c;)d-=360;for(;d<u;)d+=360;f=d>=u&&d<=c}return f?j8(j8({},e),{},{radius:i,angle:O0e(d,e)}):null};function gX(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:s}=t,o=Ni(e,n,r,i),l=Ni(e,n,r,s);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:s}}function R3(){return R3=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},R3.apply(null,arguments)}var I0e=(t,e)=>{var n=ra(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},g_=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:s,isExternal:o,cornerRadius:l,cornerIsExternal:c}=t,u=l*(o?1:-1)+r,d=Math.asin(l/u)/Kw,f=c?i:i+s*d,m=Ni(e,n,u,f),g=Ni(e,n,r,f),x=c?i-s*d:i,y=Ni(e,n,u*Math.cos(d*Kw),x);return{center:m,circleTangency:g,lineTangency:y,theta:d}},xX=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:s,endAngle:o}=t,l=I0e(s,o),c=s+l,u=Ni(e,n,i,s),d=Ni(e,n,i,c),f="M ".concat(u.x,",").concat(u.y,`
- A `).concat(i,",").concat(i,`,0,
- `).concat(+(Math.abs(l)>180),",").concat(+(s>c),`,
- `).concat(d.x,",").concat(d.y,`
- `);if(r>0){var m=Ni(e,n,r,s),g=Ni(e,n,r,c);f+="L ".concat(g.x,",").concat(g.y,`
- A `).concat(r,",").concat(r,`,0,
- `).concat(+(Math.abs(l)>180),",").concat(+(s<=c),`,
- `).concat(m.x,",").concat(m.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},F0e=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:s,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=ra(u-c),{circleTangency:f,lineTangency:m,theta:g}=g_({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:s,cornerIsExternal:l}),{circleTangency:x,lineTangency:y,theta:b}=g_({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:s,cornerIsExternal:l}),v=l?Math.abs(c-u):Math.abs(c-u)-g-b;if(v<0)return o?"M ".concat(m.x,",").concat(m.y,`
- a`).concat(s,",").concat(s,",0,0,1,").concat(s*2,`,0
- a`).concat(s,",").concat(s,",0,0,1,").concat(-s*2,`,0
- `):xX({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var N="M ".concat(m.x,",").concat(m.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(f.x,",").concat(f.y,`
- A`).concat(i,",").concat(i,",0,").concat(+(v>180),",").concat(+(d<0),",").concat(x.x,",").concat(x.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(y.x,",").concat(y.y,`
- `);if(r>0){var{circleTangency:S,lineTangency:T,theta:E}=g_({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:s,cornerIsExternal:l}),{circleTangency:k,lineTangency:C,theta:D}=g_({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:s,cornerIsExternal:l}),A=l?Math.abs(c-u):Math.abs(c-u)-E-D;if(A<0&&s===0)return"".concat(N,"L").concat(e,",").concat(n,"Z");N+="L".concat(C.x,",").concat(C.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(k.x,",").concat(k.y,`
- A`).concat(r,",").concat(r,",0,").concat(+(A>180),",").concat(+(d>0),",").concat(S.x,",").concat(S.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(T.x,",").concat(T.y,"Z")}else N+="L".concat(e,",").concat(n,"Z");return N},U0e={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},bX=t=>{var e=Xr(t,U0e),{cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:o,forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d,className:f}=e;if(s<i||u===d)return null;var m=Vn("recharts-sector",f),g=s-i,x=Fa(o,g,0,!0),y;return x>0&&Math.abs(u-d)<360?y=F0e({cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:Math.min(x,g/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):y=xX({cx:n,cy:r,innerRadius:i,outerRadius:s,startAngle:u,endAngle:d}),w.createElement("path",R3({},Ea(e),{className:m,d:y}))};function z0e(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(XW(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:s,outerRadius:o,angle:l}=e,c=Ni(r,i,s,l),u=Ni(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return gX(e)}}var HC={},VC={},GC={},P8;function B0e(){return P8||(P8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lK();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(GC)),GC}var R8;function $0e(){return R8||(R8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=B0e();function n(r){return r?(r=e.toNumber(r),r===1/0||r===-1/0?(r<0?-1:1)*Number.MAX_VALUE:r===r?r:0):r===0?r:0}t.toFinite=n})(VC)),VC}var D8;function H0e(){return D8||(D8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=cK(),n=$0e();function r(i,s,o){o&&typeof o!="number"&&e.isIterateeCall(i,s,o)&&(s=o=void 0),i=n.toFinite(i),s===void 0?(s=i,i=0):s=n.toFinite(s),o=o===void 0?i<s?1:-1:n.toFinite(o);const l=Math.max(Math.ceil((s-i)/(o||1)),0),c=new Array(l);for(let u=0;u<l;u++)c[u]=i,i+=o;return c}t.range=r})(HC)),HC}var qC,O8;function V0e(){return O8||(O8=1,qC=H0e().range),qC}var G0e=V0e();const yX=Uo(G0e);function Od(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function q0e(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function WD(t){let e,n,r;t.length!==2?(e=Od,n=(l,c)=>Od(t(l),c),r=(l,c)=>t(l)-c):(e=t===Od||t===q0e?t:W0e,n=t,r=t);function i(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(l[f],c)<0?u=f+1:d=f}while(u<d)}return u}function s(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(l[f],c)<=0?u=f+1:d=f}while(u<d)}return u}function o(l,c,u=0,d=l.length){const f=i(l,c,u,d-1);return f>u&&r(l[f-1],c)>-r(l[f],c)?f-1:f}return{left:i,center:o,right:s}}function W0e(){return 0}function vX(t){return t===null?NaN:+t}function*K0e(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const X0e=WD(Od),by=X0e.right;WD(vX).center;class L8 extends Map{constructor(e,n=Z0e){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(I8(this,e))}has(e){return super.has(I8(this,e))}set(e,n){return super.set(Y0e(this,e),n)}delete(e){return super.delete(Q0e(this,e))}}function I8({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function Y0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function Q0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function Z0e(t){return t!==null&&typeof t=="object"?t.valueOf():t}function J0e(t=Od){if(t===Od)return _X;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 _X(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const eye=Math.sqrt(50),tye=Math.sqrt(10),nye=Math.sqrt(2);function Xw(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),s=r/Math.pow(10,i),o=s>=eye?10:s>=tye?5:s>=nye?2:1;let l,c,u;return i<0?(u=Math.pow(10,-i)/o,l=Math.round(t*u),c=Math.round(e*u),l/u<t&&++l,c/u>e&&--c,u=-u):(u=Math.pow(10,i)*o,l=Math.round(t/u),c=Math.round(e/u),l*u<t&&++l,c*u>e&&--c),c<l&&.5<=n&&n<2?Xw(t,e,n*2):[l,c,u]}function D3(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,s,o]=r?Xw(e,t,n):Xw(t,e,n);if(!(s>=i))return[];const l=s-i+1,c=new Array(l);if(r)if(o<0)for(let u=0;u<l;++u)c[u]=(s-u)/-o;else for(let u=0;u<l;++u)c[u]=(s-u)*o;else if(o<0)for(let u=0;u<l;++u)c[u]=(i+u)/-o;else for(let u=0;u<l;++u)c[u]=(i+u)*o;return c}function O3(t,e,n){return e=+e,t=+t,n=+n,Xw(t,e,n)[2]}function L3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?O3(e,t,n):O3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function F8(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function U8(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function wX(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?_X:J0e(i);r>n;){if(r-n>600){const c=r-n+1,u=e-n+1,d=Math.log(c),f=.5*Math.exp(2*d/3),m=.5*Math.sqrt(d*f*(c-f)/c)*(u-c/2<0?-1:1),g=Math.max(n,Math.floor(e-u*f/c+m)),x=Math.min(r,Math.floor(e+(c-u)*f/c+m));wX(t,e,g,x,i)}const s=t[e];let o=n,l=r;for(ib(t,n,e),i(t[r],s)>0&&ib(t,n,r);o<l;){for(ib(t,o,l),++o,--l;i(t[o],s)<0;)++o;for(;i(t[l],s)>0;)--l}i(t[n],s)===0?ib(t,n,l):(++l,ib(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function ib(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function rye(t,e,n){if(t=Float64Array.from(K0e(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return U8(t);if(e>=1)return F8(t);var r,i=(r-1)*e,s=Math.floor(i),o=F8(wX(t,s).subarray(0,s+1)),l=U8(t.subarray(s+1));return o+(l-o)*(i-s)}}function iye(t,e,n=vX){if(!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return+n(t[0],0,t);if(e>=1)return+n(t[r-1],r-1,t);var r,i=(r-1)*e,s=Math.floor(i),o=+n(t[s],s,t),l=+n(t[s+1],s+1,t);return o+(l-o)*(i-s)}}function aye(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((e-t)/n))|0,s=new Array(i);++r<i;)s[r]=t+r*n;return s}function Bo(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function wu(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 I3=Symbol("implicit");function KD(){var t=new L8,e=[],n=[],r=I3;function i(s){let o=t.get(s);if(o===void 0){if(r!==I3)return r;t.set(s,o=e.push(s)-1)}return n[o%n.length]}return i.domain=function(s){if(!arguments.length)return e.slice();e=[],t=new L8;for(const o of s)t.has(o)||t.set(o,e.push(o)-1);return i},i.range=function(s){return arguments.length?(n=Array.from(s),i):n.slice()},i.unknown=function(s){return arguments.length?(r=s,i):r},i.copy=function(){return KD(e,n).unknown(r)},Bo.apply(i,arguments),i}function XD(){var t=KD().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,s,o,l=!1,c=0,u=0,d=.5;delete t.unknown;function f(){var m=e().length,g=i<r,x=g?i:r,y=g?r:i;s=(y-x)/Math.max(1,m-c+u*2),l&&(s=Math.floor(s)),x+=(y-x-s*(m-c))*d,o=s*(1-c),l&&(x=Math.round(x),o=Math.round(o));var b=aye(m).map(function(v){return x+s*v});return n(g?b.reverse():b)}return t.domain=function(m){return arguments.length?(e(m),f()):e()},t.range=function(m){return arguments.length?([r,i]=m,r=+r,i=+i,f()):[r,i]},t.rangeRound=function(m){return[r,i]=m,r=+r,i=+i,l=!0,f()},t.bandwidth=function(){return o},t.step=function(){return s},t.round=function(m){return arguments.length?(l=!!m,f()):l},t.padding=function(m){return arguments.length?(c=Math.min(1,u=+m),f()):c},t.paddingInner=function(m){return arguments.length?(c=Math.min(1,m),f()):c},t.paddingOuter=function(m){return arguments.length?(u=+m,f()):u},t.align=function(m){return arguments.length?(d=Math.max(0,Math.min(1,m)),f()):d},t.copy=function(){return XD(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},Bo.apply(f(),arguments)}function SX(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return SX(e())},t}function sye(){return SX(XD.apply(null,arguments).paddingInner(1))}function YD(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function NX(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function yy(){}var C0=.7,Yw=1/C0,Qp="\\s*([+-]?\\d+)\\s*",A0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ll="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",oye=/^#([0-9a-f]{3,8})$/,lye=new RegExp(`^rgb\\(${Qp},${Qp},${Qp}\\)$`),cye=new RegExp(`^rgb\\(${Ll},${Ll},${Ll}\\)$`),uye=new RegExp(`^rgba\\(${Qp},${Qp},${Qp},${A0}\\)$`),dye=new RegExp(`^rgba\\(${Ll},${Ll},${Ll},${A0}\\)$`),hye=new RegExp(`^hsl\\(${A0},${Ll},${Ll}\\)$`),fye=new RegExp(`^hsla\\(${A0},${Ll},${Ll},${A0}\\)$`),z8={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};YD(yy,k0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:B8,formatHex:B8,formatHex8:mye,formatHsl:pye,formatRgb:$8,toString:$8});function B8(){return this.rgb().formatHex()}function mye(){return this.rgb().formatHex8()}function pye(){return MX(this).formatHsl()}function $8(){return this.rgb().formatRgb()}function k0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=oye.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?H8(e):n===3?new ys(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?x_(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?x_(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=lye.exec(t))?new ys(e[1],e[2],e[3],1):(e=cye.exec(t))?new ys(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=uye.exec(t))?x_(e[1],e[2],e[3],e[4]):(e=dye.exec(t))?x_(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=hye.exec(t))?q8(e[1],e[2]/100,e[3]/100,1):(e=fye.exec(t))?q8(e[1],e[2]/100,e[3]/100,e[4]):z8.hasOwnProperty(t)?H8(z8[t]):t==="transparent"?new ys(NaN,NaN,NaN,0):null}function H8(t){return new ys(t>>16&255,t>>8&255,t&255,1)}function x_(t,e,n,r){return r<=0&&(t=e=n=NaN),new ys(t,e,n,r)}function gye(t){return t instanceof yy||(t=k0(t)),t?(t=t.rgb(),new ys(t.r,t.g,t.b,t.opacity)):new ys}function F3(t,e,n,r){return arguments.length===1?gye(t):new ys(t,e,n,r??1)}function ys(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}YD(ys,F3,NX(yy,{brighter(t){return t=t==null?Yw:Math.pow(Yw,t),new ys(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?C0:Math.pow(C0,t),new ys(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new ys(vf(this.r),vf(this.g),vf(this.b),Qw(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:V8,formatHex:V8,formatHex8:xye,formatRgb:G8,toString:G8}));function V8(){return`#${lf(this.r)}${lf(this.g)}${lf(this.b)}`}function xye(){return`#${lf(this.r)}${lf(this.g)}${lf(this.b)}${lf((isNaN(this.opacity)?1:this.opacity)*255)}`}function G8(){const t=Qw(this.opacity);return`${t===1?"rgb(":"rgba("}${vf(this.r)}, ${vf(this.g)}, ${vf(this.b)}${t===1?")":`, ${t})`}`}function Qw(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 lf(t){return t=vf(t),(t<16?"0":"")+t.toString(16)}function q8(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new el(t,e,n,r)}function MX(t){if(t instanceof el)return new el(t.h,t.s,t.l,t.opacity);if(t instanceof yy||(t=k0(t)),!t)return new el;if(t instanceof el)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),s=Math.max(e,n,r),o=NaN,l=s-i,c=(s+i)/2;return l?(e===s?o=(n-r)/l+(n<r)*6:n===s?o=(r-e)/l+2:o=(e-n)/l+4,l/=c<.5?s+i:2-s-i,o*=60):l=c>0&&c<1?0:o,new el(o,l,c,t.opacity)}function bye(t,e,n,r){return arguments.length===1?MX(t):new el(t,e,n,r??1)}function el(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}YD(el,bye,NX(yy,{brighter(t){return t=t==null?Yw:Math.pow(Yw,t),new el(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?C0:Math.pow(C0,t),new el(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new ys(WC(t>=240?t-240:t+120,i,r),WC(t,i,r),WC(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new el(W8(this.h),b_(this.s),b_(this.l),Qw(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=Qw(this.opacity);return`${t===1?"hsl(":"hsla("}${W8(this.h)}, ${b_(this.s)*100}%, ${b_(this.l)*100}%${t===1?")":`, ${t})`}`}}));function W8(t){return t=(t||0)%360,t<0?t+360:t}function b_(t){return Math.max(0,Math.min(1,t||0))}function WC(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 QD=t=>()=>t;function yye(t,e){return function(n){return t+n*e}}function vye(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 _ye(t){return(t=+t)==1?EX:function(e,n){return n-e?vye(e,n,t):QD(isNaN(e)?n:e)}}function EX(t,e){var n=e-t;return n?yye(t,n):QD(isNaN(t)?e:t)}const K8=(function t(e){var n=_ye(e);function r(i,s){var o=n((i=F3(i)).r,(s=F3(s)).r),l=n(i.g,s.g),c=n(i.b,s.b),u=EX(i.opacity,s.opacity);return function(d){return i.r=o(d),i.g=l(d),i.b=c(d),i.opacity=u(d),i+""}}return r.gamma=t,r})(1);function wye(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(s){for(i=0;i<n;++i)r[i]=t[i]*(1-s)+e[i]*s;return r}}function Sye(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Nye(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),s=new Array(n),o;for(o=0;o<r;++o)i[o]=qg(t[o],e[o]);for(;o<n;++o)s[o]=e[o];return function(l){for(o=0;o<r;++o)s[o]=i[o](l);return s}}function Mye(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Zw(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Eye(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]=qg(t[i],e[i]):r[i]=e[i];return function(s){for(i in n)r[i]=n[i](s);return r}}var U3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,KC=new RegExp(U3.source,"g");function Tye(t){return function(){return t}}function Cye(t){return function(e){return t(e)+""}}function Aye(t,e){var n=U3.lastIndex=KC.lastIndex=0,r,i,s,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=U3.exec(t))&&(i=KC.exec(e));)(s=i.index)>n&&(s=e.slice(n,s),l[o]?l[o]+=s:l[++o]=s),(r=r[0])===(i=i[0])?l[o]?l[o]+=i:l[++o]=i:(l[++o]=null,c.push({i:o,x:Zw(r,i)})),n=KC.lastIndex;return n<e.length&&(s=e.slice(n),l[o]?l[o]+=s:l[++o]=s),l.length<2?c[0]?Cye(c[0].x):Tye(e):(e=c.length,function(u){for(var d=0,f;d<e;++d)l[(f=c[d]).i]=f.x(u);return l.join("")})}function qg(t,e){var n=typeof e,r;return e==null||n==="boolean"?QD(e):(n==="number"?Zw:n==="string"?(r=k0(e))?(e=r,K8):Aye:e instanceof k0?K8:e instanceof Date?Mye:Sye(e)?wye:Array.isArray(e)?Nye:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Eye:Zw)(t,e)}function ZD(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function kye(t,e){e===void 0&&(e=t,t=qg);for(var n=0,r=e.length-1,i=e[0],s=new Array(r<0?0:r);n<r;)s[n]=t(i,i=e[++n]);return function(o){var l=Math.max(0,Math.min(r-1,Math.floor(o*=r)));return s[l](o-l)}}function jye(t){return function(){return t}}function Jw(t){return+t}var X8=[0,1];function Xa(t){return t}function z3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:jye(isNaN(e)?NaN:.5)}function Pye(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Rye(t,e,n){var r=t[0],i=t[1],s=e[0],o=e[1];return i<r?(r=z3(i,r),s=n(o,s)):(r=z3(r,i),s=n(s,o)),function(l){return s(r(l))}}function Dye(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),s=new Array(r),o=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<r;)i[o]=z3(t[o],t[o+1]),s[o]=n(e[o],e[o+1]);return function(l){var c=by(t,l,1,r)-1;return s[c](i[c](l))}}function vy(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function pN(){var t=X8,e=X8,n=qg,r,i,s,o=Xa,l,c,u;function d(){var m=Math.min(t.length,e.length);return o!==Xa&&(o=Pye(t[0],t[m-1])),l=m>2?Dye:Rye,c=u=null,f}function f(m){return m==null||isNaN(m=+m)?s:(c||(c=l(t.map(r),e,n)))(r(o(m)))}return f.invert=function(m){return o(i((u||(u=l(e,t.map(r),Zw)))(m)))},f.domain=function(m){return arguments.length?(t=Array.from(m,Jw),d()):t.slice()},f.range=function(m){return arguments.length?(e=Array.from(m),d()):e.slice()},f.rangeRound=function(m){return e=Array.from(m),n=ZD,d()},f.clamp=function(m){return arguments.length?(o=m?!0:Xa,d()):o!==Xa},f.interpolate=function(m){return arguments.length?(n=m,d()):n},f.unknown=function(m){return arguments.length?(s=m,f):s},function(m,g){return r=m,i=g,d()}}function JD(){return pN()(Xa,Xa)}function Oye(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function eS(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 gg(t){return t=eS(Math.abs(t)),t?t[1]:NaN}function Lye(t,e){return function(n,r){for(var i=n.length,s=[],o=0,l=t[0],c=0;i>0&&l>0&&(c+l+1>r&&(l=Math.max(1,r-c)),s.push(n.substring(i-=l,i+l)),!((c+=l+1)>r));)l=t[o=(o+1)%t.length];return s.reverse().join(e)}}function Iye(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var Fye=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function j0(t){if(!(e=Fye.exec(t)))throw new Error("invalid format: "+t);var e;return new e4({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]})}j0.prototype=e4.prototype;function e4(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+""}e4.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 Uye(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 TX;function zye(t,e){var n=eS(t,e);if(!n)return t+"";var r=n[0],i=n[1],s=i-(TX=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return s===o?r:s>o?r+new Array(s-o+1).join("0"):s>0?r.slice(0,s)+"."+r.slice(s):"0."+new Array(1-s).join("0")+eS(t,Math.max(0,e+s-1))[0]}function Y8(t,e){var n=eS(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 Q8={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Oye,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)=>Y8(t*100,e),r:Y8,s:zye,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Z8(t){return t}var J8=Array.prototype.map,e6=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Bye(t){var e=t.grouping===void 0||t.thousands===void 0?Z8:Lye(J8.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",s=t.numerals===void 0?Z8:Iye(J8.call(t.numerals,String)),o=t.percent===void 0?"%":t.percent+"",l=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(f){f=j0(f);var m=f.fill,g=f.align,x=f.sign,y=f.symbol,b=f.zero,v=f.width,N=f.comma,S=f.precision,T=f.trim,E=f.type;E==="n"?(N=!0,E="g"):Q8[E]||(S===void 0&&(S=12),T=!0,E="g"),(b||m==="0"&&g==="=")&&(b=!0,m="0",g="=");var k=y==="$"?n:y==="#"&&/[boxX]/.test(E)?"0"+E.toLowerCase():"",C=y==="$"?r:/[%p]/.test(E)?o:"",D=Q8[E],A=/[defgprs%]/.test(E);S=S===void 0?6:/[gprs]/.test(E)?Math.max(1,Math.min(21,S)):Math.max(0,Math.min(20,S));function R(F){var O=k,q=C,j,G,Y;if(E==="c")q=D(F)+q,F="";else{F=+F;var K=F<0||1/F<0;if(F=isNaN(F)?c:D(Math.abs(F),S),T&&(F=Uye(F)),K&&+F==0&&x!=="+"&&(K=!1),O=(K?x==="("?x:l:x==="-"||x==="("?"":x)+O,q=(E==="s"?e6[8+TX/3]:"")+q+(K&&x==="("?")":""),A){for(j=-1,G=F.length;++j<G;)if(Y=F.charCodeAt(j),48>Y||Y>57){q=(Y===46?i+F.slice(j+1):F.slice(j))+q,F=F.slice(0,j);break}}}N&&!b&&(F=e(F,1/0));var Z=O.length+F.length+q.length,te=Z<v?new Array(v-Z+1).join(m):"";switch(N&&b&&(F=e(te+F,te.length?v-q.length:1/0),te=""),g){case"<":F=O+F+q+te;break;case"=":F=O+te+F+q;break;case"^":F=te.slice(0,Z=te.length>>1)+O+F+q+te.slice(Z);break;default:F=te+O+F+q;break}return s(F)}return R.toString=function(){return f+""},R}function d(f,m){var g=u((f=j0(f),f.type="f",f)),x=Math.max(-8,Math.min(8,Math.floor(gg(m)/3)))*3,y=Math.pow(10,-x),b=e6[8+x/3];return function(v){return g(y*v)+b}}return{format:u,formatPrefix:d}}var y_,t4,CX;$ye({thousands:",",grouping:[3],currency:["$",""]});function $ye(t){return y_=Bye(t),t4=y_.format,CX=y_.formatPrefix,y_}function Hye(t){return Math.max(0,-gg(Math.abs(t)))}function Vye(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(gg(e)/3)))*3-gg(Math.abs(t)))}function Gye(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,gg(e)-gg(t))+1}function AX(t,e,n,r){var i=L3(t,e,n),s;switch(r=j0(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(s=Vye(i,o))&&(r.precision=s),CX(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=Gye(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=Hye(i))&&(r.precision=s-(r.type==="%")*2);break}}return t4(r)}function dh(t){var e=t.domain;return t.ticks=function(n){var r=e();return D3(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return AX(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,s=r.length-1,o=r[i],l=r[s],c,u,d=10;for(l<o&&(u=o,o=l,l=u,u=i,i=s,s=u);d-- >0;){if(u=O3(o,l,n),u===c)return r[i]=o,r[s]=l,e(r);if(u>0)o=Math.floor(o/u)*u,l=Math.ceil(l/u)*u;else if(u<0)o=Math.ceil(o*u)/u,l=Math.floor(l*u)/u;else break;c=u}return t},t}function kX(){var t=JD();return t.copy=function(){return vy(t,kX())},Bo.apply(t,arguments),dh(t)}function jX(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,Jw),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return jX(t).unknown(e)},t=arguments.length?Array.from(t,Jw):[0,1],dh(n)}function PX(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],s=t[r],o;return s<i&&(o=n,n=r,r=o,o=i,i=s,s=o),t[n]=e.floor(i),t[r]=e.ceil(s),t}function t6(t){return Math.log(t)}function n6(t){return Math.exp(t)}function qye(t){return-Math.log(-t)}function Wye(t){return-Math.exp(-t)}function Kye(t){return isFinite(t)?+("1e"+t):t<0?0:t}function Xye(t){return t===10?Kye:t===Math.E?Math.exp:e=>Math.pow(t,e)}function Yye(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 r6(t){return(e,n)=>-t(-e,n)}function n4(t){const e=t(t6,n6),n=e.domain;let r=10,i,s;function o(){return i=Yye(r),s=Xye(r),n()[0]<0?(i=r6(i),s=r6(s),t(qye,Wye)):t(t6,n6),e}return e.base=function(l){return arguments.length?(r=+l,o()):r},e.domain=function(l){return arguments.length?(n(l),o()):n()},e.ticks=l=>{const c=n();let u=c[0],d=c[c.length-1];const f=d<u;f&&([u,d]=[d,u]);let m=i(u),g=i(d),x,y;const b=l==null?10:+l;let v=[];if(!(r%1)&&g-m<b){if(m=Math.floor(m),g=Math.ceil(g),u>0){for(;m<=g;++m)for(x=1;x<r;++x)if(y=m<0?x/s(-m):x*s(m),!(y<u)){if(y>d)break;v.push(y)}}else for(;m<=g;++m)for(x=r-1;x>=1;--x)if(y=m>0?x/s(-m):x*s(m),!(y<u)){if(y>d)break;v.push(y)}v.length*2<b&&(v=D3(u,d,b))}else v=D3(m,g,Math.min(g-m,b)).map(s);return f?v.reverse():v},e.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=j0(c)).precision==null&&(c.trim=!0),c=t4(c)),l===1/0)return c;const u=Math.max(1,r*l/e.ticks().length);return d=>{let f=d/s(Math.round(i(d)));return f*r<r-.5&&(f*=r),f<=u?c(d):""}},e.nice=()=>n(PX(n(),{floor:l=>s(Math.floor(i(l))),ceil:l=>s(Math.ceil(i(l)))})),e}function RX(){const t=n4(pN()).domain([1,10]);return t.copy=()=>vy(t,RX()).base(t.base()),Bo.apply(t,arguments),t}function i6(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function a6(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function r4(t){var e=1,n=t(i6(e),a6(e));return n.constant=function(r){return arguments.length?t(i6(e=+r),a6(e)):e},dh(n)}function DX(){var t=r4(pN());return t.copy=function(){return vy(t,DX()).constant(t.constant())},Bo.apply(t,arguments)}function s6(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function Qye(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function Zye(t){return t<0?-t*t:t*t}function i4(t){var e=t(Xa,Xa),n=1;function r(){return n===1?t(Xa,Xa):n===.5?t(Qye,Zye):t(s6(n),s6(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},dh(e)}function a4(){var t=i4(pN());return t.copy=function(){return vy(t,a4()).exponent(t.exponent())},Bo.apply(t,arguments),t}function Jye(){return a4.apply(null,arguments).exponent(.5)}function o6(t){return Math.sign(t)*t*t}function eve(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function OX(){var t=JD(),e=[0,1],n=!1,r;function i(s){var o=eve(t(s));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(s){return t.invert(o6(s))},i.domain=function(s){return arguments.length?(t.domain(s),i):t.domain()},i.range=function(s){return arguments.length?(t.range((e=Array.from(s,Jw)).map(o6)),i):e.slice()},i.rangeRound=function(s){return i.range(s).round(!0)},i.round=function(s){return arguments.length?(n=!!s,i):n},i.clamp=function(s){return arguments.length?(t.clamp(s),i):t.clamp()},i.unknown=function(s){return arguments.length?(r=s,i):r},i.copy=function(){return OX(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},Bo.apply(i,arguments),dh(i)}function LX(){var t=[],e=[],n=[],r;function i(){var o=0,l=Math.max(1,e.length);for(n=new Array(l-1);++o<l;)n[o-1]=iye(t,o/l);return s}function s(o){return o==null||isNaN(o=+o)?r:e[by(n,o)]}return s.invertExtent=function(o){var l=e.indexOf(o);return l<0?[NaN,NaN]:[l>0?n[l-1]:t[0],l<n.length?n[l]:t[t.length-1]]},s.domain=function(o){if(!arguments.length)return t.slice();t=[];for(let l of o)l!=null&&!isNaN(l=+l)&&t.push(l);return t.sort(Od),i()},s.range=function(o){return arguments.length?(e=Array.from(o),i()):e.slice()},s.unknown=function(o){return arguments.length?(r=o,s):r},s.quantiles=function(){return n.slice()},s.copy=function(){return LX().domain(t).range(e).unknown(r)},Bo.apply(s,arguments)}function IX(){var t=0,e=1,n=1,r=[.5],i=[0,1],s;function o(c){return c!=null&&c<=c?i[by(r,c,0,n)]:s}function l(){var c=-1;for(r=new Array(n);++c<n;)r[c]=((c+1)*e-(c-n)*t)/(n+1);return o}return o.domain=function(c){return arguments.length?([t,e]=c,t=+t,e=+e,l()):[t,e]},o.range=function(c){return arguments.length?(n=(i=Array.from(c)).length-1,l()):i.slice()},o.invertExtent=function(c){var u=i.indexOf(c);return u<0?[NaN,NaN]:u<1?[t,r[0]]:u>=n?[r[n-1],e]:[r[u-1],r[u]]},o.unknown=function(c){return arguments.length&&(s=c),o},o.thresholds=function(){return r.slice()},o.copy=function(){return IX().domain([t,e]).range(i).unknown(s)},Bo.apply(dh(o),arguments)}function FX(){var t=[.5],e=[0,1],n,r=1;function i(s){return s!=null&&s<=s?e[by(t,s,0,r)]:n}return i.domain=function(s){return arguments.length?(t=Array.from(s),r=Math.min(t.length,e.length-1),i):t.slice()},i.range=function(s){return arguments.length?(e=Array.from(s),r=Math.min(t.length,e.length-1),i):e.slice()},i.invertExtent=function(s){var o=e.indexOf(s);return[t[o-1],t[o]]},i.unknown=function(s){return arguments.length?(n=s,i):n},i.copy=function(){return FX().domain(t).range(e).unknown(n)},Bo.apply(i,arguments)}const XC=new Date,YC=new Date;function $i(t,e,n,r){function i(s){return t(s=arguments.length===0?new Date:new Date(+s)),s}return i.floor=s=>(t(s=new Date(+s)),s),i.ceil=s=>(t(s=new Date(s-1)),e(s,1),t(s),s),i.round=s=>{const o=i(s),l=i.ceil(s);return s-o<l-s?o:l},i.offset=(s,o)=>(e(s=new Date(+s),o==null?1:Math.floor(o)),s),i.range=(s,o,l)=>{const c=[];if(s=i.ceil(s),l=l==null?1:Math.floor(l),!(s<o)||!(l>0))return c;let u;do c.push(u=new Date(+s)),e(s,l),t(s);while(u<s&&s<o);return c},i.filter=s=>$i(o=>{if(o>=o)for(;t(o),!s(o);)o.setTime(o-1)},(o,l)=>{if(o>=o)if(l<0)for(;++l<=0;)for(;e(o,-1),!s(o););else for(;--l>=0;)for(;e(o,1),!s(o););}),n&&(i.count=(s,o)=>(XC.setTime(+s),YC.setTime(+o),t(XC),t(YC),Math.floor(n(XC,YC))),i.every=s=>(s=Math.floor(s),!isFinite(s)||!(s>0)?null:s>1?i.filter(r?o=>r(o)%s===0:o=>i.count(0,o)%s===0):i)),i}const tS=$i(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);tS.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?$i(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):tS);tS.range;const Gc=1e3,Co=Gc*60,qc=Co*60,hu=qc*24,s4=hu*7,l6=hu*30,QC=hu*365,cf=$i(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Gc)},(t,e)=>(e-t)/Gc,t=>t.getUTCSeconds());cf.range;const o4=$i(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Gc)},(t,e)=>{t.setTime(+t+e*Co)},(t,e)=>(e-t)/Co,t=>t.getMinutes());o4.range;const l4=$i(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Co)},(t,e)=>(e-t)/Co,t=>t.getUTCMinutes());l4.range;const c4=$i(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Gc-t.getMinutes()*Co)},(t,e)=>{t.setTime(+t+e*qc)},(t,e)=>(e-t)/qc,t=>t.getHours());c4.range;const u4=$i(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*qc)},(t,e)=>(e-t)/qc,t=>t.getUTCHours());u4.range;const _y=$i(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Co)/hu,t=>t.getDate()-1);_y.range;const gN=$i(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/hu,t=>t.getUTCDate()-1);gN.range;const UX=$i(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/hu,t=>Math.floor(t/hu));UX.range;function am(t){return $i(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())*Co)/s4)}const xN=am(0),nS=am(1),tve=am(2),nve=am(3),xg=am(4),rve=am(5),ive=am(6);xN.range;nS.range;tve.range;nve.range;xg.range;rve.range;ive.range;function sm(t){return $i(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)/s4)}const bN=sm(0),rS=sm(1),ave=sm(2),sve=sm(3),bg=sm(4),ove=sm(5),lve=sm(6);bN.range;rS.range;ave.range;sve.range;bg.range;ove.range;lve.range;const d4=$i(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());d4.range;const h4=$i(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());h4.range;const fu=$i(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());fu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:$i(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)});fu.range;const mu=$i(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());mu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:$i(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)});mu.range;function zX(t,e,n,r,i,s){const o=[[cf,1,Gc],[cf,5,5*Gc],[cf,15,15*Gc],[cf,30,30*Gc],[s,1,Co],[s,5,5*Co],[s,15,15*Co],[s,30,30*Co],[i,1,qc],[i,3,3*qc],[i,6,6*qc],[i,12,12*qc],[r,1,hu],[r,2,2*hu],[n,1,s4],[e,1,l6],[e,3,3*l6],[t,1,QC]];function l(u,d,f){const m=d<u;m&&([u,d]=[d,u]);const g=f&&typeof f.range=="function"?f:c(u,d,f),x=g?g.range(u,+d+1):[];return m?x.reverse():x}function c(u,d,f){const m=Math.abs(d-u)/f,g=WD(([,,b])=>b).right(o,m);if(g===o.length)return t.every(L3(u/QC,d/QC,f));if(g===0)return tS.every(Math.max(L3(u,d,f),1));const[x,y]=o[m/o[g-1][2]<o[g][2]/m?g-1:g];return x.every(y)}return[l,c]}const[cve,uve]=zX(mu,h4,bN,UX,u4,l4),[dve,hve]=zX(fu,d4,xN,_y,c4,o4);function ZC(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 JC(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 ab(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function fve(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,s=t.days,o=t.shortDays,l=t.months,c=t.shortMonths,u=sb(i),d=ob(i),f=sb(s),m=ob(s),g=sb(o),x=ob(o),y=sb(l),b=ob(l),v=sb(c),N=ob(c),S={a:K,A:Z,b:te,B:ne,c:null,d:m6,e:m6,f:Lve,g:qve,G:Kve,H:Rve,I:Dve,j:Ove,L:BX,m:Ive,M:Fve,p:z,q:W,Q:x6,s:b6,S:Uve,u:zve,U:Bve,V:$ve,w:Hve,W:Vve,x:null,X:null,y:Gve,Y:Wve,Z:Xve,"%":g6},T={a:se,A:ae,b:de,B:me,c:null,d:p6,e:p6,f:Jve,g:c_e,G:d_e,H:Yve,I:Qve,j:Zve,L:HX,m:e_e,M:t_e,p:xe,q:be,Q:x6,s:b6,S:n_e,u:r_e,U:i_e,V:a_e,w:s_e,W:o_e,x:null,X:null,y:l_e,Y:u_e,Z:h_e,"%":g6},E={a:R,A:F,b:O,B:q,c:j,d:h6,e:h6,f:Ave,g:d6,G:u6,H:f6,I:f6,j:Mve,L:Cve,m:Nve,M:Eve,p:A,q:Sve,Q:jve,s:Pve,S:Tve,u:bve,U:yve,V:vve,w:xve,W:_ve,x:G,X:Y,y:d6,Y:u6,Z:wve,"%":kve};S.x=k(n,S),S.X=k(r,S),S.c=k(e,S),T.x=k(n,T),T.X=k(r,T),T.c=k(e,T);function k(fe,Ce){return function(Ne){var re=[],He=-1,H=0,B=fe.length,X,U,Q;for(Ne instanceof Date||(Ne=new Date(+Ne));++He<B;)fe.charCodeAt(He)===37&&(re.push(fe.slice(H,He)),(U=c6[X=fe.charAt(++He)])!=null?X=fe.charAt(++He):U=X==="e"?" ":"0",(Q=Ce[X])&&(X=Q(Ne,U)),re.push(X),H=He+1);return re.push(fe.slice(H,He)),re.join("")}}function C(fe,Ce){return function(Ne){var re=ab(1900,void 0,1),He=D(re,fe,Ne+="",0),H,B;if(He!=Ne.length)return null;if("Q"in re)return new Date(re.Q);if("s"in re)return new Date(re.s*1e3+("L"in re?re.L:0));if(Ce&&!("Z"in re)&&(re.Z=0),"p"in re&&(re.H=re.H%12+re.p*12),re.m===void 0&&(re.m="q"in re?re.q:0),"V"in re){if(re.V<1||re.V>53)return null;"w"in re||(re.w=1),"Z"in re?(H=JC(ab(re.y,0,1)),B=H.getUTCDay(),H=B>4||B===0?rS.ceil(H):rS(H),H=gN.offset(H,(re.V-1)*7),re.y=H.getUTCFullYear(),re.m=H.getUTCMonth(),re.d=H.getUTCDate()+(re.w+6)%7):(H=ZC(ab(re.y,0,1)),B=H.getDay(),H=B>4||B===0?nS.ceil(H):nS(H),H=_y.offset(H,(re.V-1)*7),re.y=H.getFullYear(),re.m=H.getMonth(),re.d=H.getDate()+(re.w+6)%7)}else("W"in re||"U"in re)&&("w"in re||(re.w="u"in re?re.u%7:"W"in re?1:0),B="Z"in re?JC(ab(re.y,0,1)).getUTCDay():ZC(ab(re.y,0,1)).getDay(),re.m=0,re.d="W"in re?(re.w+6)%7+re.W*7-(B+5)%7:re.w+re.U*7-(B+6)%7);return"Z"in re?(re.H+=re.Z/100|0,re.M+=re.Z%100,JC(re)):ZC(re)}}function D(fe,Ce,Ne,re){for(var He=0,H=Ce.length,B=Ne.length,X,U;He<H;){if(re>=B)return-1;if(X=Ce.charCodeAt(He++),X===37){if(X=Ce.charAt(He++),U=E[X in c6?Ce.charAt(He++):X],!U||(re=U(fe,Ne,re))<0)return-1}else if(X!=Ne.charCodeAt(re++))return-1}return re}function A(fe,Ce,Ne){var re=u.exec(Ce.slice(Ne));return re?(fe.p=d.get(re[0].toLowerCase()),Ne+re[0].length):-1}function R(fe,Ce,Ne){var re=g.exec(Ce.slice(Ne));return re?(fe.w=x.get(re[0].toLowerCase()),Ne+re[0].length):-1}function F(fe,Ce,Ne){var re=f.exec(Ce.slice(Ne));return re?(fe.w=m.get(re[0].toLowerCase()),Ne+re[0].length):-1}function O(fe,Ce,Ne){var re=v.exec(Ce.slice(Ne));return re?(fe.m=N.get(re[0].toLowerCase()),Ne+re[0].length):-1}function q(fe,Ce,Ne){var re=y.exec(Ce.slice(Ne));return re?(fe.m=b.get(re[0].toLowerCase()),Ne+re[0].length):-1}function j(fe,Ce,Ne){return D(fe,e,Ce,Ne)}function G(fe,Ce,Ne){return D(fe,n,Ce,Ne)}function Y(fe,Ce,Ne){return D(fe,r,Ce,Ne)}function K(fe){return o[fe.getDay()]}function Z(fe){return s[fe.getDay()]}function te(fe){return c[fe.getMonth()]}function ne(fe){return l[fe.getMonth()]}function z(fe){return i[+(fe.getHours()>=12)]}function W(fe){return 1+~~(fe.getMonth()/3)}function se(fe){return o[fe.getUTCDay()]}function ae(fe){return s[fe.getUTCDay()]}function de(fe){return c[fe.getUTCMonth()]}function me(fe){return l[fe.getUTCMonth()]}function xe(fe){return i[+(fe.getUTCHours()>=12)]}function be(fe){return 1+~~(fe.getUTCMonth()/3)}return{format:function(fe){var Ce=k(fe+="",S);return Ce.toString=function(){return fe},Ce},parse:function(fe){var Ce=C(fe+="",!1);return Ce.toString=function(){return fe},Ce},utcFormat:function(fe){var Ce=k(fe+="",T);return Ce.toString=function(){return fe},Ce},utcParse:function(fe){var Ce=C(fe+="",!0);return Ce.toString=function(){return fe},Ce}}}var c6={"-":"",_:" ",0:"0"},la=/^\s*\d+/,mve=/^%/,pve=/[\\^$*+?|[\]().{}]/g;function Qn(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",s=i.length;return r+(s<n?new Array(n-s+1).join(e)+i:i)}function gve(t){return t.replace(pve,"\\$&")}function sb(t){return new RegExp("^(?:"+t.map(gve).join("|")+")","i")}function ob(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function xve(t,e,n){var r=la.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function bve(t,e,n){var r=la.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function yve(t,e,n){var r=la.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function vve(t,e,n){var r=la.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function _ve(t,e,n){var r=la.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function u6(t,e,n){var r=la.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function d6(t,e,n){var r=la.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function wve(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 Sve(t,e,n){var r=la.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function Nve(t,e,n){var r=la.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function h6(t,e,n){var r=la.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Mve(t,e,n){var r=la.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function f6(t,e,n){var r=la.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Eve(t,e,n){var r=la.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Tve(t,e,n){var r=la.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Cve(t,e,n){var r=la.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Ave(t,e,n){var r=la.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function kve(t,e,n){var r=mve.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function jve(t,e,n){var r=la.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Pve(t,e,n){var r=la.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function m6(t,e){return Qn(t.getDate(),e,2)}function Rve(t,e){return Qn(t.getHours(),e,2)}function Dve(t,e){return Qn(t.getHours()%12||12,e,2)}function Ove(t,e){return Qn(1+_y.count(fu(t),t),e,3)}function BX(t,e){return Qn(t.getMilliseconds(),e,3)}function Lve(t,e){return BX(t,e)+"000"}function Ive(t,e){return Qn(t.getMonth()+1,e,2)}function Fve(t,e){return Qn(t.getMinutes(),e,2)}function Uve(t,e){return Qn(t.getSeconds(),e,2)}function zve(t){var e=t.getDay();return e===0?7:e}function Bve(t,e){return Qn(xN.count(fu(t)-1,t),e,2)}function $X(t){var e=t.getDay();return e>=4||e===0?xg(t):xg.ceil(t)}function $ve(t,e){return t=$X(t),Qn(xg.count(fu(t),t)+(fu(t).getDay()===4),e,2)}function Hve(t){return t.getDay()}function Vve(t,e){return Qn(nS.count(fu(t)-1,t),e,2)}function Gve(t,e){return Qn(t.getFullYear()%100,e,2)}function qve(t,e){return t=$X(t),Qn(t.getFullYear()%100,e,2)}function Wve(t,e){return Qn(t.getFullYear()%1e4,e,4)}function Kve(t,e){var n=t.getDay();return t=n>=4||n===0?xg(t):xg.ceil(t),Qn(t.getFullYear()%1e4,e,4)}function Xve(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Qn(e/60|0,"0",2)+Qn(e%60,"0",2)}function p6(t,e){return Qn(t.getUTCDate(),e,2)}function Yve(t,e){return Qn(t.getUTCHours(),e,2)}function Qve(t,e){return Qn(t.getUTCHours()%12||12,e,2)}function Zve(t,e){return Qn(1+gN.count(mu(t),t),e,3)}function HX(t,e){return Qn(t.getUTCMilliseconds(),e,3)}function Jve(t,e){return HX(t,e)+"000"}function e_e(t,e){return Qn(t.getUTCMonth()+1,e,2)}function t_e(t,e){return Qn(t.getUTCMinutes(),e,2)}function n_e(t,e){return Qn(t.getUTCSeconds(),e,2)}function r_e(t){var e=t.getUTCDay();return e===0?7:e}function i_e(t,e){return Qn(bN.count(mu(t)-1,t),e,2)}function VX(t){var e=t.getUTCDay();return e>=4||e===0?bg(t):bg.ceil(t)}function a_e(t,e){return t=VX(t),Qn(bg.count(mu(t),t)+(mu(t).getUTCDay()===4),e,2)}function s_e(t){return t.getUTCDay()}function o_e(t,e){return Qn(rS.count(mu(t)-1,t),e,2)}function l_e(t,e){return Qn(t.getUTCFullYear()%100,e,2)}function c_e(t,e){return t=VX(t),Qn(t.getUTCFullYear()%100,e,2)}function u_e(t,e){return Qn(t.getUTCFullYear()%1e4,e,4)}function d_e(t,e){var n=t.getUTCDay();return t=n>=4||n===0?bg(t):bg.ceil(t),Qn(t.getUTCFullYear()%1e4,e,4)}function h_e(){return"+0000"}function g6(){return"%"}function x6(t){return+t}function b6(t){return Math.floor(+t/1e3)}var Vm,GX,qX;f_e({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 f_e(t){return Vm=fve(t),GX=Vm.format,Vm.parse,qX=Vm.utcFormat,Vm.utcParse,Vm}function m_e(t){return new Date(t)}function p_e(t){return t instanceof Date?+t:+new Date(+t)}function f4(t,e,n,r,i,s,o,l,c,u){var d=JD(),f=d.invert,m=d.domain,g=u(".%L"),x=u(":%S"),y=u("%I:%M"),b=u("%I %p"),v=u("%a %d"),N=u("%b %d"),S=u("%B"),T=u("%Y");function E(k){return(c(k)<k?g:l(k)<k?x:o(k)<k?y:s(k)<k?b:r(k)<k?i(k)<k?v:N:n(k)<k?S:T)(k)}return d.invert=function(k){return new Date(f(k))},d.domain=function(k){return arguments.length?m(Array.from(k,p_e)):m().map(m_e)},d.ticks=function(k){var C=m();return t(C[0],C[C.length-1],k??10)},d.tickFormat=function(k,C){return C==null?E:u(C)},d.nice=function(k){var C=m();return(!k||typeof k.range!="function")&&(k=e(C[0],C[C.length-1],k??10)),k?m(PX(C,k)):d},d.copy=function(){return vy(d,f4(t,e,n,r,i,s,o,l,c,u))},d}function g_e(){return Bo.apply(f4(dve,hve,fu,d4,xN,_y,c4,o4,cf,GX).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function x_e(){return Bo.apply(f4(cve,uve,mu,h4,bN,gN,u4,l4,cf,qX).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function yN(){var t=0,e=1,n,r,i,s,o=Xa,l=!1,c;function u(f){return f==null||isNaN(f=+f)?c:o(i===0?.5:(f=(s(f)-n)*i,l?Math.max(0,Math.min(1,f)):f))}u.domain=function(f){return arguments.length?([t,e]=f,n=s(t=+t),r=s(e=+e),i=n===r?0:1/(r-n),u):[t,e]},u.clamp=function(f){return arguments.length?(l=!!f,u):l},u.interpolator=function(f){return arguments.length?(o=f,u):o};function d(f){return function(m){var g,x;return arguments.length?([g,x]=m,o=f(g,x),u):[o(0),o(1)]}}return u.range=d(qg),u.rangeRound=d(ZD),u.unknown=function(f){return arguments.length?(c=f,u):c},function(f){return s=f,n=f(t),r=f(e),i=n===r?0:1/(r-n),u}}function hh(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function WX(){var t=dh(yN()(Xa));return t.copy=function(){return hh(t,WX())},wu.apply(t,arguments)}function KX(){var t=n4(yN()).domain([1,10]);return t.copy=function(){return hh(t,KX()).base(t.base())},wu.apply(t,arguments)}function XX(){var t=r4(yN());return t.copy=function(){return hh(t,XX()).constant(t.constant())},wu.apply(t,arguments)}function m4(){var t=i4(yN());return t.copy=function(){return hh(t,m4()).exponent(t.exponent())},wu.apply(t,arguments)}function b_e(){return m4.apply(null,arguments).exponent(.5)}function YX(){var t=[],e=Xa;function n(r){if(r!=null&&!isNaN(r=+r))return e((by(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(Od),n},n.interpolator=function(r){return arguments.length?(e=r,n):e},n.range=function(){return t.map((r,i)=>e(i/(t.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(i,s)=>rye(t,s/r))},n.copy=function(){return YX(e).domain(t)},wu.apply(n,arguments)}function vN(){var t=0,e=.5,n=1,r=1,i,s,o,l,c,u=Xa,d,f=!1,m;function g(y){return isNaN(y=+y)?m:(y=.5+((y=+d(y))-s)*(r*y<r*s?l:c),u(f?Math.max(0,Math.min(1,y)):y))}g.domain=function(y){return arguments.length?([t,e,n]=y,i=d(t=+t),s=d(e=+e),o=d(n=+n),l=i===s?0:.5/(s-i),c=s===o?0:.5/(o-s),r=s<i?-1:1,g):[t,e,n]},g.clamp=function(y){return arguments.length?(f=!!y,g):f},g.interpolator=function(y){return arguments.length?(u=y,g):u};function x(y){return function(b){var v,N,S;return arguments.length?([v,N,S]=b,u=kye(y,[v,N,S]),g):[u(0),u(.5),u(1)]}}return g.range=x(qg),g.rangeRound=x(ZD),g.unknown=function(y){return arguments.length?(m=y,g):m},function(y){return d=y,i=y(t),s=y(e),o=y(n),l=i===s?0:.5/(s-i),c=s===o?0:.5/(o-s),r=s<i?-1:1,g}}function QX(){var t=dh(vN()(Xa));return t.copy=function(){return hh(t,QX())},wu.apply(t,arguments)}function ZX(){var t=n4(vN()).domain([.1,1,10]);return t.copy=function(){return hh(t,ZX()).base(t.base())},wu.apply(t,arguments)}function JX(){var t=r4(vN());return t.copy=function(){return hh(t,JX()).constant(t.constant())},wu.apply(t,arguments)}function p4(){var t=i4(vN());return t.copy=function(){return hh(t,p4()).exponent(t.exponent())},wu.apply(t,arguments)}function y_e(){return p4.apply(null,arguments).exponent(.5)}const Ab=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:XD,scaleDiverging:QX,scaleDivergingLog:ZX,scaleDivergingPow:p4,scaleDivergingSqrt:y_e,scaleDivergingSymlog:JX,scaleIdentity:jX,scaleImplicit:I3,scaleLinear:kX,scaleLog:RX,scaleOrdinal:KD,scalePoint:sye,scalePow:a4,scaleQuantile:LX,scaleQuantize:IX,scaleRadial:OX,scaleSequential:WX,scaleSequentialLog:KX,scaleSequentialPow:m4,scaleSequentialQuantile:YX,scaleSequentialSqrt:b_e,scaleSequentialSymlog:XX,scaleSqrt:Jye,scaleSymlog:DX,scaleThreshold:FX,scaleTime:g_e,scaleUtc:x_e,tickFormat:AX},Symbol.toStringTag,{value:"Module"}));var fh=t=>t.chartData,g4=tt([fh],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),wy=(t,e,n,r)=>r?g4(t):fh(t);function Yd(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(cr(e)&&cr(n))return!0}return!1}function y6(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function eY(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,s;if(cr(n))i=n;else if(typeof n=="function")return;if(cr(r))s=r;else if(typeof r=="function")return;var o=[i,s];if(Yd(o))return o}}function v_e(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(Yd(r))return y6(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,s]=t,o,l;if(i==="auto")e!=null&&(o=Math.min(...e));else if(Ut(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&WB.test(i)){var c=WB.exec(i);if(c==null||e==null)o=void 0;else{var u=+c[1];o=e[0]-u}}else o=e?.[0];if(s==="auto")e!=null&&(l=Math.max(...e));else if(Ut(s))l=s;else if(typeof s=="function")try{e!=null&&(l=s(e?.[1]))}catch{}else if(typeof s=="string"&&KB.test(s)){var d=KB.exec(s);if(d==null||e==null)l=void 0;else{var f=+d[1];l=e[1]+f}}else l=e?.[1];var m=[o,l];if(Yd(m))return e==null?m:y6(m,e,n)}}}var Wg=1e9,__e={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},b4,Hr=!0,Fo="[DecimalError] ",_f=Fo+"Invalid argument: ",x4=Fo+"Exponent out of range: ",Kg=Math.floor,Yh=Math.pow,w_e=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Vs,Ji=1e7,Lr=7,tY=9007199254740991,iS=Kg(tY/Lr),Ht={};Ht.absoluteValue=Ht.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Ht.comparedTo=Ht.cmp=function(t){var e,n,r,i,s=this;if(t=new s.constructor(t),s.s!==t.s)return s.s||-t.s;if(s.e!==t.e)return s.e>t.e^s.s<0?1:-1;for(r=s.d.length,i=t.d.length,e=0,n=r<i?r:i;e<n;++e)if(s.d[e]!==t.d[e])return s.d[e]>t.d[e]^s.s<0?1:-1;return r===i?0:r>i^s.s<0?1:-1};Ht.decimalPlaces=Ht.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*Lr;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Ht.dividedBy=Ht.div=function(t){return Jc(this,new this.constructor(t))};Ht.dividedToIntegerBy=Ht.idiv=function(t){var e=this,n=e.constructor;return Mr(Jc(e,new n(t),0,1),n.precision)};Ht.equals=Ht.eq=function(t){return!this.cmp(t)};Ht.exponent=function(){return Ti(this)};Ht.greaterThan=Ht.gt=function(t){return this.cmp(t)>0};Ht.greaterThanOrEqualTo=Ht.gte=function(t){return this.cmp(t)>=0};Ht.isInteger=Ht.isint=function(){return this.e>this.d.length-2};Ht.isNegative=Ht.isneg=function(){return this.s<0};Ht.isPositive=Ht.ispos=function(){return this.s>0};Ht.isZero=function(){return this.s===0};Ht.lessThan=Ht.lt=function(t){return this.cmp(t)<0};Ht.lessThanOrEqualTo=Ht.lte=function(t){return this.cmp(t)<1};Ht.logarithm=Ht.log=function(t){var e,n=this,r=n.constructor,i=r.precision,s=i+5;if(t===void 0)t=new r(10);else if(t=new r(t),t.s<1||t.eq(Vs))throw Error(Fo+"NaN");if(n.s<1)throw Error(Fo+(n.s?"NaN":"-Infinity"));return n.eq(Vs)?new r(0):(Hr=!1,e=Jc(P0(n,s),P0(t,s),s),Hr=!0,Mr(e,i))};Ht.minus=Ht.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?iY(e,t):nY(e,(t.s=-t.s,t))};Ht.modulo=Ht.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(Fo+"NaN");return n.s?(Hr=!1,e=Jc(n,t,0,1).times(t),Hr=!0,n.minus(e)):Mr(new r(n),i)};Ht.naturalExponential=Ht.exp=function(){return rY(this)};Ht.naturalLogarithm=Ht.ln=function(){return P0(this)};Ht.negated=Ht.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Ht.plus=Ht.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?nY(e,t):iY(e,(t.s=-t.s,t))};Ht.precision=Ht.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(_f+t);if(e=Ti(i)+1,r=i.d.length-1,n=r*Lr+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};Ht.squareRoot=Ht.sqrt=function(){var t,e,n,r,i,s,o,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(Fo+"NaN")}for(t=Ti(l),Hr=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=Pl(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=Kg((t+1)/2)-(t<0||t%2),i==1/0?e="5e"+t:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+t),r=new c(e)):r=new c(i.toString()),n=c.precision,i=o=n+3;;)if(s=r,r=s.plus(Jc(l,s,o+2)).times(.5),Pl(s.d).slice(0,o)===(e=Pl(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(Mr(s,n+1,0),s.times(s).eq(l)){r=s;break}}else if(e!="9999")break;o+=4}return Hr=!0,Mr(r,n)};Ht.times=Ht.mul=function(t){var e,n,r,i,s,o,l,c,u,d=this,f=d.constructor,m=d.d,g=(t=new f(t)).d;if(!d.s||!t.s)return new f(0);for(t.s*=d.s,n=d.e+t.e,c=m.length,u=g.length,c<u&&(s=m,m=g,g=s,o=c,c=u,u=o),s=[],o=c+u,r=o;r--;)s.push(0);for(r=u;--r>=0;){for(e=0,i=c+r;i>r;)l=s[i]+g[r]*m[i-r-1]+e,s[i--]=l%Ji|0,e=l/Ji|0;s[i]=(s[i]+e)%Ji|0}for(;!s[--o];)s.pop();return e?++n:s.shift(),t.d=s,t.e=n,Hr?Mr(t,f.precision):t};Ht.toDecimalPlaces=Ht.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:($l(t,0,Wg),e===void 0?e=r.rounding:$l(e,0,8),Mr(n,t+Ti(n)+1,e))};Ht.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=$f(r,!0):($l(t,0,Wg),e===void 0?e=i.rounding:$l(e,0,8),r=Mr(new i(r),t+1,e),n=$f(r,!0,t+1)),n};Ht.toFixed=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?$f(i):($l(t,0,Wg),e===void 0?e=s.rounding:$l(e,0,8),r=Mr(new s(i),t+Ti(i)+1,e),n=$f(r.abs(),!1,t+Ti(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Ht.toInteger=Ht.toint=function(){var t=this,e=t.constructor;return Mr(new e(t),Ti(t)+1,e.rounding)};Ht.toNumber=function(){return+this};Ht.toPower=Ht.pow=function(t){var e,n,r,i,s,o,l=this,c=l.constructor,u=12,d=+(t=new c(t));if(!t.s)return new c(Vs);if(l=new c(l),!l.s){if(t.s<1)throw Error(Fo+"Infinity");return l}if(l.eq(Vs))return l;if(r=c.precision,t.eq(Vs))return Mr(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,s=l.s,o){if((n=d<0?-d:d)<=tY){for(i=new c(Vs),e=Math.ceil(r/Lr+4),Hr=!1;n%2&&(i=i.times(l),_6(i.d,e)),n=Kg(n/2),n!==0;)l=l.times(l),_6(l.d,e);return Hr=!0,t.s<0?new c(Vs).div(i):Mr(i,r)}}else if(s<0)throw Error(Fo+"NaN");return s=s<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,Hr=!1,i=t.times(P0(l,r+u)),Hr=!0,i=rY(i),i.s=s,i};Ht.toPrecision=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?(n=Ti(i),r=$f(i,n<=s.toExpNeg||n>=s.toExpPos)):($l(t,1,Wg),e===void 0?e=s.rounding:$l(e,0,8),i=Mr(new s(i),t,e),n=Ti(i),r=$f(i,t<=n||n<=s.toExpNeg,t)),r};Ht.toSignificantDigits=Ht.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):($l(t,1,Wg),e===void 0?e=r.rounding:$l(e,0,8)),Mr(new r(n),t,e)};Ht.toString=Ht.valueOf=Ht.val=Ht.toJSON=Ht[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=Ti(t),n=t.constructor;return $f(t,e<=n.toExpNeg||e>=n.toExpPos)};function nY(t,e){var n,r,i,s,o,l,c,u,d=t.constructor,f=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),Hr?Mr(e,f):e;if(c=t.d,u=e.d,o=t.e,i=e.e,c=c.slice(),s=o-i,s){for(s<0?(r=c,s=-s,l=u.length):(r=u,i=o,l=c.length),o=Math.ceil(f/Lr),l=o>l?o+1:l+1,s>l&&(s=l,r.length=1),r.reverse();s--;)r.push(0);r.reverse()}for(l=c.length,s=u.length,l-s<0&&(s=l,r=u,u=c,c=r),n=0;s;)n=(c[--s]=c[s]+u[s]+n)/Ji|0,c[s]%=Ji;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,Hr?Mr(e,f):e}function $l(t,e,n){if(t!==~~t||t<e||t>n)throw Error(_f+t)}function Pl(t){var e,n,r,i=t.length-1,s="",o=t[0];if(i>0){for(s+=o,e=1;e<i;e++)r=t[e]+"",n=Lr-r.length,n&&(s+=dd(n)),s+=r;o=t[e],r=o+"",n=Lr-r.length,n&&(s+=dd(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}var Jc=(function(){function t(r,i){var s,o=0,l=r.length;for(r=r.slice();l--;)s=r[l]*i+o,r[l]=s%Ji|0,o=s/Ji|0;return o&&r.unshift(o),r}function e(r,i,s,o){var l,c;if(s!=o)c=s>o?1:-1;else for(l=c=0;l<s;l++)if(r[l]!=i[l]){c=r[l]>i[l]?1:-1;break}return c}function n(r,i,s){for(var o=0;s--;)r[s]-=o,o=r[s]<i[s]?1:0,r[s]=o*Ji+r[s]-i[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,s,o){var l,c,u,d,f,m,g,x,y,b,v,N,S,T,E,k,C,D,A=r.constructor,R=r.s==i.s?1:-1,F=r.d,O=i.d;if(!r.s)return new A(r);if(!i.s)throw Error(Fo+"Division by zero");for(c=r.e-i.e,C=O.length,E=F.length,g=new A(R),x=g.d=[],u=0;O[u]==(F[u]||0);)++u;if(O[u]>(F[u]||0)&&--c,s==null?N=s=A.precision:o?N=s+(Ti(r)-Ti(i))+1:N=s,N<0)return new A(0);if(N=N/Lr+2|0,u=0,C==1)for(d=0,O=O[0],N++;(u<E||d)&&N--;u++)S=d*Ji+(F[u]||0),x[u]=S/O|0,d=S%O|0;else{for(d=Ji/(O[0]+1)|0,d>1&&(O=t(O,d),F=t(F,d),C=O.length,E=F.length),T=C,y=F.slice(0,C),b=y.length;b<C;)y[b++]=0;D=O.slice(),D.unshift(0),k=O[0],O[1]>=Ji/2&&++k;do d=0,l=e(O,y,C,b),l<0?(v=y[0],C!=b&&(v=v*Ji+(y[1]||0)),d=v/k|0,d>1?(d>=Ji&&(d=Ji-1),f=t(O,d),m=f.length,b=y.length,l=e(f,y,m,b),l==1&&(d--,n(f,C<m?D:O,m))):(d==0&&(l=d=1),f=O.slice()),m=f.length,m<b&&f.unshift(0),n(y,f,b),l==-1&&(b=y.length,l=e(O,y,C,b),l<1&&(d++,n(y,C<b?D:O,b))),b=y.length):l===0&&(d++,y=[0]),x[u++]=d,l&&y[0]?y[b++]=F[T]||0:(y=[F[T]],b=1);while((T++<E||y[0]!==void 0)&&N--)}return x[0]||x.shift(),g.e=c,Mr(g,o?s+Ti(g)+1:s)}})();function rY(t,e){var n,r,i,s,o,l,c=0,u=0,d=t.constructor,f=d.precision;if(Ti(t)>16)throw Error(x4+Ti(t));if(!t.s)return new d(Vs);for(Hr=!1,l=f,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(r=Math.log(Yh(2,u))/Math.LN10*2+5|0,l+=r,n=i=s=new d(Vs),d.precision=l;;){if(i=Mr(i.times(t),l),n=n.times(++c),o=s.plus(Jc(i,n,l)),Pl(o.d).slice(0,l)===Pl(s.d).slice(0,l)){for(;u--;)s=Mr(s.times(s),l);return d.precision=f,e==null?(Hr=!0,Mr(s,f)):s}s=o}}function Ti(t){for(var e=t.e*Lr,n=t.d[0];n>=10;n/=10)e++;return e}function eA(t,e,n){if(e>t.LN10.sd())throw Hr=!0,n&&(t.precision=n),Error(Fo+"LN10 precision limit exceeded");return Mr(new t(t.LN10),e)}function dd(t){for(var e="";t--;)e+="0";return e}function P0(t,e){var n,r,i,s,o,l,c,u,d,f=1,m=10,g=t,x=g.d,y=g.constructor,b=y.precision;if(g.s<1)throw Error(Fo+(g.s?"NaN":"-Infinity"));if(g.eq(Vs))return new y(0);if(e==null?(Hr=!1,u=b):u=e,g.eq(10))return e==null&&(Hr=!0),eA(y,u);if(u+=m,y.precision=u,n=Pl(x),r=n.charAt(0),s=Ti(g),Math.abs(s)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)g=g.times(t),n=Pl(g.d),r=n.charAt(0),f++;s=Ti(g),r>1?(g=new y("0."+n),s++):g=new y(r+"."+n.slice(1))}else return c=eA(y,u+2,b).times(s+""),g=P0(new y(r+"."+n.slice(1)),u-m).plus(c),y.precision=b,e==null?(Hr=!0,Mr(g,b)):g;for(l=o=g=Jc(g.minus(Vs),g.plus(Vs),u),d=Mr(g.times(g),u),i=3;;){if(o=Mr(o.times(d),u),c=l.plus(Jc(o,new y(i),u)),Pl(c.d).slice(0,u)===Pl(l.d).slice(0,u))return l=l.times(2),s!==0&&(l=l.plus(eA(y,u+2,b).times(s+""))),l=Jc(l,new y(f),u),y.precision=b,e==null?(Hr=!0,Mr(l,b)):l;l=c,i+=2}}function v6(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=Kg(n/Lr),t.d=[],r=(n+1)%Lr,n<0&&(r+=Lr),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=Lr;r<i;)t.d.push(+e.slice(r,r+=Lr));e=e.slice(r),r=Lr-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),Hr&&(t.e>iS||t.e<-iS))throw Error(x4+n)}else t.s=0,t.e=0,t.d=[0];return t}function Mr(t,e,n){var r,i,s,o,l,c,u,d,f=t.d;for(o=1,s=f[0];s>=10;s/=10)o++;if(r=e-o,r<0)r+=Lr,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/Lr),s=f.length,d>=s)return t;for(u=s=f[d],o=1;s>=10;s/=10)o++;r%=Lr,i=r-Lr+o}if(n!==void 0&&(s=Yh(10,o-i-1),l=u/s%10|0,c=e<0||f[d+1]!==void 0||u%s,c=n<4?(l||c)&&(n==0||n==(t.s<0?3:2)):l>5||l==5&&(n==4||c||n==6&&(r>0?i>0?u/Yh(10,o-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(s=Ti(t),f.length=1,e=e-s-1,f[0]=Yh(10,(Lr-e%Lr)%Lr),t.e=Kg(-e/Lr)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(r==0?(f.length=d,s=1,d--):(f.length=d+1,s=Yh(10,Lr-r),f[d]=i>0?(u/Yh(10,o-i)%Yh(10,i)|0)*s:0),c)for(;;)if(d==0){(f[0]+=s)==Ji&&(f[0]=1,++t.e);break}else{if(f[d]+=s,f[d]!=Ji)break;f[d--]=0,s=1}for(r=f.length;f[--r]===0;)f.pop();if(Hr&&(t.e>iS||t.e<-iS))throw Error(x4+Ti(t));return t}function iY(t,e){var n,r,i,s,o,l,c,u,d,f,m=t.constructor,g=m.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new m(t),Hr?Mr(e,g):e;if(c=t.d,f=e.d,r=e.e,u=t.e,c=c.slice(),o=u-r,o){for(d=o<0,d?(n=c,o=-o,l=f.length):(n=f,r=u,l=c.length),i=Math.max(Math.ceil(g/Lr),l)+2,o>i&&(o=i,n.length=1),n.reverse(),i=o;i--;)n.push(0);n.reverse()}else{for(i=c.length,l=f.length,d=i<l,d&&(l=i),i=0;i<l;i++)if(c[i]!=f[i]){d=c[i]<f[i];break}o=0}for(d&&(n=c,c=f,f=n,e.s=-e.s),l=c.length,i=f.length-l;i>0;--i)c[l++]=0;for(i=f.length;i>o;){if(c[--i]<f[i]){for(s=i;s&&c[--s]===0;)c[s]=Ji-1;--c[s],c[i]+=Ji}c[i]-=f[i]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--r;return c[0]?(e.d=c,e.e=r,Hr?Mr(e,g):e):new m(0)}function $f(t,e,n){var r,i=Ti(t),s=Pl(t.d),o=s.length;return e?(n&&(r=n-o)>0?s=s.charAt(0)+"."+s.slice(1)+dd(r):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i<0?"e":"e+")+i):i<0?(s="0."+dd(-i-1)+s,n&&(r=n-o)>0&&(s+=dd(r))):i>=o?(s+=dd(i+1-o),n&&(r=n-i-1)>0&&(s=s+"."+dd(r))):((r=i+1)<o&&(s=s.slice(0,r)+"."+s.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(s+="."),s+=dd(r))),t.s<0?"-"+s:s}function _6(t,e){if(t.length>e)return t.length=e,!0}function aY(t){var e,n,r;function i(s){var o=this;if(!(o instanceof i))return new i(s);if(o.constructor=i,s instanceof i){o.s=s.s,o.e=s.e,o.d=(s=s.d)?s.slice():s;return}if(typeof s=="number"){if(s*0!==0)throw Error(_f+s);if(s>0)o.s=1;else if(s<0)s=-s,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(s===~~s&&s<1e7){o.e=0,o.d=[s];return}return v6(o,s.toString())}else if(typeof s!="string")throw Error(_f+s);if(s.charCodeAt(0)===45?(s=s.slice(1),o.s=-1):o.s=1,w_e.test(s))v6(o,s);else throw Error(_f+s)}if(i.prototype=Ht,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=aY,i.config=i.set=S_e,t===void 0&&(t={}),t)for(r=["precision","rounding","toExpNeg","toExpPos","LN10"],e=0;e<r.length;)t.hasOwnProperty(n=r[e++])||(t[n]=this[n]);return i.config(t),i}function S_e(t){if(!t||typeof t!="object")throw Error(Fo+"Object expected");var e,n,r,i=["precision",1,Wg,"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(Kg(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(_f+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(_f+n+": "+r);return this}var b4=aY(__e);Vs=new b4(1);const or=b4;var N_e=t=>t,sY={},oY=t=>t===sY,w6=t=>function e(){return arguments.length===0||arguments.length===1&&oY(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},lY=(t,e)=>t===1?e:w6(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var s=r.filter(o=>o!==sY).length;return s>=t?e(...r):lY(t-s,w6(function(){for(var o=arguments.length,l=new Array(o),c=0;c<o;c++)l[c]=arguments[c];var u=r.map(d=>oY(d)?l.shift():d);return e(...u,...l)}))}),M_e=t=>lY(t.length,t),B3=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},E_e=M_e((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),T_e=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return N_e;var i=n.reverse(),s=i[0],o=i.slice(1);return function(){return o.reduce((l,c)=>c(l),s(...arguments))}},$3=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function cY(t){var e;return t===0?e=1:e=Math.floor(new or(t).abs().log(10).toNumber())+1,e}function uY(t,e,n){for(var r=new or(t),i=0,s=[];r.lt(e)&&i<1e5;)s.push(r.toNumber()),r=r.add(n),i++;return s}var dY=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},hY=(t,e,n)=>{if(t.lte(0))return new or(0);var r=cY(t.toNumber()),i=new or(10).pow(r),s=t.div(i),o=r!==1?.05:.1,l=new or(Math.ceil(s.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new or(c.toNumber()):new or(Math.ceil(c.toNumber()))},C_e=(t,e,n)=>{var r=new or(1),i=new or(t);if(!i.isint()&&n){var s=Math.abs(t);s<1?(r=new or(10).pow(cY(t)-1),i=new or(Math.floor(i.div(r).toNumber())).mul(r)):s>1&&(i=new or(Math.floor(t)))}else t===0?i=new or(Math.floor((e-1)/2)):n||(i=new or(Math.floor(t)));var o=Math.floor((e-1)/2),l=T_e(E_e(c=>i.add(new or(c-o).mul(r)).toNumber()),B3);return l(0,e)},fY=function(e,n,r,i){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-e)/(r-1)))return{step:new or(0),tickMin:new or(0),tickMax:new or(0)};var o=hY(new or(n).sub(e).div(r-1),i,s),l;e<=0&&n>=0?l=new or(0):(l=new or(e).add(n).div(2),l=l.sub(new or(l).mod(o)));var c=Math.ceil(l.sub(e).div(o).toNumber()),u=Math.ceil(new or(n).sub(l).div(o).toNumber()),d=c+u+1;return d>r?fY(e,n,r,i,s+1):(d<r&&(u=n>0?u+(r-d):u,c=n>0?c:c+(r-d)),{step:o,tickMin:l.sub(new or(c).mul(o)),tickMax:l.add(new or(u).mul(o))})},A_e=function(e){var[n,r]=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=Math.max(i,2),[l,c]=dY([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...B3(0,i-1).map(()=>1/0)]:[...B3(0,i-1).map(()=>-1/0),c];return n>r?$3(u):u}if(l===c)return C_e(l,i,s);var{step:d,tickMin:f,tickMax:m}=fY(l,c,o,s,0),g=uY(f,m.add(new or(.1).mul(d)),d);return n>r?$3(g):g},k_e=function(e,n){var[r,i]=e,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=dY([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=hY(new or(l).sub(o).div(c-1),s,0),d=[...uY(new or(o),new or(l),u),l];return s===!1&&(d=d.map(f=>Math.round(f))),r>i?$3(d):d},mY=t=>t.rootProps.maxBarSize,j_e=t=>t.rootProps.barGap,pY=t=>t.rootProps.barCategoryGap,P_e=t=>t.rootProps.barSize,Sy=t=>t.rootProps.stackOffset,gY=t=>t.rootProps.reverseStackOrder,y4=t=>t.options.chartName,v4=t=>t.rootProps.syncId,xY=t=>t.rootProps.syncMethod,_4=t=>t.options.eventEmitter,R_e=t=>t.rootProps.baseValue,oi={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},zc={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},Bs={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},_N=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},D_e={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:zc.angleAxisId,includeHidden:!1,name:void 0,reversed:zc.reversed,scale:zc.scale,tick:zc.tick,tickCount:void 0,ticks:void 0,type:zc.type,unit:void 0},O_e={allowDataOverflow:Bs.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:Bs.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Bs.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:Bs.scale,tick:Bs.tick,tickCount:Bs.tickCount,ticks:void 0,type:Bs.type,unit:void 0},L_e={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:zc.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:zc.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:zc.scale,tick:zc.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},I_e={allowDataOverflow:Bs.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:Bs.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Bs.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:Bs.scale,tick:Bs.tick,tickCount:Bs.tickCount,ticks:void 0,type:"category",unit:void 0},w4=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?L_e:D_e,S4=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?I_e:O_e,wN=t=>t.polarOptions,N4=tt([vu,_u,zi],pX),bY=tt([wN,N4],(t,e)=>{if(t!=null)return Fa(t.innerRadius,e,0)}),yY=tt([wN,N4],(t,e)=>{if(t!=null)return Fa(t.outerRadius,e,e*.8)}),F_e=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},vY=tt([wN],F_e);tt([w4,vY],_N);var _Y=tt([N4,bY,yY],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});tt([S4,_Y],_N);var wY=tt([Dn,wN,bY,yY,vu,_u],(t,e,n,r,i,s)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:o,cy:l,startAngle:c,endAngle:u}=e;return{cx:Fa(o,i,i/2),cy:Fa(l,s,s/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),qr=(t,e)=>e,Ny=(t,e,n)=>n;function SN(t){return t?.id}function SY(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:s}=n,o=new Map;return t.forEach(l=>{var c,u=(c=l.data)!==null&&c!==void 0?c:r;if(!(u==null||u.length===0)){var d=SN(l);u.forEach((f,m)=>{var g=s==null||i?m:String(lr(f,s,null)),x=lr(f,l.dataKey,0),y;o.has(g)?y=o.get(g):y={},Object.assign(y,{[d]:x}),o.set(g,y)})}}),Array.from(o.values())}function NN(t){return t.stackId!=null&&t.dataKey!=null}var MN=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function EN(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function U_e(t,e){if(t.length===e.length){for(var n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}return!1}var Hi=t=>{var e=Dn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},Xg=t=>t.tooltip.settings.axisId;function S6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function aS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?S6(Object(n),!0).forEach(function(r){z_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function z_e(t,e,n){return(e=B_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function B_e(t){var e=$_e(t,"string");return typeof e=="symbol"?e:e+""}function $_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 H3=[0,"auto"],Qi={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},NY=(t,e)=>t.cartesianAxis.xAxis[e],Zl=(t,e)=>{var n=NY(t,e);return n??Qi},Zi={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:H3,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:py},MY=(t,e)=>t.cartesianAxis.yAxis[e],Jl=(t,e)=>{var n=MY(t,e);return n??Zi},H_e={domain:[0,"auto"],includeHidden:!1,reversed:!1,allowDataOverflow:!1,allowDuplicatedCategory:!1,dataKey:void 0,id:0,name:"",range:[64,64],scale:"auto",type:"number",unit:""},M4=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??H_e},Yr=(t,e,n)=>{switch(e){case"xAxis":return Zl(t,n);case"yAxis":return Jl(t,n);case"zAxis":return M4(t,n);case"angleAxis":return w4(t,n);case"radiusAxis":return S4(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},V_e=(t,e,n)=>{switch(e){case"xAxis":return Zl(t,n);case"yAxis":return Jl(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},My=(t,e,n)=>{switch(e){case"xAxis":return Zl(t,n);case"yAxis":return Jl(t,n);case"angleAxis":return w4(t,n);case"radiusAxis":return S4(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},EY=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function E4(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 Ey=t=>t.graphicalItems.cartesianItems,G_e=tt([qr,Ny],E4),T4=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),Ty=tt([Ey,Yr,G_e],T4,{memoizeOptions:{resultEqualityCheck:EN}}),TY=tt([Ty],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(NN)),CY=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),q_e=tt([Ty],CY),C4=t=>t.map(e=>e.data).filter(Boolean).flat(1),W_e=tt([Ty],C4,{memoizeOptions:{resultEqualityCheck:EN}}),A4=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},k4=tt([W_e,wy],A4),j4=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:lr(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:lr(i,r)}))):t.map(r=>({value:r})),TN=tt([k4,Yr,Ty],j4);function AY(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function X1(t){if(Lo(t)||t instanceof Date){var e=Number(t);if(cr(e))return e}}function N6(t){if(Array.isArray(t)){var e=[X1(t[0]),X1(t[1])];return Yd(e)?e:void 0}var n=X1(t);if(n!=null)return[n,n]}function pu(t){return t.map(X1).filter(Vme)}function K_e(t,e,n){return!n||typeof e!="number"||Es(e)?[]:n.length?pu(n.flatMap(r=>{var i=lr(t,r.dataKey),s,o;if(Array.isArray(i)?[s,o]=i:s=o=i,!(!cr(s)||!cr(o)))return[e-s,e+o]})):[]}var Vi=t=>{var e=Hi(t),n=Xg(t);return My(t,e,n)},Cy=tt([Vi],t=>t?.dataKey),X_e=tt([TY,wy,Vi],SY),kY=(t,e,n,r)=>{var i={},s=e.reduce((o,l)=>(l.stackId==null||(o[l.stackId]==null&&(o[l.stackId]=[]),o[l.stackId].push(l)),o),i);return Object.fromEntries(Object.entries(s).map(o=>{var[l,c]=o,u=r?[...c].reverse():c,d=u.map(SN);return[l,{stackedData:mxe(t,d,n),graphicalItems:u}]}))},R0=tt([X_e,TY,Sy,gY],kY),jY=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:s}=e;if(r==null&&n!=="zAxis"){var o=bxe(t,i,s);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},Y_e=tt([Yr],t=>t.allowDataOverflow),P4=t=>{var e;if(t==null||!("domain"in t))return H3;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=pu(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:H3},R4=tt([Yr],P4),D4=tt([R4,Y_e],eY),Q_e=tt([R0,fh,qr,D4],jY,{memoizeOptions:{resultEqualityCheck:MN}}),CN=t=>t.errorBars,Z_e=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>AY(n,r)),sS=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=n.filter(Boolean);if(i.length!==0){var s=i.flat(),o=Math.min(...s),l=Math.max(...s);return[o,l]}},O4=(t,e,n,r,i)=>{var s,o;if(n.length>0&&t.forEach(l=>{n.forEach(c=>{var u,d,f=(u=r[c.id])===null||u===void 0?void 0:u.filter(v=>AY(i,v)),m=lr(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),g=K_e(l,m,f);if(g.length>=2){var x=Math.min(...g),y=Math.max(...g);(s==null||x<s)&&(s=x),(o==null||y>o)&&(o=y)}var b=N6(m);b!=null&&(s=s==null?b[0]:Math.min(s,b[0]),o=o==null?b[1]:Math.max(o,b[1]))})}),e?.dataKey!=null&&t.forEach(l=>{var c=N6(lr(l,e.dataKey));c!=null&&(s=s==null?c[0]:Math.min(s,c[0]),o=o==null?c[1]:Math.max(o,c[1]))}),cr(s)&&cr(o))return[s,o]},J_e=tt([k4,Yr,q_e,CN,qr],O4,{memoizeOptions:{resultEqualityCheck:MN}});function e1e(t){var{value:e}=t;if(Lo(e)||e instanceof Date)return e}var t1e=(t,e,n)=>{var r=t.map(e1e).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&qW(r))?yX(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},PY=t=>t.referenceElements.dots,Yg=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),n1e=tt([PY,qr,Ny],Yg),RY=t=>t.referenceElements.areas,r1e=tt([RY,qr,Ny],Yg),DY=t=>t.referenceElements.lines,i1e=tt([DY,qr,Ny],Yg),OY=(t,e)=>{var n=pu(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},a1e=tt(n1e,qr,OY),LY=(t,e)=>{var n=pu(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)]},s1e=tt([r1e,qr],LY);function o1e(t){var e;if(t.x!=null)return pu([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:pu(n)}function l1e(t){var e;if(t.y!=null)return pu([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:pu(n)}var IY=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?o1e(r):l1e(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},c1e=tt([i1e,qr],IY),u1e=tt(a1e,c1e,s1e,(t,e,n)=>sS(t,n,e)),L4=(t,e,n,r,i,s,o,l)=>{if(n!=null)return n;var c=o==="vertical"&&l==="xAxis"||o==="horizontal"&&l==="yAxis",u=c?sS(r,s,i):sS(s,i);return v_e(e,u,t.allowDataOverflow)},d1e=tt([Yr,R4,D4,Q_e,J_e,u1e,Dn,qr],L4,{memoizeOptions:{resultEqualityCheck:MN}}),h1e=[0,1],I4=(t,e,n,r,i,s,o)=>{if(!((t==null||n==null||n.length===0)&&o===void 0)){var{dataKey:l,type:c}=t,u=Ql(e,s);if(u&&l==null){var d;return yX(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?t1e(r,t,u):i==="expand"?h1e:o}},F4=tt([Yr,Dn,k4,TN,Sy,qr,d1e],I4),FY=(t,e,n,r,i)=>{if(t!=null){var{scale:s,type:o}=t;if(s==="auto")return e==="radial"&&i==="radiusAxis"?"band":e==="radial"&&i==="angleAxis"?"linear":o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":o==="category"?"band":"linear";if(typeof s=="string"){var l="scale".concat(cy(s));return l in Ab?l:"point"}}},Qg=tt([Yr,Dn,EY,y4,qr],FY);function f1e(t){if(t!=null){if(t in Ab)return Ab[t]();var e="scale".concat(cy(t));if(e in Ab)return Ab[e]()}}function U4(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=f1e(e);if(i!=null){var s=i.domain(n).range(r);return cxe(s),s}}}var z4=(t,e,n)=>{var r=P4(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&Yd(t))return A_e(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&Yd(t))return k_e(t,e.tickCount,e.allowDecimals)}},B4=tt([F4,My,Qg],z4),$4=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&Yd(e)&&Array.isArray(n)&&n.length>0){var i=e[0],s=n[0],o=e[1],l=n[n.length-1];return[Math.min(i,s),Math.max(o,l)]}return e},m1e=tt([Yr,F4,B4,qr],$4),p1e=tt(TN,Yr,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(pu(t.map(l=>l.value))).sort((l,c)=>l-c);if(r.length<2)return 1/0;var i=r[r.length-1]-r[0];if(i===0)return 1/0;for(var s=0;s<r.length-1;s++){var o=r[s+1]-r[s];n=Math.min(n,o)}return n/i}}),UY=tt(p1e,Dn,pY,zi,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!cr(t))return 0;var s=e==="vertical"?r.height:r.width;if(i==="gap")return t*s/2;if(i==="no-gap"){var o=Fa(n,t*s),l=t*s/2;return l-o-(l-o)/s*o}return 0}),g1e=(t,e)=>{var n=Zl(t,e);return n==null||typeof n.padding!="string"?0:UY(t,"xAxis",e,n.padding)},x1e=(t,e)=>{var n=Jl(t,e);return n==null||typeof n.padding!="string"?0:UY(t,"yAxis",e,n.padding)},b1e=tt(Zl,g1e,(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}}),y1e=tt(Jl,x1e,(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}}),v1e=tt([zi,b1e,uN,cN,(t,e,n)=>n],(t,e,n,r,i)=>{var{padding:s}=r;return i?[s.left,n.width-s.right]:[t.left+e.left,t.left+t.width-e.right]}),_1e=tt([zi,Dn,y1e,uN,cN,(t,e,n)=>n],(t,e,n,r,i,s)=>{var{padding:o}=i;return s?[r.height-o.bottom,o.top]:e==="horizontal"?[t.top+t.height-n.bottom,t.top+n.top]:[t.top+n.top,t.top+t.height-n.bottom]}),Ay=(t,e,n,r)=>{var i;switch(e){case"xAxis":return v1e(t,n,r);case"yAxis":return _1e(t,n,r);case"zAxis":return(i=M4(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return vY(t);case"radiusAxis":return _Y(t,n);default:return}},zY=tt([Yr,Ay],_N),Qd=tt([Yr,Qg,m1e,zY],U4);tt([Ty,CN,qr],Z_e);function BY(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var AN=(t,e)=>e,kN=(t,e,n)=>n,w1e=tt(oN,AN,kN,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(BY)),S1e=tt(lN,AN,kN,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(BY)),$Y=(t,e)=>({width:t.width,height:e.height}),N1e=(t,e)=>{var n=typeof e.width=="number"?e.width:py;return{width:n,height:t.height}},HY=tt(zi,Zl,$Y),M1e=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},E1e=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},T1e=tt(_u,zi,w1e,AN,kN,(t,e,n,r,i)=>{var s={},o;return n.forEach(l=>{var c=$Y(e,l);o==null&&(o=M1e(e,r,t));var u=r==="top"&&!i||r==="bottom"&&i;s[l.id]=o-Number(u)*c.height,o+=(u?-1:1)*c.height}),s}),C1e=tt(vu,zi,S1e,AN,kN,(t,e,n,r,i)=>{var s={},o;return n.forEach(l=>{var c=N1e(e,l);o==null&&(o=E1e(e,r,t));var u=r==="left"&&!i||r==="right"&&i;s[l.id]=o-Number(u)*c.width,o+=(u?-1:1)*c.width}),s}),A1e=(t,e)=>{var n=Zl(t,e);if(n!=null)return T1e(t,n.orientation,n.mirror)},k1e=tt([zi,Zl,A1e,(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}}}),j1e=(t,e)=>{var n=Jl(t,e);if(n!=null)return C1e(t,n.orientation,n.mirror)},P1e=tt([zi,Jl,j1e,(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}}}),VY=tt(zi,Jl,(t,e)=>{var n=typeof e.width=="number"?e.width:py;return{width:n,height:t.height}}),M6=(t,e,n)=>{switch(e){case"xAxis":return HY(t,n).width;case"yAxis":return VY(t,n).height;default:return}},GY=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:s,dataKey:o}=n,l=Ql(t,r),c=e.map(u=>u.value);if(o&&l&&s==="category"&&i&&qW(c))return c}},H4=tt([Dn,TN,Yr,qr],GY),qY=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:s}=n,o=Ql(t,r);if(o&&(i==="number"||s!=="auto"))return e.map(l=>l.value)}},V4=tt([Dn,TN,My,qr],qY),E6=tt([Dn,V_e,Qg,Qd,H4,V4,Ay,B4,qr],(t,e,n,r,i,s,o,l,c)=>{if(e!=null){var u=Ql(t,c);return{angle:e.angle,interval:e.interval,minTickGap:e.minTickGap,orientation:e.orientation,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit,axisType:c,categoricalDomain:s,duplicateDomain:i,isCategorical:u,niceTicks:l,range:o,realScaleType:n,scale:r}}}),R1e=(t,e,n,r,i,s,o,l,c)=>{if(!(e==null||r==null)){var u=Ql(t,c),{type:d,ticks:f,tickCount:m}=e,g=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,x=d==="category"&&r.bandwidth?r.bandwidth()/g:0;x=c==="angleAxis"&&s!=null&&s.length>=2?ra(s[0]-s[1])*2*x:x;var y=f||i;if(y){var b=y.map((v,N)=>{var S=o?o.indexOf(v):v;return{index:N,coordinate:r(S)+x,value:v,offset:x}});return b.filter(v=>cr(v.coordinate))}return u&&l?l.map((v,N)=>({coordinate:r(v)+x,value:v,index:N,offset:x})).filter(v=>cr(v.coordinate)):r.ticks?r.ticks(m).map(v=>({coordinate:r(v)+x,value:v,offset:x})):r.domain().map((v,N)=>({coordinate:r(v)+x,value:o?o[v]:v,index:N,offset:x}))}},WY=tt([Dn,My,Qg,Qd,B4,Ay,H4,V4,qr],R1e),D1e=(t,e,n,r,i,s,o)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=Ql(t,o),{tickCount:c}=e,u=0;return u=o==="angleAxis"&&r?.length>=2?ra(r[0]-r[1])*2*u:u,l&&s?s.map((d,f)=>({coordinate:n(d)+u,value:d,index:f,offset:u})):n.ticks?n.ticks(c).map(d=>({coordinate:n(d)+u,value:d,offset:u})):n.domain().map((d,f)=>({coordinate:n(d)+u,value:i?i[d]:d,index:f,offset:u}))}},Hl=tt([Dn,My,Qd,Ay,H4,V4,qr],D1e),Vl=tt(Yr,Qd,(t,e)=>{if(!(t==null||e==null))return aS(aS({},t),{},{scale:e})}),O1e=tt([Yr,Qg,F4,zY],U4);tt((t,e,n)=>M4(t,n),O1e,(t,e)=>{if(!(t==null||e==null))return aS(aS({},t),{},{scale:e})});var L1e=tt([Dn,oN,lN],(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}}),KY=t=>t.options.defaultTooltipEventType,XY=t=>t.options.validateTooltipEventTypes;function YY(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function G4(t,e){var n=KY(t),r=XY(t);return YY(e,n,r)}function I1e(t){return It(e=>G4(e,t))}var QY=(t,e)=>{var n,r=Number(e);if(!(Es(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},F1e=t=>t.tooltip.settings,yd={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},U1e={itemInteraction:{click:yd,hover:yd},axisInteraction:{click:yd,hover:yd},keyboardInteraction:yd,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}},ZY=Ts({name:"tooltip",initialState:U1e,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:Ur()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=sl(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:Ur()},removeTooltipEntrySettings:{reducer(t,e){var n=sl(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:Ur()},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:z1e,replaceTooltipEntrySettings:B1e,removeTooltipEntrySettings:$1e,setTooltipSettingsState:H1e,setActiveMouseOverItemIndex:JY,mouseLeaveItem:V1e,mouseLeaveChart:eQ,setActiveClickItemIndex:G1e,setMouseOverAxisIndex:tQ,setMouseClickAxisIndex:q1e,setSyncInteraction:V3,setKeyboardInteraction:G3}=ZY.actions,W1e=ZY.reducer;function T6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function v_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?T6(Object(n),!0).forEach(function(r){K1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):T6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function K1e(t,e,n){return(e=X1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function X1e(t){var e=Y1e(t,"string");return typeof e=="symbol"?e:e+""}function Y1e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Q1e(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function Z1e(t){return t.index!=null}var nQ=(t,e,n,r)=>{if(e==null)return yd;var i=Q1e(t,e,n);if(i==null)return yd;if(i.active)return i;if(t.keyboardInteraction.active)return t.keyboardInteraction;if(t.syncInteraction.active&&t.syncInteraction.index!=null)return t.syncInteraction;var s=t.settings.active===!0;if(Z1e(i)){if(s)return v_(v_({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return v_(v_({},yd),{},{coordinate:i.coordinate})};function J1e(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 ewe(t,e){var n=J1e(t),r=e[0],i=e[1];if(n===void 0)return!1;var s=Math.min(r,i),o=Math.max(r,i);return n>=s&&n<=o}function twe(t,e,n){if(n==null||e==null)return!0;var r=lr(t,e);return r==null||!Yd(n)?!0:ewe(r,n)}var q4=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var s=Number(i);if(!cr(s))return i;var o=0,l=1/0;e.length>0&&(l=e.length-1);var c=Math.max(o,Math.min(s,l)),u=e[c];return u==null||twe(u,n,r)?String(c):null},rQ=(t,e,n,r,i,s,o,l)=>{if(!(s==null||l==null)){var c=o[0],u=c==null?void 0:l(c.positions,s);if(u!=null)return u;var d=i?.[Number(s)];if(d)switch(n){case"horizontal":return{x:d.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:d.coordinate}}}},iQ=(t,e,n,r)=>{if(e==="axis")return t.tooltipItemPayloads;if(t.tooltipItemPayloads.length===0)return[];var i;return n==="hover"?i=t.itemInteraction.hover.dataKey:i=t.itemInteraction.click.dataKey,i==null&&r!=null?[t.tooltipItemPayloads[0]]:t.tooltipItemPayloads.filter(s=>{var o;return((o=s.settings)===null||o===void 0?void 0:o.dataKey)===i})},ky=t=>t.options.tooltipPayloadSearcher,Zg=t=>t.tooltip;function C6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function A6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?C6(Object(n),!0).forEach(function(r){nwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):C6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nwe(t,e,n){return(e=rwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rwe(t){var e=iwe(t,"string");return typeof e=="symbol"?e:e+""}function iwe(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 awe(t,e){return t??e}var aQ=(t,e,n,r,i,s,o)=>{if(!(e==null||s==null)){var{chartData:l,computedData:c,dataStartIndex:u,dataEndIndex:d}=n,f=[];return t.reduce((m,g)=>{var x,{dataDefinedOnItem:y,settings:b}=g,v=awe(y,l),N=Array.isArray(v)?BK(v,u,d):v,S=(x=b?.dataKey)!==null&&x!==void 0?x:r,T=b?.nameKey,E;if(r&&Array.isArray(N)&&!Array.isArray(N[0])&&o==="axis"?E=WW(N,r,i):E=s(N,e,c,T),Array.isArray(E))E.forEach(C=>{var D=A6(A6({},b),{},{name:C.name,unit:C.unit,color:void 0,fill:void 0});m.push(XB({tooltipEntrySettings:D,dataKey:C.dataKey,payload:C.payload,value:lr(C.payload,C.dataKey),name:C.name}))});else{var k;m.push(XB({tooltipEntrySettings:b,dataKey:S,payload:E,value:lr(E,S),name:(k=lr(E,T))!==null&&k!==void 0?k:b?.name}))}return m},f)}},W4=tt([Vi,Dn,EY,y4,Hi],FY),swe=tt([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),owe=tt([Hi,Xg],E4),jy=tt([swe,Vi,owe],T4,{memoizeOptions:{resultEqualityCheck:EN}}),lwe=tt([jy],t=>t.filter(NN)),cwe=tt([jy],C4,{memoizeOptions:{resultEqualityCheck:EN}}),Jg=tt([cwe,fh],A4),uwe=tt([lwe,fh,Vi],SY),K4=tt([Jg,Vi,jy],j4),sQ=tt([Vi],P4),dwe=tt([Vi],t=>t.allowDataOverflow),oQ=tt([sQ,dwe],eY),hwe=tt([jy],t=>t.filter(NN)),fwe=tt([uwe,hwe,Sy,gY],kY),mwe=tt([fwe,fh,Hi,oQ],jY),pwe=tt([jy],CY),gwe=tt([Jg,Vi,pwe,CN,Hi],O4,{memoizeOptions:{resultEqualityCheck:MN}}),xwe=tt([PY,Hi,Xg],Yg),bwe=tt([xwe,Hi],OY),ywe=tt([RY,Hi,Xg],Yg),vwe=tt([ywe,Hi],LY),_we=tt([DY,Hi,Xg],Yg),wwe=tt([_we,Hi],IY),Swe=tt([bwe,wwe,vwe],sS),Nwe=tt([Vi,sQ,oQ,mwe,gwe,Swe,Dn,Hi],L4),Py=tt([Vi,Dn,Jg,K4,Sy,Hi,Nwe],I4),Mwe=tt([Py,Vi,W4],z4),Ewe=tt([Vi,Py,Mwe,Hi],$4),lQ=t=>{var e=Hi(t),n=Xg(t),r=!1;return Ay(t,e,n,r)},cQ=tt([Vi,lQ],_N),uQ=tt([Vi,W4,Ewe,cQ],U4),Twe=tt([Dn,K4,Vi,Hi],GY),Cwe=tt([Dn,K4,Vi,Hi],qY),Awe=(t,e,n,r,i,s,o,l)=>{if(e){var{type:c}=e,u=Ql(t,l);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,f=c==="category"&&r.bandwidth?r.bandwidth()/d:0;return f=l==="angleAxis"&&i!=null&&i?.length>=2?ra(i[0]-i[1])*2*f:f,u&&o?o.map((m,g)=>({coordinate:r(m)+f,value:m,index:g,offset:f})):r.domain().map((m,g)=>({coordinate:r(m)+f,value:s?s[m]:m,index:g,offset:f}))}}},Su=tt([Dn,Vi,W4,uQ,lQ,Twe,Cwe,Hi],Awe),X4=tt([KY,XY,F1e],(t,e,n)=>YY(n.shared,t,e)),dQ=t=>t.tooltip.settings.trigger,Y4=t=>t.tooltip.settings.defaultIndex,Ry=tt([Zg,X4,dQ,Y4],nQ),Zd=tt([Ry,Jg,Cy,Py],q4),hQ=tt([Su,Zd],QY),Q4=tt([Ry],t=>{if(t)return t.dataKey}),kwe=tt([Ry],t=>{if(t)return t.graphicalItemId}),fQ=tt([Zg,X4,dQ,Y4],iQ),jwe=tt([vu,_u,Dn,zi,Su,Y4,fQ,ky],rQ),Pwe=tt([Ry,jwe],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),Rwe=tt([Ry],t=>t.active),Dwe=tt([fQ,Zd,fh,Cy,hQ,ky,X4],aQ),Owe=tt([Dwe],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function k6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function j6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?k6(Object(n),!0).forEach(function(r){Lwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):k6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Lwe(t,e,n){return(e=Iwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Iwe(t){var e=Fwe(t,"string");return typeof e=="symbol"?e:e+""}function Fwe(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 Uwe=()=>It(Vi),zwe=()=>{var t=Uwe(),e=It(Su),n=It(uQ);return Xd(!t||!n?void 0:j6(j6({},t),{},{scale:n}),e)};function P6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Gm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P6(Object(n),!0).forEach(function(r){Bwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Bwe(t,e,n){return(e=$we(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $we(t){var e=Hwe(t,"string");return typeof e=="symbol"?e:e+""}function Hwe(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 Vwe=(t,e,n,r)=>{var i=e.find(s=>s&&s.index===n);if(i){if(t==="horizontal")return{x:i.coordinate,y:r.chartY};if(t==="vertical")return{x:r.chartX,y:i.coordinate}}return{x:0,y:0}},Gwe=(t,e,n,r)=>{var i=e.find(u=>u&&u.index===n);if(i){if(t==="centric"){var s=i.coordinate,{radius:o}=r;return Gm(Gm(Gm({},r),Ni(r.cx,r.cy,o,s)),{},{angle:s,radius:o})}var l=i.coordinate,{angle:c}=r;return Gm(Gm(Gm({},r),Ni(r.cx,r.cy,l,c)),{},{angle:c,radius:l})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function qwe(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 mQ=(t,e,n,r,i)=>{var s,o=-1,l=(s=e?.length)!==null&&s!==void 0?s:0;if(l<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var c=0;c<l;c++){var u=c>0?n[c-1].coordinate:n[l-1].coordinate,d=n[c].coordinate,f=c>=l-1?n[0].coordinate:n[c+1].coordinate,m=void 0;if(ra(d-u)!==ra(f-d)){var g=[];if(ra(f-d)===ra(i[1]-i[0])){m=f;var x=d+i[1]-i[0];g[0]=Math.min(x,(x+u)/2),g[1]=Math.max(x,(x+u)/2)}else{m=u;var y=f+i[1]-i[0];g[0]=Math.min(d,(y+d)/2),g[1]=Math.max(d,(y+d)/2)}var b=[Math.min(d,(m+d)/2),Math.max(d,(m+d)/2)];if(t>b[0]&&t<=b[1]||t>=g[0]&&t<=g[1]){({index:o}=n[c]);break}}else{var v=Math.min(u,f),N=Math.max(u,f);if(t>(v+d)/2&&t<=(N+d)/2){({index:o}=n[c]);break}}}else if(e){for(var S=0;S<l;S++)if(S===0&&t<=(e[S].coordinate+e[S+1].coordinate)/2||S>0&&S<l-1&&t>(e[S].coordinate+e[S-1].coordinate)/2&&t<=(e[S].coordinate+e[S+1].coordinate)/2||S===l-1&&t>(e[S].coordinate+e[S-1].coordinate)/2){({index:o}=e[S]);break}}return o},pQ=()=>It(y4),Z4=(t,e)=>e,gQ=(t,e,n)=>n,J4=(t,e,n,r)=>r,Wwe=tt(Su,t=>Z2(t,e=>e.coordinate)),eO=tt([Zg,Z4,gQ,J4],nQ),tO=tt([eO,Jg,Cy,Py],q4),Kwe=(t,e,n)=>{if(e!=null){var r=Zg(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=tt([Zg,Z4,gQ,J4],iQ),oS=tt([vu,_u,Dn,zi,Su,J4,xQ,ky],rQ),Xwe=tt([eO,oS],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),bQ=tt([Su,tO],QY),Ywe=tt([xQ,tO,fh,Cy,bQ,ky,Z4],aQ),Qwe=tt([eO,tO],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),Zwe=(t,e,n,r,i,s,o)=>{if(!(!t||!n||!r||!i)&&qwe(t,o)){var l=yxe(t,e),c=mQ(l,s,i,n,r),u=Vwe(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},Jwe=(t,e,n,r,i,s,o)=>{if(!(!t||!r||!i||!s||!n)){var l=L0e(t,n);if(l){var c=vxe(l,e),u=mQ(c,o,s,r,i),d=Gwe(e,s,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},eSe=(t,e,n,r,i,s,o,l)=>{if(!(!t||!e||!r||!i||!s))return e==="horizontal"||e==="vertical"?Zwe(t,e,r,i,s,o,l):Jwe(t,e,n,r,i,s,o)},tSe=tt(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}}),nSe=tt(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(oi)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:U_e}});function R6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function D6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?R6(Object(n),!0).forEach(function(r){rSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):R6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rSe(t,e,n){return(e=iSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function iSe(t){var e=aSe(t,"string");return typeof e=="symbol"?e:e+""}function aSe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var sSe={},oSe={zIndexMap:Object.values(oi).reduce((t,e)=>D6(D6({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),sSe)},lSe=new Set(Object.values(oi));function cSe(t){return lSe.has(t)}var yQ=Ts({name:"zIndex",initialState:oSe,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:Ur()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!cSe(n)&&delete t.zIndexMap[n])},prepare:Ur()},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:Ur()},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:Ur()}}}),{registerZIndexPortal:uSe,unregisterZIndexPortal:dSe,registerZIndexPortalId:hSe,unregisterZIndexPortalId:fSe}=yQ.actions,mSe=yQ.reducer;function za(t){var{zIndex:e,children:n}=t,r=Zxe(),i=r&&e!==void 0&&e!==0,s=Bi(),o=Er();w.useLayoutEffect(()=>i?(o(uSe({zIndex:e})),()=>{o(dSe({zIndex:e}))}):uy,[o,e,i]);var l=It(u=>tSe(u,e,s));if(!i)return n;if(!l)return null;var c=document.getElementById(l);return c?Vc.createPortal(n,c):null}function q3(){return q3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},q3.apply(null,arguments)}function O6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function __(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?O6(Object(n),!0).forEach(function(r){pSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):O6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pSe(t,e,n){return(e=gSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gSe(t){var e=xSe(t,"string");return typeof e=="symbol"?e:e+""}function xSe(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 bSe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return w.isValidElement(e)?w.cloneElement(e,r):w.createElement(n,r)}function ySe(t){var e,{coordinate:n,payload:r,index:i,offset:s,tooltipAxisBandSize:o,layout:l,cursor:c,tooltipEventType:u,chartName:d}=t,f=n,m=r,g=i;if(!c||!f||d!=="ScatterChart"&&u!=="axis")return null;var x,y,b;if(d==="ScatterChart")x=f,y=Qbe,b=oi.cursorLine;else if(d==="BarChart")x=Zbe(l,f,s,o),y=mX,b=oi.cursorRectangle;else if(l==="radial"&&XW(f)){var{cx:v,cy:N,radius:S,startAngle:T,endAngle:E}=gX(f);x={cx:v,cy:N,startAngle:T,endAngle:E,innerRadius:S,outerRadius:S},y=bX,b=oi.cursorLine}else x={points:z0e(l,f,s)},y=Yp,b=oi.cursorLine;var k=typeof c=="object"&&"className"in c?c.className:void 0,C=__(__(__(__({stroke:"#ccc",pointerEvents:"none"},s),x),Ff(c)),{},{payload:m,payloadIndex:g,className:Vn("recharts-tooltip-cursor",k)});return w.createElement(za,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:b},w.createElement(bSe,{cursor:c,cursorComp:y,cursorProps:C}))}function vSe(t){var e=zwe(),n=ZK(),r=im(),i=pQ();return e==null||n==null||r==null||i==null?null:w.createElement(ySe,q3({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var vQ=w.createContext(null),_Se=()=>w.useContext(vQ),tA={exports:{}},L6;function wSe(){return L6||(L6=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function s(c,u,d,f,m){if(typeof d!="function")throw new TypeError("The listener must be a function");var g=new i(d,f||c,m),x=n?n+u:u;return c._events[x]?c._events[x].fn?c._events[x]=[c._events[x],g]:c._events[x].push(g):(c._events[x]=g,c._eventsCount++),c}function o(c,u){--c._eventsCount===0?c._events=new r:delete c._events[u]}function l(){this._events=new r,this._eventsCount=0}l.prototype.eventNames=function(){var u=[],d,f;if(this._eventsCount===0)return u;for(f in d=this._events)e.call(d,f)&&u.push(n?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},l.prototype.listeners=function(u){var d=n?n+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var m=0,g=f.length,x=new Array(g);m<g;m++)x[m]=f[m].fn;return x},l.prototype.listenerCount=function(u){var d=n?n+u:u,f=this._events[d];return f?f.fn?1:f.length:0},l.prototype.emit=function(u,d,f,m,g,x){var y=n?n+u:u;if(!this._events[y])return!1;var b=this._events[y],v=arguments.length,N,S;if(b.fn){switch(b.once&&this.removeListener(u,b.fn,void 0,!0),v){case 1:return b.fn.call(b.context),!0;case 2:return b.fn.call(b.context,d),!0;case 3:return b.fn.call(b.context,d,f),!0;case 4:return b.fn.call(b.context,d,f,m),!0;case 5:return b.fn.call(b.context,d,f,m,g),!0;case 6:return b.fn.call(b.context,d,f,m,g,x),!0}for(S=1,N=new Array(v-1);S<v;S++)N[S-1]=arguments[S];b.fn.apply(b.context,N)}else{var T=b.length,E;for(S=0;S<T;S++)switch(b[S].once&&this.removeListener(u,b[S].fn,void 0,!0),v){case 1:b[S].fn.call(b[S].context);break;case 2:b[S].fn.call(b[S].context,d);break;case 3:b[S].fn.call(b[S].context,d,f);break;case 4:b[S].fn.call(b[S].context,d,f,m);break;default:if(!N)for(E=1,N=new Array(v-1);E<v;E++)N[E-1]=arguments[E];b[S].fn.apply(b[S].context,N)}}return!0},l.prototype.on=function(u,d,f){return s(this,u,d,f,!1)},l.prototype.once=function(u,d,f){return s(this,u,d,f,!0)},l.prototype.removeListener=function(u,d,f,m){var g=n?n+u:u;if(!this._events[g])return this;if(!d)return o(this,g),this;var x=this._events[g];if(x.fn)x.fn===d&&(!m||x.once)&&(!f||x.context===f)&&o(this,g);else{for(var y=0,b=[],v=x.length;y<v;y++)(x[y].fn!==d||m&&!x[y].once||f&&x[y].context!==f)&&b.push(x[y]);b.length?this._events[g]=b.length===1?b[0]:b:o(this,g)}return this},l.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&o(this,d)):(this._events=new r,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=n,l.EventEmitter=l,t.exports=l})(tA)),tA.exports}var SSe=wSe();const NSe=Uo(SSe);var D0=new NSe,W3="recharts.syncEvent.tooltip",I6="recharts.syncEvent.brush";function jN(t,e){if(e){var n=Number.parseInt(e,10);if(!Es(n))return t?.[n]}}var MSe={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},_Q=Ts({name:"options",initialState:MSe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),ESe=_Q.reducer,{createEventEmitter:TSe}=_Q.actions;function CSe(t){return t.tooltip.syncInteraction}var ASe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},wQ=Ts({name:"chartData",initialState:ASe,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:F6,setDataStartEndIndexes:kSe,setComputedData:AXe}=wQ.actions,jSe=wQ.reducer,PSe=["x","y"];function U6(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 qm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?U6(Object(n),!0).forEach(function(r){RSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):U6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function RSe(t,e,n){return(e=DSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DSe(t){var e=OSe(t,"string");return typeof e=="symbol"?e:e+""}function OSe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function LSe(t,e){if(t==null)return{};var n,r,i=ISe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function ISe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function FSe(){var t=It(v4),e=It(_4),n=Er(),r=It(xY),i=It(Su),s=im(),o=gy(),l=It(c=>c.rootProps.className);w.useEffect(()=>{if(t==null)return uy;var c=(u,d,f)=>{if(e!==f&&t===u){if(r==="index"){var m;if(o&&d!==null&&d!==void 0&&(m=d.payload)!==null&&m!==void 0&&m.coordinate&&d.payload.sourceViewBox){var g=d.payload.coordinate,{x,y}=g,b=LSe(g,PSe),{x:v,y:N,width:S,height:T}=d.payload.sourceViewBox,E=qm(qm({},b),{},{x:o.x+(S?(x-v)/S:0)*o.width,y:o.y+(T?(y-N)/T:0)*o.height});n(qm(qm({},d),{},{payload:qm(qm({},d.payload),{},{coordinate:E})}))}else n(d);return}if(i!=null){var k;if(typeof r=="function"){var C={activeTooltipIndex:d.payload.index==null?void 0:Number(d.payload.index),isTooltipActive:d.payload.active,activeIndex:d.payload.index==null?void 0:Number(d.payload.index),activeLabel:d.payload.label,activeDataKey:d.payload.dataKey,activeCoordinate:d.payload.coordinate},D=r(i,C);k=i[D]}else r==="value"&&(k=i.find(Y=>String(Y.value)===d.payload.label));var{coordinate:A}=d.payload;if(k==null||d.payload.active===!1||A==null||o==null){n(V3({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:R,y:F}=A,O=Math.min(R,o.x+o.width),q=Math.min(F,o.y+o.height),j={x:s==="horizontal"?k.coordinate:O,y:s==="horizontal"?q:k.coordinate},G=V3({active:d.payload.active,coordinate:j,dataKey:d.payload.dataKey,index:String(k.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(G)}}};return D0.on(W3,c),()=>{D0.off(W3,c)}},[l,n,e,t,r,i,s,o])}function USe(){var t=It(v4),e=It(_4),n=Er();w.useEffect(()=>{if(t==null)return uy;var r=(i,s,o)=>{e!==o&&t===i&&n(kSe(s))};return D0.on(I6,r),()=>{D0.off(I6,r)}},[n,e,t])}function zSe(){var t=Er();w.useEffect(()=>{t(TSe())},[t]),FSe(),USe()}function BSe(t,e,n,r,i,s){var o=It(g=>Kwe(g,t,e)),l=It(_4),c=It(v4),u=It(xY),d=It(CSe),f=d?.active,m=gy();w.useEffect(()=>{if(!f&&c!=null&&l!=null){var g=V3({active:s,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:m,graphicalItemId:void 0});D0.emit(W3,c,g,l)}},[f,n,o,i,r,l,c,u,s,m])}function z6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function B6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?z6(Object(n),!0).forEach(function(r){$Se(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):z6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $Se(t,e,n){return(e=HSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function HSe(t){var e=VSe(t,"string");return typeof e=="symbol"?e:e+""}function VSe(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 GSe(t){return t.dataKey}function qSe(t,e){return w.isValidElement(t)?w.cloneElement(t,e):typeof t=="function"?w.createElement(t,e):w.createElement(kbe,e)}var $6=[],WSe={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 Y1(t){var e,n,r=Xr(t,WSe),{active:i,allowEscapeViewBox:s,animationDuration:o,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:m,position:g,reverseDirection:x,useTranslate3d:y,wrapperStyle:b,cursor:v,shared:N,trigger:S,defaultIndex:T,portal:E,axisId:k}=r,C=Er(),D=typeof T=="number"?String(T):T;w.useEffect(()=>{C(H1e({shared:N,trigger:S,axisId:k,active:i,defaultIndex:D}))},[C,N,S,k,i,D]);var A=gy(),R=cX(),F=I1e(N),{activeIndex:O,isActive:q}=(e=It(xe=>Qwe(xe,F,S,D)))!==null&&e!==void 0?e:{},j=It(xe=>Ywe(xe,F,S,D)),G=It(xe=>bQ(xe,F,S,D)),Y=It(xe=>Xwe(xe,F,S,D)),K=j,Z=_Se(),te=(n=i??q)!==null&&n!==void 0?n:!1,[ne,z]=dK([K,te]),W=F==="axis"?G:void 0;BSe(F,S,Y,W,O,te);var se=E??Z;if(se==null||A==null||F==null)return null;var ae=K??$6;te||(ae=$6),u&&ae.length&&(ae=aK(ae.filter(xe=>xe.value!=null&&(xe.hide!==!0||r.includeHidden)),m,GSe));var de=ae.length>0,me=w.createElement(Ibe,{allowEscapeViewBox:s,animationDuration:o,animationEasing:l,isAnimationActive:d,active:te,coordinate:Y,hasPayload:de,offset:f,position:g,reverseDirection:x,useTranslate3d:y,viewBox:A,wrapperStyle:b,lastBoundingBox:ne,innerRef:z,hasPortalFromProps:!!E},qSe(c,B6(B6({},r),{},{payload:ae,label:W,active:te,activeIndex:O,coordinate:Y,accessibilityLayer:R})));return w.createElement(w.Fragment,null,Vc.createPortal(me,se),te&&w.createElement(vSe,{cursor:v,tooltipEventType:F,coordinate:Y,payload:ae,index:O}))}var Dy=t=>null;Dy.displayName="Cell";function KSe(t,e,n){return(e=XSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function XSe(t){var e=YSe(t,"string");return typeof e=="symbol"?e:e+""}function YSe(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 QSe{constructor(e){KSe(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 H6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ZSe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?H6(Object(n),!0).forEach(function(r){JSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):H6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function JSe(t,e,n){return(e=e2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function e2e(t){var e=t2e(t,"string");return typeof e=="symbol"?e:e+""}function t2e(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 n2e={cacheSize:2e3,enableCache:!0},SQ=ZSe({},n2e),V6=new QSe(SQ.cacheSize),r2e={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},G6="recharts_measurement_span";function i2e(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",s=e.fontStyle||"",o=e.letterSpacing||"",l=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(s,"|").concat(o,"|").concat(l)}var q6=(t,e)=>{try{var n=document.getElementById(G6);n||(n=document.createElement("span"),n.setAttribute("id",G6),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,r2e,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},Vb=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Hg.isSsr)return{width:0,height:0};if(!SQ.enableCache)return q6(e,n);var r=i2e(e,n),i=V6.get(r);if(i)return i;var s=q6(e,n);return V6.set(r,s),s},W6=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,K6=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,a2e=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,s2e=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,NQ={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},o2e=Object.keys(NQ),Bp="NaN";function l2e(t,e){return t*NQ[e]}class ms{static parse(e){var n,[,r,i]=(n=s2e.exec(e))!==null&&n!==void 0?n:[];return new ms(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,Es(e)&&(this.unit=""),n!==""&&!a2e.test(n)&&(this.num=NaN,this.unit=""),o2e.includes(n)&&(this.num=l2e(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new ms(NaN,""):new ms(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new ms(NaN,""):new ms(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new ms(NaN,""):new ms(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new ms(NaN,""):new ms(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return Es(this.num)}}function MQ(t){if(t.includes(Bp))return Bp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,s]=(n=W6.exec(e))!==null&&n!==void 0?n:[],o=ms.parse(r??""),l=ms.parse(s??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return Bp;e=e.replace(W6,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,m]=(u=K6.exec(e))!==null&&u!==void 0?u:[],g=ms.parse(d??""),x=ms.parse(m??""),y=f==="+"?g.add(x):g.subtract(x);if(y.isNaN())return Bp;e=e.replace(K6,y.toString())}return e}var X6=/\(([^()]*)\)/;function c2e(t){for(var e=t,n;(n=X6.exec(e))!=null;){var[,r]=n;e=e.replace(X6,MQ(r))}return e}function u2e(t){var e=t.replace(/\s+/g,"");return e=c2e(e),e=MQ(e),e}function d2e(t){try{return u2e(t)}catch{return Bp}}function nA(t){var e=d2e(t.slice(5,-1));return e===Bp?"":e}var h2e=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],f2e=["dx","dy","angle","className","breakAll"];function K3(){return K3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},K3.apply(null,arguments)}function Y6(t,e){if(t==null)return{};var n,r,i=m2e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function m2e(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 EQ=/[ \f\n\r\t\v\u2028\u2029]+/,TQ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Ir(e)||(n?i=e.toString().split(""):i=e.toString().split(EQ));var s=i.map(l=>({word:l,width:Vb(l,r).width})),o=n?0:Vb(" ",r).width;return{wordsWithComputedWidth:s,spaceWidth:o}}catch{return null}};function p2e(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var CQ=(t,e,n,r)=>t.reduce((i,s)=>{var{word:o,width:l}=s,c=i[i.length-1];if(c&&l!=null&&(e==null||r||c.width+l+n<Number(e)))c.words.push(o),c.width+=l+n;else{var u={words:[o],width:l};i.push(u)}return i},[]),AQ=t=>t.reduce((e,n)=>e.width>n.width?e:n),g2e="…",Q6=(t,e,n,r,i,s,o,l)=>{var c=t.slice(0,e),u=TQ({breakAll:n,style:r,children:c+g2e});if(!u)return[!1,[]];var d=CQ(u.wordsWithComputedWidth,s,o,l),f=d.length>i||AQ(d).width>Number(s);return[f,d]},x2e=(t,e,n,r,i)=>{var{maxLines:s,children:o,style:l,breakAll:c}=t,u=Ut(s),d=String(o),f=CQ(e,r,n,i);if(!u||i)return f;var m=f.length>s||AQ(f).width>Number(r);if(!m)return f;for(var g=0,x=d.length-1,y=0,b;g<=x&&y<=d.length-1;){var v=Math.floor((g+x)/2),N=v-1,[S,T]=Q6(d,N,c,l,s,r,n,i),[E]=Q6(d,v,c,l,s,r,n,i);if(!S&&!E&&(g=v+1),S&&E&&(x=v-1),!S&&E){b=T;break}y++}return b||f},Z6=t=>{var e=Ir(t)?[]:t.toString().split(EQ);return[{words:e,width:void 0}]},b2e=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:s,maxLines:o}=t;if((e||n)&&!Hg.isSsr){var l,c,u=TQ({breakAll:s,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;l=d,c=f}else return Z6(r);return x2e({breakAll:s,children:r,maxLines:o,style:i},l,c,e,!!n)}return Z6(r)},kQ="#808080",y2e={angle:0,breakAll:!1,capHeight:"0.71em",fill:kQ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},PN=w.forwardRef((t,e)=>{var n=Xr(t,y2e),{x:r,y:i,lineHeight:s,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=Y6(n,h2e),m=w.useMemo(()=>b2e({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:c,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,c,f.style,f.width]),{dx:g,dy:x,angle:y,className:b,breakAll:v}=f,N=Y6(f,f2e);if(!Lo(r)||!Lo(i)||m.length===0)return null;var S=Number(r)+(Ut(g)?g:0),T=Number(i)+(Ut(x)?x:0);if(!cr(S)||!cr(T))return null;var E;switch(d){case"start":E=nA("calc(".concat(o,")"));break;case"middle":E=nA("calc(".concat((m.length-1)/2," * -").concat(s," + (").concat(o," / 2))"));break;default:E=nA("calc(".concat(m.length-1," * -").concat(s,")"));break}var k=[];if(c){var C=m[0].width,{width:D}=f;k.push("scale(".concat(Ut(D)&&Ut(C)?D/C:1,")"))}return y&&k.push("rotate(".concat(y,", ").concat(S,", ").concat(T,")")),k.length&&(N.transform=k.join(" ")),w.createElement("text",K3({},Ea(N),{ref:e,x:S,y:T,className:Vn("recharts-text",b),textAnchor:u,fill:l.includes("url")?kQ:l}),m.map((A,R)=>{var F=A.words.join(v?"":" ");return w.createElement("tspan",{x:S,dy:R===0?E:s,key:"".concat(F,"-").concat(R)},F)}))});PN.displayName="Text";var v2e=["labelRef"];function _2e(t,e){if(t==null)return{};var n,r,i=w2e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function w2e(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 J6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function di(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?J6(Object(n),!0).forEach(function(r){S2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):J6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function S2e(t,e,n){return(e=N2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function N2e(t){var e=M2e(t,"string");return typeof e=="symbol"?e:e+""}function M2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Bc(){return Bc=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},Bc.apply(null,arguments)}var jQ=w.createContext(null),PQ=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:o,children:l}=t,c=w.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:o}),[e,n,r,i,s,o]);return w.createElement(jQ.Provider,{value:c},l)},RQ=()=>{var t=w.useContext(jQ),e=gy();return t||QK(e)},E2e=w.createContext(null),T2e=()=>{var t=w.useContext(E2e),e=It(wY);return t||e},C2e=t=>{var{value:e,formatter:n}=t,r=Ir(t.children)?e:t.children;return typeof n=="function"?n(r):r},nO=t=>t!=null&&typeof t=="function",A2e=(t,e)=>{var n=ra(e-t),r=Math.min(Math.abs(e-t),360);return n*r},k2e=(t,e,n,r,i)=>{var{offset:s,className:o}=t,{cx:l,cy:c,innerRadius:u,outerRadius:d,startAngle:f,endAngle:m,clockWise:g}=i,x=(u+d)/2,y=A2e(f,m),b=y>=0?1:-1,v,N;switch(e){case"insideStart":v=f+b*s,N=g;break;case"insideEnd":v=m-b*s,N=!g;break;case"end":v=m+b*s,N=g;break;default:throw new Error("Unsupported position ".concat(e))}N=y<=0?N:!N;var S=Ni(l,c,x,v),T=Ni(l,c,x,v+(N?1:-1)*359),E="M".concat(S.x,",").concat(S.y,`
- A`).concat(x,",").concat(x,",0,1,").concat(N?0:1,`,
- `).concat(T.x,",").concat(T.y),k=Ir(t.id)?v0("recharts-radial-line-"):t.id;return w.createElement("text",Bc({},r,{dominantBaseline:"central",className:Vn("recharts-radial-bar-label",o)}),w.createElement("defs",null,w.createElement("path",{id:k,d:E})),w.createElement("textPath",{xlinkHref:"#".concat(k)},n))},j2e=(t,e,n)=>{var{cx:r,cy:i,innerRadius:s,outerRadius:o,startAngle:l,endAngle:c}=t,u=(l+c)/2;if(n==="outside"){var{x:d,y:f}=Ni(r,i,o+e,u);return{x:d,y:f,textAnchor:d>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var m=(s+o)/2,{x:g,y:x}=Ni(r,i,m,u);return{x:g,y:x,textAnchor:"middle",verticalAnchor:"middle"}},X3=t=>"cx"in t&&Ut(t.cx),P2e=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,s;n!=null&&!X3(n)&&(s=n);var{x:o,y:l,upperWidth:c,lowerWidth:u,height:d}=e,f=o,m=o+(c-u)/2,g=(f+m)/2,x=(c+u)/2,y=f+c/2,b=d>=0?1:-1,v=b*r,N=b>0?"end":"start",S=b>0?"start":"end",T=c>=0?1:-1,E=T*r,k=T>0?"end":"start",C=T>0?"start":"end";if(i==="top"){var D={x:f+c/2,y:l-v,textAnchor:"middle",verticalAnchor:N};return di(di({},D),s?{height:Math.max(l-s.y,0),width:c}:{})}if(i==="bottom"){var A={x:m+u/2,y:l+d+v,textAnchor:"middle",verticalAnchor:S};return di(di({},A),s?{height:Math.max(s.y+s.height-(l+d),0),width:u}:{})}if(i==="left"){var R={x:g-E,y:l+d/2,textAnchor:k,verticalAnchor:"middle"};return di(di({},R),s?{width:Math.max(R.x-s.x,0),height:d}:{})}if(i==="right"){var F={x:g+x+E,y:l+d/2,textAnchor:C,verticalAnchor:"middle"};return di(di({},F),s?{width:Math.max(s.x+s.width-F.x,0),height:d}:{})}var O=s?{width:x,height:d}:{};return i==="insideLeft"?di({x:g+E,y:l+d/2,textAnchor:C,verticalAnchor:"middle"},O):i==="insideRight"?di({x:g+x-E,y:l+d/2,textAnchor:k,verticalAnchor:"middle"},O):i==="insideTop"?di({x:f+c/2,y:l+v,textAnchor:"middle",verticalAnchor:S},O):i==="insideBottom"?di({x:m+u/2,y:l+d-v,textAnchor:"middle",verticalAnchor:N},O):i==="insideTopLeft"?di({x:f+E,y:l+v,textAnchor:C,verticalAnchor:S},O):i==="insideTopRight"?di({x:f+c-E,y:l+v,textAnchor:k,verticalAnchor:S},O):i==="insideBottomLeft"?di({x:m+E,y:l+d-v,textAnchor:C,verticalAnchor:N},O):i==="insideBottomRight"?di({x:m+u-E,y:l+d-v,textAnchor:k,verticalAnchor:N},O):i&&typeof i=="object"&&(Ut(i.x)||uu(i.x))&&(Ut(i.y)||uu(i.y))?di({x:o+Fa(i.x,x),y:l+Fa(i.y,d),textAnchor:"end",verticalAnchor:"end"},O):di({x:y,y:l+d/2,textAnchor:"middle",verticalAnchor:"middle"},O)},R2e={angle:0,offset:5,zIndex:oi.label,position:"middle",textBreakAll:!1};function hd(t){var e=Xr(t,R2e),{viewBox:n,position:r,value:i,children:s,content:o,className:l="",textBreakAll:c,labelRef:u}=e,d=T2e(),f=RQ(),m=r==="center"?f:d??f,g,x,y;if(n==null?g=m:X3(n)?g=n:g=QK(n),!g||Ir(i)&&Ir(s)&&!w.isValidElement(o)&&typeof o!="function")return null;var b=di(di({},e),{},{viewBox:g});if(w.isValidElement(o)){var{labelRef:v}=b,N=_2e(b,v2e);return w.cloneElement(o,N)}if(typeof o=="function"){if(x=w.createElement(o,b),w.isValidElement(x))return x}else x=C2e(e);var S=Ea(e);if(X3(g)){if(r==="insideStart"||r==="insideEnd"||r==="end")return k2e(e,r,x,S,g);y=j2e(g,e.offset,e.position)}else y=P2e(e,g);return w.createElement(za,{zIndex:e.zIndex},w.createElement(PN,Bc({ref:u,className:Vn("recharts-label",l)},S,y,{textAnchor:p2e(S.textAnchor)?S.textAnchor:y.textAnchor,breakAll:c}),x))}hd.displayName="Label";var D2e=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?w.createElement(hd,Bc({key:"label-implicit"},r)):Lo(t)?w.createElement(hd,Bc({key:"label-implicit",value:t},r)):w.isValidElement(t)?t.type===hd?w.cloneElement(t,di({key:"label-implicit"},r)):w.createElement(hd,Bc({key:"label-implicit",content:t},r)):nO(t)?w.createElement(hd,Bc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?w.createElement(hd,Bc({},t,{key:"label-implicit"},r)):null};function DQ(t){var{label:e,labelRef:n}=t,r=RQ();return D2e(e,r,n)||null}var rA={},iA={},e$;function O2e(){return e$||(e$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(iA)),iA}var aA={},t$;function L2e(){return t$||(t$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(aA)),aA}var n$;function I2e(){return n$||(n$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=O2e(),n=L2e(),r=kD();function i(s){if(r.isArrayLike(s))return e.last(n.toArray(s))}t.last=i})(rA)),rA}var sA,r$;function F2e(){return r$||(r$=1,sA=I2e().last),sA}var U2e=F2e();const z2e=Uo(U2e);var B2e=["valueAccessor"],$2e=["dataKey","clockWise","id","textBreakAll","zIndex"];function lS(){return lS=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},lS.apply(null,arguments)}function i$(t,e){if(t==null)return{};var n,r,i=H2e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function H2e(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 V2e=t=>Array.isArray(t.value)?z2e(t.value):t.value,OQ=w.createContext(void 0),rO=OQ.Provider,LQ=w.createContext(void 0),G2e=LQ.Provider;function q2e(){return w.useContext(OQ)}function W2e(){return w.useContext(LQ)}function Q1(t){var{valueAccessor:e=V2e}=t,n=i$(t,B2e),{dataKey:r,clockWise:i,id:s,textBreakAll:o,zIndex:l}=n,c=i$(n,$2e),u=q2e(),d=W2e(),f=u||d;return!f||!f.length?null:w.createElement(za,{zIndex:l??oi.label},w.createElement(Kr,{className:"recharts-label-list"},f.map((m,g)=>{var x,y=Ir(r)?e(m,g):lr(m&&m.payload,r),b=Ir(s)?{}:{id:"".concat(s,"-").concat(g)};return w.createElement(hd,lS({key:"label-".concat(g)},Ea(m),c,b,{fill:(x=n.fill)!==null&&x!==void 0?x:m.fill,parentViewBox:m.parentViewBox,value:y,textBreakAll:o,viewBox:m.viewBox,index:g,zIndex:0}))})))}Q1.displayName="LabelList";function RN(t){var{label:e}=t;return e?e===!0?w.createElement(Q1,{key:"labelList-implicit"}):w.isValidElement(e)||nO(e)?w.createElement(Q1,{key:"labelList-implicit",content:e}):typeof e=="object"?w.createElement(Q1,lS({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function Y3(){return Y3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Y3.apply(null,arguments)}var IQ=t=>{var{cx:e,cy:n,r,className:i}=t,s=Vn("recharts-dot",i);return Ut(e)&&Ut(n)&&Ut(r)?w.createElement("circle",Y3({},Ja(t),AD(t),{className:s,cx:e,cy:n,r})):null},FQ=t=>t.graphicalItems.polarItems,K2e=tt([qr,Ny],E4),DN=tt([FQ,Yr,K2e],T4),X2e=tt([DN],C4),ON=tt([X2e,g4],A4),Y2e=tt([ON,Yr,DN],j4);tt([ON,Yr,DN],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var s,o=lr(r,(s=e.dataKey)!==null&&s!==void 0?s:i.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:lr(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var a$=()=>{},Q2e=tt([ON,Yr,DN,CN,qr],O4),Z2e=tt([Yr,R4,D4,a$,Q2e,a$,Dn,qr],L4),UQ=tt([Yr,Dn,ON,Y2e,Sy,qr,Z2e],I4),J2e=tt([UQ,Yr,Qg],z4);tt([Yr,UQ,J2e,qr],$4);var eNe={radiusAxis:{},angleAxis:{}},zQ=Ts({name:"polarAxis",initialState:eNe,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:kXe,removeRadiusAxis:jXe,addAngleAxis:PXe,removeAngleAxis:RXe}=zQ.actions,tNe=zQ.reducer;function s$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function o$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?s$(Object(n),!0).forEach(function(r){nNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nNe(t,e,n){return(e=rNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rNe(t){var e=iNe(t,"string");return typeof e=="symbol"?e:e+""}function iNe(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 aNe=(t,e)=>e,iO=tt([FQ,aNe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),sNe=[],aO=(t,e,n)=>n?.length===0?sNe:n,BQ=tt([g4,iO,aO],(t,e,n)=>{var{chartData:r}=t;if(e!=null){var i;if(e?.data!=null&&e.data.length>0?i=e.data:i=r,(!i||!i.length)&&n!=null&&(i=n.map(s=>o$(o$({},e.presentationProps),s.props))),i!=null)return i}}),oNe=tt([BQ,iO,aO],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var s,o=lr(r,e.nameKey,e.name),l;return n!=null&&(s=n[i])!==null&&s!==void 0&&(s=s.props)!==null&&s!==void 0&&s.fill?l=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?l=r.fill:l=e.fill,{value:uh(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),lNe=tt([BQ,iO,aO,zi],(t,e,n,r)=>{if(!(e==null||t==null))return cMe({offset:r,pieSettings:e,displayedData:t,cells:n})}),oA={exports:{}},mr={};var l$;function cNe(){if(l$)return mr;l$=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),m=Symbol.for("react.view_transition"),g=Symbol.for("react.client.reference");function x(y){if(typeof y=="object"&&y!==null){var b=y.$$typeof;switch(b){case t:switch(y=y.type,y){case n:case i:case r:case c:case u:case m:return y;default:switch(y=y&&y.$$typeof,y){case o:case l:case f:case d:return y;case s:return y;default:return b}}case e:return b}}}return mr.ContextConsumer=s,mr.ContextProvider=o,mr.Element=t,mr.ForwardRef=l,mr.Fragment=n,mr.Lazy=f,mr.Memo=d,mr.Portal=e,mr.Profiler=i,mr.StrictMode=r,mr.Suspense=c,mr.SuspenseList=u,mr.isContextConsumer=function(y){return x(y)===s},mr.isContextProvider=function(y){return x(y)===o},mr.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},mr.isForwardRef=function(y){return x(y)===l},mr.isFragment=function(y){return x(y)===n},mr.isLazy=function(y){return x(y)===f},mr.isMemo=function(y){return x(y)===d},mr.isPortal=function(y){return x(y)===e},mr.isProfiler=function(y){return x(y)===i},mr.isStrictMode=function(y){return x(y)===r},mr.isSuspense=function(y){return x(y)===c},mr.isSuspenseList=function(y){return x(y)===u},mr.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===n||y===i||y===r||y===c||y===u||typeof y=="object"&&y!==null&&(y.$$typeof===f||y.$$typeof===d||y.$$typeof===o||y.$$typeof===s||y.$$typeof===l||y.$$typeof===g||y.getModuleId!==void 0)},mr.typeOf=x,mr}var c$;function uNe(){return c$||(c$=1,oA.exports=cNe()),oA.exports}var dNe=uNe(),u$=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",d$=null,lA=null,$Q=t=>{if(t===d$&&Array.isArray(lA))return lA;var e=[];return w.Children.forEach(t,n=>{Ir(n)||(dNe.isFragment(n)?e=e.concat($Q(n.props.children)):e.push(n))}),lA=e,d$=t,e};function sO(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>u$(i)):r=[u$(e)],$Q(t).forEach(i=>{var s=Uf(i,"type.displayName")||Uf(i,"type.name");s&&r.indexOf(s)!==-1&&n.push(i)}),n}var oO=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,cA={},h$;function hNe(){return h$||(h$=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})(cA)),cA}var uA,f$;function fNe(){return f$||(f$=1,uA=hNe().isPlainObject),uA}var mNe=fNe();const pNe=Uo(mNe);function m$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function p$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?m$(Object(n),!0).forEach(function(r){gNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):m$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gNe(t,e,n){return(e=xNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xNe(t){var e=bNe(t,"string");return typeof e=="symbol"?e:e+""}function bNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function cS(){return cS=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},cS.apply(null,arguments)}var g$=(t,e,n,r,i)=>{var s=n-r,o;return o="M ".concat(t,",").concat(e),o+="L ".concat(t+n,",").concat(e),o+="L ".concat(t+n-s/2,",").concat(e+i),o+="L ".concat(t+n-s/2-r,",").concat(e+i),o+="L ".concat(t,",").concat(e," Z"),o},yNe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},vNe=t=>{var e=Xr(t,yNe),{x:n,y:r,upperWidth:i,lowerWidth:s,height:o,className:l}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:f}=e,m=w.useRef(null),[g,x]=w.useState(-1),y=w.useRef(i),b=w.useRef(s),v=w.useRef(o),N=w.useRef(n),S=w.useRef(r),T=Gg(t,"trapezoid-");if(w.useEffect(()=>{if(m.current&&m.current.getTotalLength)try{var j=m.current.getTotalLength();j&&x(j)}catch{}},[]),n!==+n||r!==+r||i!==+i||s!==+s||o!==+o||i===0&&s===0||o===0)return null;var E=Vn("recharts-trapezoid",l);if(!f)return w.createElement("g",null,w.createElement("path",cS({},Ea(e),{className:E,d:g$(n,r,i,s,o)})));var k=y.current,C=b.current,D=v.current,A=N.current,R=S.current,F="0px ".concat(g===-1?1:g,"px"),O="".concat(g,"px 0px"),q=uX(["strokeDasharray"],u,c);return w.createElement(Vg,{animationId:T,key:T,canBegin:g>0,duration:u,easing:c,isActive:f,begin:d},j=>{var G=nr(k,i,j),Y=nr(C,s,j),K=nr(D,o,j),Z=nr(A,n,j),te=nr(R,r,j);m.current&&(y.current=G,b.current=Y,v.current=K,N.current=Z,S.current=te);var ne=j>0?{transition:q,strokeDasharray:O}:{strokeDasharray:F};return w.createElement("path",cS({},Ea(e),{className:E,d:g$(Z,te,G,Y,K),ref:m,style:p$(p$({},ne),e.style)}))})},_Ne=["option","shapeType","propTransformer","activeClassName"];function wNe(t,e){if(t==null)return{};var n,r,i=SNe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function SNe(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 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 uS(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){NNe(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 NNe(t,e,n){return(e=MNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function MNe(t){var e=ENe(t,"string");return typeof e=="symbol"?e:e+""}function ENe(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 TNe(t,e){return uS(uS({},e),t)}function CNe(t,e){return t==="symbols"}function b$(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return w.createElement(mX,n);case"trapezoid":return w.createElement(vNe,n);case"sector":return w.createElement(bX,n);case"symbols":if(CNe(e))return w.createElement(CD,n);break;case"curve":return w.createElement(Yp,n);default:return null}}function ANe(t){return w.isValidElement(t)?t.props:t}function lO(t){var{option:e,shapeType:n,propTransformer:r=TNe,activeClassName:i="recharts-active-shape"}=t,s=wNe(t,_Ne),o;if(w.isValidElement(e))o=w.cloneElement(e,uS(uS({},s),ANe(e)));else if(typeof e=="function")o=e(s,s.index);else if(pNe(e)&&typeof e!="boolean"){var l=r(e,s);o=w.createElement(b$,{shapeType:n,elementProps:l})}else{var c=s;o=w.createElement(b$,{shapeType:n,elementProps:c})}return s.isActive?w.createElement(Kr,{className:i},o):o}var cO=(t,e,n)=>{var r=Er();return(i,s)=>o=>{t?.(i,s,o),r(JY({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},uO=t=>{var e=Er();return(n,r)=>i=>{t?.(n,r,i),e(V1e())}},dO=(t,e,n)=>{var r=Er();return(i,s)=>o=>{t?.(i,s,o),r(G1e({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function LN(t){var{tooltipEntrySettings:e}=t,n=Er(),r=Bi(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(z1e(e)):i.current!==e&&n(B1e({prev:i.current,next:e})),i.current=e)},[e,n,r]),w.useLayoutEffect(()=>()=>{i.current&&(n($1e(i.current)),i.current=null)},[n]),null}function hO(t){var{legendPayload:e}=t,n=Er(),r=Bi(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(sX(e)):i.current!==e&&n(oX({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(lX(i.current)),i.current=null)},[n]),null}function kNe(t){var{legendPayload:e}=t,n=Er(),r=It(Dn),i=w.useRef(null);return w.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(sX(e)):i.current!==e&&n(oX({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(lX(i.current)),i.current=null)},[n]),null}var dA,jNe=()=>{var[t]=w.useState(()=>v0("uid-"));return t},PNe=(dA=Lae.useId)!==null&&dA!==void 0?dA:jNe;function HQ(t,e){var n=PNe();return e||(t?"".concat(t,"-").concat(n):n)}var RNe=w.createContext(void 0),IN=t=>{var{id:e,type:n,children:r}=t,i=HQ("recharts-".concat(n),e);return w.createElement(RNe.Provider,{value:i},r(i))},DNe={cartesianItems:[],polarItems:[]},VQ=Ts({name:"graphicalItems",initialState:DNe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:Ur()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=sl(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:Ur()},removeCartesianGraphicalItem:{reducer(t,e){var n=sl(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:Ur()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:Ur()},removePolarGraphicalItem:{reducer(t,e){var n=sl(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:Ur()}}}),{addCartesianGraphicalItem:ONe,replaceCartesianGraphicalItem:LNe,removeCartesianGraphicalItem:INe,addPolarGraphicalItem:FNe,removePolarGraphicalItem:UNe}=VQ.actions,zNe=VQ.reducer,BNe=t=>{var e=Er(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(ONe(t)):n.current!==t&&e(LNe({prev:n.current,next:t})),n.current=t},[e,t]),w.useLayoutEffect(()=>()=>{n.current&&(e(INe(n.current)),n.current=null)},[e]),null},fO=w.memo(BNe);function $Ne(t){var e=Er();return w.useLayoutEffect(()=>(e(FNe(t)),()=>{e(UNe(t))}),[e,t]),null}var HNe=["key"],VNe=["onMouseEnter","onClick","onMouseLeave"],GNe=["id"],qNe=["id"];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 ri(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){WNe(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 WNe(t,e,n){return(e=KNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function KNe(t){var e=XNe(t,"string");return typeof e=="symbol"?e:e+""}function XNe(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 Jd(){return Jd=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},Jd.apply(null,arguments)}function FN(t,e){if(t==null)return{};var n,r,i=YNe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function YNe(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 QNe(t){var e=w.useMemo(()=>sO(t.children,Dy),[t.children]),n=It(r=>oNe(r,t.id,e));return n==null?null:w.createElement(kNe,{legendPayload:n})}var ZNe=w.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:s,fill:o,name:l,hide:c,tooltipType:u}=t,d={dataDefinedOnItem:r.map(f=>f.tooltipPayload),positions:r.map(f=>f.tooltipPosition),settings:{stroke:i,strokeWidth:s,fill:o,dataKey:e,nameKey:n,name:uh(l,e),hide:c,type:u,color:o,unit:""}};return w.createElement(LN,{tooltipEntrySettings:d})}),JNe=(t,e)=>t>e?"start":t<e?"end":"middle",eMe=(t,e,n)=>Fa(typeof e=="function"?e(t):e,n,n*.8),tMe=(t,e,n)=>{var{top:r,left:i,width:s,height:o}=e,l=pX(s,o),c=i+Fa(t.cx,s,s/2),u=r+Fa(t.cy,o,o/2),d=Fa(t.innerRadius,l,0),f=eMe(n,t.outerRadius,l),m=t.maxRadius||Math.sqrt(s*s+o*o)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:f,maxRadius:m}},nMe=(t,e)=>{var n=ra(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function rMe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var iMe=(t,e)=>{if(w.isValidElement(t))return w.cloneElement(t,e);if(typeof t=="function")return t(e);var n=Vn("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=FN(e,HNe);return w.createElement(Yp,Jd({},i,{type:"linear",className:n}))},aMe=(t,e,n)=>{if(w.isValidElement(t))return w.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),w.isValidElement(r)))return r;var i=Vn("recharts-pie-label-text",rMe(t));return w.createElement(PN,Jd({},e,{alignmentBaseline:"middle",className:i}),r)};function sMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:s,dataKey:o}=n;if(!r||!i||!e)return null;var l=Ja(n),c=Ff(i),u=Ff(s),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((m,g)=>{var x=(m.startAngle+m.endAngle)/2,y=Ni(m.cx,m.cy,m.outerRadius+d,x),b=ri(ri(ri(ri({},l),m),{},{stroke:"none"},c),{},{index:g,textAnchor:JNe(y.x,m.cx)},y),v=ri(ri(ri(ri({},l),m),{},{fill:"none",stroke:m.fill},u),{},{index:g,points:[Ni(m.cx,m.cy,m.outerRadius,x),y],key:"line"});return w.createElement(za,{zIndex:oi.label,key:"label-".concat(m.startAngle,"-").concat(m.endAngle,"-").concat(m.midAngle,"-").concat(g)},w.createElement(Kr,null,s&&iMe(s,v),aMe(i,b,lr(m,o))))});return w.createElement(Kr,{className:"recharts-pie-labels"},f)}function oMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?w.createElement(RN,{label:i}):w.createElement(sMe,{sectors:e,props:n,showLabels:r})}function lMe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:s,id:o}=t,l=It(Zd),c=It(Q4),u=It(kwe),{onMouseEnter:d,onClick:f,onMouseLeave:m}=i,g=FN(i,VNe),x=cO(d,i.dataKey,o),y=uO(m),b=dO(f,i.dataKey,o);return e==null||e.length===0?null:w.createElement(w.Fragment,null,e.map((v,N)=>{if(v?.startAngle===0&&v?.endAngle===0&&e.length!==1)return null;var S=u==null||u===o,T=String(N)===l&&(c==null||i.dataKey===c)&&S,E=l?r:null,k=n&&T?n:E,C=ri(ri({},v),{},{stroke:v.stroke,tabIndex:-1,[qK]:N,[WK]:i.dataKey});return w.createElement(Kr,Jd({key:"sector-".concat(v?.startAngle,"-").concat(v?.endAngle,"-").concat(v.midAngle,"-").concat(N),tabIndex:-1,className:"recharts-pie-sector"},dy(g,v,N),{onMouseEnter:x(v,N),onMouseLeave:y(v,N),onClick:b(v,N)}),w.createElement(lO,Jd({option:s??k,index:N,shapeType:"sector",isActive:T},C)))}))}function cMe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:s}=t,{cornerRadius:o,startAngle:l,endAngle:c,dataKey:u,nameKey:d,tooltipType:f}=n,m=Math.abs(n.minAngle),g=nMe(l,c),x=Math.abs(g),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,b=r.filter(k=>lr(k,u,0)!==0).length,v=(x>=360?b:b-1)*y,N=x-b*m-v,S=r.reduce((k,C)=>{var D=lr(C,u,0);return k+(Ut(D)?D:0)},0),T;if(S>0){var E;T=r.map((k,C)=>{var D=lr(k,u,0),A=lr(k,d,C),R=tMe(n,s,k),F=(Ut(D)?D:0)/S,O,q=ri(ri({},k),i&&i[C]&&i[C].props);C?O=E.endAngle+ra(g)*y*(D!==0?1:0):O=l;var j=O+ra(g)*((D!==0?m:0)+F*N),G=(O+j)/2,Y=(R.innerRadius+R.outerRadius)/2,K=[{name:A,value:D,payload:q,dataKey:u,type:f}],Z=Ni(R.cx,R.cy,Y,G);return E=ri(ri(ri(ri({},n.presentationProps),{},{percent:F,cornerRadius:typeof o=="string"?parseFloat(o):o,name:A,tooltipPayload:K,midAngle:G,middleRadius:Y,tooltipPosition:Z},q),R),{},{value:D,dataKey:u,startAngle:O,endAngle:j,payload:q,paddingAngle:ra(g)*y}),E})}return T}function uMe(t){var{showLabels:e,sectors:n,children:r}=t,i=w.useMemo(()=>!e||!n?[]:n.map(s=>({value:s.value,payload:s.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:s.cx,cy:s.cy,innerRadius:s.innerRadius,outerRadius:s.outerRadius,startAngle:s.startAngle,endAngle:s.endAngle,clockWise:!1},fill:s.fill})),[n,e]);return w.createElement(G2e,{value:e?i:void 0},r)}function dMe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:s,animationBegin:o,animationDuration:l,animationEasing:c,activeShape:u,inactiveShape:d,onAnimationStart:f,onAnimationEnd:m}=e,g=Gg(e,"recharts-pie-"),x=n.current,[y,b]=w.useState(!1),v=w.useCallback(()=>{typeof m=="function"&&m(),b(!1)},[m]),N=w.useCallback(()=>{typeof f=="function"&&f(),b(!0)},[f]);return w.createElement(uMe,{showLabels:!y,sectors:i},w.createElement(Vg,{animationId:g,begin:o,duration:l,isActive:s,easing:c,onAnimationStart:N,onAnimationEnd:v,key:g},S=>{var T=[],E=i&&i[0],k=E?.startAngle;return i?.forEach((C,D)=>{var A=x&&x[D],R=D>0?Uf(C,"paddingAngle",0):0;if(A){var F=nr(A.endAngle-A.startAngle,C.endAngle-C.startAngle,S),O=ri(ri({},C),{},{startAngle:k+R,endAngle:k+F+R});T.push(O),k=O.endAngle}else{var{endAngle:q,startAngle:j}=C,G=nr(0,q-j,S),Y=ri(ri({},C),{},{startAngle:k+R,endAngle:k+G+R});T.push(Y),k=Y.endAngle}}),n.current=T,w.createElement(Kr,null,w.createElement(lMe,{sectors:T,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),w.createElement(oMe,{showLabels:!y,sectors:i,props:e}),e.children)}var hMe={animationBegin:400,animationDuration:1500,animationEasing:"ease",cx:"50%",cy:"50%",dataKey:"value",endAngle:360,fill:"#808080",hide:!1,innerRadius:0,isAnimationActive:"auto",label:!1,labelLine:!0,legendType:"rect",minAngle:0,nameKey:"name",outerRadius:"80%",paddingAngle:0,rootTabIndex:0,startAngle:0,stroke:"#fff",zIndex:oi.area};function fMe(t){var{id:e}=t,n=FN(t,GNe),{hide:r,className:i,rootTabIndex:s}=t,o=w.useMemo(()=>sO(t.children,Dy),[t.children]),l=It(d=>lNe(d,e,o)),c=w.useRef(null),u=Vn("recharts-pie",i);return r||l==null?(c.current=null,w.createElement(Kr,{tabIndex:s,className:u})):w.createElement(za,{zIndex:t.zIndex},w.createElement(ZNe,{dataKey:t.dataKey,nameKey:t.nameKey,sectors:l,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,tooltipType:t.tooltipType}),w.createElement(Kr,{tabIndex:s,className:u},w.createElement(dMe,{props:ri(ri({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function GQ(t){var e=Xr(t,hMe),{id:n}=e,r=FN(e,qNe),i=Ja(r);return w.createElement(IN,{id:n,type:"pie"},s=>w.createElement(w.Fragment,null,w.createElement($Ne,{type:"pie",id:s,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:e.maxRadius}),w.createElement(QNe,Jd({},r,{id:s})),w.createElement(fMe,Jd({},r,{id:s}))))}GQ.displayName="Pie";var mMe=["points"];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 hA(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){pMe(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 pMe(t,e,n){return(e=gMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gMe(t){var e=xMe(t,"string");return typeof e=="symbol"?e:e+""}function xMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function dS(){return dS=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},dS.apply(null,arguments)}function bMe(t,e){if(t==null)return{};var n,r,i=yMe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function yMe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function vMe(t){var{option:e,dotProps:n,className:r}=t;if(w.isValidElement(e))return w.cloneElement(e,n);if(typeof e=="function")return e(n);var i=Vn(r,typeof e!="boolean"?e.className:""),s=n??{},{points:o}=s,l=bMe(s,mMe);return w.createElement(IQ,dS({},l,{className:i}))}function _Me(t,e){return t==null?!1:e?!0:t.length===1}function qQ(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:s,baseProps:o,needClip:l,clipPathId:c,zIndex:u=oi.scatter}=t;if(!_Me(e,n))return null;var d=oO(n),f=Zfe(n),m=e.map((x,y)=>{var b,v,N=hA(hA(hA({r:3},o),f),{},{index:y,cx:(b=x.x)!==null&&b!==void 0?b:void 0,cy:(v=x.y)!==null&&v!==void 0?v:void 0,dataKey:s,value:x.value,payload:x.payload,points:e});return w.createElement(vMe,{key:"dot-".concat(y),option:n,dotProps:N,className:i})}),g={};return l&&c!=null&&(g.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),w.createElement(za,{zIndex:u},w.createElement(Kr,dS({className:r},g),m))}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 w$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?_$(Object(n),!0).forEach(function(r){wMe(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 wMe(t,e,n){return(e=SMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function SMe(t){var e=NMe(t,"string");return typeof e=="symbol"?e:e+""}function NMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var MMe={xAxis:{},yAxis:{},zAxis:{}},WQ=Ts({name:"cartesianAxis",initialState:MMe,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:Ur()},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:Ur()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:Ur()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:Ur()},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:Ur()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:Ur()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:Ur()},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:Ur()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:Ur()},updateYAxisWidth(t,e){var{id:n,width:r}=e.payload,i=t.yAxis[n];if(i){var s=i.widthHistory||[];if(s.length===3&&s[0]===s[2]&&r===s[1]&&r!==i.width&&Math.abs(r-s[0])<=1)return;var o=[...s,r].slice(-3);t.yAxis[n]=w$(w$({},t.yAxis[n]),{},{width:r,widthHistory:o})}}}}),{addXAxis:EMe,replaceXAxis:TMe,removeXAxis:CMe,addYAxis:AMe,replaceYAxis:kMe,removeYAxis:jMe,addZAxis:DXe,replaceZAxis:OXe,removeZAxis:LXe,updateYAxisWidth:PMe}=WQ.actions,RMe=WQ.reducer,DMe=tt([zi],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),OMe=tt([DMe,vu,_u],(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)}}),UN=()=>It(OMe),LMe=()=>It(Owe);function S$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function fA(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?S$(Object(n),!0).forEach(function(r){IMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function IMe(t,e,n){return(e=FMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function FMe(t){var e=UMe(t,"string");return typeof e=="symbol"?e:e+""}function UMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var zMe=t=>{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:s,clipPath:o}=t;if(i===!1||e.x==null||e.y==null)return null;var l={index:n,dataKey:s,cx:e.x,cy:e.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},c=fA(fA(fA({},l),Ff(i)),AD(i)),u;return w.isValidElement(i)?u=w.cloneElement(i,c):typeof i=="function"?u=i(c):u=w.createElement(IQ,c),w.createElement(Kr,{className:"recharts-active-dot",clipPath:o},u)};function Q3(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:s,zIndex:o=oi.activeDot}=t,l=It(Zd),c=LMe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return Ir(u)?null:w.createElement(za,{zIndex:o},w.createElement(zMe,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:s}))}var BMe="Invariant failed";function $Me(t,e){throw new Error(BMe)}var HMe=["x","y"];function Z3(){return Z3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Z3.apply(null,arguments)}function N$(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 lb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?N$(Object(n),!0).forEach(function(r){VMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):N$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function VMe(t,e,n){return(e=GMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function GMe(t){var e=qMe(t,"string");return typeof e=="symbol"?e:e+""}function qMe(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 WMe(t,e){if(t==null)return{};var n,r,i=KMe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function KMe(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 XMe(t,e){var{x:n,y:r}=t,i=WMe(t,HMe),s="".concat(n),o=parseInt(s,10),l="".concat(r),c=parseInt(l,10),u="".concat(e.height||i.height),d=parseInt(u,10),f="".concat(e.width||i.width),m=parseInt(f,10);return lb(lb(lb(lb(lb({},e),i),o?{x:o}:{}),c?{y:c}:{}),{},{height:d,width:m,name:e.name,radius:e.radius})}function hS(t){return w.createElement(lO,Z3({shapeType:"rectangle",propTransformer:XMe,activeClassName:"recharts-active-bar"},t))}var YMe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Ut(e))return e;var s=Ut(r)||Ir(r);return s?e(r,i):(s||$Me(),n)}},QMe={},KQ=Ts({name:"errorBars",initialState:QMe,reducers:{addErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]||(t[n]=[]),t[n].push(r)},replaceErrorBar:(t,e)=>{var{itemId:n,prev:r,next:i}=e.payload;t[n]&&(t[n]=t[n].map(s=>s.dataKey===r.dataKey&&s.direction===r.direction?i:s))},removeErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]&&(t[n]=t[n].filter(i=>i.dataKey!==r.dataKey||i.direction!==r.direction))}}}),{addErrorBar:IXe,replaceErrorBar:FXe,removeErrorBar:UXe}=KQ.actions,ZMe=KQ.reducer,JMe=["children"];function eEe(t,e){if(t==null)return{};var n,r,i=tEe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function tEe(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 nEe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},rEe=w.createContext(nEe);function XQ(t){var{children:e}=t,n=eEe(t,JMe);return w.createElement(rEe.Provider,{value:n},e)}function zN(t,e){var n,r,i=It(u=>Zl(u,t)),s=It(u=>Jl(u,e)),o=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Qi.allowDataOverflow,l=(r=s?.allowDataOverflow)!==null&&r!==void 0?r:Zi.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function mO(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=UN(),{needClipX:s,needClipY:o,needClip:l}=zN(e,n);if(!l||!i)return null;var{x:c,y:u,width:d,height:f}=i;return w.createElement("clipPath",{id:"clipPath-".concat(r)},w.createElement("rect",{x:s?c:c-d/2,y:o?u:u-f/2,width:s?d:d*2,height:o?f:f*2}))}function iEe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&cr(t.zIndex)?t.zIndex:e}var mA={exports:{}},pA={};var M$;function aEe(){if(M$)return pA;M$=1;var t=Ig();function e(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,s=t.useEffect,o=t.useMemo,l=t.useDebugValue;return pA.useSyncExternalStoreWithSelector=function(c,u,d,f,m){var g=i(null);if(g.current===null){var x={hasValue:!1,value:null};g.current=x}else x=g.current;g=o(function(){function b(E){if(!v){if(v=!0,N=E,E=f(E),m!==void 0&&x.hasValue){var k=x.value;if(m(k,E))return S=k}return S=E}if(k=S,n(N,E))return k;var C=f(E);return m!==void 0&&m(k,C)?(N=E,k):(N=E,S=C)}var v=!1,N,S,T=d===void 0?null:d;return[function(){return b(u())},T===null?void 0:function(){return b(T())}]},[u,d,f,m]);var y=r(c,g[0],g[1]);return s(function(){x.hasValue=!0,x.value=y},[y]),l(y),y},pA}var E$;function sEe(){return E$||(E$=1,mA.exports=aEe()),mA.exports}sEe();function oEe(t){t()}function lEe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){oEe(()=>{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 T$={notify(){},get:()=>[]};function cEe(t,e){let n,r=T$,i=0,s=!1;function o(y){d();const b=r.subscribe(y);let v=!1;return()=>{v||(v=!0,b(),f())}}function l(){r.notify()}function c(){x.onStateChange&&x.onStateChange()}function u(){return s}function d(){i++,n||(n=t.subscribe(c),r=lEe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=T$)}function m(){s||(s=!0,d())}function g(){s&&(s=!1,f())}const x={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:m,tryUnsubscribe:g,getListeners:()=>r};return x}var uEe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",dEe=uEe(),hEe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",fEe=hEe(),mEe=()=>dEe||fEe?w.useLayoutEffect:w.useEffect,pEe=mEe();function C$(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function gEe(t,e){if(C$(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])||!C$(t[n[i]],e[n[i]]))return!1;return!0}var xEe=Symbol.for("react-redux-context"),bEe=typeof globalThis<"u"?globalThis:{};function yEe(){if(!w.createContext)return{};const t=bEe[xEe]??=new Map;let e=t.get(w.createContext);return e||(e=w.createContext(null),t.set(w.createContext,e)),e}var vEe=yEe();function _Ee(t){const{children:e,context:n,serverState:r,store:i}=t,s=w.useMemo(()=>{const c=cEe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=w.useMemo(()=>i.getState(),[i]);pEe(()=>{const{subscription:c}=s;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),o!==i.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[s,o]);const l=n||vEe;return w.createElement(l.Provider,{value:s},e)}var wEe=_Ee,SEe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function NEe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function Oy(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(SEe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!gEe(t[r],e[r]))return!1}else if(!NEe(t[r],e[r]))return!1;return!0}var MEe=["onMouseEnter","onMouseLeave","onClick"],EEe=["value","background","tooltipPosition"],TEe=["id"],CEe=["onMouseEnter","onClick","onMouseLeave"];function gu(){return gu=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},gu.apply(null,arguments)}function A$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Wa(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?A$(Object(n),!0).forEach(function(r){AEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):A$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function AEe(t,e,n){return(e=kEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function kEe(t){var e=jEe(t,"string");return typeof e=="symbol"?e:e+""}function jEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function fS(t,e){if(t==null)return{};var n,r,i=PEe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function PEe(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 REe=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:uh(n,e),payload:t}]},DEe=w.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:s,hide:o,unit:l,tooltipType:c}=t,u={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:uh(s,e),hide:o,type:c,color:i,unit:l}};return w.createElement(LN,{tooltipEntrySettings:u})});function OEe(t){var e=It(Zd),{data:n,dataKey:r,background:i,allOtherBarProps:s}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=s,u=fS(s,MEe),d=cO(o,r),f=uO(l),m=dO(c,r);if(!i||n==null)return null;var g=Ff(i);return w.createElement(za,{zIndex:iEe(i,oi.barBackground)},n.map((x,y)=>{var{value:b,background:v,tooltipPosition:N}=x,S=fS(x,EEe);if(!v)return null;var T=d(x,y),E=f(x,y),k=m(x,y),C=Wa(Wa(Wa(Wa(Wa({option:i,isActive:String(y)===e},S),{},{fill:"#eee"},v),g),dy(u,x,y)),{},{onMouseEnter:T,onMouseLeave:E,onClick:k,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return w.createElement(hS,gu({key:"background-bar-".concat(y)},C))}))}function LEe(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(s=>{var o={x:s.x,y:s.y,width:s.width,lowerWidth:s.width,upperWidth:s.width,height:s.height};return Wa(Wa({},o),{},{value:s.value,payload:s.payload,parentViewBox:s.parentViewBox,viewBox:o,fill:s.fill})});return w.createElement(rO,{value:e?i:void 0},n)}function IEe(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:s,dataKey:o}=t,l=It(Zd),c=It(Q4),u=n&&String(s)===l&&(c==null||o===c),d=u?n:e;return u?w.createElement(za,{zIndex:oi.activeBar},w.createElement(hS,gu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:o}))):w.createElement(hS,gu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:o}))}function FEe(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:s}=t;return w.createElement(hS,gu({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:s}))}function UEe(t){var e,{data:n,props:r}=t,i=(e=Ja(r))!==null&&e!==void 0?e:{},{id:s}=i,o=fS(i,TEe),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:m}=r,g=fS(r,CEe),x=cO(d,c),y=uO(m),b=dO(f,c);return n?w.createElement(w.Fragment,null,n.map((v,N)=>w.createElement(Kr,gu({key:"rectangle-".concat(v?.x,"-").concat(v?.y,"-").concat(v?.value,"-").concat(N),className:"recharts-bar-rectangle"},dy(g,v,N),{onMouseEnter:x(v,N),onMouseLeave:y(v,N),onClick:b(v,N)}),u?w.createElement(IEe,{shape:l,activeBar:u,baseProps:o,entry:v,index:N,dataKey:c}):w.createElement(FEe,{shape:l,baseProps:o,entry:v,index:N,dataKey:c})))):null}function zEe(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:s,animationBegin:o,animationDuration:l,animationEasing:c,onAnimationEnd:u,onAnimationStart:d}=e,f=n.current,m=Gg(e,"recharts-bar-"),[g,x]=w.useState(!1),y=!g,b=w.useCallback(()=>{typeof u=="function"&&u(),x(!1)},[u]),v=w.useCallback(()=>{typeof d=="function"&&d(),x(!0)},[d]);return w.createElement(LEe,{showLabels:y,rects:r},w.createElement(Vg,{animationId:m,begin:o,duration:l,isActive:s,easing:c,onAnimationEnd:b,onAnimationStart:v,key:m},N=>{var S=N===1?r:r?.map((T,E)=>{var k=f&&f[E];if(k)return Wa(Wa({},T),{},{x:nr(k.x,T.x,N),y:nr(k.y,T.y,N),width:nr(k.width,T.width,N),height:nr(k.height,T.height,N)});if(i==="horizontal"){var C=nr(0,T.height,N),D=nr(T.stackedBarStart,T.y,N);return Wa(Wa({},T),{},{y:D,height:C})}var A=nr(0,T.width,N),R=nr(T.stackedBarStart,T.x,N);return Wa(Wa({},T),{},{width:A,x:R})});return N>0&&(n.current=S??null),S==null?null:w.createElement(Kr,null,w.createElement(UEe,{props:e,data:S}))}),w.createElement(RN,{label:e.label}),e.children)}function BEe(t){var e=w.useRef(null);return w.createElement(zEe,{previousRectanglesRef:e,props:t})}var YQ=0,$Ee=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:lr(t,e)}};class HEe extends w.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:s,yAxisId:o,needClip:l,background:c,id:u}=this.props;if(e||n==null)return null;var d=Vn("recharts-bar",i),f=u;return w.createElement(Kr,{className:d,id:u},l&&w.createElement("defs",null,w.createElement(mO,{clipPathId:f,xAxisId:s,yAxisId:o})),w.createElement(Kr,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(f,")"):void 0},w.createElement(OEe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),w.createElement(BEe,this.props)))}}var VEe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:YQ,xAxisId:0,yAxisId:0,zIndex:oi.bar};function GEe(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d}=t,{needClip:f}=zN(e,n),m=im(),g=Bi(),x=sO(t.children,Dy),y=It(N=>yTe(N,e,n,g,t.id,x));if(m!=="vertical"&&m!=="horizontal")return null;var b,v=y?.[0];return v==null||v.height==null||v.width==null?b=0:b=m==="vertical"?v.height/2:v.width/2,w.createElement(XQ,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:$Ee,errorBarOffset:b},w.createElement(HEe,gu({},t,{layout:m,needClip:f,data:y,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function qEe(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:s,xAxis:o,yAxis:l,xAxisTicks:c,yAxisTicks:u,stackedData:d,displayedData:f,offset:m,cells:g,parentViewBox:x,dataStartIndex:y}=t,b=e==="horizontal"?l:o,v=d?b.scale.domain():null,N=pxe({numericAxis:b}),S=b.scale(N);return f.map((T,E)=>{var k,C,D,A,R,F;d?k=uxe(d[E+y],v):(k=lr(T,n),Array.isArray(k)||(k=[N,k]));var O=YMe(r,YQ)(k[1],E);if(e==="horizontal"){var q,[j,G]=[l.scale(k[0]),l.scale(k[1])];C=qB({axis:o,ticks:c,bandSize:s,offset:i.offset,entry:T,index:E}),D=(q=G??j)!==null&&q!==void 0?q:void 0,A=i.size;var Y=j-G;if(R=Es(Y)?0:Y,F={x:C,y:m.top,width:A,height:m.height},Math.abs(O)>0&&Math.abs(R)<Math.abs(O)){var K=ra(R||O)*(Math.abs(O)-Math.abs(R));D-=K,R+=K}}else{var[Z,te]=[o.scale(k[0]),o.scale(k[1])];if(C=Z,D=qB({axis:l,ticks:u,bandSize:s,offset:i.offset,entry:T,index:E}),A=te-Z,R=i.size,F={x:m.left,y:D,width:m.width,height:R},Math.abs(O)>0&&Math.abs(A)<Math.abs(O)){var ne=ra(A||O)*(Math.abs(O)-Math.abs(A));A+=ne}}if(C==null||D==null||A==null||R==null)return null;var z=Wa(Wa({},T),{},{stackedBarStart:S,x:C,y:D,width:A,height:R,value:d?k:k[1],payload:T,background:F,tooltipPosition:{x:C+A/2,y:D+R/2},parentViewBox:x},g&&g[E]&&g[E].props);return z}).filter(Boolean)}function WEe(t){var e=Xr(t,VEe),n=Bi();return w.createElement(IN,{id:e.id,type:"bar"},r=>w.createElement(w.Fragment,null,w.createElement(hO,{legendPayload:REe(e)}),w.createElement(DEe,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),w.createElement(fO,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:VK(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),w.createElement(za,{zIndex:e.zIndex},w.createElement(GEe,gu({},e,{id:r})))))}var QQ=w.memo(WEe,Oy);QQ.displayName="Bar";function k$(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 w_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?k$(Object(n),!0).forEach(function(r){KEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):k$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function KEe(t,e,n){return(e=XEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function XEe(t){var e=YEe(t,"string");return typeof e=="symbol"?e:e+""}function YEe(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 QEe=(t,e)=>e,ZEe=(t,e,n)=>n,JEe=(t,e,n,r)=>r,eTe=(t,e,n,r,i)=>i,Ly=tt([Ey,eTe],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),tTe=tt([Ly],t=>t?.maxBarSize),nTe=(t,e,n,r,i,s)=>s,j$=(t,e,n)=>{var r=n??t;if(!Ir(r))return Fa(r,e,0)},rTe=tt([Dn,Ey,QEe,ZEe,JEe],(t,e,n,r,i)=>e.filter(s=>t==="horizontal"?s.xAxisId===n:s.yAxisId===r).filter(s=>s.isPanorama===i).filter(s=>s.hide===!1).filter(s=>s.type==="bar")),iTe=(t,e,n,r)=>{var i=Dn(t);return i==="horizontal"?R0(t,"yAxis",n,r):R0(t,"xAxis",e,r)},aTe=(t,e,n)=>{var r=Dn(t);return r==="horizontal"?M6(t,"xAxis",e):M6(t,"yAxis",n)},sTe=(t,e,n)=>{var r={},i=t.filter(NN),s=t.filter(u=>u.stackId==null),o=i.reduce((u,d)=>(u[d.stackId]||(u[d.stackId]=[]),u[d.stackId].push(d),u),r),l=Object.entries(o).map(u=>{var[d,f]=u,m=f.map(x=>x.dataKey),g=j$(e,n,f[0].barSize);return{stackId:d,dataKeys:m,barSize:g}}),c=s.map(u=>{var d=[u.dataKey].filter(m=>m!=null),f=j$(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...l,...c]},oTe=tt([rTe,P_e,aTe],sTe),lTe=(t,e,n,r,i)=>{var s,o,l=Ly(t,e,n,r,i);if(l!=null){var c=Dn(t),u=mY(t),{maxBarSize:d}=l,f=Ir(d)?u:d,m,g;return c==="horizontal"?(m=Vl(t,"xAxis",e,r),g=Hl(t,"xAxis",e,r)):(m=Vl(t,"yAxis",n,r),g=Hl(t,"yAxis",n,r)),(s=(o=Xd(m,g,!0))!==null&&o!==void 0?o:f)!==null&&s!==void 0?s:0}},ZQ=(t,e,n,r)=>{var i=Dn(t),s,o;return i==="horizontal"?(s=Vl(t,"xAxis",e,r),o=Hl(t,"xAxis",e,r)):(s=Vl(t,"yAxis",n,r),o=Hl(t,"yAxis",n,r)),Xd(s,o)};function cTe(t,e,n,r,i){var s=r.length;if(!(s<1)){var o=Fa(t,n,0,!0),l,c=[];if(cr(r[0].barSize)){var u=!1,d=n/s,f=r.reduce((v,N)=>v+(N.barSize||0),0);f+=(s-1)*o,f>=n&&(f-=(s-1)*o,o=0),f>=n&&d>0&&(u=!0,d*=.9,f=s*d);var m=(n-f)/2>>0,g={offset:m-o,size:0};l=r.reduce((v,N)=>{var S,T={stackId:N.stackId,dataKeys:N.dataKeys,position:{offset:g.offset+g.size+o,size:u?d:(S=N.barSize)!==null&&S!==void 0?S:0}},E=[...v,T];return g=E[E.length-1].position,E},c)}else{var x=Fa(e,n,0,!0);n-2*x-(s-1)*o<=0&&(o=0);var y=(n-2*x-(s-1)*o)/s;y>1&&(y>>=0);var b=cr(i)?Math.min(y,i):y;l=r.reduce((v,N,S)=>[...v,{stackId:N.stackId,dataKeys:N.dataKeys,position:{offset:x+(y+o)*S+(y-b)/2,size:b}}],c)}return l}}var uTe=(t,e,n,r,i,s,o)=>{var l=Ir(o)?e:o,c=cTe(n,r,i!==s?i:s,t,l);return i!==s&&c!=null&&(c=c.map(u=>w_(w_({},u),{},{position:w_(w_({},u.position),{},{offset:u.position.offset-i/2})}))),c},dTe=tt([oTe,mY,j_e,pY,lTe,ZQ,tTe],uTe),hTe=(t,e,n,r)=>Vl(t,"xAxis",e,r),fTe=(t,e,n,r)=>Vl(t,"yAxis",n,r),mTe=(t,e,n,r)=>Hl(t,"xAxis",e,r),pTe=(t,e,n,r)=>Hl(t,"yAxis",n,r),gTe=tt([dTe,Ly],(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}}),xTe=(t,e)=>{var n=SN(e);if(!(!t||n==null||e==null)){var{stackId:r}=e;if(r!=null){var i=t[r];if(i){var{stackedData:s}=i;if(s)return s.find(o=>o.key===n)}}}},bTe=tt([iTe,Ly],xTe),yTe=tt([zi,zD,hTe,fTe,mTe,pTe,gTe,Dn,wy,ZQ,bTe,Ly,nTe],(t,e,n,r,i,s,o,l,c,u,d,f,m)=>{var{chartData:g,dataStartIndex:x,dataEndIndex:y}=c;if(!(f==null||o==null||e==null||l!=="horizontal"&&l!=="vertical"||n==null||r==null||i==null||s==null||u==null)){var{data:b}=f,v;if(b!=null&&b.length>0?v=b:v=g?.slice(x,y+1),v!=null)return qEe({layout:l,barSettings:f,pos:o,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,stackedData:d,displayedData:v,offset:t,cells:m,dataStartIndex:x})}}),JQ=t=>{var{chartData:e}=t,n=Er(),r=Bi();return w.useEffect(()=>r?()=>{}:(n(F6(e)),()=>{n(F6(void 0))}),[e,n,r]),null},P$={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},eZ=Ts({name:"brush",initialState:P$,reducers:{setBrushSettings(t,e){return e.payload==null?P$:e.payload}}}),{setBrushSettings:zXe}=eZ.actions,vTe=eZ.reducer;function R$(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_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?R$(Object(n),!0).forEach(function(r){tZ(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):R$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tZ(t,e,n){return(e=_Te(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _Te(t){var e=wTe(t,"string");return typeof e=="symbol"?e:e+""}function wTe(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 STe=(t,e)=>{var{x:n,y:r}=t,{x:i,y:s}=e;return{x:Math.min(n,i),y:Math.min(r,s),width:Math.abs(i-n),height:Math.abs(s-r)}},NTe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return STe({x:e,y:n},{x:r,y:i})};class BN{static create(e){return new BN(e)}constructor(e){this.scale=e}get domain(){return this.scale.domain}get range(){return this.scale.range}get rangeMin(){return this.range()[0]}get rangeMax(){return this.range()[1]}get bandwidth(){return this.scale.bandwidth}apply(e){var{bandAware:n,position:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e!==void 0){if(r)switch(r){case"start":return this.scale(e);case"middle":{var i=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+i}case"end":{var s=this.bandwidth?this.bandwidth():0;return this.scale(e)+s}default:return this.scale(e)}if(n){var o=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+o}return this.scale(e)}}isInRange(e){var n=this.range(),r=n[0],i=n[n.length-1];return r<=i?e>=r&&e<=i:e>=i&&e<=r}}tZ(BN,"EPS",1e-4);var MTe=t=>{var e=Object.keys(t).reduce((n,r)=>S_(S_({},n),{},{[r]:BN.create(t[r])}),{});return S_(S_({},e),{},{apply(n){var{bandAware:r,position:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object.fromEntries(Object.entries(n).map(s=>{var[o,l]=s;return[o,e[o].apply(l,{bandAware:r,position:i})]}))},isInRange(n){return Object.keys(n).every(r=>e[r].isInRange(n[r]))}})};function ETe(t){return(t%180+180)%180}var TTe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=ETe(i),o=s*Math.PI/180,l=Math.atan(r/n),c=o>l&&o<Math.PI-l?r/Math.sin(o):n/Math.cos(o);return Math.abs(c)},CTe={dots:[],areas:[],lines:[]},nZ=Ts({name:"referenceElements",initialState:CTe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=sl(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=sl(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=sl(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:BXe,removeDot:$Xe,addArea:HXe,removeArea:VXe,addLine:ATe,removeLine:kTe}=nZ.actions,jTe=nZ.reducer,rZ=w.createContext(void 0),PTe=t=>{var{children:e}=t,[n]=w.useState("".concat(v0("recharts"),"-clip")),r=UN();if(r==null)return null;var{x:i,y:s,width:o,height:l}=r;return w.createElement(rZ.Provider,{value:n},w.createElement("defs",null,w.createElement("clipPath",{id:n},w.createElement("rect",{x:i,y:s,height:l,width:o}))),e)},RTe=()=>w.useContext(rZ);function D$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function O$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?D$(Object(n),!0).forEach(function(r){DTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):D$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function DTe(t,e,n){return(e=OTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function OTe(t){var e=LTe(t,"string");return typeof e=="symbol"?e:e+""}function LTe(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 mS(){return mS=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},mS.apply(null,arguments)}var ITe=(t,e)=>{var n;if(w.isValidElement(t))n=w.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!cr(e.x1)||!cr(e.y1)||!cr(e.x2)||!cr(e.y2))return null;n=w.createElement("line",mS({},e,{className:"recharts-reference-line-line"}))}return n},FTe=(t,e,n,r,i,s)=>{var{x:o,width:l}=s,c=i.y.apply(t,{position:n});if(Es(c)||e==="discard"&&!i.y.isInRange(c))return null;var u=[{x:o+l,y:c},{x:o,y:c}];return r==="left"?u.reverse():u},UTe=(t,e,n,r,i,s)=>{var{y:o,height:l}=s,c=i.x.apply(t,{position:n});if(Es(c)||e==="discard"&&!i.x.isInRange(c))return null;var u=[{x:c,y:o+l},{x:c,y:o}];return r==="top"?u.reverse():u},zTe=(t,e,n,r)=>{var i=t.map(s=>r.apply(s,{position:n}));return e==="discard"&&i.some(s=>!r.isInRange(s))?null:i},BTe=(t,e,n,r,i,s)=>{var{x:o,y:l,segment:c,ifOverflow:u}=s,d=Lo(o),f=Lo(l);return f?FTe(l,u,n,i,t,e):d?UTe(o,u,n,r,t,e):c!=null&&c.length===2?zTe(c,u,n,t):null};function $Te(t){var e=Er();return w.useEffect(()=>(e(ATe(t)),()=>{e(kTe(t))})),null}function HTe(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:s}=t,o=Bi(),l=RTe(),c=It(k=>Zl(k,e)),u=It(k=>Jl(k,n)),d=It(k=>Qd(k,"xAxis",e,o)),f=It(k=>Qd(k,"yAxis",n,o)),m=gy();if(!l||!m||c==null||u==null||d==null||f==null)return null;var g=MTe({x:d,y:f}),x=BTe(g,m,t.position,c.orientation,u.orientation,t);if(!x)return null;var[{x:y,y:b},{x:v,y:N}]=x,S=s==="hidden"?"url(#".concat(l,")"):void 0,T=O$(O$({clipPath:S},Ea(t)),{},{x1:y,y1:b,x2:v,y2:N}),E=NTe({x1:y,y1:b,x2:v,y2:N});return w.createElement(za,{zIndex:t.zIndex},w.createElement(Kr,{className:Vn("recharts-reference-line",i)},ITe(r,T),w.createElement(PQ,mS({},E,{lowerWidth:E.width,upperWidth:E.width}),w.createElement(DQ,{label:t.label}),t.children)))}var VTe={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:oi.line};function kb(t){var e=Xr(t,VTe);return w.createElement(w.Fragment,null,w.createElement($Te,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),w.createElement(HTe,e))}kb.displayName="ReferenceLine";function iZ(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 GTe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return TTe(r,n)}function qTe(t,e,n){var r=n==="width",{x:i,y:s,width:o,height:l}=t;return e===1?{start:r?i:s,end:r?i+o:s+l}:{start:r?i+o:s+l,end:r?i:s}}function pS(t,e,n,r,i){if(t*e<t*r||t*e>t*i)return!1;var s=n();return t*(e-t*s/2-r)>=0&&t*(e+t*s/2-i)<=0}function WTe(t,e){return iZ(t,e+1)}function KTe(t,e,n,r,i){for(var s=(r||[]).slice(),{start:o,end:l}=e,c=0,u=1,d=o,f=function(){var x=r?.[c];if(x===void 0)return{v:iZ(r,u)};var y=c,b,v=()=>(b===void 0&&(b=n(x,y)),b),N=x.coordinate,S=c===0||pS(t,N,v,d,l);S||(c=0,d=o,u+=1),S&&(d=N+t*(v()/2+i),c+=u)},m;u<=s.length;)if(m=f(),m)return m.v;return[]}function L$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ra(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?L$(Object(n),!0).forEach(function(r){XTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function XTe(t,e,n){return(e=YTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function YTe(t){var e=QTe(t,"string");return typeof e=="symbol"?e:e+""}function QTe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ZTe(t,e,n,r,i){for(var s=(r||[]).slice(),o=s.length,{start:l}=e,{end:c}=e,u=function(m){var g=s[m],x,y=()=>(x===void 0&&(x=n(g,m)),x);if(m===o-1){var b=t*(g.coordinate+t*y()/2-c);s[m]=g=Ra(Ra({},g),{},{tickCoord:b>0?g.coordinate-b*t:g.coordinate})}else s[m]=g=Ra(Ra({},g),{},{tickCoord:g.coordinate});if(g.tickCoord!=null){var v=pS(t,g.tickCoord,y,l,c);v&&(c=g.tickCoord-t*(y()/2+i),s[m]=Ra(Ra({},g),{},{isShow:!0}))}},d=o-1;d>=0;d--)u(d);return s}function JTe(t,e,n,r,i,s){var o=(r||[]).slice(),l=o.length,{start:c,end:u}=e;if(s){var d=r[l-1],f=n(d,l-1),m=t*(d.coordinate+t*f/2-u);if(o[l-1]=d=Ra(Ra({},d),{},{tickCoord:m>0?d.coordinate-m*t:d.coordinate}),d.tickCoord!=null){var g=pS(t,d.tickCoord,()=>f,c,u);g&&(u=d.tickCoord-t*(f/2+i),o[l-1]=Ra(Ra({},d),{},{isShow:!0}))}}for(var x=s?l-1:l,y=function(N){var S=o[N],T,E=()=>(T===void 0&&(T=n(S,N)),T);if(N===0){var k=t*(S.coordinate-t*E()/2-c);o[N]=S=Ra(Ra({},S),{},{tickCoord:k<0?S.coordinate-k*t:S.coordinate})}else o[N]=S=Ra(Ra({},S),{},{tickCoord:S.coordinate});if(S.tickCoord!=null){var C=pS(t,S.tickCoord,E,c,u);C&&(c=S.tickCoord+t*(E()/2+i),o[N]=Ra(Ra({},S),{},{isShow:!0}))}},b=0;b<x;b++)y(b);return o}function pO(t,e,n){var{tick:r,ticks:i,viewBox:s,minTickGap:o,orientation:l,interval:c,tickFormatter:u,unit:d,angle:f}=t;if(!i||!i.length||!r)return[];if(Ut(c)||Hg.isSsr){var m;return(m=WTe(i,Ut(c)?c:0))!==null&&m!==void 0?m:[]}var g=[],x=l==="top"||l==="bottom"?"width":"height",y=d&&x==="width"?Vb(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},b=(S,T)=>{var E=typeof u=="function"?u(S.value,T):S.value;return x==="width"?GTe(Vb(E,{fontSize:e,letterSpacing:n}),y,f):Vb(E,{fontSize:e,letterSpacing:n})[x]},v=i.length>=2?ra(i[1].coordinate-i[0].coordinate):1,N=qTe(s,v,x);return c==="equidistantPreserveStart"?KTe(v,N,b,i,o):(c==="preserveStart"||c==="preserveStartEnd"?g=JTe(v,N,b,i,o,c==="preserveStartEnd"):g=ZTe(v,N,b,i,o),g.filter(S=>S.isShow))}var eCe=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:s=0}=t,o=0;if(e){Array.from(e).forEach(d=>{if(d){var f=d.getBoundingClientRect();f.width>o&&(o=f.width)}});var l=n?n.getBoundingClientRect().width:0,c=i+s,u=o+c+l+(n?r:0);return Math.round(u)}return 0},tCe=["axisLine","width","height","className","hide","ticks","axisType"];function nCe(t,e){if(t==null)return{};var n,r,i=rCe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function rCe(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 Hf(){return Hf=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},Hf.apply(null,arguments)}function I$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _i(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?I$(Object(n),!0).forEach(function(r){iCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):I$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function iCe(t,e,n){return(e=aCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aCe(t){var e=sCe(t,"string");return typeof e=="symbol"?e:e+""}function sCe(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 eu={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:oi.axis};function oCe(t){var{x:e,y:n,width:r,height:i,orientation:s,mirror:o,axisLine:l,otherSvgProps:c}=t;if(!l)return null;var u=_i(_i(_i({},c),Ja(l)),{},{fill:"none"});if(s==="top"||s==="bottom"){var d=+(s==="top"&&!o||s==="bottom"&&o);u=_i(_i({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(s==="left"&&!o||s==="right"&&o);u=_i(_i({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return w.createElement("line",Hf({},u,{className:Vn("recharts-cartesian-axis-line",Uf(l,"className"))}))}function lCe(t,e,n,r,i,s,o,l,c){var u,d,f,m,g,x,y=l?-1:1,b=t.tickSize||o,v=Ut(t.tickCoord)?t.tickCoord:t.coordinate;switch(s){case"top":u=d=t.coordinate,m=n+ +!l*i,f=m-y*b,x=f-y*c,g=v;break;case"left":f=m=t.coordinate,d=e+ +!l*r,u=d-y*b,g=u-y*c,x=v;break;case"right":f=m=t.coordinate,d=e+ +l*r,u=d+y*b,g=u+y*c,x=v;break;default:u=d=t.coordinate,m=n+ +l*i,f=m+y*b,x=f+y*c,g=v;break}return{line:{x1:u,y1:f,x2:d,y2:m},tick:{x:g,y:x}}}function cCe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function uCe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function dCe(t){var{option:e,tickProps:n,value:r}=t,i,s=Vn(n.className,"recharts-cartesian-axis-tick-value");if(w.isValidElement(e))i=w.cloneElement(e,_i(_i({},n),{},{className:s}));else if(typeof e=="function")i=e(_i(_i({},n),{},{className:s}));else{var o="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(o=Vn(o,e?.className)),i=w.createElement(PN,Hf({},n,{className:o}),r)}return i}var hCe=w.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:s,tickFormatter:o,unit:l,padding:c,tickTextProps:u,orientation:d,mirror:f,x:m,y:g,width:x,height:y,tickSize:b,tickMargin:v,fontSize:N,letterSpacing:S,getTicksConfig:T,events:E,axisType:k}=t,C=pO(_i(_i({},T),{},{ticks:n}),N,S),D=cCe(d,f),A=uCe(d,f),R=Ja(T),F=Ff(r),O={};typeof i=="object"&&(O=i);var q=_i(_i({},R),{},{fill:"none"},O),j=C.map(K=>_i({entry:K},lCe(K,m,g,x,y,d,b,f,v))),G=j.map(K=>{var{entry:Z,line:te}=K;return w.createElement(Kr,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(Z.value,"-").concat(Z.coordinate,"-").concat(Z.tickCoord)},i&&w.createElement("line",Hf({},q,te,{className:Vn("recharts-cartesian-axis-tick-line",Uf(i,"className"))})))}),Y=j.map((K,Z)=>{var{entry:te,tick:ne}=K,z=_i(_i(_i(_i({textAnchor:D,verticalAnchor:A},R),{},{stroke:"none",fill:s},F),ne),{},{index:Z,payload:te,visibleTicksCount:C.length,tickFormatter:o,padding:c},u);return w.createElement(Kr,Hf({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(te.value,"-").concat(te.coordinate,"-").concat(te.tickCoord)},dy(E,te,Z)),r&&w.createElement(dCe,{option:r,tickProps:z,value:"".concat(typeof o=="function"?o(te.value,Z):te.value).concat(l||"")}))});return w.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(k,"-ticks")},Y.length>0&&w.createElement(za,{zIndex:oi.label},w.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(k,"-tick-labels"),ref:e},Y)),G.length>0&&w.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(k,"-tick-lines")},G))}),fCe=w.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:s,hide:o,ticks:l,axisType:c}=t,u=nCe(t,tCe),[d,f]=w.useState(""),[m,g]=w.useState(""),x=w.useRef(null);w.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var b;return eCe({ticks:x.current,label:(b=t.labelRef)===null||b===void 0?void 0:b.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var y=w.useCallback(b=>{if(b){var v=b.getElementsByClassName("recharts-cartesian-axis-tick-value");x.current=v;var N=v[0];if(N){var S=window.getComputedStyle(N),T=S.fontSize,E=S.letterSpacing;(T!==d||E!==m)&&(f(T),g(E))}}},[d,m]);return o||r!=null&&r<=0||i!=null&&i<=0?null:w.createElement(za,{zIndex:t.zIndex},w.createElement(Kr,{className:Vn("recharts-cartesian-axis",s)},w.createElement(oCe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Ja(t)}),w.createElement(hCe,{ref:y,axisType:c,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:m,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:l,unit:t.unit,width:t.width,x:t.x,y:t.y}),w.createElement(PQ,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},w.createElement(DQ,{label:t.label,labelRef:t.labelRef}),t.children)))}),gO=w.forwardRef((t,e)=>{var n=Xr(t,eu);return w.createElement(fCe,Hf({},n,{ref:e}))});gO.displayName="CartesianAxis";var mCe=["x1","y1","x2","y2","key"],pCe=["offset"],gCe=["xAxisId","yAxisId"],xCe=["xAxisId","yAxisId"];function F$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function La(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?F$(Object(n),!0).forEach(function(r){bCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):F$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function bCe(t,e,n){return(e=yCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yCe(t){var e=vCe(t,"string");return typeof e=="symbol"?e:e+""}function vCe(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 uf(){return uf=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},uf.apply(null,arguments)}function gS(t,e){if(t==null)return{};var n,r,i=_Ce(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function _Ce(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 wCe=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:s,height:o,ry:l}=t;return w.createElement("rect",{x:r,y:i,ry:l,width:s,height:o,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function aZ(t){var{option:e,lineItemProps:n}=t,r;if(w.isValidElement(e))r=w.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:s,y1:o,x2:l,y2:c,key:u}=n,d=gS(n,mCe),f=(i=Ja(d))!==null&&i!==void 0?i:{},{offset:m}=f,g=gS(f,pCe);r=w.createElement("line",uf({},g,{x1:s,y1:o,x2:l,y2:c,fill:"none",key:u}))}return r}function SCe(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:s,yAxisId:o}=t,l=gS(t,gCe),c=i.map((u,d)=>{var f=La(La({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return w.createElement(aZ,{key:"line-".concat(d),option:r,lineItemProps:f})});return w.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function NCe(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:s,yAxisId:o}=t,l=gS(t,xCe),c=i.map((u,d)=>{var f=La(La({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return w.createElement(aZ,{option:r,lineItemProps:f,key:"line-".concat(d)})});return w.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function MCe(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:s,height:o,horizontalPoints:l,horizontal:c=!0}=t;if(!c||!e||!e.length||l==null)return null;var u=l.map(f=>Math.round(f+i-i)).sort((f,m)=>f-m);i!==u[0]&&u.unshift(0);var d=u.map((f,m)=>{var g=!u[m+1],x=g?i+o-f:u[m+1]-f;if(x<=0)return null;var y=m%e.length;return w.createElement("rect",{key:"react-".concat(m),y:f,x:r,height:x,width:s,stroke:"none",fill:e[y],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return w.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function ECe(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:s,width:o,height:l,verticalPoints:c}=t;if(!e||!n||!n.length)return null;var u=c.map(f=>Math.round(f+i-i)).sort((f,m)=>f-m);i!==u[0]&&u.unshift(0);var d=u.map((f,m)=>{var g=!u[m+1],x=g?i+o-f:u[m+1]-f;if(x<=0)return null;var y=m%n.length;return w.createElement("rect",{key:"react-".concat(m),x:f,y:s,width:x,height:l,stroke:"none",fill:n[y],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return w.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var TCe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:s}=t;return $K(pO(La(La(La({},eu),n),{},{ticks:HK(n),viewBox:{x:0,y:0,width:r,height:i}})),s.left,s.left+s.width,e)},CCe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:s}=t;return $K(pO(La(La(La({},eu),n),{},{ticks:HK(n),viewBox:{x:0,y:0,width:r,height:i}})),s.top,s.top+s.height,e)},ACe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:oi.grid};function xS(t){var e=$D(),n=HD(),r=ZK(),i=La(La({},Xr(t,ACe)),{},{x:Ut(t.x)?t.x:r.left,y:Ut(t.y)?t.y:r.top,width:Ut(t.width)?t.width:r.width,height:Ut(t.height)?t.height:r.height}),{xAxisId:s,yAxisId:o,x:l,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:m,verticalValues:g}=i,x=Bi(),y=It(A=>E6(A,"xAxis",s,x)),b=It(A=>E6(A,"yAxis",o,x));if(!Bl(u)||!Bl(d)||!Ut(l)||!Ut(c))return null;var v=i.verticalCoordinatesGenerator||TCe,N=i.horizontalCoordinatesGenerator||CCe,{horizontalPoints:S,verticalPoints:T}=i;if((!S||!S.length)&&typeof N=="function"){var E=m&&m.length,k=N({yAxis:b?La(La({},b),{},{ticks:E?m:b.ticks}):void 0,width:e??u,height:n??d,offset:r},E?!0:f);zw(Array.isArray(k),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof k,"]")),Array.isArray(k)&&(S=k)}if((!T||!T.length)&&typeof v=="function"){var C=g&&g.length,D=v({xAxis:y?La(La({},y),{},{ticks:C?g:y.ticks}):void 0,width:e??u,height:n??d,offset:r},C?!0:f);zw(Array.isArray(D),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof D,"]")),Array.isArray(D)&&(T=D)}return w.createElement(za,{zIndex:i.zIndex},w.createElement("g",{className:"recharts-cartesian-grid"},w.createElement(wCe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),w.createElement(MCe,uf({},i,{horizontalPoints:S})),w.createElement(ECe,uf({},i,{verticalPoints:T})),w.createElement(SCe,uf({},i,{offset:r,horizontalPoints:S,xAxis:y,yAxis:b})),w.createElement(NCe,uf({},i,{offset:r,verticalPoints:T,xAxis:y,yAxis:b}))))}xS.displayName="CartesianGrid";var sZ=(t,e,n,r)=>Vl(t,"xAxis",e,r),oZ=(t,e,n,r)=>Hl(t,"xAxis",e,r),lZ=(t,e,n,r)=>Vl(t,"yAxis",n,r),cZ=(t,e,n,r)=>Hl(t,"yAxis",n,r),kCe=tt([Dn,sZ,lZ,oZ,cZ],(t,e,n,r,i)=>Ql(t,"xAxis")?Xd(e,r,!1):Xd(n,i,!1)),jCe=(t,e,n,r,i)=>i;function PCe(t){return t.type==="line"}var RCe=tt([Ey,jCe],(t,e)=>t.filter(PCe).find(n=>n.id===e)),DCe=tt([Dn,sZ,lZ,oZ,cZ,RCe,kCe,wy],(t,e,n,r,i,s,o,l)=>{var{chartData:c,dataStartIndex:u,dataEndIndex:d}=l;if(!(s==null||e==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||t!=="horizontal"&&t!=="vertical")){var{dataKey:f,data:m}=s,g;if(m!=null&&m.length>0?g=m:g=c?.slice(u,d+1),g!=null)return eAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:o,displayedData:g})}});function uZ(t){var e=Ff(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:s}=e,o=Number(i),l=Number(s);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(l)||l<0)&&(l=r),{r:o,strokeWidth:l}}return{r:n,strokeWidth:r}}var OCe=["id"],LCe=["type","layout","connectNulls","needClip","shape"],ICe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function O0(){return O0=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},O0.apply(null,arguments)}function U$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Tl(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?U$(Object(n),!0).forEach(function(r){FCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):U$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function FCe(t,e,n){return(e=UCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function UCe(t){var e=zCe(t,"string");return typeof e=="symbol"?e:e+""}function zCe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function xO(t,e){if(t==null)return{};var n,r,i=BCe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function BCe(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 $Ce=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:uh(n,e),payload:t}]},HCe=w.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:uh(o,e),hide:l,type:u,color:r,unit:c}};return w.createElement(LN,{tooltipEntrySettings:d})}),dZ=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function VCe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var GCe=(t,e,n)=>{var r=n.reduce((f,m)=>f+m);if(!r)return dZ(e,t);for(var i=Math.floor(t/r),s=t%r,o=e-t,l=[],c=0,u=0;c<n.length;u+=n[c],++c)if(u+n[c]>s){l=[...n.slice(0,c),s-u];break}var d=l.length%2===0?[0,o]:[o];return[...VCe(n,i),...l,...d].map(f=>"".concat(f,"px")).join(", ")};function qCe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:s,needClip:o}=r,{id:l}=r,c=xO(r,OCe),u=Ja(c);return w.createElement(qQ,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:s,baseProps:u,needClip:o,clipPathId:e})}function WCe(t){var{showLabels:e,children:n,points:r}=t,i=w.useMemo(()=>r?.map(s=>{var o,l,c={x:(o=s.x)!==null&&o!==void 0?o:0,y:(l=s.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Tl(Tl({},c),{},{value:s.value,payload:s.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return w.createElement(rO,{value:e?i:void 0},n)}function z$(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:s}=t,{type:o,layout:l,connectNulls:c,needClip:u,shape:d}=s,f=xO(s,LCe),m=Tl(Tl({},Ea(f)),{},{fill:"none",className:"recharts-line-curve",clipPath:u?"url(#clipPath-".concat(e,")"):void 0,points:r,type:o,layout:l,connectNulls:c,strokeDasharray:i??s.strokeDasharray});return w.createElement(w.Fragment,null,r?.length>1&&w.createElement(lO,O0({shapeType:"curve",option:d},m,{pathRef:n})),w.createElement(qCe,{points:r,clipPathId:e,props:s}))}function KCe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function XCe(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:s}=t,{points:o,strokeDasharray:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,animateNewValues:m,width:g,height:x,onAnimationEnd:y,onAnimationStart:b}=n,v=i.current,N=Gg(o,"recharts-line-"),S=w.useRef(N),[T,E]=w.useState(!1),k=!T,C=w.useCallback(()=>{typeof y=="function"&&y(),E(!1)},[y]),D=w.useCallback(()=>{typeof b=="function"&&b(),E(!0)},[b]),A=KCe(r.current),R=w.useRef(0);S.current!==N&&(R.current=s.current,S.current=N);var F=R.current;return w.createElement(WCe,{points:o,showLabels:k},n.children,w.createElement(Vg,{animationId:N,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:C,onAnimationStart:D,key:N},O=>{var q=nr(F,A+F,O),j=Math.min(q,A),G;if(c)if(l){var Y="".concat(l).split(/[,\s]+/gim).map(te=>parseFloat(te));G=GCe(j,A,Y)}else G=dZ(A,j);else G=l==null?void 0:String(l);if(O>0&&A>0&&(i.current=o,s.current=Math.max(s.current,j)),v){var K=v.length/o.length,Z=O===1?o:o.map((te,ne)=>{var z=Math.floor(ne*K);if(v[z]){var W=v[z];return Tl(Tl({},te),{},{x:nr(W.x,te.x,O),y:nr(W.y,te.y,O)})}return m?Tl(Tl({},te),{},{x:nr(g*2,te.x,O),y:nr(x/2,te.y,O)}):Tl(Tl({},te),{},{x:te.x,y:te.y})});return i.current=Z,w.createElement(z$,{props:n,points:Z,clipPathId:e,pathRef:r,strokeDasharray:G})}return w.createElement(z$,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:G})}),w.createElement(RN,{label:n.label}))}function YCe(t){var{clipPathId:e,props:n}=t,r=w.useRef(null),i=w.useRef(0),s=w.useRef(null);return w.createElement(XCe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:s})}var QCe=(t,e)=>{var n,r;return{x:(n=t.x)!==null&&n!==void 0?n:void 0,y:(r=t.y)!==null&&r!==void 0?r:void 0,value:t.value,errorVal:lr(t.payload,e)}};class ZCe extends w.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:s,yAxisId:o,top:l,left:c,width:u,height:d,id:f,needClip:m,zIndex:g}=this.props;if(e)return null;var x=Vn("recharts-line",i),y=f,{r:b,strokeWidth:v}=uZ(n),N=oO(n),S=b*2+v,T=m?"url(#clipPath-".concat(N?"":"dots-").concat(y,")"):void 0;return w.createElement(za,{zIndex:g},w.createElement(Kr,{className:x},m&&w.createElement("defs",null,w.createElement(mO,{clipPathId:y,xAxisId:s,yAxisId:o}),!N&&w.createElement("clipPath",{id:"clipPath-dots-".concat(y)},w.createElement("rect",{x:c-S/2,y:l-S/2,width:u+S,height:d+S}))),w.createElement(XQ,{xAxisId:s,yAxisId:o,data:r,dataPointFormatter:QCe,errorBarOffset:0},w.createElement(YCe,{props:this.props,clipPathId:y}))),w.createElement(Q3,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:T}))}}var hZ={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:oi.line,type:"linear"};function JCe(t){var e=Xr(t,hZ),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:s,animationEasing:o,connectNulls:l,dot:c,hide:u,isAnimationActive:d,label:f,legendType:m,xAxisId:g,yAxisId:x,id:y}=e,b=xO(e,ICe),{needClip:v}=zN(g,x),N=UN(),S=im(),T=Bi(),E=It(R=>DCe(R,g,x,T,y));if(S!=="horizontal"&&S!=="vertical"||E==null||N==null)return null;var{height:k,width:C,x:D,y:A}=N;return w.createElement(ZCe,O0({},b,{id:y,connectNulls:l,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:s,animationEasing:o,isAnimationActive:d,hide:u,label:f,legendType:m,xAxisId:g,yAxisId:x,points:E,layout:S,height:k,width:C,left:D,top:A,needClip:v}))}function eAe(t){var{layout:e,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,dataKey:o,bandSize:l,displayedData:c}=t;return c.map((u,d)=>{var f=lr(u,o);if(e==="horizontal"){var m=Uw({axis:n,ticks:i,bandSize:l,entry:u,index:d}),g=Ir(f)?null:r.scale(f);return{x:m,y:g,value:f,payload:u}}var x=Ir(f)?null:n.scale(f),y=Uw({axis:r,ticks:s,bandSize:l,entry:u,index:d});return x==null||y==null?null:{x,y,value:f,payload:u}}).filter(Boolean)}function tAe(t){var e=Xr(t,hZ),n=Bi();return w.createElement(IN,{id:e.id,type:"line"},r=>w.createElement(w.Fragment,null,w.createElement(hO,{legendPayload:$Ce(e)}),w.createElement(HCe,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),w.createElement(fO,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),w.createElement(JCe,O0({},e,{id:r}))))}var fZ=w.memo(tAe,Oy);fZ.displayName="Line";var mZ=(t,e,n,r)=>Vl(t,"xAxis",e,r),pZ=(t,e,n,r)=>Hl(t,"xAxis",e,r),gZ=(t,e,n,r)=>Vl(t,"yAxis",n,r),xZ=(t,e,n,r)=>Hl(t,"yAxis",n,r),nAe=tt([Dn,mZ,gZ,pZ,xZ],(t,e,n,r,i)=>Ql(t,"xAxis")?Xd(e,r,!1):Xd(n,i,!1)),rAe=(t,e,n,r,i)=>i,bZ=tt([Ey,rAe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),iAe=(t,e,n,r,i)=>{var s,o=bZ(t,e,n,r,i);if(o!=null){var l=Dn(t),c=Ql(l,"xAxis"),u;if(c?u=R0(t,"yAxis",n,r):u=R0(t,"xAxis",e,r),u!=null){var{stackId:d}=o,f=SN(o);if(!(d==null||f==null)){var m=(s=u[d])===null||s===void 0?void 0:s.stackedData;return m?.find(g=>g.key===f)}}}},aAe=tt([Dn,mZ,gZ,pZ,xZ,iAe,wy,nAe,bZ,R_e],(t,e,n,r,i,s,o,l,c,u)=>{var{chartData:d,dataStartIndex:f,dataEndIndex:m}=o;if(!(c==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||l==null)){var{data:g}=c,x;if(g&&g.length>0?x=g:x=d?.slice(f,m+1),x!=null)return NAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:s,displayedData:x,chartBaseValue:u,bandSize:l})}}),sAe=["id"],oAe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function wf(){return wf=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},wf.apply(null,arguments)}function yZ(t,e){if(t==null)return{};var n,r,i=lAe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function lAe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function B$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function $p(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?B$(Object(n),!0).forEach(function(r){cAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):B$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function cAe(t,e,n){return(e=uAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uAe(t){var e=dAe(t,"string");return typeof e=="symbol"?e:e+""}function dAe(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(t,e){return t&&t!=="none"?t:e}var hAe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:s,hide:o}=t;return[{inactive:o,dataKey:e,type:s,color:bS(r,i),value:uh(n,e),payload:t}]},fAe=w.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:uh(o,e),hide:l,type:u,color:bS(r,s),unit:c}};return w.createElement(LN,{tooltipEntrySettings:d})});function mAe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:s,dataKey:o}=r,l=Ja(r);return w.createElement(qQ,{points:n,dot:s,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function pAe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(s=>{var o,l,c={x:(o=s.x)!==null&&o!==void 0?o:0,y:(l=s.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return $p($p({},c),{},{value:s.value,payload:s.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return w.createElement(rO,{value:e?i:void 0},n)}function $$(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:s}=t,{layout:o,type:l,stroke:c,connectNulls:u,isRange:d}=s,{id:f}=s,m=yZ(s,sAe),g=Ja(m),x=Ea(m);return w.createElement(w.Fragment,null,e?.length>1&&w.createElement(Kr,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},w.createElement(Yp,wf({},x,{id:f,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&w.createElement(Yp,wf({},g,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&w.createElement(Yp,wf({},g,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:n}))),w.createElement(mAe,{points:e,props:m,clipPathId:i}))}function gAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].y,o=r[r.length-1].y;if(!cr(s)||!cr(o))return null;var l=e*Math.abs(s-o),c=Math.max(...r.map(u=>u.x||0));return Ut(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),Ut(c)?w.createElement("rect",{x:0,y:s<o?s:s-l,width:c+(i?parseInt("".concat(i),10):1),height:Math.floor(l)}):null}function xAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].x,o=r[r.length-1].x;if(!cr(s)||!cr(o))return null;var l=e*Math.abs(s-o),c=Math.max(...r.map(u=>u.y||0));return Ut(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),Ut(c)?w.createElement("rect",{x:s<o?s:s-l,y:0,width:l,height:Math.floor(c+(i?parseInt("".concat(i),10):1))}):null}function bAe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:s}=t;return n==="vertical"?w.createElement(gAe,{alpha:e,points:r,baseLine:i,strokeWidth:s}):w.createElement(xAe,{alpha:e,points:r,baseLine:i,strokeWidth:s})}function yAe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s}=t,{points:o,baseLine:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:m,onAnimationEnd:g}=r,x=w.useMemo(()=>({points:o,baseLine:l}),[o,l]),y=Gg(x,"recharts-area-"),b=Qxe(),[v,N]=w.useState(!1),S=!v,T=w.useCallback(()=>{typeof g=="function"&&g(),N(!1)},[g]),E=w.useCallback(()=>{typeof m=="function"&&m(),N(!0)},[m]);if(b==null)return null;var k=i.current,C=s.current;return w.createElement(pAe,{showLabels:S,points:o},r.children,w.createElement(Vg,{animationId:y,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:T,onAnimationStart:E,key:y},D=>{if(k){var A=k.length/o.length,R=D===1?o:o.map((O,q)=>{var j=Math.floor(q*A);if(k[j]){var G=k[j];return $p($p({},O),{},{x:nr(G.x,O.x,D),y:nr(G.y,O.y,D)})}return O}),F;return Ut(l)?F=nr(C,l,D):Ir(l)||Es(l)?F=nr(C,0,D):F=l.map((O,q)=>{var j=Math.floor(q*A);if(Array.isArray(C)&&C[j]){var G=C[j];return $p($p({},O),{},{x:nr(G.x,O.x,D),y:nr(G.y,O.y,D)})}return O}),D>0&&(i.current=R,s.current=F),w.createElement($$,{points:R,baseLine:F,needClip:e,clipPathId:n,props:r})}return D>0&&(i.current=o,s.current=l),w.createElement(Kr,null,c&&w.createElement("defs",null,w.createElement("clipPath",{id:"animationClipPath-".concat(n)},w.createElement(bAe,{alpha:D,points:o,baseLine:l,layout:b,strokeWidth:r.strokeWidth}))),w.createElement(Kr,{clipPath:"url(#animationClipPath-".concat(n,")")},w.createElement($$,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),w.createElement(RN,{label:r.label}))}function vAe(t){var{needClip:e,clipPathId:n,props:r}=t,i=w.useRef(null),s=w.useRef();return w.createElement(yAe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s})}class _Ae extends w.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:s,left:o,needClip:l,xAxisId:c,yAxisId:u,width:d,height:f,id:m,baseLine:g,zIndex:x}=this.props;if(e)return null;var y=Vn("recharts-area",i),b=m,{r:v,strokeWidth:N}=uZ(n),S=oO(n),T=v*2+N,E=l?"url(#clipPath-".concat(S?"":"dots-").concat(b,")"):void 0;return w.createElement(za,{zIndex:x},w.createElement(Kr,{className:y},l&&w.createElement("defs",null,w.createElement(mO,{clipPathId:b,xAxisId:c,yAxisId:u}),!S&&w.createElement("clipPath",{id:"clipPath-dots-".concat(b)},w.createElement("rect",{x:o-T/2,y:s-T/2,width:d+T,height:f+T}))),w.createElement(vAe,{needClip:l,clipPathId:b,props:this.props})),w.createElement(Q3,{points:r,mainColor:bS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:E}),this.props.isRange&&Array.isArray(g)&&w.createElement(Q3,{points:g,mainColor:bS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:E}))}}var vZ={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:oi.area};function wAe(t){var e,n=Xr(t,vZ),{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:o,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:m,legendType:g,stroke:x,xAxisId:y,yAxisId:b}=n,v=yZ(n,oAe),N=im(),S=pQ(),{needClip:T}=zN(y,b),E=Bi(),{points:k,isRange:C,baseLine:D}=(e=It(j=>aAe(j,y,b,E,t.id)))!==null&&e!==void 0?e:{},A=UN();if(N!=="horizontal"&&N!=="vertical"||A==null||S!=="AreaChart"&&S!=="ComposedChart")return null;var{height:R,width:F,x:O,y:q}=A;return!k||!k.length?null:w.createElement(_Ae,wf({},v,{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:o,baseLine:D,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:R,hide:f,layout:N,isAnimationActive:m==="auto"?!Hg.isSsr:m,isRange:C,legendType:g,needClip:T,points:k,stroke:x,width:F,left:O,top:q,xAxisId:y,yAxisId:b}))}var SAe=(t,e,n,r,i)=>{var s=n??e;if(Ut(s))return s;var o=t==="horizontal"?i:r,l=o.scale.domain();if(o.type==="number"){var c=Math.max(l[0],l[1]),u=Math.min(l[0],l[1]);return s==="dataMin"?u:s==="dataMax"||c<0?c:Math.max(Math.min(l[0],l[1]),0)}return s==="dataMin"?l[0]:s==="dataMax"?l[1]:l[0]};function NAe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:s,chartBaseValue:o,xAxis:l,yAxis:c,displayedData:u,dataStartIndex:d,xAxisTicks:f,yAxisTicks:m,bandSize:g}=t,x=i&&i.length,y=SAe(s,o,n,l,c),b=s==="horizontal",v=!1,N=u.map((T,E)=>{var k;x?k=i[d+E]:(k=lr(T,r),Array.isArray(k)?v=!0:k=[y,k]);var C=k[1]==null||x&&!e&&lr(T,r)==null;return b?{x:Uw({axis:l,ticks:f,bandSize:g,entry:T,index:E}),y:C?null:c.scale(k[1]),value:k,payload:T}:{x:C?null:l.scale(k[1]),y:Uw({axis:c,ticks:m,bandSize:g,entry:T,index:E}),value:k,payload:T}}),S;return x||v?S=N.map(T=>{var E=Array.isArray(T.value)?T.value[0]:null;return b?{x:T.x,y:E!=null&&T.y!=null?c.scale(E):null,payload:T.payload}:{x:E!=null?l.scale(E):null,y:T.y,payload:T.payload}}):S=b?c.scale(y):l.scale(y),{points:N,baseLine:S,isRange:v}}function MAe(t){var e=Xr(t,vZ),n=Bi();return w.createElement(IN,{id:e.id,type:"area"},r=>w.createElement(w.Fragment,null,w.createElement(hO,{legendPayload:hAe(e)}),w.createElement(fAe,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),w.createElement(fO,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:VK(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),w.createElement(wAe,wf({},e,{id:r}))))}var _Z=w.memo(MAe,Oy);_Z.displayName="Area";var EAe=["domain","range"],TAe=["domain","range"];function H$(t,e){if(t==null)return{};var n,r,i=CAe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function CAe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function V$(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 wZ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=H$(t,EAe),{domain:s,range:o}=e,l=H$(e,TAe);return!V$(n,s)||!V$(r,o)?!1:Oy(i,l)}var AAe=["dangerouslySetInnerHTML","ticks"],kAe=["id"];function J3(){return J3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},J3.apply(null,arguments)}function G$(t,e){if(t==null)return{};var n,r,i=jAe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function jAe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function PAe(t){var e=Er(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(EMe(t)):n.current!==t&&e(TMe({prev:n.current,next:t})),n.current=t},[t,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(CMe(n.current)),n.current=null)},[e]),null}var RAe=t=>{var{xAxisId:e,className:n}=t,r=It(zD),i=Bi(),s="xAxis",o=It(b=>Qd(b,s,e,i)),l=It(b=>WY(b,s,e,i)),c=It(b=>HY(b,e)),u=It(b=>k1e(b,e)),d=It(b=>NY(b,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:m}=t,g=G$(t,AAe),{id:x}=d,y=G$(d,kAe);return w.createElement(gO,J3({},g,y,{scale:o,x:u.x,y:u.y,width:c.width,height:c.height,className:Vn("recharts-".concat(s," ").concat(s),n),viewBox:r,ticks:l,axisType:s}))},DAe={allowDataOverflow:Qi.allowDataOverflow,allowDecimals:Qi.allowDecimals,allowDuplicatedCategory:Qi.allowDuplicatedCategory,angle:Qi.angle,axisLine:eu.axisLine,height:Qi.height,hide:!1,includeHidden:Qi.includeHidden,interval:Qi.interval,minTickGap:Qi.minTickGap,mirror:Qi.mirror,orientation:Qi.orientation,padding:Qi.padding,reversed:Qi.reversed,scale:Qi.scale,tick:Qi.tick,tickCount:Qi.tickCount,tickLine:eu.tickLine,tickSize:eu.tickSize,type:Qi.type,xAxisId:0},OAe=t=>{var e=Xr(t,DAe);return w.createElement(w.Fragment,null,w.createElement(PAe,{allowDataOverflow:e.allowDataOverflow,allowDecimals:e.allowDecimals,allowDuplicatedCategory:e.allowDuplicatedCategory,angle:e.angle,dataKey:e.dataKey,domain:e.domain,height:e.height,hide:e.hide,id:e.xAxisId,includeHidden:e.includeHidden,interval:e.interval,minTickGap:e.minTickGap,mirror:e.mirror,name:e.name,orientation:e.orientation,padding:e.padding,reversed:e.reversed,scale:e.scale,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit}),w.createElement(RAe,e))},yS=w.memo(OAe,wZ);yS.displayName="XAxis";var LAe=["dangerouslySetInnerHTML","ticks"],IAe=["id"];function eP(){return eP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},eP.apply(null,arguments)}function q$(t,e){if(t==null)return{};var n,r,i=FAe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function FAe(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 UAe(t){var e=Er(),n=w.useRef(null);return w.useLayoutEffect(()=>{n.current===null?e(AMe(t)):n.current!==t&&e(kMe({prev:n.current,next:t})),n.current=t},[t,e]),w.useLayoutEffect(()=>()=>{n.current&&(e(jMe(n.current)),n.current=null)},[e]),null}var zAe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,s=w.useRef(null),o=w.useRef(null),l=It(zD),c=Bi(),u=Er(),d="yAxis",f=It(E=>Qd(E,d,e,c)),m=It(E=>VY(E,e)),g=It(E=>P1e(E,e)),x=It(E=>WY(E,d,e,c)),y=It(E=>MY(E,e));if(w.useLayoutEffect(()=>{if(!(r!=="auto"||!m||nO(i)||w.isValidElement(i)||y==null)){var E=s.current;if(E){var k=E.getCalculatedWidth();Math.round(m.width)!==Math.round(k)&&u(PMe({id:e,width:k}))}}},[x,m,u,i,e,r,y]),m==null||g==null||y==null)return null;var{dangerouslySetInnerHTML:b,ticks:v}=t,N=q$(t,LAe),{id:S}=y,T=q$(y,IAe);return w.createElement(gO,eP({},N,T,{ref:s,labelRef:o,scale:f,x:g.x,y:g.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:m.width,height:m.height,className:Vn("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:x,axisType:d}))},BAe={allowDataOverflow:Zi.allowDataOverflow,allowDecimals:Zi.allowDecimals,allowDuplicatedCategory:Zi.allowDuplicatedCategory,angle:Zi.angle,axisLine:eu.axisLine,hide:!1,includeHidden:Zi.includeHidden,interval:Zi.interval,minTickGap:Zi.minTickGap,mirror:Zi.mirror,orientation:Zi.orientation,padding:Zi.padding,reversed:Zi.reversed,scale:Zi.scale,tick:Zi.tick,tickCount:Zi.tickCount,tickLine:eu.tickLine,tickSize:eu.tickSize,type:Zi.type,width:Zi.width,yAxisId:0},$Ae=t=>{var e=Xr(t,BAe);return w.createElement(w.Fragment,null,w.createElement(UAe,{interval:e.interval,id:e.yAxisId,scale:e.scale,type:e.type,domain:e.domain,allowDataOverflow:e.allowDataOverflow,dataKey:e.dataKey,allowDuplicatedCategory:e.allowDuplicatedCategory,allowDecimals:e.allowDecimals,tickCount:e.tickCount,padding:e.padding,includeHidden:e.includeHidden,reversed:e.reversed,ticks:e.ticks,width:e.width,orientation:e.orientation,mirror:e.mirror,hide:e.hide,unit:e.unit,name:e.name,angle:e.angle,minTickGap:e.minTickGap,tick:e.tick,tickFormatter:e.tickFormatter}),w.createElement(zAe,e))},vS=w.memo($Ae,wZ);vS.displayName="YAxis";var HAe=(t,e)=>e,bO=tt([HAe,Dn,wY,Hi,cQ,Su,Wwe,zi],eSe),yO=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)}},SZ=Io("mouseClick"),NZ=my();NZ.startListening({actionCreator:SZ,effect:(t,e)=>{var n=t.payload,r=bO(e.getState(),yO(n));r?.activeIndex!=null&&e.dispatch(q1e({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var tP=Io("mouseMove"),MZ=my(),N_=null;MZ.startListening({actionCreator:tP,effect:(t,e)=>{var n=t.payload;N_!==null&&cancelAnimationFrame(N_);var r=yO(n);N_=requestAnimationFrame(()=>{var i=e.getState(),s=G4(i,i.tooltip.settings.shared);if(s==="axis"){var o=bO(i,r);o?.activeIndex!=null?e.dispatch(tQ({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch(eQ())}N_=null})}});var W$={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},EZ=Ts({name:"rootProps",initialState:W$,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:W$.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}}}),VAe=EZ.reducer,{updateOptions:GAe}=EZ.actions,TZ=Ts({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:qAe}=TZ.actions,WAe=TZ.reducer,CZ=Io("keyDown"),AZ=Io("focus"),vO=my();vO.startListening({actionCreator:CZ,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip,s=t.payload;if(!(s!=="ArrowRight"&&s!=="ArrowLeft"&&s!=="Enter")){var o=q4(i,Jg(n),Cy(n),Py(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=Su(n);if(s==="Enter"){var u=oS(n,"axis","hover",String(i.index));e.dispatch(G3({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=L1e(n),f=d==="left-to-right"?1:-1,m=s==="ArrowRight"?1:-1,g=l+m*f;if(!(c==null||g>=c.length||g<0)){var x=oS(n,"axis","hover",String(g));e.dispatch(G3({active:!0,activeIndex:g.toString(),activeDataKey:void 0,activeCoordinate:x}))}}}}}});vO.startListening({actionCreator:AZ,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;if(!i.active&&i.index==null){var s="0",o=oS(n,"axis","hover",String(s));e.dispatch(G3({activeDataKey:void 0,active:!0,activeIndex:s,activeCoordinate:o}))}}}});var go=Io("externalEvent"),kZ=my(),gA=new Map;kZ.startListening({actionCreator:go,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,s=gA.get(i);s!==void 0&&cancelAnimationFrame(s);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:Pwe(l),activeDataKey:Q4(l),activeIndex:Zd(l),activeLabel:hQ(l),activeTooltipIndex:Zd(l),isTooltipActive:Rwe(l)};n(c,r)}finally{gA.delete(i)}});gA.set(i,o)}}});var KAe=tt([Zg],t=>t.tooltipItemPayloads),XAe=tt([KAe,ky,(t,e,n)=>e,(t,e,n)=>n],(t,e,n,r)=>{var i=t.find(l=>l.settings.dataKey===r);if(i!=null){var{positions:s}=i;if(s!=null){var o=e(s,n);return o}}}),jZ=Io("touchMove"),PZ=my();PZ.startListening({actionCreator:jZ,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=G4(r,r.tooltip.settings.shared);if(i==="axis"){var s=bO(r,yO({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));s?.activeIndex!=null&&e.dispatch(tQ({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate}))}else if(i==="item"){var o,l=n.touches[0];if(document.elementFromPoint==null)return;var c=document.elementFromPoint(l.clientX,l.clientY);if(!c||!c.getAttribute)return;var u=c.getAttribute(qK),d=(o=c.getAttribute(WK))!==null&&o!==void 0?o:void 0,f=XAe(e.getState(),u,d);e.dispatch(JY({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var YAe=fK({brush:vTe,cartesianAxis:RMe,chartData:jSe,errorBars:ZMe,graphicalItems:zNe,layout:ixe,legend:hbe,options:ESe,polarAxis:tNe,polarOptions:WAe,referenceElements:jTe,rootProps:VAe,tooltip:W1e,zIndex:mSe}),QAe=function(e){return Age({reducer:YAe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([NZ.middleware,MZ.middleware,vO.middleware,kZ.middleware,PZ.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(CK({type:"raf"}))},devTools:Hg.devToolsEnabled})};function RZ(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=Bi(),s=w.useRef(null);if(i)return n;s.current==null&&(s.current=QAe(e));var o=jD;return w.createElement(wEe,{context:o,store:s.current},n)}function ZAe(t){var{layout:e,margin:n}=t,r=Er(),i=Bi();return w.useEffect(()=>{i||(r(txe(e)),r(exe(n)))},[r,i,e,n]),null}var DZ=w.memo(ZAe,Oy);function OZ(t){var e=Er();return w.useEffect(()=>{e(GAe(t))},[e,t]),null}function K$(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=HQ("".concat(r).concat(e)),s=Er();return w.useLayoutEffect(()=>(s(hSe({zIndex:e,elementId:i,isPanorama:n})),()=>{s(fSe({zIndex:e,isPanorama:n}))}),[s,e,i,n]),w.createElement("g",{tabIndex:-1,id:i})}function X$(t){var{children:e,isPanorama:n}=t,r=It(nSe);if(!r||r.length===0)return e;var i=r.filter(o=>o<0),s=r.filter(o=>o>0);return w.createElement(w.Fragment,null,i.map(o=>w.createElement(K$,{key:o,zIndex:o,isPanorama:n})),e,s.map(o=>w.createElement(K$,{key:o,zIndex:o,isPanorama:n})))}var JAe=["children"];function eke(t,e){if(t==null)return{};var n,r,i=tke(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function tke(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 _S(){return _S=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},_S.apply(null,arguments)}var nke={width:"100%",height:"100%",display:"block"},rke=w.forwardRef((t,e)=>{var n=$D(),r=HD(),i=cX();if(!Bl(n)||!Bl(r))return null;var{children:s,otherAttributes:o,title:l,desc:c}=t,u,d;return o!=null&&(typeof o.tabIndex=="number"?u=o.tabIndex:u=i?0:void 0,typeof o.role=="string"?d=o.role:d=i?"application":void 0),w.createElement(_D,_S({},o,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:nke,ref:e}),s)}),ike=t=>{var{children:e}=t,n=It(uN);if(!n)return null;var{width:r,height:i,y:s,x:o}=n;return w.createElement(_D,{width:r,height:i,x:o,y:s},e)},Y$=w.forwardRef((t,e)=>{var{children:n}=t,r=eke(t,JAe),i=Bi();return i?w.createElement(ike,null,w.createElement(X$,{isPanorama:!0},n)):w.createElement(rke,_S({ref:e},r),w.createElement(X$,{isPanorama:!1},n))});function ake(){var t=Er(),[e,n]=w.useState(null),r=It(_xe);return w.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),s=i.width/e.offsetWidth;cr(s)&&s!==r&&t(rxe(s))}},[e,t,r]),n}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 ske(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){oke(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 oke(t,e,n){return(e=lke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lke(t){var e=cke(t,"string");return typeof e=="symbol"?e:e+""}function cke(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 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)}var uke=()=>(zSe(),null);function wS(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var dke=w.forwardRef((t,e)=>{var n,r,i=w.useRef(null),[s,o]=w.useState({containerWidth:wS((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:wS((r=t.style)===null||r===void 0?void 0:r.height)}),l=w.useCallback((u,d)=>{o(f=>{var m=Math.round(u),g=Math.round(d);return f.containerWidth===m&&f.containerHeight===g?f:{containerWidth:m,containerHeight:g}})},[]),c=w.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();l(d,f);var m=x=>{var{width:y,height:b}=x[0].contentRect;l(y,b)},g=new ResizeObserver(m);g.observe(u),i.current=g}},[e,l]);return w.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[l]),w.createElement(w.Fragment,null,w.createElement(dN,{width:s.containerWidth,height:s.containerHeight}),w.createElement("div",Vf({ref:c},t)))}),hke=w.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,s]=w.useState({containerWidth:wS(n),containerHeight:wS(r)}),o=w.useCallback((c,u)=>{s(d=>{var f=Math.round(c),m=Math.round(u);return d.containerWidth===f&&d.containerHeight===m?d:{containerWidth:f,containerHeight:m}})},[]),l=w.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:u,height:d}=c.getBoundingClientRect();o(u,d)}},[e,o]);return w.createElement(w.Fragment,null,w.createElement(dN,{width:i.containerWidth,height:i.containerHeight}),w.createElement("div",Vf({ref:l},t)))}),fke=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return w.createElement(w.Fragment,null,w.createElement(dN,{width:n,height:r}),w.createElement("div",Vf({ref:e},t)))}),mke=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return uu(n)||uu(r)?w.createElement(hke,Vf({},t,{ref:e})):w.createElement(fke,Vf({},t,{ref:e}))});function pke(t){return t===!0?dke:mke}var gke=w.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:s,onContextMenu:o,onDoubleClick:l,onMouseDown:c,onMouseEnter:u,onMouseLeave:d,onMouseMove:f,onMouseUp:m,onTouchEnd:g,onTouchMove:x,onTouchStart:y,style:b,width:v,responsive:N,dispatchTouchEvents:S=!0}=t,T=w.useRef(null),E=Er(),[k,C]=w.useState(null),[D,A]=w.useState(null),R=ake(),F=BD(),O=F?.width>0?F.width:v,q=F?.height>0?F.height:i,j=w.useCallback(fe=>{R(fe),typeof e=="function"&&e(fe),C(fe),A(fe),fe!=null&&(T.current=fe)},[R,e,C,A]),G=w.useCallback(fe=>{E(SZ(fe)),E(go({handler:s,reactEvent:fe}))},[E,s]),Y=w.useCallback(fe=>{E(tP(fe)),E(go({handler:u,reactEvent:fe}))},[E,u]),K=w.useCallback(fe=>{E(eQ()),E(go({handler:d,reactEvent:fe}))},[E,d]),Z=w.useCallback(fe=>{E(tP(fe)),E(go({handler:f,reactEvent:fe}))},[E,f]),te=w.useCallback(()=>{E(AZ())},[E]),ne=w.useCallback(fe=>{E(CZ(fe.key))},[E]),z=w.useCallback(fe=>{E(go({handler:o,reactEvent:fe}))},[E,o]),W=w.useCallback(fe=>{E(go({handler:l,reactEvent:fe}))},[E,l]),se=w.useCallback(fe=>{E(go({handler:c,reactEvent:fe}))},[E,c]),ae=w.useCallback(fe=>{E(go({handler:m,reactEvent:fe}))},[E,m]),de=w.useCallback(fe=>{E(go({handler:y,reactEvent:fe}))},[E,y]),me=w.useCallback(fe=>{S&&E(jZ(fe)),E(go({handler:x,reactEvent:fe}))},[E,S,x]),xe=w.useCallback(fe=>{E(go({handler:g,reactEvent:fe}))},[E,g]),be=pke(N);return w.createElement(vQ.Provider,{value:k},w.createElement(CW.Provider,{value:D},w.createElement(be,{width:O??b?.width,height:q??b?.height,className:Vn("recharts-wrapper",r),style:ske({position:"relative",cursor:"default",width:O,height:q},b),onClick:G,onContextMenu:z,onDoubleClick:W,onFocus:te,onKeyDown:ne,onMouseDown:se,onMouseEnter:Y,onMouseLeave:K,onMouseMove:Z,onMouseUp:ae,onTouchEnd:xe,onTouchMove:me,onTouchStart:de,ref:j},w.createElement(uke,null),n)))}),xke=["width","height","responsive","children","className","style","compact","title","desc"];function bke(t,e){if(t==null)return{};var n,r,i=yke(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function yke(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 LZ=w.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:s,className:o,style:l,compact:c,title:u,desc:d}=t,f=bke(t,xke),m=Ja(f);return c?w.createElement(w.Fragment,null,w.createElement(dN,{width:n,height:r}),w.createElement(Y$,{otherAttributes:m,title:u,desc:d},s)):w.createElement(gke,{className:o,style:l,width:n,height:r,responsive:i??!1,onClick:t.onClick,onMouseLeave:t.onMouseLeave,onMouseEnter:t.onMouseEnter,onMouseMove:t.onMouseMove,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onContextMenu:t.onContextMenu,onDoubleClick:t.onDoubleClick,onTouchStart:t.onTouchStart,onTouchMove:t.onTouchMove,onTouchEnd:t.onTouchEnd},w.createElement(Y$,{otherAttributes:m,title:u,desc:d,ref:e},w.createElement(PTe,null,s)))});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 vke={top:5,right:5,bottom:5,left:5},_ke={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:vke,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},_O=w.forwardRef(function(e,n){var r,i=Xr(e.categoricalChartProps,_ke),{chartName:s,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:s,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return w.createElement(RZ,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:s},w.createElement(JQ,{chartData:u.data}),w.createElement(DZ,{layout:i.layout,margin:i.margin}),w.createElement(OZ,{baseValue:i.baseValue,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),w.createElement(LZ,nP({},i,{ref:n})))}),wke=["axis"],Ske=w.forwardRef((t,e)=>w.createElement(_O,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:wke,tooltipPayloadSearcher:jN,categoricalChartProps:t,ref:e})),Nke=["axis","item"],Mke=w.forwardRef((t,e)=>w.createElement(_O,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Nke,tooltipPayloadSearcher:jN,categoricalChartProps:t,ref:e}));function Eke(t){var e=Er();return w.useEffect(()=>{e(qAe(t))},[e,t]),null}var Tke=["layout"];function rP(){return rP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},rP.apply(null,arguments)}function Cke(t,e){if(t==null)return{};var n,r,i=Ake(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Ake(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 kke={top:5,right:5,bottom:5,left:5},IZ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:kke,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},jke=w.forwardRef(function(e,n){var r,i=Xr(e.categoricalChartProps,IZ),{layout:s}=i,o=Cke(i,Tke),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return w.createElement(RZ,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},w.createElement(JQ,{chartData:i.data}),w.createElement(DZ,{layout:s,margin:i.margin}),w.createElement(OZ,{baseValue:void 0,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),w.createElement(Eke,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),w.createElement(LZ,rP({},o,{ref:n})))});function Z$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function J$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Z$(Object(n),!0).forEach(function(r){Pke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Z$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Pke(t,e,n){return(e=Rke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Rke(t){var e=Dke(t,"string");return typeof e=="symbol"?e:e+""}function Dke(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Oke=["item"],Lke=J$(J$({},IZ),{},{layout:"centric",startAngle:0,endAngle:360}),Ike=w.forwardRef((t,e)=>{var n=Xr(t,Lke);return w.createElement(jke,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:Oke,tooltipPayloadSearcher:jN,categoricalChartProps:n,ref:e})}),Fke=["axis"],Uke=w.forwardRef((t,e)=>w.createElement(_O,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Fke,tooltipPayloadSearcher:jN,categoricalChartProps:t,ref:e}));const eH=[{value:"6h",label:"6h",hours:6},{value:"24h",label:"24h",hours:24},{value:"48h",label:"48h",hours:48},{value:"7d",label:"7d",hours:168}];function zke({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:s,initialMode:o="humidity",thresholds:l}){const{t:c}=Fg(),{mode:u}=lh(),[d,f]=w.useState("24h"),[m,g]=w.useState(o),x=u==="dark",{data:y}=ct({queryKey:["settings"],queryFn:he.getSettings}),b=y?.time_format||"system";w.useEffect(()=>{if(!t)return;const ae=de=>{de.key==="Escape"&&e()};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[t,e]);const v=eH.find(ae=>ae.value===d)?.hours||24,{data:N,isLoading:S,error:T}=ct({queryKey:["ams-history",n,i,v],queryFn:()=>he.getAMSHistory(n,i,v),enabled:t,refetchInterval:6e4});if(!t)return null;const E=N?.data.map(ae=>{const de=wi(ae.recorded_at)||new Date,me={hour:"2-digit",minute:"2-digit",...v>24?{day:"numeric",month:"short"}:{}};return{time:de.getTime(),humidity:ae.humidity,temperature:ae.temperature,timeLabel:de.toLocaleTimeString([],Hb(me,b))}})||[],k=l?.humidityGood||40,C=l?.humidityFair||60,D=l?.tempGood||30,A=l?.tempFair||35,R=E[E.length-1],F=R?.humidity,O=R?.temperature,q=ae=>{const de=ae.filter(Ne=>Ne!=null);if(de.length<4)return"stable";const me=de.slice(0,Math.floor(de.length/4)),xe=de.slice(-Math.floor(de.length/4)),be=me.reduce((Ne,re)=>Ne+re,0)/me.length,Ce=xe.reduce((Ne,re)=>Ne+re,0)/xe.length-be;return Math.abs(Ce)<2?"stable":Ce>0?"up":"down"},j=q(E.map(ae=>ae.humidity)),G=q(E.map(ae=>ae.temperature)),Y=({trend:ae})=>ae==="up"?a.jsx(Jj,{className:"w-4 h-4 text-red-400"}):ae==="down"?a.jsx(bW,{className:"w-4 h-4 text-green-400"}):a.jsx(Yj,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),K=ae=>ae==null?"#9ca3af":ae<=k?"#22a352":ae<=C?"#d4a017":"#c62828",Z=ae=>ae==null?"#9ca3af":ae<=D?"#22a352":ae<=A?"#d4a017":"#c62828",te=x?"#2d2d2d":"#ffffff",ne=x?"#1d1d1d":"#f3f4f6",z=x?"#3d3d3d":"#e5e7eb",W=x?"#ffffff":"#111827",se=x?"#9ca3af":"#4b5563";return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:a.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:te},onClick:ae=>ae.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:z},children:[a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold",style:{color:W},children:[s," ",c("common.history","History")]}),a.jsx("p",{className:"text-sm",style:{color:se},children:r})]}),a.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:se},children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:ne},children:[a.jsxs("button",{onClick:()=>g("humidity"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${m==="humidity"?"bg-blue-600 text-white":""}`,style:m!=="humidity"?{color:se}:void 0,children:[a.jsx(uD,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),a.jsxs("button",{onClick:()=>g("temperature"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${m==="temperature"?"bg-orange-600 text-white":""}`,style:m!=="temperature"?{color:se}:void 0,children:[a.jsx(W2,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),a.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:ne},children:eH.map(ae=>a.jsx("button",{onClick:()=>f(ae.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===ae.value?"bg-bambu-green text-white":""}`,style:d!==ae.value?{color:se}:void 0,children:ae.label},ae.value))})]}),a.jsx("div",{className:"grid grid-cols-4 gap-4",children:m==="humidity"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ne},children:[a.jsx("p",{className:"text-xs",style:{color:se},children:c("common.current","Current")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"text-2xl font-bold",style:{color:K(F)},children:F!=null?`${F}%`:"—"}),a.jsx(Y,{trend:j})]})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ne},children:[a.jsx("p",{className:"text-xs",style:{color:se},children:c("common.average","Average")}),a.jsx("p",{className:"text-2xl font-bold",style:{color:W},children:N?.avg_humidity!=null?`${N.avg_humidity}%`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ne},children:[a.jsx("p",{className:"text-xs",style:{color:se},children:c("common.min","Min")}),a.jsx("p",{className:"text-2xl font-bold text-green-500",children:N?.min_humidity!=null?`${N.min_humidity}%`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ne},children:[a.jsx("p",{className:"text-xs",style:{color:se},children:c("common.max","Max")}),a.jsx("p",{className:"text-2xl font-bold text-red-500",children:N?.max_humidity!=null?`${N.max_humidity}%`:"—"})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ne},children:[a.jsx("p",{className:"text-xs",style:{color:se},children:c("common.current","Current")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"text-2xl font-bold",style:{color:Z(O)},children:O!=null?`${O}°C`:"—"}),a.jsx(Y,{trend:G})]})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ne},children:[a.jsx("p",{className:"text-xs",style:{color:se},children:c("common.average","Average")}),a.jsx("p",{className:"text-2xl font-bold",style:{color:W},children:N?.avg_temperature!=null?`${N.avg_temperature}°C`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ne},children:[a.jsx("p",{className:"text-xs",style:{color:se},children:c("common.min","Min")}),a.jsx("p",{className:"text-2xl font-bold text-blue-500",children:N?.min_temperature!=null?`${N.min_temperature}°C`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ne},children:[a.jsx("p",{className:"text-xs",style:{color:se},children:c("common.max","Max")}),a.jsx("p",{className:"text-2xl font-bold text-red-500",children:N?.max_temperature!=null?`${N.max_temperature}°C`:"—"})]})]})}),a.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:ne},children:S?a.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:se},children:c("common.loading","Loading...")}):T?a.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):E.length===0?a.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:se},children:c("common.noData","No data available for this time range")}):a.jsx(K1,{width:"100%",height:300,children:a.jsxs(Ske,{data:E,children:[a.jsx(xS,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),a.jsx(yS,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:ae=>{const de=new Date(ae);return v>24?de.toLocaleDateString([],{day:"numeric",month:"short"}):de.toLocaleTimeString([],Hb({hour:"2-digit",minute:"2-digit"},b))},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),a.jsx(vS,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:m==="humidity"?[0,100]:["auto","auto"],tickFormatter:ae=>m==="humidity"?`${ae}%`:`${ae}°C`}),a.jsx(Y1,{contentStyle:{backgroundColor:x?"#2d2d2d":"#ffffff",border:`1px solid ${x?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:x?"#fff":"#000"},labelFormatter:ae=>new Date(ae).toLocaleString(void 0,Hb({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},b)),formatter:ae=>[m==="humidity"?`${ae??0}%`:`${ae??0}°C`,m==="humidity"?"Humidity":"Temperature"]}),a.jsx(qD,{}),m==="humidity"?a.jsxs(a.Fragment,{children:[a.jsx(kb,{y:k,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),a.jsx(kb,{y:C,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):a.jsxs(a.Fragment,{children:[a.jsx(kb,{y:D,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),a.jsx(kb,{y:A,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),a.jsx(fZ,{type:"monotone",dataKey:m,name:m==="humidity"?"Humidity":"Temperature",stroke:m==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),a.jsx("div",{className:"text-xs text-center",style:{color:se},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function xA({data:t,children:e,disabled:n,className:r="",spoolman:i,configureSlot:s}){const[o,l]=w.useState(!1),[c,u]=w.useState("top"),[d,f]=w.useState(!1),m=w.useRef(null),g=w.useRef(null),x=w.useRef(null),y=()=>{const k=t.trayUuid;k&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(k).then(()=>{f(!0),setTimeout(()=>f(!1),2e3)}).catch(()=>{b(k)}):b(k))},b=k=>{const C=document.createElement("textarea");C.value=k,C.style.position="fixed",C.style.opacity="0",document.body.appendChild(C),C.select();try{document.execCommand("copy"),f(!0),setTimeout(()=>f(!1),2e3)}catch{console.error("Failed to copy to clipboard")}document.body.removeChild(C)};w.useEffect(()=>{if(o&&m.current&&g.current){const k=m.current.getBoundingClientRect(),C=g.current.offsetHeight,D=k.top,A=window.innerHeight-k.bottom;D<C+12&&A>D?u("bottom"):u("top")}},[o]);const v=()=>{n||(x.current&&clearTimeout(x.current),x.current=setTimeout(()=>l(!0),80))},N=()=>{x.current&&clearTimeout(x.current),x.current=setTimeout(()=>l(!1),100)};w.useEffect(()=>()=>{x.current&&clearTimeout(x.current)},[]);const S=k=>k<=15?"#ef4444":k<=30?"#f97316":k<=50?"#eab308":"#22c55e",T=k=>{if(!k)return!1;const C=k.replace("#",""),D=parseInt(C.slice(0,2),16),A=parseInt(C.slice(2,4),16),R=parseInt(C.slice(4,6),16);return(.299*D+.587*A+.114*R)/255>.6},E=t.colorHex?`#${t.colorHex.replace("#","")}`:null;return a.jsxs("div",{ref:m,className:`relative ${r}`,onMouseEnter:v,onMouseLeave:N,children:[e,o&&a.jsxs("div",{ref:g,className:`
- absolute left-1/2 -translate-x-1/2 z-50
- ${c==="top"?"bottom-full mb-2":"top-full mt-2"}
- animate-in fade-in-0 zoom-in-95 duration-150
- `,style:{maxWidth:"calc(100vw - 24px)"},children:[a.jsxs("div",{className:`
- w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-lg shadow-xl overflow-hidden
- backdrop-blur-sm
- `,children:[a.jsxs("div",{className:"h-12 relative overflow-hidden",style:{backgroundColor:E||"#3d3d3d"},children:[a.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"}),a.jsx("div",{className:`
- absolute inset-0 flex items-center justify-center
- font-semibold text-sm tracking-wide
- ${T(E)?"text-black/80":"text-white/90"}
- `,children:t.colorName}),a.jsx("div",{className:`
- absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
- ${t.vendor==="Bambu Lab"?"bg-black/60 text-white":"bg-black/50 text-white/90"}
- `,children:t.vendor==="Bambu Lab"?"BBL":"GEN"})]}),a.jsxs("div",{className:"p-3 space-y-2.5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Profile"}),a.jsx("span",{className:"text-xs text-white font-semibold truncate max-w-[120px]",children:t.profile})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"K Factor"}),a.jsx("span",{className:"text-xs text-bambu-green font-mono font-bold",children:t.kFactor})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium flex items-center gap-1",children:[a.jsx(uD,{className:"w-3 h-3"}),"Fill"]}),a.jsx("span",{className:"text-xs text-white font-semibold",children:t.fillLevel!==null?`${t.fillLevel}%`:"—"})]}),a.jsx("div",{className:"h-1.5 bg-black/40 rounded-full overflow-hidden",children:t.fillLevel!==null?a.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${t.fillLevel}%`,backgroundColor:S(t.fillLevel)}}):a.jsx("div",{className:"h-full w-full bg-bambu-gray/30 rounded-full"})})]}),i?.enabled&&t.trayUuid&&a.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Spool ID"}),a.jsxs("button",{onClick:k=>{k.stopPropagation(),y()},className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",title:"Copy spool UUID",children:[a.jsxs("span",{className:"font-mono text-[10px] truncate max-w-[80px]",children:[t.trayUuid.slice(0,8),"..."]}),d?a.jsx(Ua,{className:"w-3 h-3 text-bambu-green"}):a.jsx(ll,{className:"w-3 h-3"})]})]}),i.onLinkSpool&&a.jsxs("button",{onClick:k=>{k.stopPropagation(),i.hasUnlinkedSpools!==!1&&i.onLinkSpool?.(t.trayUuid)},disabled:i.hasUnlinkedSpools===!1,className:`w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors ${i.hasUnlinkedSpools===!1?"bg-bambu-gray/10 text-bambu-gray cursor-not-allowed":"bg-bambu-green/20 hover:bg-bambu-green/30 text-bambu-green"}`,title:i.hasUnlinkedSpools===!1?"No unlinked spools available":"Link this spool to a Spoolman spool",children:[a.jsx(Ol,{className:"w-3.5 h-3.5"}),"Link to Spoolman"]})]}),s?.enabled&&a.jsx("div",{className:`${i?.enabled&&t.trayUuid?"":"pt-2 mt-2 border-t border-bambu-dark-tertiary"}`,children:a.jsxs("button",{onClick:k=>{k.stopPropagation(),s.onConfigure?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue",title:"Configure slot with filament profile and K value",children:[a.jsx(Gd,{className:"w-3.5 h-3.5"}),"Configure"]})})]})]}),a.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 w-0 h-0
- border-l-[6px] border-l-transparent
- border-r-[6px] border-r-transparent
- ${c==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
- `})]})]})}function tH({children:t,className:e="",configureSlot:n}){const[r,i]=w.useState(!1),s=w.useRef(null),o=()=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>i(!0),80)},l=()=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>i(!1),100)};return w.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]),a.jsxs("div",{className:`relative ${e}`,onMouseEnter:o,onMouseLeave:l,children:[t,r&&a.jsxs("div",{className:`
- absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-50
- animate-in fade-in-0 zoom-in-95 duration-150
- `,children:[a.jsxs("div",{className:`
- bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-md shadow-lg overflow-hidden
- `,children:[a.jsx("div",{className:"px-3 py-1.5 text-xs text-bambu-gray whitespace-nowrap",children:"Empty slot"}),n?.enabled&&a.jsx("div",{className:"px-2 pb-2",children:a.jsxs("button",{onClick:c=>{c.stopPropagation(),n.onConfigure?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue",title:"Configure slot with filament profile and K value",children:[a.jsx(Gd,{className:"w-3.5 h-3.5"}),"Configure"]})})]}),a.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 top-full w-0 h-0
- border-l-[5px] border-l-transparent
- border-r-[5px] border-r-transparent
- border-t-[5px] border-t-bambu-dark-tertiary
- `})]})]})}function Bke({isOpen:t,onClose:e,trayUuid:n,trayInfo:r}){const i=an(),[s,o]=w.useState(null),{data:l,isLoading:c}=ct({queryKey:["unlinked-spools"],queryFn:he.getUnlinkedSpools,enabled:t}),u=ht({mutationFn:f=>he.linkSpool(f,n),onSuccess:()=>{i.invalidateQueries({queryKey:["unlinked-spools"]}),i.invalidateQueries({queryKey:["spoolman-status"]}),e()}});if(!t)return null;const d=()=>{s&&u.mutate(s)};return a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),a.jsxs("div",{className:"relative w-full max-w-md mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ol,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Link to Spoolman"})]}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[r&&a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Linking AMS tray:"}),a.jsxs("div",{className:"flex items-center gap-2",children:[r.color&&a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.color}`}}),a.jsx("span",{className:"text-white font-medium",children:r.type}),a.jsxs("span",{className:"text-bambu-gray",children:["(",r.location,")"]})]})]}),a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Spool UUID:"}),a.jsx("code",{className:"text-xs text-bambu-green font-mono break-all",children:n})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Select a Spoolman spool to link:"}),c?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(ut,{className:"w-6 h-6 text-bambu-green animate-spin"})}):l&&l.length>0?a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-2",children:l.map(f=>a.jsx("button",{onClick:()=>o(f.id),className:`w-full p-3 rounded-lg border text-left transition-colors ${s===f.id?"bg-bambu-green/20 border-bambu-green":"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:a.jsxs("div",{className:"flex items-center gap-2",children:[f.filament_color_hex&&a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:`#${f.filament_color_hex}`}}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-white font-medium truncate",children:f.filament_name||"Unknown filament"}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[f.filament_material||"Unknown",f.remaining_weight!==null&&` - ${Math.round(f.remaining_weight)}g`,f.location&&` - ${f.location}`]})]}),s===f.id&&a.jsx(Ua,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]})},f.id))}):a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx("p",{children:"No unlinked spools found in Spoolman."}),a.jsx("p",{className:"text-xs mt-1",children:"All spools are already linked to AMS trays."})]})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Te,{variant:"secondary",onClick:e,children:"Cancel"}),a.jsx(Te,{onClick:d,disabled:!s||u.isPending,children:u.isPending?a.jsxs(a.Fragment,{children:[a.jsx(ut,{className:"w-4 h-4 animate-spin"}),"Linking..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Ol,{className:"w-4 h-4"}),"Link Spool"]})})]}),u.isError&&a.jsx("div",{className:"mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:u.error.message})]})]})}function $ke(t,e){if(t===255)return"External";let n,r=!1;t>=128&&t<=135?(n=t-128,r=!0):t>=0&&t<=3?(n=t,r=e===1):n=0,n=Math.max(0,Math.min(n,7));const i=String.fromCharCode(65+n);return r?`HT-${i}`:`AMS-${i}`}function nH(t){const e=t.includes("_")?t.split("_")[0]:t;return e.startsWith("GFS")?"GF"+e.slice(3):(e.startsWith("PFUS")||e.startsWith("PFSP"),e)}const Hke=["PLA","PETG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function rH(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of Hke){const s=new RegExp(`\\b${i}\\b`,"i");if(s.test(n)){const o=e.split(s),l=o[0]?.trim()||"",c=o[1]?.trim()||"";return{material:i,brand:l,variant:c}}}const r=e.split(/\s+/);return r.length>=2?{material:r[1],brand:r[0],variant:r.slice(2).join(" ")}:{material:e,brand:"",variant:""}}function bA(t){return!t.startsWith("GF")&&!t.startsWith("P1")}const Vke={white:"FFFFFF",black:"000000",red:"FF0000",green:"00FF00",blue:"0000FF",yellow:"FFFF00",cyan:"00FFFF",magenta:"FF00FF",orange:"FFA500",purple:"800080",pink:"FFC0CB",brown:"8B4513",gray:"808080",grey:"808080","jade white":"FFFEF2",ivory:"FFFFF0",beige:"F5F5DC",cream:"FFFDD0",silver:"C0C0C0",gold:"FFD700",bronze:"CD7F32",copper:"B87333",navy:"000080",teal:"008080",olive:"808000",maroon:"800000",coral:"FF7F50",salmon:"FA8072",lime:"32CD32",mint:"98FF98","forest green":"228B22","sky blue":"87CEEB","royal blue":"4169E1",turquoise:"40E0D0",lavender:"E6E6FA",violet:"EE82EE",plum:"DDA0DD",tan:"D2B48C",chocolate:"D2691E",charcoal:"36454F",slate:"708090",transparent:"000000",natural:"F5F5DC",wood:"DEB887"},Gke=[{name:"White",hex:"FFFFFF"},{name:"Black",hex:"000000"},{name:"Red",hex:"FF0000"},{name:"Blue",hex:"0000FF"},{name:"Green",hex:"00AA00"},{name:"Yellow",hex:"FFFF00"},{name:"Orange",hex:"FFA500"},{name:"Gray",hex:"808080"}],qke=[{name:"Cyan",hex:"00FFFF"},{name:"Magenta",hex:"FF00FF"},{name:"Purple",hex:"800080"},{name:"Pink",hex:"FFC0CB"},{name:"Brown",hex:"8B4513"},{name:"Beige",hex:"F5F5DC"},{name:"Navy",hex:"000080"},{name:"Teal",hex:"008080"},{name:"Lime",hex:"32CD32"},{name:"Gold",hex:"FFD700"},{name:"Silver",hex:"C0C0C0"},{name:"Maroon",hex:"800000"},{name:"Olive",hex:"808000"},{name:"Coral",hex:"FF7F50"},{name:"Salmon",hex:"FA8072"},{name:"Turquoise",hex:"40E0D0"},{name:"Violet",hex:"EE82EE"},{name:"Indigo",hex:"4B0082"},{name:"Chocolate",hex:"D2691E"},{name:"Tan",hex:"D2B48C"},{name:"Slate",hex:"708090"},{name:"Charcoal",hex:"36454F"},{name:"Ivory",hex:"FFFFF0"},{name:"Cream",hex:"FFFDD0"}];function Wke(t){const e=t.toLowerCase().trim();return Vke[e]||null}function Kke({isOpen:t,onClose:e,printerId:n,slotInfo:r,nozzleDiameter:i="0.4",onSuccess:s}){const[o,l]=w.useState(""),[c,u]=w.useState(null),[d,f]=w.useState(""),[m,g]=w.useState(""),[x,y]=w.useState(""),[b,v]=w.useState(!1),[N,S]=w.useState(!1),{data:T,isLoading:E}=ct({queryKey:["cloudSettings"],queryFn:()=>he.getCloudSettings(),enabled:t}),{data:k,isLoading:C}=ct({queryKey:["kprofiles",n,i],queryFn:()=>he.getKProfiles(n,i),enabled:t&&!!n}),D=ht({mutationFn:async()=>{if(!o)throw new Error("No filament preset selected");const Z=T?.filament.find(fe=>fe.setting_id===o);if(!Z)throw new Error("Selected preset not found");const te=rH(Z.name),ne=c?.slot_id??-1,z=d||r.trayColor?.slice(0,6)||"FFFFFF",W=Z.name.replace(/@.+$/,"").trim();let se=nH(o);if(!o.startsWith("GFS"))try{const fe=await he.getCloudSettingDetail(o);fe.filament_id?se=fe.filament_id:fe.base_id&&(se=nH(fe.base_id),console.log(`Derived tray_info_idx from base_id: ${fe.base_id} -> ${se}`))}catch(fe){console.warn("Failed to fetch preset detail for filament_id:",fe)}let ae=190,de=230;const me=te.material.toUpperCase();me.includes("PLA")?(ae=190,de=230):me.includes("PETG")?(ae=220,de=260):me.includes("ABS")||me.includes("ASA")?(ae=240,de=280):me.includes("TPU")?(ae=200,de=240):me.includes("PC")?(ae=260,de=300):(me.includes("PA")||me.includes("NYLON"))&&(ae=250,de=290);const xe=c?.k_value?parseFloat(c.k_value):0,be=await he.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:se,tray_type:te.material||"PLA",tray_sub_brands:W,tray_color:z+"FF",nozzle_temp_min:ae,nozzle_temp_max:de,cali_idx:ne,nozzle_diameter:i,setting_id:o,kprofile_filament_id:c?.filament_id,kprofile_setting_id:c?.setting_id||void 0,k_value:xe});try{await he.saveSlotPreset(n,r.amsId,r.trayId,o,W)}catch(fe){console.warn("Failed to save slot preset mapping:",fe)}return be},onSuccess:()=>{v(!0),s?.(),setTimeout(()=>{v(!1),e()},1500)}}),A=ht({mutationFn:async()=>he.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{v(!0),s?.(),setTimeout(()=>{v(!1),e()},1500)}}),R=w.useMemo(()=>{if(!T?.filament)return[];const Z=x.toLowerCase();return T.filament.filter(te=>Z?te.name.toLowerCase().includes(Z):!0).sort((te,ne)=>{const z=bA(te.setting_id),W=bA(ne.setting_id);return z&&!W?-1:!z&&W?1:te.name.localeCompare(ne.name)})},[T?.filament,x]),F=w.useMemo(()=>{if(!o||!T?.filament)return null;const Z=T.filament.find(z=>z.setting_id===o);if(!Z)return null;let te=Z.name.replace(/@.+$/,"").trim();te.startsWith("# ")&&(te=te.slice(2).trim());const ne=rH(te);return{fullName:te,material:ne.material,brand:ne.brand}},[o,T?.filament]),O=F?.fullName||"",q=w.useMemo(()=>{if(!k?.profiles||!F)return[];const{fullName:Z,material:te,brand:ne}=F,z=Z.toUpperCase(),W=te.toUpperCase(),se=ne.toUpperCase();if(!W||W.length<2)return[];const ae=k.profiles.filter(me=>{const xe=me.name.toUpperCase();if(se)return!(!xe.includes(se)||!xe.includes(W));if(xe.includes(z)||xe.includes(W))return!0;const fe={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[W]||[];for(const Ce of fe)if(xe.includes(Ce))return!0;return!1}),de=new Map;for(const me of ae){const xe=`${me.name}|${me.k_value}`,be=de.get(xe);be?me.extruder_id===1&&be.extruder_id===0&&de.set(xe,me):de.set(xe,me)}return Array.from(de.values())},[k?.profiles,F]);w.useEffect(()=>{if(t&&T?.filament){if(r.trayInfoIdx){const Z=T.filament.find(te=>te.setting_id===r.trayInfoIdx);Z&&l(Z.setting_id)}}else t||(l(""),u(null),f(""),g(""),y(""),v(!1))},[t,T?.filament,r.trayInfoIdx]),w.useEffect(()=>{q.length>0?u(q[0]):u(null)},[o,q]);const j=w.useCallback(Z=>{Z.key==="Escape"&&e()},[e]);if(w.useEffect(()=>{if(t)return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[t,j]),!t)return null;const G=E||C,Y=o&&!D.isPending,K=d||r.trayColor?.slice(0,6)||"FFFFFF";return a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),a.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Gd,{className:"w-5 h-5 text-bambu-blue"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Configure AMS Slot"})]}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4 max-h-[60vh] overflow-y-auto",children:[b&&a.jsx("div",{className:"absolute inset-0 bg-bambu-dark-secondary/95 z-10 flex items-center justify-center rounded-xl",children:a.jsxs("div",{className:"text-center space-y-3",children:[a.jsx(O2,{className:"w-16 h-16 text-bambu-green mx-auto"}),a.jsx("p",{className:"text-lg font-semibold text-white",children:"Slot Configured!"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Settings sent to printer"})]})}),a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Configuring slot:"}),a.jsxs("div",{className:"flex items-center gap-2",children:[r.trayColor&&a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.trayColor.slice(0,6)}`}}),a.jsxs("span",{className:"text-white font-medium",children:[$ke(r.amsId,r.trayCount)," Slot ",r.trayId+1]}),r.traySubBrands&&a.jsxs("span",{className:"text-bambu-gray",children:["(",r.traySubBrands,")"]})]})]}),G?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(ut,{className:"w-6 h-6 text-bambu-green animate-spin"})}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["Filament Profile ",a.jsx("span",{className:"text-red-400",children:"*"})]}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"text",placeholder:"Search presets...",value:x,onChange:Z=>y(Z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none mb-2"}),a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:R.length===0?a.jsx("p",{className:"text-center py-4 text-bambu-gray",children:T?.filament?.length===0?"No cloud presets. Login to Bambu Cloud to sync.":"No matching presets found."}):R.map(Z=>a.jsx("button",{onClick:()=>l(Z.setting_id),className:`w-full p-2 rounded-lg border text-left transition-colors ${o===Z.setting_id?"bg-bambu-green/20 border-bambu-green":"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-white text-sm truncate",children:Z.name}),bA(Z.setting_id)&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue",children:"Custom"})]})},Z.setting_id))})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["K Profile (Pressure Advance)",O&&a.jsxs("span",{className:"ml-2 text-xs text-bambu-blue",children:["Filtering for: ",O]})]}),q.length>0?a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:c?.name||"",onChange:Z=>{const te=q.find(ne=>ne.name===Z.target.value);u(te||null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none pr-10",children:[a.jsx("option",{value:"",children:"No K profile (use default 0.020)"}),q.map(Z=>a.jsxs("option",{value:Z.name,children:[Z.name," (K=",Z.k_value,")"]},`${Z.name}-${Z.extruder_id}`))]}),a.jsx(Br,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}):o?a.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:"No matching K profiles found. Default K=0.020 will be used."}):a.jsx("span",{className:"inline-block text-xs px-2 py-1 rounded bg-amber-500/20 text-amber-400 border border-amber-500/30",children:"Select a filament profile first"}),c&&a.jsxs("p",{className:"text-xs text-bambu-green mt-1",children:["K=",c.k_value," from printer calibration"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Custom Color (optional)"}),a.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[Gke.map(Z=>a.jsx("button",{onClick:()=>{f(Z.hex),g(Z.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===Z.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${Z.hex}`},title:Z.name},Z.hex)),a.jsx("button",{onClick:()=>S(!N),className:"w-7 h-7 rounded-md border-2 border-white/20 hover:border-white/40 flex items-center justify-center text-white/60 hover:text-white/80 transition-all text-xs",title:N?"Show less colors":"Show more colors",children:N?"−":"+"})]}),N&&a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:qke.map(Z=>a.jsx("button",{onClick:()=>{f(Z.hex),g(Z.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===Z.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${Z.hex}`},title:Z.name},Z.hex))}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg border-2 border-white/20 flex-shrink-0",style:{backgroundColor:`#${K}`}}),a.jsx("input",{type:"text",placeholder:"Color name or hex (e.g., brown, FF8800)",value:m,onChange:Z=>{const te=Z.target.value;g(te);const ne=Wke(te);if(ne)f(ne);else{const z=te.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();z.length===6?f(z):z.length===3&&f(z.split("").map(W=>W+W).join(""))}},className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none text-sm"}),d&&a.jsx("button",{onClick:()=>{f(""),g("")},className:"px-2 py-1 text-xs text-bambu-gray hover:text-white bg-bambu-dark-tertiary rounded",title:"Clear custom color",children:"Clear"})]}),d&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5",children:["Hex: #",d]})]})]})]}),a.jsxs("div",{className:"flex justify-between p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Te,{variant:"secondary",onClick:()=>A.mutate(),disabled:A.isPending||D.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:A.isPending?a.jsxs(a.Fragment,{children:[a.jsx(ut,{className:"w-4 h-4 animate-spin"}),"Resetting..."]}):a.jsxs(a.Fragment,{children:[a.jsx(rm,{className:"w-4 h-4"}),"Reset Slot"]})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Te,{variant:"secondary",onClick:e,children:"Cancel"}),a.jsx(Te,{onClick:()=>D.mutate(),disabled:!Y,children:D.isPending?a.jsxs(a.Fragment,{children:[a.jsx(ut,{className:"w-4 h-4 animate-spin"}),"Configuring..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Gd,{className:"w-4 h-4"}),"Configure Slot"]})})]})]}),(D.isError||A.isError)&&a.jsx("div",{className:"mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:D.error?.message||A.error?.message})]})]})}function Xke({on:t,className:e="w-5 h-5"}){const n=t?"#facc15":"none",r=t?"#78350f":"currentColor",i=t?1:0;return a.jsxs("svg",{viewBox:"0 0 32 32",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[a.jsxs("g",{stroke:r,opacity:i,children:[a.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),a.jsx("line",{x1:"6.1",y1:"6.1",x2:"8.9",y2:"8.9"}),a.jsx("line",{x1:"25.9",y1:"6.1",x2:"23.1",y2:"8.9"}),a.jsx("line",{x1:"2",y1:"16",x2:"6",y2:"16"}),a.jsx("line",{x1:"30",y1:"16",x2:"26",y2:"16"})]}),a.jsx("path",{d:"M12 24v-2.3c0-.9-.4-1.7-1-2.3C9.2 17.6 8 15.4 8 13c0-4.4 3.6-8 8-8s8 3.6 8 8c0 2.4-1.2 4.6-3 6.4-.6.6-1 1.4-1 2.3V24",fill:n,stroke:r}),a.jsx("path",{d:"M12 24h8",stroke:r}),a.jsx("path",{d:"M12 27h8",stroke:r}),a.jsx("path",{d:"M13 30h6",stroke:r})]})}const iH=({className:t})=>a.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[a.jsx("rect",{x:"2",y:"15",width:"5",height:"5",rx:"0.5"}),a.jsx("rect",{x:"9.5",y:"15",width:"5",height:"5",rx:"0.5",fill:"currentColor",opacity:"0.3"}),a.jsx("rect",{x:"17",y:"15",width:"5",height:"5",rx:"0.5"}),a.jsx("path",{d:"M4 12 C4 6, 14 6, 14 12"}),a.jsx("polyline",{points:"12,10 14,12 12,14"})]}),aH={"A00-W1":"Jade White","A00-P0":"Beige","A00-D2":"Light Gray","A00-Y0":"Yellow","A00-Y2":"Sunflower Yellow","A00-A1":"Pumpkin Orange","A00-A0":"Orange","A00-Y4":"Gold","A00-G3":"Bright Green","A00-G1":"Bambu Green","A00-G2":"Mistletoe Green","A00-R3":"Hot Pink","A00-P6":"Magenta","A00-R0":"Red","A00-R2":"Maroon Red","A00-P5":"Purple","A00-P2":"Indigo Purple","A00-B5":"Turquoise","A00-B8":"Cyan","A00-B3":"Cobalt Blue","A00-N0":"Brown","A00-N1":"Cocoa Brown","A00-Y3":"Bronze","A00-D0":"Gray","A00-D1":"Silver","A00-B1":"Blue Grey","A00-D3":"Dark Gray","A00-K0":"Black","A00-M3":"Pink Citrus","A00-M6":"Dusk Glare","A00-M0":"Arctic Whisper","A00-M1":"Solar Breeze","A00-M5":"Blueberry Bubblegum","A00-M4":"Mint Lime","A00-M2":"Ocean to Meadow","A00-M7":"Cotton Candy Cloud","A18-K0":"Black","A18-D0":"Gray","A18-W0":"White","A18-R0":"Red","A18-Y0":"Yellow","A18-B0":"Cyan","A18-B1":"Blue","A18-P0":"Matte Beige","A01-W2":"Ivory White","A01-W3":"Bone White","A01-Y2":"Lemon Yellow","A01-A2":"Mandarin Orange","A01-P3":"Sakura Pink","A01-P4":"Lilac Purple","A01-R3":"Plum","A01-R1":"Scarlet Red","A01-R4":"Dark Red","A01-G0":"Apple Green","A01-G1":"Grass Green","A01-G7":"Dark Green","A01-B4":"Ice Blue","A01-B0":"Sky Blue","A01-B3":"Marine Blue","A01-B6":"Dark Blue","A01-Y3":"Desert Tan","A01-N1":"Latte Brown","A01-N3":"Caramel","A01-R2":"Terracotta","A01-N2":"Dark Brown","A01-N0":"Dark Chocolate","A01-D3":"Ash Gray","A01-D0":"Nardo Gray","A01-K1":"Charcoal","A12-G0":"Green","A12-R0":"Pink","A12-A0":"Orange","A12-Y0":"Yellow","A12-B0":"Blue","A07-R5":"Red Granite","A07-D4":"White Marble","A11-W0":"White","A11-K0":"Black","A08-G3":"Alpine Green Sparkle","A08-D5":"Slate Gray Sparkle","A08-B7":"Royal Purple Sparkle","A08-R2":"Crimson Red Sparkle","A08-K2":"Onyx Black Sparkle","A08-Y1":"Classic Gold Sparkle","A02-B2":"Cobalt Blue Metallic","A02-G2":"Oxide Green Metallic","A02-Y1":"Iridium Gold Metallic","A02-D2":"Iron Gray Metallic","A17-B1":"Blue","A17-A0":"Orange","A17-P0":"Purple","A06-Y1":"Gold","A06-D0":"Titan Gray","A06-D1":"Silver","A06-W0":"White","A06-R0":"Candy Red","A06-G0":"Candy Green","A06-G1":"Mint","A06-B1":"Blue","A06-B0":"Baby Blue","A06-P0":"Purple","A06-R1":"Rose Gold","A06-R2":"Pink","A06-Y0":"Champagne","A05-M8":"Dawn Radiance","A05-M4":"Aurora Purple","A05-M1":"South Beach","A05-T3":"Neon City","A05-T2":"Midnight Blaze","A05-T1":"Gilded Rose","A05-T4":"Blue Hawaii","A05-T5":"Velvet Eclipse","A15-B0":"Purple","A15-G0":"Green","A15-G1":"Nebulae","A15-R0":"Brown","A16-K0":"Black Walnut","A16-R0":"Rosewood","A16-N0":"Clay Brown","A16-G0":"Classic Birch","A16-W0":"White Oak","A16-Y0":"Ochre Yellow","A50-D6":"Lava Gray","A50-K0":"Black","A50-B6":"Royal Blue","A10-W0":"White","A10-D0":"Gray","A09-B5":"Lavender Blue","A09-B4":"Light Blue","A09-A0":"Orange","A09-D1":"Silver","A09-R3":"Vermilion Red","A09-Y0":"Yellow","G02-K0":"Black","G02-W0":"White","G02-R0":"Red","G02-D0":"Gray","G02-D1":"Dark Gray","G02-Y1":"Cream","G02-Y0":"Yellow","G02-A0":"Orange","G02-N1":"Peanut Brown","G02-G1":"Lime Green","G02-G0":"Green","G02-G2":"Forest Green","G02-B1":"Lake Blue","G02-B0":"Blue","G01-G1":"Translucent Teal","G01-B0":"Translucent Light Blue","G01-C0":"Clear","G01-D0":"Translucent Gray","G01-G0":"Translucent Olive","G01-N0":"Translucent Brown","G01-A0":"Translucent Orange","G01-P1":"Translucent Pink","G01-P0":"Translucent Purple","G50-P7":"Violet Purple","G50-K0":"Black","B00-D1":"Silver","B00-K0":"Black","B00-W0":"White","B00-G6":"Bambu Green","B00-G7":"Olive","B00-Y1":"Tangerine Yellow","B00-A0":"Orange","B00-R0":"Red","B00-B4":"Azure","B00-B0":"Blue","B00-B6":"Navy Blue","B50-A0":"Orange","B50-K0":"Black","B01-W0":"White","B01-K0":"Black","B01-D0":"Gray","B02-W0":"White","C00-C1":"Transparent","C00-C0":"Clear Black","C00-K0":"Black","C00-W0":"White","C01-K0":"Black","U02-B0":"Blue","U02-D0":"Gray","U02-K0":"Black","N04-K0":"Black","N08-K0":"Black","S02-W0":"Nature","S02-W1":"White","S05-C0":"Black","S06-W0":"White","S03-G1":"Green","S04-Y0":"Clear"},Yke={W0:"White",W1:"Jade White",W2:"Ivory White",W3:"Bone White",Y0:"Yellow",Y1:"Gold",Y2:"Sunflower Yellow",Y3:"Bronze",Y4:"Gold",A0:"Orange",A1:"Pumpkin Orange",A2:"Mandarin Orange",R0:"Red",R1:"Scarlet Red",R2:"Maroon Red",R3:"Hot Pink",R4:"Dark Red",R5:"Red Granite",P0:"Beige",P1:"Pink",P2:"Indigo Purple",P3:"Sakura Pink",P4:"Lilac Purple",P5:"Purple",P6:"Magenta",P7:"Violet Purple",B0:"Blue",B1:"Blue Grey",B2:"Cobalt Blue",B3:"Cobalt Blue",B4:"Ice Blue",B5:"Turquoise",B6:"Navy Blue",B7:"Royal Purple",B8:"Cyan",G0:"Green",G1:"Grass Green",G2:"Mistletoe Green",G3:"Bright Green",G6:"Bambu Green",G7:"Dark Green",N0:"Brown",N1:"Peanut Brown",N2:"Dark Brown",N3:"Caramel",D0:"Gray",D1:"Silver",D2:"Light Gray",D3:"Dark Gray",D4:"White Marble",D5:"Slate Gray",D6:"Lava Gray",K0:"Black",K1:"Charcoal",K2:"Onyx Black",C0:"Clear Black",C1:"Transparent",M0:"Arctic Whisper",M1:"Solar Breeze",M2:"Ocean to Meadow",M3:"Pink Citrus",M4:"Aurora Purple",M5:"Blueberry Bubblegum",M6:"Dusk Glare",M7:"Cotton Candy Cloud",M8:"Dawn Radiance",T1:"Gilded Rose",T2:"Midnight Blaze",T3:"Neon City",T4:"Blue Hawaii",T5:"Velvet Eclipse"};function yA(t){if(!t)return null;if(aH[t])return aH[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return Yke[n]||null}function vA(t){if(!t||t.length<6)return"Unknown";const e=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16),i=Math.max(e,n,r)/255,s=Math.min(e,n,r)/255,o=(i+s)/2;let l=0,c=0;if(i!==s){const u=i-s;c=o>.5?u/(2-i-s):u/(i+s);const d=e/255,f=n/255,m=r/255;i===d?l=((f-m)/u+(f<m?6:0))/6:i===f?l=((m-d)/u+2)/6:l=((d-f)/u+4)/6}return l=l*360,o<.15?"Black":o>.85?"White":c<.15?o<.4?"Dark Gray":o>.6?"Light Gray":"Gray":l>=15&&l<45&&o<.45||l>=45&&l<70&&o<.4?"Brown":l<15||l>=345?"Red":l<45?"Orange":l<70?"Yellow":l<150?"Green":l<200?"Cyan":l<260?"Blue":l<290?"Purple":l<345?"Pink":"Unknown"}function _A(t){return(t??.02).toFixed(3)}function sH({side:t}){const{mode:e}=lh(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return a.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 text-[10px] font-bold rounded",style:{backgroundColor:n,color:"#00ae42"},children:t})}function oH({className:t}){return a.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:a.jsx("path",{d:"M17.8131 0.00538C18.4463 -0.15091 20.3648 3.14642 20.8264 3.84781C25.4187 10.816 35.3089 26.9368 35.9383 34.8694C37.4182 53.5822 11.882 61.3357 2.53721 45.3789C-1.73471 38.0791 0.016 32.2049 3.178 25.0232C6.99221 16.3662 12.6411 7.90372 17.8131 0.00538ZM18.3738 7.24807L17.5881 7.48441C14.4452 12.9431 10.917 18.2341 8.19369 23.9368C4.6808 31.29 1.18317 38.5479 7.69403 45.5657C17.3058 55.9228 34.9847 46.8808 31.4604 32.8681C29.2558 24.0969 22.4207 15.2913 18.3776 7.24807H18.3738Z",fill:"#C3C2C1"})})}function Qke({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M17.3165 0.0038C17.932 -0.14959 19.7971 3.08645 20.2458 3.77481C24.7103 10.6135 34.3251 26.4346 34.937 34.2198C36.3757 52.5848 11.5505 60.1942 2.46584 44.534C-1.68714 37.3735 0.0148 31.6085 3.08879 24.5603C6.79681 16.0605 12.2884 7.75907 17.3165 0.0038ZM17.8615 7.11561L17.0977 7.34755C14.0423 12.7048 10.6124 17.8974 7.96483 23.4941C4.54975 30.7107 1.14949 37.8337 7.47908 44.721C16.8233 54.8856 34.01 46.0117 30.5838 32.2595C28.4405 23.6512 21.7957 15.0093 17.8652 7.11561H17.8615Z",fill:"#C3C2C1"}),a.jsx("path",{d:"M5.03547 30.112C9.64453 30.4936 11.632 35.7985 16.4154 35.791C19.6339 35.7873 20.2161 33.2283 22.3853 31.6197C31.6776 24.7286 33.5835 37.4894 27.9881 44.4254C18.1878 56.5653 -1.16063 44.6013 5.03917 30.1158L5.03547 30.112Z",fill:"#1F8FEB"})]})}function Zke({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M17.9625 4.48059L4.77216 26.3154L2.08228 40.2175L10.0224 50.8414H23.1594L33.3246 42.1693V30.2455L17.9625 4.48059Z",fill:"#1F8FEB"}),a.jsx("path",{d:"M17.7948 0.00538C18.4273 -0.15091 20.3438 3.14642 20.8048 3.84781C25.3921 10.816 35.2715 26.9368 35.9001 34.8694C37.3784 53.5822 11.8702 61.3357 2.53562 45.3789C-1.73163 38.0829 0.0134 32.2087 3.1757 25.027C6.98574 16.3662 12.6284 7.90372 17.7948 0.00538ZM18.3549 7.24807L17.57 7.48441C14.4306 12.9431 10.9063 18.2341 8.1859 23.9368C4.67686 31.29 1.18305 38.5479 7.68679 45.5657C17.2881 55.9228 34.9476 46.8808 31.4271 32.8681C29.2249 24.0969 22.3974 15.2913 18.3587 7.24807H18.3549Z",fill:"#C3C2C1"})]})}function Jke({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"}),a.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function eje({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),a.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function tje({className:t}){return a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),a.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function wA({className:t,color:e,isHeating:n}){const i={"text-orange-400":"#fb923c","text-blue-400":"#60a5fa","text-green-400":"#4ade80"}[e]||"#888",s=n?{filter:`drop-shadow(0 0 4px ${i}) drop-shadow(0 0 8px ${i})`}:{};return n?a.jsxs("svg",{className:t,style:s,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:i,rx:"0.5"}),a.jsx("circle",{cx:"6",cy:"15",r:"2",fill:i}),a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"})]}):a.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"}),a.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:i,strokeWidth:"1",fill:"none"})]})}function lH({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r,compact:i}){const s=typeof t=="string"?parseInt(t,10):t,o=typeof e=="number"?e:40,l=typeof n=="number"?n:60;let c,u;isNaN(s)?(c="#C3C2C1",u="Unknown"):s<=o?(c="#22a352",u="Good"):s<=l?(c="#d4a017",u="Fair"):(c="#c62828",u="Bad");let d;return isNaN(s)||s<=o?d=oH:s<=l?d=Qke:d=Zke,a.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Humidity: ${s}% - ${u}${r?" (click for history)":""}`,children:[a.jsx(d,{className:i?"w-2.5 h-3":"w-3 h-4"}),a.jsxs("span",{className:`font-medium tabular-nums ${i?"text-[10px]":"text-xs"}`,style:{color:c},children:[s,"%"]})]})}function cH({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r,compact:i}){const s=typeof e=="number"?e:28,o=typeof n=="number"?n:35;let l,c,u;return t<=s?(l="#22a352",c="Good",u=Jke):t<=o?(l="#d4a017",c="Fair",u=eje):(l="#c62828",c="Bad",u=tje),a.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Temperature: ${t}°C - ${c}${r?" (click for history)":""}`,children:[a.jsx(u,{className:i?"w-2.5 h-3":"w-3 h-4"}),a.jsxs("span",{className:`tabular-nums text-right ${i?"text-[10px] w-8":"w-12"}`,style:{color:l},children:[t,"°C"]})]})}function Ku(t,e){const n=typeof t=="string"?parseInt(t,10):t,r=isNaN(n)?0:n,i=e===1,s=r>=128?r-128:r,o=String.fromCharCode(65+s);return i?`HT-${o}`:`AMS-${o}`}function uH(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function nje(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function rje(t,e="system"){const n=new Date,r=new Date(n.getTime()+t*60*1e3),i=new Date;i.setHours(0,0,0,0);const s=new Date(r);s.setHours(0,0,0,0);const o={hour:"2-digit",minute:"2-digit"};e==="12h"?o.hour12=!0:e==="24h"&&(o.hour12=!1);const l=r.toLocaleTimeString([],o),c=Math.floor((s.getTime()-i.getTime())/(1e3*60*60*24));return c===0?l:c===1?`Tomorrow ${l}`:r.toLocaleDateString([],{weekday:"short"})+" "+l}function ije(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 aje(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 SA(t){return t?!!(t.tray_info_idx&&t.tray_info_idx.startsWith("GF")||t.tray_uuid&&t.tray_uuid!=="00000000000000000000000000000000"||t.tag_uid&&t.tag_uid!=="0000000000000000"):!1}function sje({url:t,printName:e}){const[n,r]=w.useState(!1),[i,s]=w.useState(!1),[o,l]=w.useState(!1);return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:`w-20 h-20 flex-shrink-0 rounded-lg overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${t&&n?"cursor-pointer":""}`,onClick:()=>t&&n&&l(!0),children:t&&!i?a.jsxs(a.Fragment,{children:[a.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>r(!0),onError:()=>s(!0)}),!n&&a.jsx(Hs,{className:"w-8 h-8 text-bambu-gray"})]}):a.jsx(Hs,{className:"w-8 h-8 text-bambu-gray"})}),o&&t&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>l(!1),children:a.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[a.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&a.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function oje({printers:t}){const e=an(),n=w.useMemo(()=>{let i=0,s=0,o=0,l=0;return t?.forEach(c=>{const u=e.getQueryData(["printerStatus",c.id]);u===void 0?l++:u.connected?u.state==="RUNNING"?i++:s++:o++}),{printing:i,idle:s,offline:o,loading:l,total:t?.length||0}},[t,e]),[,r]=w.useState(0);return w.useEffect(()=>{let i=!1;const s=e.getQueryCache().subscribe(()=>{i||(i=!0,requestAnimationFrame(()=>{r(o=>o+1),i=!1}))});return()=>s()},[e]),t?.length?a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[n.printing>0&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white font-medium",children:n.printing})," printing"]})]}),n.idle>0&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white font-medium",children:n.idle})," idle"]})]}),n.offline>0&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white font-medium",children:n.offline})," offline"]})]})]}):null}function dH(t,e){if(e)return e;switch(t){case"RUNNING":return"Printing";case"PAUSE":return"Paused";case"FINISH":return"Finished";case"FAILED":return"Failed";case"IDLE":return"Idle";default:return t?t.charAt(0)+t.slice(1).toLowerCase():"Idle"}}function hH({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:s,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,timeFormat:c="system",cameraViewMode:u="window",onOpenEmbeddedCamera:d,checkPrinterFirmware:f=!0}){const m=an(),g=fl(),{showToast:x}=Gn(),[y,b]=w.useState(!1),[v,N]=w.useState(!1),[S,T]=w.useState(!0),[E,k]=w.useState(!1),[C,D]=w.useState(!1),[A,R]=w.useState(!1),[F,O]=w.useState(!1),[q,j]=w.useState(!1),[G,Y]=w.useState(!1),[K,Z]=w.useState(!1),[te,ne]=w.useState(!1),[z,W]=w.useState(!1),[se,ae]=w.useState(!1),[de,me]=w.useState(null),[xe,be]=w.useState(null),[fe,Ce]=w.useState(null),[Ne,re]=w.useState(!1),[He,H]=w.useState(null),[B,X]=w.useState(!1),[U,Q]=w.useState(!1),[le,Pe]=w.useState(null),[Oe,je]=w.useState(!1),[$,I]=w.useState(!1),{data:V}=ct({queryKey:["printerStatus",t.id],queryFn:()=>he.getPrinterStatus(t.id),refetchInterval:3e4}),{data:ie}=ct({queryKey:["firmwareUpdate",t.id],queryFn:()=>V1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3,enabled:f}),Se=w.useMemo(()=>{const Be=new Set;if(V?.ams)for(const Et of V.ams)for(const Wt of Et.tray||[])Wt.tray_info_idx&&Be.add(Wt.tray_info_idx);return V?.vt_tray?.tray_info_idx&&Be.add(V.vt_tray.tray_info_idx),Array.from(Be)},[V?.ams,V?.vt_tray]),{data:ye}=ct({queryKey:["filamentInfo",Se],queryFn:()=>he.getFilamentInfo(Se),enabled:Se.length>0,staleTime:300*1e3}),{data:$e}=ct({queryKey:["slotPresets",t.id],queryFn:()=>he.getSlotPresets(t.id),staleTime:120*1e3}),[Ue,Ge]=w.useState(null);w.useEffect(()=>{V?.wifi_signal!=null&&Ge(V.wifi_signal)},[V?.wifi_signal]);const We=V?.wifi_signal??Ue,Ye=w.useRef(void 0);w.useEffect(()=>{V?.connected!==void 0&&(Ye.current=V.connected)},[V?.connected]);const oe=V?.connected??Ye.current,ve=w.useRef({});w.useEffect(()=>{V?.ams_extruder_map&&Object.keys(V.ams_extruder_map).length>0&&(ve.current=V.ams_extruder_map)},[V?.ams_extruder_map]);const Le=V?.ams_extruder_map&&Object.keys(V.ams_extruder_map).length>0?V.ams_extruder_map:ve.current,Ke=w.useRef([]);w.useEffect(()=>{V?.ams&&V.ams.length>0&&(Ke.current=V.ams)},[V?.ams]);const lt=V?.ams&&V.ams.length>0?V.ams:Ke.current,_e=w.useRef(255),ce=V?.tray_now;ce!==void 0&&ce!==255&&(_e.current=ce);const ee=ce===void 0||ce===255?_e.current:ce,{data:ke}=ct({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>he.getSmartPlugByPrinter(t.id)}),{data:De}=ct({queryKey:["scriptPlugsByPrinter",t.id],queryFn:()=>he.getScriptPlugsByPrinter(t.id)}),{data:Ae}=ct({queryKey:["smartPlugStatus",ke?.id],queryFn:()=>ke?he.getSmartPlugStatus(ke.id):null,enabled:!!ke,refetchInterval:1e4}),{data:Je}=ct({queryKey:["queue",t.id,"pending"],queryFn:()=>he.getQueue(t.id,"pending")}),gt=Je?.length||0,{data:At}=ct({queryKey:["archives",t.id,"last"],queryFn:()=>he.getArchives(t.id,1,0),enabled:V?.connected&&V?.state!=="RUNNING"}),jt=At?.[0],ln=e&&oe===!1,Lt=ht({mutationFn:Be=>he.deletePrinter(t.id,Be.deleteArchives),onSuccess:()=>{m.invalidateQueries({queryKey:["printers"]}),m.invalidateQueries({queryKey:["archives"]}),m.invalidateQueries({queryKey:["maintenanceOverview"]})}}),Cn=ht({mutationFn:()=>he.connectPrinter(t.id),onSuccess:()=>{m.invalidateQueries({queryKey:["printerStatus",t.id]})}}),en=ht({mutationFn:Be=>ke?he.controlSmartPlug(ke.id,Be):Promise.reject("No plug"),onSuccess:()=>{m.invalidateQueries({queryKey:["smartPlugStatus",ke?.id]})}}),er=ht({mutationFn:Be=>ke?he.updateSmartPlug(ke.id,{auto_off:Be}):Promise.reject("No plug"),onSuccess:()=>{m.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),m.invalidateQueries({queryKey:["smart-plugs"]})}}),ur=ht({mutationFn:Be=>he.controlSmartPlug(Be,"on"),onSuccess:()=>{x("Script triggered")},onError:Be=>x(Be.message||"Failed to run script","error")}),Un=ht({mutationFn:()=>he.stopPrint(t.id),onSuccess:()=>{x("Print stopped"),m.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:Be=>x(Be.message||"Failed to stop print","error")}),wr=ht({mutationFn:()=>he.pausePrint(t.id),onSuccess:()=>{x("Print paused"),m.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:Be=>x(Be.message||"Failed to pause print","error")}),jr=ht({mutationFn:()=>he.resumePrint(t.id),onSuccess:()=>{x("Print resumed"),m.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:Be=>x(Be.message||"Failed to resume print","error")}),Zn=ht({mutationFn:Be=>he.setChamberLight(t.id,Be),onMutate:async Be=>{await m.cancelQueries({queryKey:["printerStatus",t.id]});const Et=m.getQueryData(["printerStatus",t.id]);return m.setQueryData(["printerStatus",t.id],Wt=>({...Wt,chamber_light:Be})),{previousStatus:Et}},onSuccess:(Be,Et)=>{x(`Chamber light ${Et?"on":"off"}`)},onError:(Be,Et,Wt)=>{Wt?.previousStatus&&m.setQueryData(["printerStatus",t.id],Wt.previousStatus),x(Be.message||"Failed to control chamber light","error")}}),Xt=ht({mutationFn:Be=>he.updatePrinter(t.id,{plate_detection_enabled:Be}),onSuccess:()=>{m.invalidateQueries({queryKey:["printers"]}),x(Xt.variables?"Plate check enabled":"Plate check disabled")},onError:Be=>x(Be.message||"Failed to update setting","error")}),zn=(V?.state==="RUNNING"||V?.state==="PAUSE"||V?.state==="PAUSED")&&(V?.printable_objects_count??0)>=2,{data:Wn,refetch:Zr}=ct({queryKey:["printableObjects",t.id],queryFn:()=>he.getPrintableObjects(t.id),enabled:se||zn,refetchInterval:se?5e3:zn?3e4:!1}),Ee=ht({mutationFn:Be=>he.skipObjects(t.id,Be),onSuccess:Be=>{x(Be.message||"Objects skipped"),Zr()},onError:Be=>x(Be.message||"Failed to skip objects","error")}),[Xe,it]=w.useState(null),st=w.useRef(!1),et=w.useRef(null),Ct=w.useRef(!1),ue=ht({mutationFn:({amsId:Be,slotId:Et})=>he.refreshAmsSlot(t.id,Be,Et),onMutate:({amsId:Be,slotId:Et})=>{et.current&&clearTimeout(et.current),st.current=!1,Ct.current=!1,it({amsId:Be,slotId:Et}),setTimeout(()=>{Ct.current=!0},2e3),et.current=setTimeout(()=>{it(null)},3e4)},onSuccess:Be=>{x(Be.message||"RFID re-read initiated")},onError:Be=>{x(Be.message||"Failed to re-read RFID","error"),et.current&&clearTimeout(et.current),it(null)}}),[ge,Fe]=w.useState(null),[Ie,Me]=w.useState(null),mt=async()=>{try{const Be=await he.getPlateReferences(t.id);Fe(Be)}catch{}},wt=()=>{Xt.mutate(!t.plate_detection_enabled)},kt=async()=>{X(!0),H(null);const Be=V?.chamber_light===!1;I(Be),Be&&(await he.setChamberLight(t.id,!0),await new Promise(Et=>setTimeout(Et,2500)));try{const Et=await he.checkPlateEmpty(t.id,{includeDebugImage:!0});H(Et),mt()}catch(Et){x(Et instanceof Error?Et.message:"Failed to check plate","error"),Be&&(await he.setChamberLight(t.id,!1),I(!1))}finally{X(!1)}},pt=w.useCallback(async()=>{H(null),$&&(await he.setChamberLight(t.id,!1),I(!1))},[$,t.id]),zt=async Be=>{Q(!0);try{const Et=await he.calibratePlateDetection(t.id,{label:Be});if(Et.success){x(Et.message||"Calibration saved!","success"),mt();const Wt=await he.checkPlateEmpty(t.id,{includeDebugImage:!0});H(Wt)}else x(Et.message||"Calibration failed","error")}catch(Et){x(Et instanceof Error?Et.message:"Calibration failed","error")}finally{Q(!1)}},Pt=async(Be,Et)=>{try{await he.updatePlateReferenceLabel(t.id,Be,Et),Me(null),mt()}catch(Wt){x(Wt instanceof Error?Wt.message:"Failed to update label","error")}},Mt=async Be=>{try{await he.deletePlateReference(t.id,Be),x("Reference deleted","success"),mt();const Et=await he.checkPlateEmpty(t.id,{includeDebugImage:!0});H(Et)}catch(Et){x(Et instanceof Error?Et.message:"Failed to delete reference","error")}},nn=async()=>{if(le){je(!0);try{await he.updatePrinter(t.id,{plate_detection_roi:le}),x("Detection area saved","success"),Pe(null);const Be=await he.checkPlateEmpty(t.id,{includeDebugImage:!0});H(Be)}catch(Be){x(Be instanceof Error?Be.message:"Failed to save detection area","error")}finally{je(!1)}}};w.useEffect(()=>{const Be=Et=>{Et.key==="Escape"&&He&&pt()};return window.addEventListener("keydown",Be),()=>window.removeEventListener("keydown",Be)},[He,pt]);const Bt=w.useRef(null);w.useEffect(()=>{if(!Xe)return;const Be=V?.ams_status_main??0;return Be!==0&&(st.current=!0,Bt.current&&(clearTimeout(Bt.current),Bt.current=null)),st.current&&Be===0&&(Ct.current?(et.current&&clearTimeout(et.current),it(null)):Bt.current||(Bt.current=setTimeout(()=>{et.current&&clearTimeout(et.current),it(null)},2e3))),()=>{Bt.current&&clearTimeout(Bt.current)}},[V?.ams_status_main,Xe]);const[tn,cn]=w.useState(null);if(ln)return null;const we=()=>{switch(i){case 1:return"w-10 h-10";case 2:return"w-14 h-14";case 3:return"w-16 h-16";case 4:return"w-20 h-20";default:return"w-14 h-14"}},bt=()=>{switch(i){case 1:return"text-base truncate";case 2:return"text-lg";case 3:return"text-xl";case 4:return"text-2xl";default:return"text-lg"}},$t=()=>{switch(i){case 1:return"mb-2";case 2:return"mb-4";case 3:return"mb-5";case 4:return"mb-6";default:return"mb-4"}};return a.jsxs(_t,{className:"relative",children:[a.jsxs(St,{className:i>=3?"p-5":"",children:[a.jsxs("div",{className:$t(),children:[a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("img",{src:ije(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${we()}`}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:`font-semibold text-white ${bt()}`,children:t.name}),r==="compact"&&a.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${V?.connected?"bg-status-ok":"bg-status-error"}`,title:V?.connected?"Connected":"Offline"})]}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&V?.nozzles&&V.nozzles[0]?.nozzle_diameter&&a.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:V.nozzles[0].nozzle_type||"Nozzle",children:["• ",V.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&a.jsxs("span",{className:"ml-2 text-bambu-gray",children:[a.jsx(qn,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),a.jsxs("div",{className:"relative flex-shrink-0",children:[a.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>b(!y),children:a.jsx(Pd,{className:"w-4 h-4"})}),y&&a.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10",children:[a.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{k(!0),b(!1)},children:[a.jsx(Oi,{className:"w-4 h-4"}),"Edit"]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{Cn.mutate(),b(!1)},children:[a.jsx(vr,{className:"w-4 h-4"}),"Reconnect"]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{R(!0),b(!1)},children:[a.jsx(xW,{className:"w-4 h-4"}),"MQTT Debug"]}),a.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:()=>{N(!0),b(!1)},children:[a.jsx(on,{className:"w-4 h-4"}),"Delete"]})]})]})]}),r==="expanded"&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[a.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${V?.connected?"bg-status-ok/20 text-status-ok":"bg-status-error/20 text-status-error"}`,children:[V?.connected?a.jsx($g,{className:"w-3 h-3"}):a.jsx(pD,{className:"w-3 h-3"}),V?.connected?"Connected":"Offline"]}),V?.connected&&We!=null&&a.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${We>=-50||We>=-60?"bg-status-ok/20 text-status-ok":We>=-70?"bg-status-warning/20 text-status-warning":We>=-80?"bg-orange-500/20 text-orange-600":"bg-status-error/20 text-status-error"}`,title:`WiFi: ${We} dBm - ${aje(We).label}`,children:[a.jsx(Nhe,{className:"w-3 h-3"}),We,"dBm"]}),V?.connected&&(()=>{const Be=V.hms_errors?Vfe(V.hms_errors):[];return a.jsxs("button",{onClick:()=>Y(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${Be.length>0?Be.some(Et=>Et.severity<=2)?"bg-status-error/20 text-status-error":"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,title:"Click to view HMS errors",children:[a.jsx(xn,{className:"w-3 h-3"}),Be.length>0?Be.length:"OK"]})})(),n&&a.jsxs("button",{onClick:()=>g("/maintenance"),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${n.due_count>0?"bg-status-error/20 text-status-error":n.warning_count>0?"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,title:n.due_count>0||n.warning_count>0?`${n.due_count>0?`${n.due_count} maintenance due`:""}${n.due_count>0&&n.warning_count>0?", ":""}${n.warning_count>0?`${n.warning_count} due soon`:""} - Click to view`:"All maintenance up to date - Click to view",children:[a.jsx(Wd,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),gt>0&&a.jsxs("button",{onClick:()=>g("/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:`${gt} print${gt>1?"s":""} in queue`,children:[a.jsx(ul,{className:"w-3 h-3"}),gt]}),ie?.update_available&&a.jsxs("button",{onClick:()=>re(!0),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-orange-500/20 text-orange-400 hover:opacity-80 transition-opacity",title:`Firmware update available: ${ie.current_version} → ${ie.latest_version}`,children:[a.jsx(Gr,{className:"w-3 h-3"}),"Update"]})]})]}),v&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsx(_t,{className:"w-full max-w-md mx-4",children:a.jsxs(St,{children:[a.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[a.jsx("div",{className:"p-2 rounded-full bg-red-500/20",children:a.jsx(xn,{className:"w-5 h-5 text-red-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Printer"}),a.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:['Are you sure you want to delete "',t.name,'"? This will remove all connection settings.']})]})]}),a.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:a.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:S,onChange:Be=>T(Be.target.checked),className:"mt-0.5 w-4 h-4 rounded border-bambu-gray bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-white",children:"Delete print archives"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:S?"All print history for this printer will be permanently deleted.":"Print history will be kept but no longer associated with this printer."})]})]})}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Te,{variant:"secondary",onClick:()=>{N(!1),T(!0)},children:"Cancel"}),a.jsx(Te,{variant:"danger",onClick:()=>{Lt.mutate({deleteArchives:S}),N(!1),T(!0)},children:"Delete"})]})]})})}),V?.connected&&a.jsxs(a.Fragment,{children:[r==="compact"?a.jsx("div",{className:"mt-2",children:V.state==="RUNNING"?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:a.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${V.progress||0}%`}})}),a.jsxs("span",{className:"text-xs text-white",children:[Math.round(V.progress||0),"%"]})]}):a.jsx("p",{className:"text-xs text-bambu-gray",children:dH(V.state,V.stg_cur_name)})}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg relative",children:[a.jsxs("button",{onClick:()=>ae(!0),disabled:!(V.state==="RUNNING"||V.state==="PAUSE"||V.state==="PAUSED")||(V.printable_objects_count??0)<2,className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(V.state==="RUNNING"||V.state==="PAUSE"||V.state==="PAUSED")&&(V.printable_objects_count??0)>=2?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:V.state==="RUNNING"||V.state==="PAUSE"||V.state==="PAUSED"?(V.printable_objects_count??0)>=2?"Skip objects":"Skip objects (requires 2+ objects)":"Skip objects (only while printing)",children:[a.jsx(iH,{className:"w-4 h-4"}),Wn&&Wn.skipped_count>0&&a.jsx("span",{className:"absolute -top-1 -right-1 min-w-[16px] h-4 px-1 flex items-center justify-center text-[10px] font-bold bg-red-500 text-white rounded-full",children:Wn.skipped_count})]}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(sje,{url:V.state==="RUNNING"?V.cover_url:null,printName:V.state==="RUNNING"&&(V.subtask_name||V.current_print)||void 0}),a.jsx("div",{className:"flex-1 min-w-0",children:V.current_print&&V.state==="RUNNING"?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:V.stg_cur_name||"Printing"}),a.jsx("p",{className:"text-white text-sm mb-2 truncate",children:V.subtask_name||V.current_print}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:a.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${V.progress||0}%`}})}),a.jsxs("span",{className:"text-white",children:[Math.round(V.progress||0),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[V.remaining_time!=null&&V.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(qn,{className:"w-3 h-3"}),nje(V.remaining_time*60)]}),a.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",rje(V.remaining_time,c)]})]}),V.layer_num!=null&&V.total_layers!=null&&V.total_layers>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(ul,{className:"w-3 h-3"}),V.layer_num,"/",V.total_layers]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),a.jsx("p",{className:"text-white text-sm mb-2",children:dH(V.state,V.stg_cur_name)}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:a.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),a.jsx("span",{className:"text-bambu-gray",children:"—"})]}),jt?a.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:jt.print_name||jt.filename,children:["Last: ",jt.print_name||jt.filename,jt.completed_at&&a.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",cg(jt.completed_at,{month:"short",day:"numeric"})]})]}):a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})]}),V.state!=="RUNNING"&&a.jsx(Kfe,{printerId:t.id})]}),V.temperatures&&r==="expanded"&&(()=>{const Be=V.temperatures.nozzle_heating||V.temperatures.nozzle_2_heating||!1,Et=V.temperatures.bed_heating||!1,Wt=V.temperatures.chamber_heating||!1,dt=t.nozzle_count===2||V.temperatures.nozzle_2!==void 0,Kt=V.active_extruder===1?"L":"R";return a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[a.jsx(wA,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-orange-400",isHeating:Be}),V.temperatures.nozzle_2!==void 0?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-[9px] text-bambu-gray",children:"L / R"}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(V.temperatures.nozzle||0),"° / ",Math.round(V.temperatures.nozzle_2||0),"°"]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Nozzle"}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(V.temperatures.nozzle||0),"°C"]})]})]}),a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[a.jsx(wA,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-blue-400",isHeating:Et}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Bed"}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(V.temperatures.bed||0),"°C"]})]}),V.temperatures.chamber!==void 0&&a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[a.jsx(wA,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-green-400",isHeating:Wt}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Chamber"}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(V.temperatures.chamber||0),"°C"]})]}),dt&&a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg",title:`Active: ${Kt==="L"?"Left":"Right"} nozzle`,children:[a.jsx("p",{className:`text-[11px] font-bold ${Kt==="L"?"text-amber-400":"text-gray-500"}`,children:"L"}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Nozzle"}),a.jsx("p",{className:`text-[11px] font-bold ${Kt==="R"?"text-amber-400":"text-gray-500"}`,children:"R"})]})]})})(),r==="expanded"&&(()=>{const Be=V.state==="RUNNING",Et=V.state==="PAUSED"||V.state==="PAUSE",Wt=Be||Et,dt=Un.isPending||wr.isPending||jr.isPending,Kt=V.cooling_fan_speed,sn=V.big_fan1_speed,En=V.big_fan2_speed;return a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Controls"}),a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Kt&&Kt>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:"Part Cooling Fan",children:[a.jsx(sW,{className:`w-3.5 h-3.5 ${Kt&&Kt>0?"text-cyan-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${Kt&&Kt>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[Kt??0,"%"]})]}),a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${sn&&sn>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:"Auxiliary Fan",children:[a.jsx(yW,{className:`w-3.5 h-3.5 ${sn&&sn>0?"text-blue-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${sn&&sn>0?"text-blue-400":"text-bambu-gray/50"}`,children:[sn??0,"%"]})]}),a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${En&&En>0?"bg-green-500/10":"bg-bambu-dark"}`,title:"Chamber Fan",children:[a.jsx(ace,{className:`w-3.5 h-3.5 ${En&&En>0?"text-green-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${En&&En>0?"text-green-400":"text-bambu-gray/50"}`,children:[En??0,"%"]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:()=>Z(!0),disabled:!Wt||dt,className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${Wt?"bg-red-500/20 text-red-400 hover:bg-red-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
- `,title:"Stop print",children:[a.jsx(Oo,{className:"w-3 h-3"}),"Stop"]}),a.jsxs("button",{onClick:()=>Et?W(!0):ne(!0),disabled:!Wt||dt,className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${Wt?Et?"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30":"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
- `,title:Et?"Resume print":"Pause print",children:[Et?a.jsx(vs,{className:"w-3 h-3"}):a.jsx(hD,{className:"w-3 h-3"}),Et?"Resume":"Pause"]})]})]})]})})(),lt&<.length>0&&r==="expanded"&&(()=>{const Be=lt.filter(dt=>dt.tray.length>1),Et=lt.filter(dt=>dt.tray.length===1),Wt=t.nozzle_count===2||V?.temperatures?.nozzle_2!==void 0;return a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Filaments"}),a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),a.jsxs("div",{className:"space-y-3",children:[Be.length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-3",children:Be.map(dt=>{const Kt=Le[String(dt.id)],sn=dt.id>=128?dt.id-128:dt.id,En=Kt!==void 0?Kt:sn,On=En===1,Tr=En===0;return a.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"text-[10px] text-white font-medium",children:Ku(dt.id,dt.tray.length)}),Wt&&(On||Tr)&&a.jsx(sH,{side:On?"L":"R"})]}),(dt.humidity!=null||dt.temp!=null)&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[dt.humidity!=null&&a.jsx(lH,{humidity:dt.humidity,goodThreshold:s?.humidityGood,fairThreshold:s?.humidityFair,onClick:()=>me({amsId:dt.id,amsLabel:Ku(dt.id,dt.tray.length),mode:"humidity"}),compact:!0}),dt.temp!=null&&a.jsx(cH,{temp:dt.temp,goodThreshold:s?.tempGood,fairThreshold:s?.tempFair,onClick:()=>me({amsId:dt.id,amsLabel:Ku(dt.id,dt.tray.length),mode:"temperature"}),compact:!0})]})]}),a.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(Gt=>{const hn=dt.tray[Gt]||dt.tray.find(ua=>ua.id===Gt),ki=hn?.tray_type&&hn.remain>=0,tc=!hn?.tray_type,xh=dt.id*4+Gt,bh=ee===xh,cx=hn?.tray_info_idx?ye?.[hn.tray_info_idx]:null,nc=$e?.[xh],qi=hn?.tray_type?{vendor:SA(hn)?"Bambu Lab":"Generic",profile:cx?.name||nc?.preset_name||hn.tray_sub_brands||hn.tray_type,colorName:yA(hn.tray_id_name)||vA(hn.tray_color),colorHex:hn.tray_color||null,kFactor:_A(hn.k),fillLevel:ki?hn.remain:null,trayUuid:hn.tray_uuid||null}:null,ca=Xe?.amsId===dt.id&&Xe?.slotId===Gt,rc=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${tc?"opacity-50":""} ${bh?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[a.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:hn?.tray_color?`#${hn.tray_color}`:hn?.tray_type?"#333":"transparent",borderColor:tc?"#666":"rgba(255,255,255,0.1)",borderStyle:tc?"dashed":"solid"}}),a.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:hn?.tray_type||"—"}),a.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:ki&&hn?a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${hn.remain}%`,backgroundColor:uH(hn.remain)}}):hn?.tray_type?a.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return a.jsxs("div",{className:"relative group",children:[ca&&a.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:a.jsx(vr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),V?.state!=="RUNNING"&&a.jsx("button",{onClick:ua=>{ua.stopPropagation(),cn(tn?.amsId===dt.id&&tn?.slotId===Gt?null:{amsId:dt.id,slotId:Gt})},className:"absolute -top-1 -right-1 w-4 h-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:bg-bambu-dark-tertiary",title:"Slot options",children:a.jsx(Pd,{className:"w-2.5 h-2.5 text-bambu-gray"})}),V?.state!=="RUNNING"&&tn?.amsId===dt.id&&tn?.slotId===Gt&&a.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:a.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-xs text-white hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:ua=>{ua.stopPropagation(),ue.mutate({amsId:dt.id,slotId:Gt}),cn(null)},disabled:ca,children:[a.jsx(vr,{className:`w-3 h-3 ${ca?"animate-spin":""}`}),"Re-read RFID"]})}),qi?a.jsx(xA,{data:qi,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&qi.trayUuid?ua=>{be({trayUuid:ua,trayInfo:{type:qi.profile,color:qi.colorHex||"",location:`${Ku(dt.id,dt.tray.length)} Slot ${Gt+1}`}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>Ce({amsId:dt.id,trayId:Gt,trayCount:dt.tray.length,trayType:hn?.tray_type||void 0,trayColor:hn?.tray_color||void 0,traySubBrands:hn?.tray_sub_brands||void 0,trayInfoIdx:hn?.tray_info_idx||void 0})},children:rc}):a.jsx(tH,{configureSlot:{enabled:!0,onConfigure:()=>Ce({amsId:dt.id,trayId:Gt,trayCount:dt.tray.length})},children:rc})]},Gt)})})]},dt.id)})}),(Et.length>0||V.vt_tray&&V.vt_tray.tray_type)&&a.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[Et.map(dt=>{const Kt=Le[String(dt.id)],sn=dt.id>=128?dt.id-128:dt.id,En=Kt!==void 0?Kt:sn,On=En===1,Tr=En===0,Gt=dt.tray[0],hn=Gt?.tray_type&&Gt.remain>=0,ki=!Gt?.tray_type,tc=dt.id*4+(Gt?.id??0),xh=ee===tc,bh=Gt?.tray_info_idx?ye?.[Gt.tray_info_idx]:null,cx=$e?.[tc],nc=Gt?.tray_type?{vendor:SA(Gt)?"Bambu Lab":"Generic",profile:bh?.name||cx?.preset_name||Gt.tray_sub_brands||Gt.tray_type,colorName:yA(Gt.tray_id_name)||vA(Gt.tray_color),colorHex:Gt.tray_color||null,kFactor:_A(Gt.k),fillLevel:hn?Gt.remain:null,trayUuid:Gt.tray_uuid||null}:null,qi=Gt?.id??0,ca=Xe?.amsId===dt.id&&Xe?.slotId===qi,rc=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${ki?"opacity-50":""} ${xh?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[a.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:Gt?.tray_color?`#${Gt.tray_color}`:Gt?.tray_type?"#333":"transparent",borderColor:ki?"#666":"rgba(255,255,255,0.1)",borderStyle:ki?"dashed":"solid"}}),a.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:Gt?.tray_type||"—"}),a.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:hn?a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Gt.remain}%`,backgroundColor:uH(Gt.remain)}}):Gt?.tray_type?a.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return a.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[a.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[a.jsx("span",{className:"text-[10px] text-white font-medium",children:Ku(dt.id,dt.tray.length)}),Wt&&(On||Tr)&&a.jsx(sH,{side:On?"L":"R"})]}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsxs("div",{className:"relative group flex-1",children:[ca&&a.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:a.jsx(vr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),V?.state!=="RUNNING"&&a.jsx("button",{onClick:ua=>{ua.stopPropagation(),cn(tn?.amsId===dt.id&&tn?.slotId===qi?null:{amsId:dt.id,slotId:qi})},className:"absolute -top-1 -right-1 w-4 h-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:bg-bambu-dark-tertiary",title:"Slot options",children:a.jsx(Pd,{className:"w-2.5 h-2.5 text-bambu-gray"})}),V?.state!=="RUNNING"&&tn?.amsId===dt.id&&tn?.slotId===qi&&a.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:a.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-xs text-white hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:ua=>{ua.stopPropagation(),ue.mutate({amsId:dt.id,slotId:qi}),cn(null)},disabled:ca,children:[a.jsx(vr,{className:`w-3 h-3 ${ca?"animate-spin":""}`}),"Re-read RFID"]})}),nc?a.jsx(xA,{data:nc,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&nc.trayUuid?ua=>{be({trayUuid:ua,trayInfo:{type:nc.profile,color:nc.colorHex||"",location:Ku(dt.id,dt.tray.length)}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>Ce({amsId:dt.id,trayId:qi,trayCount:dt.tray.length,trayType:Gt?.tray_type||void 0,trayColor:Gt?.tray_color||void 0,traySubBrands:Gt?.tray_sub_brands||void 0,trayInfoIdx:Gt?.tray_info_idx||void 0})},children:rc}):a.jsx(tH,{configureSlot:{enabled:!0,onConfigure:()=>Ce({amsId:dt.id,trayId:qi,trayCount:dt.tray.length})},children:rc})]}),(dt.humidity!=null||dt.temp!=null)&&a.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[dt.temp!=null&&a.jsx(cH,{temp:dt.temp,goodThreshold:s?.tempGood,fairThreshold:s?.tempFair,onClick:()=>me({amsId:dt.id,amsLabel:Ku(dt.id,dt.tray.length),mode:"temperature"}),compact:!0}),dt.humidity!=null&&a.jsx(lH,{humidity:dt.humidity,goodThreshold:s?.humidityGood,fairThreshold:s?.humidityFair,onClick:()=>me({amsId:dt.id,amsLabel:Ku(dt.id,dt.tray.length),mode:"humidity"}),compact:!0})]})]})]},dt.id)}),V.vt_tray&&V.vt_tray.tray_type&&(()=>{const dt=V.vt_tray,Kt=ee===254,sn=dt.tray_info_idx?ye?.[dt.tray_info_idx]:null,En=$e?.[1020],On={vendor:SA(dt)?"Bambu Lab":"Generic",profile:sn?.name||En?.preset_name||dt.tray_sub_brands||dt.tray_type||"Unknown",colorName:yA(dt.tray_id_name)||vA(dt.tray_color),colorHex:dt.tray_color||null,kFactor:_A(dt.k),fillLevel:null,trayUuid:dt.tray_uuid||null},Tr=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${Kt?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[a.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:dt.tray_color?`#${dt.tray_color}`:"#333",borderColor:Kt?"var(--accent)":"rgba(255,255,255,0.1)"}}),a.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:dt.tray_type||"Spool"}),a.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"})})]});return a.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[a.jsx("div",{className:"flex items-center gap-1 mb-2",children:a.jsx("span",{className:"text-[10px] text-white font-medium",children:"External"})}),a.jsx(xA,{data:On,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&On.trayUuid?Gt=>{be({trayUuid:Gt,trayInfo:{type:On.profile,color:On.colorHex||"",location:"External Spool"}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>Ce({amsId:255,trayId:0,trayCount:1,trayType:dt.tray_type||void 0,trayColor:dt.tray_color||void 0,traySubBrands:dt.tray_sub_brands||void 0,trayInfoIdx:dt.tray_info_idx||void 0})},children:Tr})]})})()]})]})]})})()]}),ke&&r==="expanded"&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx(Kd,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"text-sm text-white truncate",children:ke.name}),Ae&&a.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${Ae.state==="ON"?"bg-bambu-green/20 text-bambu-green":Ae.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[Ae.state||"?",Ae.state==="ON"&&Ae.energy?.power!=null&&a.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",Ae.energy.power,"W"]})]})]}),a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("button",{onClick:()=>O(!0),disabled:en.isPending||Ae?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${Ae?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(yu,{className:"w-3 h-3"}),"On"]}),a.jsxs("button",{onClick:()=>j(!0),disabled:en.isPending||Ae?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${Ae?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[a.jsx(q2,{className:"w-3 h-3"}),"Off"]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx("span",{className:`text-xs hidden sm:inline ${ke.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:ke.auto_off_executed?"Auto-off done":"Auto-off"}),a.jsx("button",{onClick:()=>er.mutate(!ke.auto_off),disabled:er.isPending||ke.auto_off_executed,title:ke.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 ${ke.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":ke.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:a.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${ke.auto_off||ke.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]}),De&&De.length>0&&a.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-bambu-dark-tertiary/50",children:[a.jsx(vs,{className:"w-3.5 h-3.5 text-blue-400 flex-shrink-0"}),a.jsx("span",{className:"text-xs text-bambu-gray",children:"Scripts:"}),a.jsx("div",{className:"flex flex-wrap gap-1",children:De.map(Be=>a.jsxs("button",{onClick:()=>ur.mutate(Be.id),disabled:ur.isPending,title:`Run ${Be.ha_entity_id}`,className:"px-2 py-0.5 text-xs bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 rounded transition-colors flex items-center gap-1",children:[a.jsx(vs,{className:"w-2.5 h-2.5"}),Be.name]},Be.id))})]})]}),r==="expanded"&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[a.jsxs("div",{className:"text-xs text-bambu-gray",children:[a.jsx("p",{children:t.ip_address}),a.jsx("p",{className:"truncate",children:t.serial_number})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>Zn.mutate(!V?.chamber_light),disabled:!V?.connected||Zn.isPending,title:V?.chamber_light?"Turn off chamber light":"Turn on chamber light",className:V?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30 border-yellow-500/30":"",children:a.jsx(Xke,{on:V?.chamber_light??!1,className:"w-4 h-4"})}),a.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>{if(u==="embedded"&&d)d(t.id,t.name);else{const Be=localStorage.getItem("cameraWindowState"),Et=Be?JSON.parse(Be):{width:640,height:400},Wt=[`width=${Et.width}`,`height=${Et.height}`,Et.left!==void 0?`left=${Et.left}`:"",Et.top!==void 0?`top=${Et.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,Wt)}},disabled:!V?.connected,title:u==="embedded"?"Open camera overlay":"Open camera in new window",children:a.jsx(gD,{className:"w-4 h-4"})}),a.jsxs("div",{className:`inline-flex rounded-md ${t.plate_detection_enabled?"ring-1 ring-green-500":""}`,children:[a.jsx(Te,{variant:"secondary",size:"sm",onClick:wt,disabled:!V?.connected||Xt.isPending,title:t.plate_detection_enabled?"Plate check enabled - Click to disable":"Plate check disabled - Click to enable",className:`!rounded-r-none !border-r-0 ${t.plate_detection_enabled?"!border-green-500 !text-green-400 hover:!bg-green-500/20":""}`,children:Xt.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(Sw,{className:"w-4 h-4"})}),a.jsx(Te,{variant:"secondary",size:"sm",onClick:kt,disabled:!V?.connected||B,title:"Manage plate detection calibration",className:`!rounded-l-none !px-1.5 ${t.plate_detection_enabled?"!border-green-500 !text-green-400 hover:!bg-green-500/20":""}`,children:B?a.jsx(ut,{className:"w-3 h-3 animate-spin"}):a.jsx(Br,{className:"w-3 h-3"})})]}),a.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>D(!0),title:"Browse printer files",children:[a.jsx(B2,{className:"w-4 h-4"}),"Files"]})]})]})]}),C&&a.jsx(Lfe,{printerId:t.id,printerName:t.name,onClose:()=>D(!1)}),A&&a.jsx($fe,{printerId:t.id,printerName:t.name,onClose:()=>R(!1)}),He&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>pt(),children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-w-lg w-full",onClick:Be=>Be.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[He.needs_calibration?a.jsx(Sw,{className:"w-5 h-5 text-blue-500"}):He.is_empty?a.jsx(Fn,{className:"w-5 h-5 text-green-500"}):a.jsx(aa,{className:"w-5 h-5 text-yellow-500"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Build Plate Check"}),He.reference_count!==void 0&&He.max_references&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded",children:[He.reference_count,"/",He.max_references," refs"]})]}),a.jsx("button",{onClick:()=>pt(),className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[He.needs_calibration?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"p-3 rounded-lg bg-blue-500/20 border border-blue-500/50",children:[a.jsx("p",{className:"font-medium text-blue-400",children:"Calibration Required"}),a.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:["Please ensure the build plate is ",a.jsx("strong",{children:"completely empty"}),", then click Calibrate."]})]}),a.jsxs("div",{className:"text-sm text-bambu-gray space-y-2",children:[a.jsx("p",{children:"Calibration captures a reference image of the empty plate. Future checks will compare against this reference to detect objects."}),a.jsxs("p",{children:[a.jsx("strong",{children:"Tip:"})," You can store up to 5 calibrations for different plates. The system automatically uses the best match when checking."]})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:`p-3 rounded-lg ${He.is_empty?"bg-green-500/20 border border-green-500/50":"bg-yellow-500/20 border border-yellow-500/50"}`,children:[a.jsx("p",{className:`font-medium ${He.is_empty?"text-green-400":"text-yellow-400"}`,children:He.is_empty?"Plate appears empty":"Objects detected on plate"}),a.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:["Confidence: ",Math.round(He.confidence*100),"% | Difference: ",He.difference_percent.toFixed(1),"%"]})]}),He.debug_image_url&&a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Analysis preview:"}),a.jsx("img",{src:He.debug_image_url,alt:"Plate detection analysis",className:"w-full rounded-lg border border-bambu-dark-tertiary"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Green box = detection area, Red overlay = differences from calibration"})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:He.message})]}),ge&&ge.references.length>0&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("p",{className:"text-sm font-medium text-white mb-2",children:["Saved References (",ge.references.length,"/",ge.max_references,")"]}),a.jsx("div",{className:"grid grid-cols-5 gap-2",children:ge.references.map(Be=>a.jsxs("div",{className:"relative group",children:[a.jsx("img",{src:he.getPlateReferenceThumbnailUrl(t.id,Be.index),alt:Be.label||`Reference ${Be.index+1}`,className:"w-full aspect-video object-cover rounded border border-bambu-dark-tertiary"}),a.jsx("button",{onClick:()=>Mt(Be.index),className:"absolute top-1 right-1 p-0.5 bg-red-500/80 rounded opacity-0 group-hover:opacity-100 transition-opacity",title:"Delete reference",children:a.jsx(Ot,{className:"w-3 h-3 text-white"})}),Ie?.index===Be.index?a.jsx("input",{type:"text",value:Ie.label,onChange:Et=>Me({...Ie,label:Et.target.value}),onBlur:()=>Pt(Be.index,Ie.label),onKeyDown:Et=>{Et.key==="Enter"&&Pt(Be.index,Ie.label),Et.key==="Escape"&&Me(null)},className:"w-full mt-1 px-1 py-0.5 text-xs bg-bambu-dark-tertiary border border-bambu-green rounded text-white",autoFocus:!0,placeholder:"Label..."}):a.jsx("p",{className:"text-xs text-bambu-gray mt-1 truncate cursor-pointer hover:text-white",onClick:()=>Me({index:Be.index,label:Be.label}),title:Be.label?`${Be.label} - Click to edit`:"Click to add label",children:Be.label||a.jsx("span",{className:"italic opacity-50",children:"No label"})}),a.jsx("p",{className:"text-[10px] text-bambu-gray/60",children:Be.timestamp?new Date(Be.timestamp).toLocaleDateString():""})]},Be.index))})]}),!He.needs_calibration&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:"Detection Area (ROI)"}),le?a.jsxs("div",{className:"flex gap-1",children:[a.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>Pe(null),disabled:Oe,children:"Cancel"}),a.jsx(Te,{size:"sm",onClick:nn,disabled:Oe,children:Oe?a.jsx(ut,{className:"w-3 h-3 animate-spin"}):"Save"})]}):a.jsxs(Te,{variant:"ghost",size:"sm",onClick:()=>Pe(He.roi||{x:.15,y:.35,w:.7,h:.55}),children:[a.jsx(Oi,{className:"w-3 h-3 mr-1"}),"Edit"]})]}),le?a.jsxs("div",{className:"space-y-3 bg-bambu-dark-tertiary/50 p-3 rounded-lg",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:"X Start"}),a.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:le.x,onChange:Be=>Pe({...le,x:parseFloat(Be.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(le.x*100),"%"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:"Y Start"}),a.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:le.y,onChange:Be=>Pe({...le,y:parseFloat(Be.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(le.y*100),"%"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:"Width"}),a.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:le.w,onChange:Be=>Pe({...le,w:parseFloat(Be.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(le.w*100),"%"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:"Height"}),a.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:le.h,onChange:Be=>Pe({...le,h:parseFloat(Be.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(le.h*100),"%"]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Adjust the detection area to focus on the build plate. The green box in the preview shows the current area."})]}):a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Current: X=",Math.round((He.roi?.x||.15)*100),"%, Y=",Math.round((He.roi?.y||.35)*100),"%, W=",Math.round((He.roi?.w||.7)*100),"%, H=",Math.round((He.roi?.h||.55)*100),"%"]})]})]}),a.jsx("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:He.needs_calibration?a.jsxs(a.Fragment,{children:[a.jsx(Te,{variant:"ghost",onClick:()=>pt(),children:"Cancel"}),a.jsx(Te,{onClick:()=>zt(),disabled:U,children:U?a.jsxs(a.Fragment,{children:[a.jsx(ut,{className:"w-4 h-4 mr-2 animate-spin"}),"Calibrating..."]}):"Calibrate Empty Plate"})]}):a.jsxs(a.Fragment,{children:[a.jsx(Te,{variant:"ghost",onClick:()=>zt(),disabled:U,children:U?"Adding...":`Add Reference (${ge?.references.length||0}/${ge?.max_references||5})`}),a.jsx(Te,{onClick:()=>pt(),children:"Close"})]})})]})}),F&&ke&&a.jsx(Hn,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{en.mutate("on"),O(!1)},onCancel:()=>O(!1)}),q&&ke&&a.jsx(Hn,{title:"Power Off Printer",message:V?.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:()=>{en.mutate("off"),j(!1)},onCancel:()=>j(!1)}),K&&a.jsx(Hn,{title:"Stop Print",message:`Are you sure you want to stop the current print on "${t.name}"? This will cancel the print job.`,confirmText:"Stop Print",variant:"danger",onConfirm:()=>{Un.mutate(),Z(!1)},onCancel:()=>Z(!1)}),te&&a.jsx(Hn,{title:"Pause Print",message:`Are you sure you want to pause the current print on "${t.name}"?`,confirmText:"Pause Print",variant:"default",onConfirm:()=>{wr.mutate(),ne(!1)},onCancel:()=>ne(!1)}),z&&a.jsx(Hn,{title:"Resume Print",message:`Are you sure you want to resume the print on "${t.name}"?`,confirmText:"Resume Print",variant:"default",onConfirm:()=>{jr.mutate(),W(!1)},onCancel:()=>W(!1)}),se&&a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>ae(!1),onKeyDown:Be=>Be.key==="Escape"&&ae(!1),tabIndex:-1,ref:Be=>Be?.focus(),children:[a.jsx("div",{className:"absolute inset-0 bg-black/50 z-0"}),a.jsxs("div",{className:"relative z-10 bg-white dark:bg-bambu-dark border border-gray-200 dark:border-bambu-dark-tertiary rounded-xl shadow-2xl w-[560px] max-h-[85vh] flex flex-col overflow-hidden",onClick:Be=>Be.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(iH,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Skip Objects"})]}),a.jsx("button",{onClick:()=>ae(!1),className:"p-1 text-gray-500 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white rounded transition-colors",children:a.jsx(Ot,{className:"w-4 h-4"})})]}),Wn?Wn.objects.length===0?a.jsxs("div",{className:"text-center py-8 px-4 text-bambu-gray",children:[a.jsx("p",{className:"text-sm",children:"No objects found"}),a.jsx("p",{className:"text-xs mt-1 opacity-70",children:"Objects are loaded when a print starts"})]}):a.jsxs("div",{className:"flex flex-col overflow-hidden",children:[a.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 bg-blue-50 dark:bg-blue-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary",children:[a.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-lg bg-blue-100 dark:bg-blue-500/20 flex items-center justify-center",children:a.jsx(Bde,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-300",children:"Match IDs with your printer display"}),a.jsx("p",{className:"text-[10px] text-blue-500/70 dark:text-blue-300/60",children:"The printer screen shows object IDs on the build plate"})]}),a.jsxs("div",{className:"flex-shrink-0 text-xs text-gray-500 dark:text-bambu-gray",children:[Wn.skipped_count,"/",Wn.total," skipped"]})]}),(V?.layer_num??0)<=1&&a.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-50 dark:bg-amber-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary",children:[a.jsx(Ei,{className:"w-4 h-4 text-amber-500 dark:text-amber-400 flex-shrink-0"}),a.jsxs("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:["Wait for layer 2+ to skip objects (currently layer ",V?.layer_num??0,")"]})]}),a.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[a.jsx("div",{className:"w-52 flex-shrink-0 p-4 border-r border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark-secondary overflow-y-auto",children:a.jsxs("div",{className:"relative",children:[V?.cover_url?a.jsx("img",{src:`${V.cover_url}?view=top`,alt:"Print preview",className:"w-full aspect-square object-contain rounded-lg bg-gray-900 dark:bg-gray-900 border border-gray-300 dark:border-gray-600"}):a.jsx("div",{className:"w-full aspect-square rounded-lg bg-gray-100 dark:bg-bambu-dark flex items-center justify-center",children:a.jsx(Hs,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),Wn.objects.length>0&&a.jsx("div",{className:"absolute inset-0 pointer-events-none",children:Wn.objects.map((Be,Et)=>{let Wt,dt;if(Be.x!=null&&Be.y!=null&&Wn.bbox_all){const[Kt,sn,En,On]=Wn.bbox_all,Tr=En-Kt,Gt=On-sn,hn=8,ki=100-hn*2;Wt=hn+(Be.x-Kt)/Tr*ki,dt=hn+(On-Be.y)/Gt*ki,Wt=Math.max(5,Math.min(95,Wt)),dt=Math.max(5,Math.min(95,dt))}else if(Be.x!=null&&Be.y!=null)Wt=Be.x/256*100,dt=100-Be.y/256*100,Wt=Math.max(5,Math.min(95,Wt)),dt=Math.max(5,Math.min(95,dt));else{const Kt=Math.ceil(Math.sqrt(Wn.objects.length)),sn=Math.floor(Et/Kt),En=Et%Kt,On=Math.ceil(Wn.objects.length/Kt);Wt=15+En*(70/Kt)+35/Kt,dt=15+sn*(70/On)+35/On}return a.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${Be.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${Wt}%`,top:`${dt}%`,transform:"translate(-50%, -50%)"},title:Be.name,children:Be.id},Be.id)})}),a.jsxs("div",{className:"absolute bottom-2 right-2 px-2 py-1 bg-white/90 dark:bg-black/80 rounded text-[10px] text-gray-700 dark:text-white shadow-sm",children:[Wn.objects.filter(Be=>!Be.skipped).length," active"]})]})}),a.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto",children:Wn.objects.map(Be=>a.jsxs("div",{className:`
- flex items-center gap-3 px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary/50 last:border-0
- ${Be.skipped?"bg-red-50 dark:bg-red-500/10":"hover:bg-gray-50 dark:hover:bg-bambu-dark/50"}
- `,children:[a.jsxs("div",{className:`
- w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center
- ${Be.skipped?"bg-red-100 dark:bg-red-500/20 border border-red-300 dark:border-red-500/40":"bg-green-100 dark:bg-bambu-green/20 border border-green-300 dark:border-bambu-green/40"}
- `,children:[a.jsx("span",{className:`text-lg font-mono font-bold ${Be.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:Be.id}),a.jsx("span",{className:`text-[8px] uppercase tracking-wider ${Be.skipped?"text-red-400/60":"text-green-500/60 dark:text-bambu-green/60"}`,children:"ID"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:`block text-sm truncate ${Be.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:Be.name}),Be.skipped&&a.jsx("span",{className:"text-[10px] text-red-400/60",children:"Will be skipped"})]}),Be.skipped?a.jsx("span",{className:"px-4 py-2 text-xs text-red-500 dark:text-red-400/70 bg-red-100 dark:bg-red-500/10 rounded-lg",children:"Skipped"}):a.jsx("button",{onClick:()=>Ee.mutate([Be.id]),disabled:Ee.isPending||(V?.layer_num??0)<=1,className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(V?.layer_num??0)<=1?"bg-gray-100 dark:bg-bambu-dark text-gray-400 dark:text-bambu-gray/50 cursor-not-allowed":"bg-red-100 dark:bg-red-500/20 text-red-600 dark:text-red-400 hover:bg-red-200 dark:hover:bg-red-500/30 border border-red-300 dark:border-red-500/30"}`,title:(V?.layer_num??0)<=1?"Wait for layer 2+":"Skip this object",children:"Skip"})]},Be.id))})]})]}):a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(ut,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}),G&&a.jsx(qfe,{printerName:t.name,errors:V?.hms_errors||[],onClose:()=>Y(!1)}),de&&a.jsx(zke,{isOpen:!!de,onClose:()=>me(null),printerId:t.id,printerName:t.name,amsId:de.amsId,amsLabel:de.amsLabel,initialMode:de.mode,thresholds:s}),xe&&a.jsx(Bke,{isOpen:!!xe,onClose:()=>be(null),trayUuid:xe.trayUuid,trayInfo:xe.trayInfo}),fe&&a.jsx(Kke,{isOpen:!!fe,onClose:()=>Ce(null),printerId:t.id,slotInfo:fe,onSuccess:()=>{m.invalidateQueries({queryKey:["slotPresets",t.id]}),m.invalidateQueries({queryKey:["printerStatus",t.id]})}}),E&&a.jsx(uje,{printer:t,onClose:()=>k(!1)}),Ne&&ie&&a.jsx(cje,{printer:t,firmwareInfo:ie,onClose:()=>re(!1)}),tn&&a.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>cn(null)})]})}function lje({onClose:t,onAdd:e,existingSerials:n}){const[r,i]=w.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0}),[s,o]=w.useState(!1),[l,c]=w.useState([]),[u,d]=w.useState(""),[f,m]=w.useState(!1),[g,x]=w.useState(!1),[y,b]=w.useState("192.168.1.0/24"),[v,N]=w.useState({scanned:0,total:0});w.useEffect(()=>{vl.getInfo().then(C=>{x(C.is_docker)}).catch(()=>{})},[]);const S=l.filter(C=>!n.includes(C.serial)),T=async()=>{d(""),c([]),o(!0),m(!1),N({scanned:0,total:0});try{if(g){await vl.startSubnetScan(y);const C=setInterval(async()=>{try{const D=await vl.getScanStatus();N({scanned:D.scanned,total:D.total});const A=await vl.getDiscoveredPrinters();c(A),D.running||(clearInterval(C),o(!1),m(!0))}catch(D){console.error("Failed to get scan status:",D)}},500)}else{await vl.startDiscovery(10);const C=setInterval(async()=>{try{const D=await vl.getDiscoveredPrinters();c(D)}catch(D){console.error("Failed to get discovered printers:",D)}},1e3);setTimeout(async()=>{clearInterval(C);try{await vl.stopDiscovery()}catch{}o(!1),m(!0);try{const D=await vl.getDiscoveredPrinters();c(D)}catch(D){console.error("Failed to get final discovered printers:",D)}},1e4)}}catch(C){console.error("Failed to start discovery:",C),d(C instanceof Error?C.message:"Failed to start discovery"),o(!1),m(!0)}},E=C=>C?{O1D:"H2D",O1C:"H2C",O1S:"H2S","BL-P001":"X1C","BL-P002":"X1","BL-P003":"X1E",C11:"P1S",C12:"P1P",C13:"P2S",N2S:"A1",N1:"A1 Mini",X1C:"X1C",X1:"X1",X1E:"X1E",P1S:"P1S",P1P:"P1P",P2S:"P2S",A1:"A1","A1 Mini":"A1 Mini",H2D:"H2D",H2C:"H2C",H2S:"H2S"}[C]||C:"",k=C=>{const D=C.serial.startsWith("unknown-")?"":C.serial;i({...r,name:C.name||"",serial_number:D,ip_address:C.ip_address,model:E(C.model)}),c([])};return w.useEffect(()=>()=>{vl.stopDiscovery().catch(()=>{}),vl.stopSubnetScan().catch(()=>{})},[]),w.useEffect(()=>{const C=D=>{D.key==="Escape"&&t()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:a.jsx(_t,{className:"w-full max-w-md",onClick:C=>C.stopPropagation(),children:a.jsxs(St,{children:[a.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),a.jsxs("div",{className:"mb-4 pb-4 border-b border-bambu-dark-tertiary",children:[g&&a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Subnet to scan"}),a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm",value:y,onChange:C=>b(C.target.value),placeholder:"192.168.1.0/24",disabled:s}),a.jsxs("p",{className:"mt-1 text-xs text-bambu-gray",children:["Docker detected. Enter your printer's subnet in CIDR notation. Requires ",a.jsx("code",{className:"text-bambu-green",children:"network_mode: host"})," in docker-compose.yml."]})]}),a.jsx(Te,{type:"button",variant:"secondary",onClick:T,disabled:s,className:"w-full",children:s?a.jsxs(a.Fragment,{children:[a.jsx(ut,{className:"w-4 h-4 animate-spin"}),g&&v.total>0?`Scanning... ${v.scanned}/${v.total}`:"Scanning..."]}):a.jsxs(a.Fragment,{children:[a.jsx(na,{className:"w-4 h-4"}),g?"Scan Subnet for Printers":"Discover Printers on Network"]})}),u&&a.jsx("div",{className:"mt-2 text-sm text-red-400",children:u}),S.length>0&&a.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:S.map(C=>a.jsxs("div",{className:"flex items-center justify-between p-2 bg-bambu-dark rounded-lg hover:bg-bambu-dark-secondary cursor-pointer transition-colors",onClick:()=>k(C),children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"font-medium text-white text-sm truncate",children:C.name||C.serial}),a.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[E(C.model)||"Unknown"," • ",C.ip_address,C.serial.startsWith("unknown-")&&a.jsx("span",{className:"text-yellow-500",children:" • Serial required"})]})]}),a.jsx(Br,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},C.serial))}),s&&a.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:g?"Scanning subnet for Bambu printers...":"Scanning network..."}),f&&!s&&l.length===0&&a.jsxs("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:["No printers found",g?" in the specified subnet":" on the network","."]}),f&&!s&&l.length>0&&S.length===0&&a.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:"All discovered printers are already configured."})]}),a.jsxs("form",{onSubmit:C=>{C.preventDefault(),e(r)},className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),a.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.name,onChange:C=>i({...r,name:C.target.value}),placeholder:"My Printer"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),a.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.ip_address,onChange:C=>i({...r,ip_address:C.target.value}),placeholder:"192.168.1.100"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),a.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.serial_number,onChange:C=>i({...r,serial_number:C.target.value}),placeholder:"01P00A000000000"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),a.jsx("input",{type:"password",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.access_code,onChange:C=>i({...r,access_code:C.target.value}),placeholder:"From printer settings"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),a.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.model||"",onChange:C=>i({...r,model:C.target.value}),children:[a.jsx("option",{value:"",children:"Select model..."}),a.jsxs("optgroup",{label:"H2 Series",children:[a.jsx("option",{value:"H2C",children:"H2C"}),a.jsx("option",{value:"H2D",children:"H2D"}),a.jsx("option",{value:"H2S",children:"H2S"})]}),a.jsxs("optgroup",{label:"X1 Series",children:[a.jsx("option",{value:"X1E",children:"X1E"}),a.jsx("option",{value:"X1C",children:"X1 Carbon"}),a.jsx("option",{value:"X1",children:"X1"})]}),a.jsxs("optgroup",{label:"P Series",children:[a.jsx("option",{value:"P2S",children:"P2S"}),a.jsx("option",{value:"P1S",children:"P1S"}),a.jsx("option",{value:"P1P",children:"P1P"})]}),a.jsxs("optgroup",{label:"A1 Series",children:[a.jsx("option",{value:"A1",children:"A1"}),a.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"auto_archive",checked:r.auto_archive,onChange:C=>i({...r,auto_archive:C.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),a.jsxs("div",{className:"flex gap-3 pt-4",children:[a.jsx(Te,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),a.jsx(Te,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function cje({printer:t,firmwareInfo:e,onClose:n}){const r=an(),{showToast:i}=Gn(),[s,o]=w.useState(null),[l,c]=w.useState(!1),[u,d]=w.useState(null),{data:f,isLoading:m}=ct({queryKey:["firmwarePrepare",t.id],queryFn:()=>V1.prepareUpload(t.id),staleTime:3e4}),g=ht({mutationFn:()=>V1.startUpload(t.id),onSuccess:()=>{c(!0);const y=setInterval(async()=>{try{const b=await V1.getUploadStatus(t.id);o(b),(b.status==="complete"||b.status==="error")&&(clearInterval(y),d(null),c(!1),b.status==="complete"&&(i("Firmware uploaded! Trigger update from printer screen.","success"),r.invalidateQueries({queryKey:["firmwareUpdate",t.id]})))}catch{}},2e3);d(y)},onError:y=>{i(`Failed to start upload: ${y.message}`,"error"),c(!1)}});w.useEffect(()=>()=>{u&&clearInterval(u)},[u]);const x=()=>{o(null),g.mutate()};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsx(_t,{className:"w-full max-w-md mx-4",children:a.jsxs(St,{children:[a.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[a.jsx("div",{className:"p-2 rounded-full bg-orange-500/20",children:a.jsx(Gr,{className:"w-5 h-5 text-orange-400"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Firmware Update"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:t.name})]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:[a.jsxs("div",{className:"flex justify-between items-center text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:"Current:"}),a.jsx("span",{className:"text-white font-mono",children:e.current_version||"Unknown"})]}),a.jsxs("div",{className:"flex justify-between items-center text-sm mt-1",children:[a.jsx("span",{className:"text-bambu-gray",children:"Latest:"}),a.jsx("span",{className:"text-orange-400 font-mono",children:e.latest_version})]}),e.release_notes&&a.jsxs("details",{className:"mt-3 text-sm",children:[a.jsx("summary",{className:"text-orange-400 cursor-pointer hover:underline",children:"Release Notes"}),a.jsx("div",{className:"mt-2 text-bambu-gray text-xs max-h-40 overflow-y-auto whitespace-pre-wrap",children:e.release_notes})]})]}),m?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm mb-4",children:[a.jsx(ut,{className:"w-4 h-4 animate-spin"}),"Checking prerequisites..."]}):f&&!l&&!s?a.jsx("div",{className:"mb-4",children:f.can_proceed?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-green text-sm",children:[a.jsx(Hs,{className:"w-4 h-4"}),"SD card ready. Click below to upload firmware."]}):a.jsx("div",{className:"space-y-1",children:f.errors.map((y,b)=>a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[a.jsx(Ei,{className:"w-4 h-4 flex-shrink-0"}),y]},b))})}):null,(l||s)&&s&&a.jsxs("div",{className:"mb-4",children:[a.jsxs("div",{className:"flex items-center justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-bambu-gray capitalize",children:s.status}),a.jsxs("span",{className:"text-white",children:[s.progress,"%"]})]}),a.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:a.jsx("div",{className:`h-2 rounded-full transition-all ${s.status==="error"?"bg-status-error":s.status==="complete"?"bg-status-ok":"bg-orange-500"} ${s.status==="uploading"?"animate-pulse":""}`,style:{width:`${s.progress}%`}})}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:s.message}),s.error&&a.jsx("p",{className:"text-xs text-red-400 mt-1",children:s.error})]}),s?.status==="complete"&&a.jsxs("div",{className:"bg-bambu-green/10 border border-bambu-green/30 rounded-lg p-3 mb-4",children:[a.jsx("p",{className:"text-sm text-bambu-green font-medium mb-2",children:"Firmware uploaded to SD card!"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"To apply the update on your printer:"}),a.jsxs("ol",{className:"text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1",children:[a.jsxs("li",{children:["On the printer's touchscreen, go to ",a.jsx("strong",{className:"text-white",children:"Settings"})]}),a.jsxs("li",{children:["Navigate to ",a.jsx("strong",{className:"text-white",children:"Firmware"})]}),a.jsxs("li",{children:["Select ",a.jsx("strong",{className:"text-white",children:"Update from SD card"})]}),a.jsx("li",{children:"The update will take 10-20 minutes"})]})]}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Te,{variant:"secondary",onClick:n,children:s?.status==="complete"?"Done":"Cancel"}),f?.can_proceed&&!l&&s?.status!=="complete"&&a.jsx(Te,{onClick:x,disabled:g.isPending,children:g.isPending?a.jsxs(a.Fragment,{children:[a.jsx(ut,{className:"w-4 h-4 animate-spin mr-2"}),"Starting..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Gr,{className:"w-4 h-4 mr-2"}),"Upload Firmware"]})})]})]})})})}function uje({printer:t,onClose:e}){const n=an(),[r,i]=w.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),s=ht({mutationFn:l=>he.updatePrinter(t.id,l),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});w.useEffect(()=>{const l=c=>{c.key==="Escape"&&e()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[e]);const o=l=>{l.preventDefault();const c={name:r.name,ip_address:r.ip_address,model:r.model||void 0,location:r.location||void 0,auto_archive:r.auto_archive};r.access_code&&(c.access_code=r.access_code),s.mutate(c)};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:a.jsx(_t,{className:"w-full max-w-md",onClick:l=>l.stopPropagation(),children:a.jsxs(St,{children:[a.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Edit Printer"}),a.jsxs("form",{onSubmit:o,className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),a.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.name,onChange:l=>i({...r,name:l.target.value}),placeholder:"My Printer"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),a.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.ip_address,onChange:l=>i({...r,ip_address:l.target.value}),placeholder:"192.168.1.100"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),a.jsx("input",{type:"text",disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed",value:t.serial_number}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Serial number cannot be changed"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),a.jsx("input",{type:"password",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.access_code,onChange:l=>i({...r,access_code:l.target.value}),placeholder:"Leave empty to keep current"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model"}),a.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.model,onChange:l=>i({...r,model:l.target.value}),children:[a.jsx("option",{value:"",children:"Select model..."}),a.jsxs("optgroup",{label:"H2 Series",children:[a.jsx("option",{value:"H2C",children:"H2C"}),a.jsx("option",{value:"H2D",children:"H2D"}),a.jsx("option",{value:"H2S",children:"H2S"})]}),a.jsxs("optgroup",{label:"X1 Series",children:[a.jsx("option",{value:"X1E",children:"X1E"}),a.jsx("option",{value:"X1C",children:"X1 Carbon"}),a.jsx("option",{value:"X1",children:"X1"})]}),a.jsxs("optgroup",{label:"P Series",children:[a.jsx("option",{value:"P2S",children:"P2S"}),a.jsx("option",{value:"P1S",children:"P1S"}),a.jsx("option",{value:"P1P",children:"P1P"})]}),a.jsxs("optgroup",{label:"A1 Series",children:[a.jsx("option",{value:"A1",children:"A1"}),a.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),a.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.location,onChange:l=>i({...r,location:l.target.value}),placeholder:"e.g., Workshop, Office, Basement"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Used to group printers on the dashboard"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:r.auto_archive,onChange:l=>i({...r,auto_archive:l.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),a.jsxs("div",{className:"flex gap-3 pt-4",children:[a.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsx(Te,{type:"submit",className:"flex-1",disabled:s.isPending,children:s.isPending?"Saving...":"Save Changes"})]})]})]})})})}function dje(t){const{data:e}=ct({queryKey:["printerStatus",t],queryFn:()=>he.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function hje({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=dje(t.id),{data:s}=ct({queryKey:["smartPlugStatus",e.id],queryFn:()=>he.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),s&&a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${s.state==="ON"?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:s.state||"?"})]}),a.jsxs("button",{onClick:()=>n(e.id),disabled:r||s?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${s?.state==="ON"?"bg-bambu-green/20 text-bambu-green cursor-default":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green hover:text-white"}`,children:[a.jsx(yu,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function fje(){const[t,e]=w.useState(!1),[n,r]=w.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,s]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState(()=>localStorage.getItem("printerSortBy")||"name"),[d,f]=w.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[m,g]=w.useState(()=>{const W=localStorage.getItem("printerCardSize");return W?parseInt(W,10):2}),x=m===1?"compact":"expanded",y=an(),[b,v]=w.useState(()=>{const W=localStorage.getItem("openEmbeddedCameras");if(W)try{const se=JSON.parse(W);return new Map(se.map(ae=>[ae.id,ae]))}catch{return new Map}return new Map});w.useEffect(()=>{const W=Array.from(b.values());W.length>0?localStorage.setItem("openEmbeddedCameras",JSON.stringify(W)):localStorage.removeItem("openEmbeddedCameras")},[b]);const{data:N,isLoading:S}=ct({queryKey:["printers"],queryFn:he.getPrinters}),{data:T}=ct({queryKey:["settings"],queryFn:he.getSettings});w.useEffect(()=>{T?.camera_view_mode==="window"&&b.size>0&&v(new Map)},[T?.camera_view_mode,b.size]);const{data:E}=ct({queryKey:["smart-plugs"],queryFn:he.getSmartPlugs}),{data:k}=ct({queryKey:["maintenanceOverview"],queryFn:he.getMaintenanceOverview,staleTime:60*1e3}),{data:C}=ct({queryKey:["spoolman-status"],queryFn:he.getSpoolmanStatus,staleTime:60*1e3}),D=C?.enabled&&C?.connected,{data:A}=ct({queryKey:["unlinked-spools"],queryFn:he.getUnlinkedSpools,enabled:!!D,staleTime:30*1e3}),R=A&&A.length>0,F=k?.reduce((W,se)=>(W[se.printer_id]={due_count:se.due_count,warning_count:se.warning_count,total_print_hours:se.total_print_hours},W),{})||{},O=E?.reduce((W,se)=>(se.printer_id&&(W[se.printer_id]=se),W),{})||{},q=ht({mutationFn:he.createPrinter,onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),y.invalidateQueries({queryKey:["maintenanceOverview"]}),e(!1)}}),j=ht({mutationFn:W=>he.controlSmartPlug(W,"on"),onSuccess:()=>{y.invalidateQueries({queryKey:["smart-plugs"]}),l(null)},onError:()=>{l(null)}}),G=()=>{const W=!n;r(W),localStorage.setItem("hideDisconnectedPrinters",String(W))},Y=W=>{u(W),localStorage.setItem("printerSortBy",W)},K=()=>{const W=!d;f(W),localStorage.setItem("printerSortAsc",String(W))},Z=()=>{switch(m){case 1:return"grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5";case 2:return"grid-cols-1 md:grid-cols-2 xl:grid-cols-3";case 3:return"grid-cols-1 lg:grid-cols-2";case 4:return"grid-cols-1";default:return"grid-cols-1 md:grid-cols-2 xl:grid-cols-3"}},te=["S","M","L","XL"],ne=w.useMemo(()=>{if(!N)return[];const W=[...N];switch(c){case"name":W.sort((se,ae)=>se.name.localeCompare(ae.name));break;case"model":W.sort((se,ae)=>(se.model||"").localeCompare(ae.model||""));break;case"location":W.sort((se,ae)=>{const de=se.location||"",me=ae.location||"";return!de&&me?1:de&&!me?-1:de.localeCompare(me)||se.name.localeCompare(ae.name)});break;case"status":W.sort((se,ae)=>{const de=y.getQueryData(["printerStatus",se.id]),me=y.getQueryData(["printerStatus",ae.id]),xe=be=>be?.connected?be.state==="RUNNING"?0:1:2;return xe(de)-xe(me)});break}return d||W.reverse(),W},[N,c,d,y]),z=w.useMemo(()=>{if(c!=="location")return null;const W={};return ne.forEach(se=>{const ae=se.location||"Ungrouped";W[ae]||(W[ae]=[]),W[ae].push(se)}),W},[c,ne]);return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:"Printers"}),a.jsx(oje,{printers:N})]}),a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-wrap",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("select",{value:c,onChange:W=>Y(W.target.value),className:"text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-2 py-1.5 text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"name",children:"Name"}),a.jsx("option",{value:"status",children:"Status"}),a.jsx("option",{value:"model",children:"Model"}),a.jsx("option",{value:"location",children:"Location"})]}),a.jsx("button",{onClick:K,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?a.jsx(og,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(p0,{className:"w-4 h-4 text-bambu-gray"})})]}),a.jsx("div",{className:"flex items-center bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:te.map((W,se)=>{const ae=se+1,de=m===ae;return a.jsx("button",{onClick:()=>{g(ae),localStorage.setItem("printerCardSize",String(ae))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${se===0?"rounded-l-lg":""} ${se===te.length-1?"rounded-r-lg":""} ${de?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:`${W==="S"?"Small":W==="M"?"Medium":W==="L"?"Large":"Extra large"} cards`,children:W},W)})}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:n,onChange:G,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(O).length>0&&a.jsxs("div",{className:"relative",children:[a.jsxs("button",{onClick:()=>s(!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:[a.jsx(yu,{className:"w-4 h-4"}),"Power On",a.jsx(Br,{className:`w-3 h-3 transition-transform ${i?"rotate-180":""}`})]}),i&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),a.jsxs("div",{className:"absolute right-0 mt-2 w-56 bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg shadow-lg z-20 py-1",children:[a.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 dark:text-bambu-gray border-b border-gray-200 dark:border-bambu-dark-tertiary",children:"Offline printers with smart plugs"}),N?.filter(W=>O[W.id]).map(W=>a.jsx(hje,{printer:W,plug:O[W.id],onPowerOn:se=>{l(se),j.mutate(se)},isPowering:o===O[W.id]?.id},W.id)),N?.filter(W=>O[W.id]).length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),a.jsxs(Te,{onClick:()=>e(!0),children:[a.jsx(rr,{className:"w-4 h-4"}),"Add Printer"]})]})]}),S?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):N?.length===0?a.jsx(_t,{children:a.jsxs(St,{className:"text-center py-12",children:[a.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),a.jsxs(Te,{onClick:()=>e(!0),children:[a.jsx(rr,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):z?a.jsx("div",{className:"space-y-6",children:Object.entries(z).map(([W,se])=>a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),W,a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",se.length,")"]})]}),a.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${Z()}`,children:se.map(ae=>a.jsx(hH,{printer:ae,hideIfDisconnected:n,maintenanceInfo:F[ae.id],viewMode:x,cardSize:m,amsThresholds:T?{humidityGood:Number(T.ams_humidity_good)||40,humidityFair:Number(T.ams_humidity_fair)||60,tempGood:Number(T.ams_temp_good)||28,tempFair:Number(T.ams_temp_fair)||35}:void 0,spoolmanEnabled:D,hasUnlinkedSpools:R,timeFormat:T?.time_format||"system",cameraViewMode:T?.camera_view_mode||"window",onOpenEmbeddedCamera:(de,me)=>v(xe=>new Map(xe).set(de,{id:de,name:me})),checkPrinterFirmware:T?.check_printer_firmware!==!1},ae.id))})]},W))}):a.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${Z()}`,children:ne.map(W=>a.jsx(hH,{printer:W,hideIfDisconnected:n,maintenanceInfo:F[W.id],viewMode:x,cardSize:m,spoolmanEnabled:D,hasUnlinkedSpools:R,amsThresholds:T?{humidityGood:Number(T.ams_humidity_good)||40,humidityFair:Number(T.ams_humidity_fair)||60,tempGood:Number(T.ams_temp_good)||28,tempFair:Number(T.ams_temp_fair)||35}:void 0,timeFormat:T?.time_format||"system",cameraViewMode:T?.camera_view_mode||"window",onOpenEmbeddedCamera:(se,ae)=>v(de=>new Map(de).set(se,{id:se,name:ae})),checkPrinterFirmware:T?.check_printer_firmware!==!1},W.id))}),t&&a.jsx(lje,{onClose:()=>e(!1),onAdd:W=>q.mutate(W),existingSerials:N?.map(W=>W.serial_number)||[]}),Array.from(b.values()).map((W,se)=>a.jsx(Bfe,{printerId:W.id,printerName:W.name,viewerIndex:se,onClose:()=>v(ae=>{const de=new Map(ae);return de.delete(W.id),de})},W.id))]})}function mje(){const t=navigator.userAgent.toLowerCase(),e=navigator.platform?.toLowerCase()||"";return t.includes("win")||e.includes("win")?"windows":t.includes("mac")||e.includes("mac")?"macos":t.includes("linux")||e.includes("linux")?"linux":"unknown"}function pje(){switch(mje()){case"windows":return"bambustudio://";case"macos":case"linux":default:return"bambustudioopen://"}}function $c(t){const e=pje();window.location.href=`${e}${encodeURIComponent(t)}`}const wO="181",Zp={ROTATE:0,DOLLY:1,PAN:2},Hp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},gje=0,fH=1,xje=2,FZ=1,bje=2,Oc=3,eh=0,_s=1,Al=2,tu=0,Jp=1,mH=2,pH=3,gH=4,yje=5,Zh=100,vje=101,_je=102,wje=103,Sje=104,Nje=200,Mje=201,Eje=202,Tje=203,iP=204,aP=205,Cje=206,Aje=207,kje=208,jje=209,Pje=210,Rje=211,Dje=212,Oje=213,Lje=214,sP=0,oP=1,lP=2,yg=3,cP=4,uP=5,dP=6,hP=7,SO=0,Ije=1,Fje=2,Ld=0,Uje=1,zje=2,Bje=3,$je=4,Hje=5,Vje=6,Gje=7,UZ=300,vg=301,_g=302,fP=303,mP=304,$N=306,pP=1e3,Wc=1001,gP=1002,Xs=1003,qje=1004,M_=1005,Ao=1006,NA=1007,df=1008,Gl=1009,zZ=1010,BZ=1011,L0=1012,NO=1013,Gf=1014,Kc=1015,ex=1016,MO=1017,EO=1018,I0=1020,$Z=35902,HZ=35899,VZ=1021,GZ=1022,rl=1023,F0=1026,U0=1027,qZ=1028,TO=1029,CO=1030,AO=1031,kO=1033,Z1=33776,J1=33777,ew=33778,tw=33779,xP=35840,bP=35841,yP=35842,vP=35843,_P=36196,wP=37492,SP=37496,NP=37808,MP=37809,EP=37810,TP=37811,CP=37812,AP=37813,kP=37814,jP=37815,PP=37816,RP=37817,DP=37818,OP=37819,LP=37820,IP=37821,FP=36492,UP=36494,zP=36495,BP=36283,$P=36284,HP=36285,VP=36286,Wje=3200,Kje=3201,WZ=0,Xje=1,vd="",vo="srgb",wg="srgb-linear",SS="linear",pr="srgb",Wm=7680,xH=519,Yje=512,Qje=513,Zje=514,KZ=515,Jje=516,e3e=517,t3e=518,n3e=519,bH=35044,yH="300 es",Rl=2e3,NS=2001;function XZ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function MS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function r3e(){const t=MS("canvas");return t.style.display="block",t}const vH={};function _H(...t){const e="THREE."+t.shift();console.log(e,...t)}function mn(...t){const e="THREE."+t.shift();console.warn(e,...t)}function hi(...t){const e="THREE."+t.shift();console.error(e,...t)}function z0(...t){const e=t.join(" ");e in vH||(vH[e]=!0,mn(...t))}function i3e(t,e,n){return new Promise(function(r,i){function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:r()}}setTimeout(s,n)})}let om=class{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const s=i.indexOf(n);s!==-1&&i.splice(s,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const r=n[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}};const Ca=["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"],nw=Math.PI/180,GP=180/Math.PI;function Iy(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Ca[t&255]+Ca[t>>8&255]+Ca[t>>16&255]+Ca[t>>24&255]+"-"+Ca[e&255]+Ca[e>>8&255]+"-"+Ca[e>>16&15|64]+Ca[e>>24&255]+"-"+Ca[n&63|128]+Ca[n>>8&255]+"-"+Ca[n>>16&255]+Ca[n>>24&255]+Ca[r&255]+Ca[r>>8&255]+Ca[r>>16&255]+Ca[r>>24&255]).toLowerCase()}function Pn(t,e,n){return Math.max(e,Math.min(n,t))}function a3e(t,e){return(t%e+e)%e}function MA(t,e,n){return(1-n)*t+n*e}function cb(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function hs(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const s3e={DEG2RAD:nw};let Nn=class YZ{constructor(e=0,n=0){YZ.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=Pn(this.x,e.x,n.x),this.y=Pn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=Pn(this.x,e,n),this.y=Pn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Pn(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(Pn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),s=this.x-e.x,o=this.y-e.y;return this.x=s*r-o*i+e.x,this.y=s*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},qf=class{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,s,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3],m=s[o+0],g=s[o+1],x=s[o+2],y=s[o+3];if(l<=0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l>=1){e[n+0]=m,e[n+1]=g,e[n+2]=x,e[n+3]=y;return}if(f!==y||c!==m||u!==g||d!==x){let b=c*m+u*g+d*x+f*y;b<0&&(m=-m,g=-g,x=-x,y=-y,b=-b);let v=1-l;if(b<.9995){const N=Math.acos(b),S=Math.sin(N);v=Math.sin(v*N)/S,l=Math.sin(l*N)/S,c=c*v+m*l,u=u*v+g*l,d=d*v+x*l,f=f*v+y*l}else{c=c*v+m*l,u=u*v+g*l,d=d*v+x*l,f=f*v+y*l;const N=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=N,u*=N,d*=N,f*=N}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,s,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=s[o],m=s[o+1],g=s[o+2],x=s[o+3];return e[n]=l*x+d*f+c*g-u*m,e[n+1]=c*x+d*m+u*f-l*g,e[n+2]=u*x+d*g+l*m-c*f,e[n+3]=d*x-l*f-c*m-u*g,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,s=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(s/2),m=c(r/2),g=c(i/2),x=c(s/2);switch(o){case"XYZ":this._x=m*d*f+u*g*x,this._y=u*g*f-m*d*x,this._z=u*d*x+m*g*f,this._w=u*d*f-m*g*x;break;case"YXZ":this._x=m*d*f+u*g*x,this._y=u*g*f-m*d*x,this._z=u*d*x-m*g*f,this._w=u*d*f+m*g*x;break;case"ZXY":this._x=m*d*f-u*g*x,this._y=u*g*f+m*d*x,this._z=u*d*x+m*g*f,this._w=u*d*f-m*g*x;break;case"ZYX":this._x=m*d*f-u*g*x,this._y=u*g*f+m*d*x,this._z=u*d*x-m*g*f,this._w=u*d*f+m*g*x;break;case"YZX":this._x=m*d*f+u*g*x,this._y=u*g*f+m*d*x,this._z=u*d*x-m*g*f,this._w=u*d*f-m*g*x;break;case"XZY":this._x=m*d*f-u*g*x,this._y=u*g*f-m*d*x,this._z=u*d*x+m*g*f,this._w=u*d*f+m*g*x;break;default:mn("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],s=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],m=r+l+f;if(m>0){const g=.5/Math.sqrt(m+1);this._w=.25/g,this._x=(d-c)*g,this._y=(s-u)*g,this._z=(o-i)*g}else if(r>l&&r>f){const g=2*Math.sqrt(1+r-l-f);this._w=(d-c)/g,this._x=.25*g,this._y=(i+o)/g,this._z=(s+u)/g}else if(l>f){const g=2*Math.sqrt(1+l-r-f);this._w=(s-u)/g,this._x=(i+o)/g,this._y=.25*g,this._z=(c+d)/g}else{const g=2*Math.sqrt(1+f-r-l);this._w=(o-i)/g,this._x=(s+u)/g,this._y=(c+d)/g,this._z=.25*g}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(Pn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,s=e._z,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-s*c,this._y=i*d+o*c+s*l-r*u,this._z=s*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-s*u,this._onChangeCallback(),this}slerp(e,n){if(n<=0)return this;if(n>=1)return this.copy(e);let r=e._x,i=e._y,s=e._z,o=e._w,l=this.dot(e);l<0&&(r=-r,i=-i,s=-s,o=-o,l=-l);let c=1-n;if(l<.9995){const u=Math.acos(l),d=Math.sin(u);c=Math.sin(c*u)/d,n=Math.sin(n*u)/d,this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+s*n,this._w=this._w*c+o*n,this._onChangeCallback()}else this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+s*n,this._w=this._w*c+o*n,this.normalize();return this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),s=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(n),s*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},ot=class QZ{constructor(e=0,n=0,r=0){QZ.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(wH.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(wH.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[3]*r+s[6]*i,this.y=s[1]*n+s[4]*r+s[7]*i,this.z=s[2]*n+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=e.elements,o=1/(s[3]*n+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*n+s[4]*r+s[8]*i+s[12])*o,this.y=(s[1]*n+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*n+s[6]*r+s[10]*i+s[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,s=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-s*i),f=2*(s*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-s*f,this.z=i+c*f+s*d-o*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i,this.y=s[1]*n+s[5]*r+s[9]*i,this.z=s[2]*n+s[6]*r+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Pn(this.x,e.x,n.x),this.y=Pn(this.y,e.y,n.y),this.z=Pn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=Pn(this.x,e,n),this.y=Pn(this.y,e,n),this.z=Pn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Pn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,s=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-s*l,this.y=s*o-r*c,this.z=r*l-i*o,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return EA.copy(this).projectOnVector(e),this.sub(EA)}reflect(e){return this.sub(EA.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(Pn(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 EA=new ot,wH=new qf;let Tn=class ZZ{constructor(e,n,r,i,s,o,l,c,u){ZZ.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,o,l,c,u)}set(e,n,r,i,s,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=s,d[5]=c,d[6]=r,d[7]=o,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],m=r[2],g=r[5],x=r[8],y=i[0],b=i[3],v=i[6],N=i[1],S=i[4],T=i[7],E=i[2],k=i[5],C=i[8];return s[0]=o*y+l*N+c*E,s[3]=o*b+l*S+c*k,s[6]=o*v+l*T+c*C,s[1]=u*y+d*N+f*E,s[4]=u*b+d*S+f*k,s[7]=u*v+d*T+f*C,s[2]=m*y+g*N+x*E,s[5]=m*b+g*S+x*k,s[8]=m*v+g*T+x*C,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*s*d+r*l*c+i*s*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,m=l*c-d*s,g=u*s-o*c,x=n*f+r*m+i*g;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/x;return e[0]=f*y,e[1]=(i*u-d*r)*y,e[2]=(l*r-i*o)*y,e[3]=m*y,e[4]=(d*n-i*c)*y,e[5]=(i*s-l*n)*y,e[6]=g*y,e[7]=(r*c-u*n)*y,e[8]=(o*n-r*s)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,s,o,l){const c=Math.cos(s),u=Math.sin(s);return this.set(r*c,r*u,-r*(c*o+u*l)+o+e,-i*u,i*c,-i*(-u*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(TA.makeScale(e,n)),this}rotate(e){return this.premultiply(TA.makeRotation(-e)),this}translate(e,n){return this.premultiply(TA.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 TA=new Tn,SH=new Tn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),NH=new Tn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function o3e(){const t={enabled:!0,workingColorSpace:wg,spaces:{},convert:function(i,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===pr&&(i.r=nu(i.r),i.g=nu(i.g),i.b=nu(i.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===pr&&(i.r=eg(i.r),i.g=eg(i.g),i.b=eg(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===vd?SS:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,o){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return z0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return z0("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,s)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return t.define({[wg]:{primaries:e,whitePoint:r,transfer:SS,toXYZ:SH,fromXYZ:NH,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:vo},outputColorSpaceConfig:{drawingBufferColorSpace:vo}},[vo]:{primaries:e,whitePoint:r,transfer:pr,toXYZ:SH,fromXYZ:NH,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:vo}}}),t}const Yn=o3e();function nu(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function eg(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Km,l3e=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{Km===void 0&&(Km=MS("canvas")),Km.width=e.width,Km.height=e.height;const i=Km.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=Km}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=MS("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=nu(s[o]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(nu(n[r]/255)*255):n[r]=nu(n[r]);return{data:n,width:e.width,height:e.height}}else return mn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},c3e=0,jO=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:c3e++}),this.uuid=Iy(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,l=i.length;o<l;o++)i[o].isDataTexture?s.push(CA(i[o].image)):s.push(CA(i[o]))}else s=CA(i);r.url=s}return n||(e.images[this.uuid]=r),r}};function CA(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?l3e.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(mn("Texture: Unable to serialize Texture."),{})}let u3e=0;const AA=new ot;let pl=class rw extends om{constructor(e=rw.DEFAULT_IMAGE,n=rw.DEFAULT_MAPPING,r=Wc,i=Wc,s=Ao,o=df,l=rl,c=Gl,u=rw.DEFAULT_ANISOTROPY,d=vd){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:u3e++}),this.uuid=Iy(),this.name="",this.source=new jO(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new Nn(0,0),this.repeat=new Nn(1,1),this.center=new Nn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Tn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(AA).x}get height(){return this.source.getSize(AA).y}get depth(){return this.source.getSize(AA).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){mn(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){mn(`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!==UZ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case pP:e.x=e.x-Math.floor(e.x);break;case Wc:e.x=e.x<0?0:1;break;case gP: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 pP:e.y=e.y-Math.floor(e.y);break;case Wc:e.y=e.y<0?0:1;break;case gP: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++}};pl.DEFAULT_IMAGE=null;pl.DEFAULT_MAPPING=UZ;pl.DEFAULT_ANISOTROPY=1;let Si=class JZ{constructor(e=0,n=0,r=0,i=1){JZ.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*s,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*s,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*s,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,s;const c=e.elements,u=c[0],d=c[4],f=c[8],m=c[1],g=c[5],x=c[9],y=c[2],b=c[6],v=c[10];if(Math.abs(d-m)<.01&&Math.abs(f-y)<.01&&Math.abs(x-b)<.01){if(Math.abs(d+m)<.1&&Math.abs(f+y)<.1&&Math.abs(x+b)<.1&&Math.abs(u+g+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const S=(u+1)/2,T=(g+1)/2,E=(v+1)/2,k=(d+m)/4,C=(f+y)/4,D=(x+b)/4;return S>T&&S>E?S<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(S),i=k/r,s=C/r):T>E?T<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(T),r=k/i,s=D/i):E<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(E),r=C/s,i=D/s),this.set(r,i,s,n),this}let N=Math.sqrt((b-x)*(b-x)+(f-y)*(f-y)+(m-d)*(m-d));return Math.abs(N)<.001&&(N=1),this.x=(b-x)/N,this.y=(f-y)/N,this.z=(m-d)/N,this.w=Math.acos((u+g+v-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Pn(this.x,e.x,n.x),this.y=Pn(this.y,e.y,n.y),this.z=Pn(this.z,e.z,n.z),this.w=Pn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=Pn(this.x,e,n),this.y=Pn(this.y,e,n),this.z=Pn(this.z,e,n),this.w=Pn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Pn(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}},d3e=class extends om{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ao,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 Si(0,0,e,n),this.scissorTest=!1,this.viewport=new Si(0,0,e,n);const i={width:e,height:n,depth:r.depth},s=new pl(i);this.textures=[];const o=r.count;for(let l=0;l<o;l++)this.textures[l]=s.clone(),this.textures[l].isRenderTargetTexture=!0,this.textures[l].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const n={minFilter:Ao,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(n.mapping=e.mapping),e.wrapS!==void 0&&(n.wrapS=e.wrapS),e.wrapT!==void 0&&(n.wrapT=e.wrapT),e.wrapR!==void 0&&(n.wrapR=e.wrapR),e.magFilter!==void 0&&(n.magFilter=e.magFilter),e.minFilter!==void 0&&(n.minFilter=e.minFilter),e.format!==void 0&&(n.format=e.format),e.type!==void 0&&(n.type=e.type),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(n.colorSpace=e.colorSpace),e.flipY!==void 0&&(n.flipY=e.flipY),e.generateMipmaps!==void 0&&(n.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(n.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(n)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,n,r=1){if(this.width!==e||this.height!==n||this.depth!==r){this.width=e,this.height=n,this.depth=r;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=e,this.textures[i].image.height=n,this.textures[i].image.depth=r,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const i=Object.assign({},e.textures[n].image);this.textures[n].source=new jO(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"})}},Wf=class extends d3e{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},eJ=class extends pl{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=Xs,this.minFilter=Xs,this.wrapR=Wc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},h3e=class extends pl{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=Xs,this.minFilter=Xs,this.wrapR=Wc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Kf=class{constructor(e=new ot(1/0,1/0,1/0),n=new ot(-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(Go.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Go.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=Go.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const s=r.getAttribute("position");if(n===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,l=s.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,Go):Go.fromBufferAttribute(s,o),Go.applyMatrix4(e.matrixWorld),this.expandByPoint(Go);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),E_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),E_.copy(r.boundingBox)),E_.applyMatrix4(e.matrixWorld),this.union(E_)}const i=e.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],n);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Go),Go.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(ub),T_.subVectors(this.max,ub),Xm.subVectors(e.a,ub),Ym.subVectors(e.b,ub),Qm.subVectors(e.c,ub),Xu.subVectors(Ym,Xm),Yu.subVectors(Qm,Ym),Oh.subVectors(Xm,Qm);let n=[0,-Xu.z,Xu.y,0,-Yu.z,Yu.y,0,-Oh.z,Oh.y,Xu.z,0,-Xu.x,Yu.z,0,-Yu.x,Oh.z,0,-Oh.x,-Xu.y,Xu.x,0,-Yu.y,Yu.x,0,-Oh.y,Oh.x,0];return!kA(n,Xm,Ym,Qm,T_)||(n=[1,0,0,0,1,0,0,0,1],!kA(n,Xm,Ym,Qm,T_))?!1:(C_.crossVectors(Xu,Yu),n=[C_.x,C_.y,C_.z],kA(n,Xm,Ym,Qm,T_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Go).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Go).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(vc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),vc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),vc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),vc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),vc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),vc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),vc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),vc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(vc),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}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 vc=[new ot,new ot,new ot,new ot,new ot,new ot,new ot,new ot],Go=new ot,E_=new Kf,Xm=new ot,Ym=new ot,Qm=new ot,Xu=new ot,Yu=new ot,Oh=new ot,ub=new ot,T_=new ot,C_=new ot,Lh=new ot;function kA(t,e,n,r,i){for(let s=0,o=t.length-3;s<=o;s+=3){Lh.fromArray(t,s);const l=i.x*Math.abs(Lh.x)+i.y*Math.abs(Lh.y)+i.z*Math.abs(Lh.z),c=e.dot(Lh),u=n.dot(Lh),d=r.dot(Lh);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const f3e=new Kf,db=new ot,jA=new ot;let HN=class{constructor(e=new ot,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):f3e.setFromPoints(e).getCenter(r);let i=0;for(let s=0,o=e.length;s<o;s++)i=Math.max(i,r.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;db.subVectors(e,this.center);const n=db.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(db,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):(jA.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(db.copy(e.center).add(jA)),this.expandByPoint(db.copy(e.center).sub(jA))),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 _c=new ot,PA=new ot,A_=new ot,Qu=new ot,RA=new ot,k_=new ot,DA=new ot;let PO=class{constructor(e=new ot,n=new ot(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,_c)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=_c.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(_c.copy(this.origin).addScaledVector(this.direction,n),_c.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){PA.copy(e).add(n).multiplyScalar(.5),A_.copy(n).sub(e).normalize(),Qu.copy(this.origin).sub(PA);const s=e.distanceTo(n)*.5,o=-this.direction.dot(A_),l=Qu.dot(this.direction),c=-Qu.dot(A_),u=Qu.lengthSq(),d=Math.abs(1-o*o);let f,m,g,x;if(d>0)if(f=o*c-l,m=o*l-c,x=s*d,f>=0)if(m>=-x)if(m<=x){const y=1/d;f*=y,m*=y,g=f*(f+o*m+2*l)+m*(o*f+m+2*c)+u}else m=s,f=Math.max(0,-(o*m+l)),g=-f*f+m*(m+2*c)+u;else m=-s,f=Math.max(0,-(o*m+l)),g=-f*f+m*(m+2*c)+u;else m<=-x?(f=Math.max(0,-(-o*s+l)),m=f>0?-s:Math.min(Math.max(-s,-c),s),g=-f*f+m*(m+2*c)+u):m<=x?(f=0,m=Math.min(Math.max(-s,-c),s),g=m*(m+2*c)+u):(f=Math.max(0,-(o*s+l)),m=f>0?s:Math.min(Math.max(-s,-c),s),g=-f*f+m*(m+2*c)+u);else m=o>0?-s:s,f=Math.max(0,-(o*m+l)),g=-f*f+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(PA).addScaledVector(A_,m),g}intersectSphere(e,n){_c.subVectors(e.center,this.origin);const r=_c.dot(this.direction),i=_c.dot(_c)-r*r,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-i),l=r-o,c=r+o;return c<0?null:l<0?this.at(c,n):this.at(l,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,s,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,m=this.origin;return u>=0?(r=(e.min.x-m.x)*u,i=(e.max.x-m.x)*u):(r=(e.max.x-m.x)*u,i=(e.min.x-m.x)*u),d>=0?(s=(e.min.y-m.y)*d,o=(e.max.y-m.y)*d):(s=(e.max.y-m.y)*d,o=(e.min.y-m.y)*d),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-m.z)*f,c=(e.max.z-m.z)*f):(l=(e.max.z-m.z)*f,c=(e.min.z-m.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,_c)!==null}intersectTriangle(e,n,r,i,s){RA.subVectors(n,e),k_.subVectors(r,e),DA.crossVectors(RA,k_);let o=this.direction.dot(DA),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Qu.subVectors(this.origin,e);const c=l*this.direction.dot(k_.crossVectors(Qu,k_));if(c<0)return null;const u=l*this.direction.dot(RA.cross(Qu));if(u<0||c+u>o)return null;const d=-l*Qu.dot(DA);return d<0?null:this.at(d/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Ci=class qP{constructor(e,n,r,i,s,o,l,c,u,d,f,m,g,x,y,b){qP.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,o,l,c,u,d,f,m,g,x,y,b)}set(e,n,r,i,s,o,l,c,u,d,f,m,g,x,y,b){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=s,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=f,v[14]=m,v[3]=g,v[7]=x,v[11]=y,v[15]=b,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new qP().fromArray(this.elements)}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){const n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,r){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,n,r){return this.set(e.x,n.x,r.x,0,e.y,n.y,r.y,0,e.z,n.z,r.z,0,0,0,0,1),this}extractRotation(e){const n=this.elements,r=e.elements,i=1/Zm.setFromMatrixColumn(e,0).length(),s=1/Zm.setFromMatrixColumn(e,1).length(),o=1/Zm.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*s,n[5]=r[5]*s,n[6]=r[6]*s,n[7]=0,n[8]=r[8]*o,n[9]=r[9]*o,n[10]=r[10]*o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,s=e.z,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const m=o*d,g=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=g+x*u,n[5]=m-y*u,n[9]=-l*c,n[2]=y-m*u,n[6]=x+g*u,n[10]=o*c}else if(e.order==="YXZ"){const m=c*d,g=c*f,x=u*d,y=u*f;n[0]=m+y*l,n[4]=x*l-g,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=g*l-x,n[6]=y+m*l,n[10]=o*c}else if(e.order==="ZXY"){const m=c*d,g=c*f,x=u*d,y=u*f;n[0]=m-y*l,n[4]=-o*f,n[8]=x+g*l,n[1]=g+x*l,n[5]=o*d,n[9]=y-m*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const m=o*d,g=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=x*u-g,n[8]=m*u+y,n[1]=c*f,n[5]=y*u+m,n[9]=g*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const m=o*c,g=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=y-m*f,n[8]=x*f+g,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=g*f+x,n[10]=m-y*f}else if(e.order==="XZY"){const m=o*c,g=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=m*f+y,n[5]=o*d,n[9]=g*f-x,n[2]=x*f-g,n[6]=l*d,n[10]=y*f+m}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(m3e,e,p3e)}lookAt(e,n,r){const i=this.elements;return Is.subVectors(e,n),Is.lengthSq()===0&&(Is.z=1),Is.normalize(),Zu.crossVectors(r,Is),Zu.lengthSq()===0&&(Math.abs(r.z)===1?Is.x+=1e-4:Is.z+=1e-4,Is.normalize(),Zu.crossVectors(r,Is)),Zu.normalize(),j_.crossVectors(Is,Zu),i[0]=Zu.x,i[4]=j_.x,i[8]=Is.x,i[1]=Zu.y,i[5]=j_.y,i[9]=Is.y,i[2]=Zu.z,i[6]=j_.z,i[10]=Is.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],m=r[9],g=r[13],x=r[2],y=r[6],b=r[10],v=r[14],N=r[3],S=r[7],T=r[11],E=r[15],k=i[0],C=i[4],D=i[8],A=i[12],R=i[1],F=i[5],O=i[9],q=i[13],j=i[2],G=i[6],Y=i[10],K=i[14],Z=i[3],te=i[7],ne=i[11],z=i[15];return s[0]=o*k+l*R+c*j+u*Z,s[4]=o*C+l*F+c*G+u*te,s[8]=o*D+l*O+c*Y+u*ne,s[12]=o*A+l*q+c*K+u*z,s[1]=d*k+f*R+m*j+g*Z,s[5]=d*C+f*F+m*G+g*te,s[9]=d*D+f*O+m*Y+g*ne,s[13]=d*A+f*q+m*K+g*z,s[2]=x*k+y*R+b*j+v*Z,s[6]=x*C+y*F+b*G+v*te,s[10]=x*D+y*O+b*Y+v*ne,s[14]=x*A+y*q+b*K+v*z,s[3]=N*k+S*R+T*j+E*Z,s[7]=N*C+S*F+T*G+E*te,s[11]=N*D+S*O+T*Y+E*ne,s[15]=N*A+S*q+T*K+E*z,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],s=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],m=e[10],g=e[14],x=e[3],y=e[7],b=e[11],v=e[15];return x*(+s*c*f-i*u*f-s*l*m+r*u*m+i*l*g-r*c*g)+y*(+n*c*g-n*u*m+s*o*m-i*o*g+i*u*d-s*c*d)+b*(+n*u*f-n*l*g-s*o*f+r*o*g+s*l*d-r*u*d)+v*(-i*l*d-n*c*f+n*l*m+i*o*f-r*o*m+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],m=e[10],g=e[11],x=e[12],y=e[13],b=e[14],v=e[15],N=f*b*u-y*m*u+y*c*g-l*b*g-f*c*v+l*m*v,S=x*m*u-d*b*u-x*c*g+o*b*g+d*c*v-o*m*v,T=d*y*u-x*f*u+x*l*g-o*y*g-d*l*v+o*f*v,E=x*f*c-d*y*c-x*l*m+o*y*m+d*l*b-o*f*b,k=n*N+r*S+i*T+s*E;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/k;return e[0]=N*C,e[1]=(y*m*s-f*b*s-y*i*g+r*b*g+f*i*v-r*m*v)*C,e[2]=(l*b*s-y*c*s+y*i*u-r*b*u-l*i*v+r*c*v)*C,e[3]=(f*c*s-l*m*s-f*i*u+r*m*u+l*i*g-r*c*g)*C,e[4]=S*C,e[5]=(d*b*s-x*m*s+x*i*g-n*b*g-d*i*v+n*m*v)*C,e[6]=(x*c*s-o*b*s-x*i*u+n*b*u+o*i*v-n*c*v)*C,e[7]=(o*m*s-d*c*s+d*i*u-n*m*u-o*i*g+n*c*g)*C,e[8]=T*C,e[9]=(x*f*s-d*y*s-x*r*g+n*y*g+d*r*v-n*f*v)*C,e[10]=(o*y*s-x*l*s+x*r*u-n*y*u-o*r*v+n*l*v)*C,e[11]=(d*l*s-o*f*s-d*r*u+n*f*u+o*r*g-n*l*g)*C,e[12]=E*C,e[13]=(d*y*i-x*f*i+x*r*m-n*y*m-d*r*b+n*f*b)*C,e[14]=(x*l*i-o*y*i-x*r*c+n*y*c+o*r*b-n*l*b)*C,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*m+n*l*m)*C,this}scale(e){const n=this.elements,r=e.x,i=e.y,s=e.z;return n[0]*=r,n[4]*=i,n[8]*=s,n[1]*=r,n[5]*=i,n[9]*=s,n[2]*=r,n[6]*=i,n[10]*=s,n[3]*=r,n[7]*=i,n[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),s=1-r,o=e.x,l=e.y,c=e.z,u=s*o,d=s*l;return this.set(u*o+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*o,0,u*c-i*l,d*c+i*o,s*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,s,o){return this.set(1,r,s,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,s=n._x,o=n._y,l=n._z,c=n._w,u=s+s,d=o+o,f=l+l,m=s*u,g=s*d,x=s*f,y=o*d,b=o*f,v=l*f,N=c*u,S=c*d,T=c*f,E=r.x,k=r.y,C=r.z;return i[0]=(1-(y+v))*E,i[1]=(g+T)*E,i[2]=(x-S)*E,i[3]=0,i[4]=(g-T)*k,i[5]=(1-(m+v))*k,i[6]=(b+N)*k,i[7]=0,i[8]=(x+S)*C,i[9]=(b-N)*C,i[10]=(1-(m+y))*C,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let s=Zm.set(i[0],i[1],i[2]).length();const o=Zm.set(i[4],i[5],i[6]).length(),l=Zm.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],qo.copy(this);const u=1/s,d=1/o,f=1/l;return qo.elements[0]*=u,qo.elements[1]*=u,qo.elements[2]*=u,qo.elements[4]*=d,qo.elements[5]*=d,qo.elements[6]*=d,qo.elements[8]*=f,qo.elements[9]*=f,qo.elements[10]*=f,n.setFromRotationMatrix(qo),r.x=s,r.y=o,r.z=l,this}makePerspective(e,n,r,i,s,o,l=Rl,c=!1){const u=this.elements,d=2*s/(n-e),f=2*s/(r-i),m=(n+e)/(n-e),g=(r+i)/(r-i);let x,y;if(c)x=s/(o-s),y=o*s/(o-s);else if(l===Rl)x=-(o+s)/(o-s),y=-2*o*s/(o-s);else if(l===NS)x=-o/(o-s),y=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=m,u[12]=0,u[1]=0,u[5]=f,u[9]=g,u[13]=0,u[2]=0,u[6]=0,u[10]=x,u[14]=y,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,s,o,l=Rl,c=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),m=-(n+e)/(n-e),g=-(r+i)/(r-i);let x,y;if(c)x=1/(o-s),y=o/(o-s);else if(l===Rl)x=-2/(o-s),y=-(o+s)/(o-s);else if(l===NS)x=-1/(o-s),y=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=0,u[12]=m,u[1]=0,u[5]=f,u[9]=0,u[13]=g,u[2]=0,u[6]=0,u[10]=x,u[14]=y,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}};const Zm=new ot,qo=new Ci,m3e=new ot(0,0,0),p3e=new ot(1,1,1),Zu=new ot,j_=new ot,Is=new ot,MH=new Ci,EH=new qf;let th=class tJ{constructor(e=0,n=0,r=0,i=tJ.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,s=i[0],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],m=i[6],g=i[10];switch(n){case"XYZ":this._y=Math.asin(Pn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,g),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(m,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Pn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,g),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(Pn(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-f,g),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Pn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(m,g),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(Pn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(l,g));break;case"XZY":this._z=Math.asin(-Pn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(m,u),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-d,g),this._y=0);break;default:mn("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return MH.makeRotationFromQuaternion(e),this.setFromRotationMatrix(MH,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return EH.setFromEuler(this),this.setFromQuaternion(EH,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}};th.DEFAULT_ORDER="XYZ";let nJ=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}},g3e=0;const TH=new ot,Jm=new qf,wc=new Ci,P_=new ot,hb=new ot,x3e=new ot,b3e=new qf,CH=new ot(1,0,0),AH=new ot(0,1,0),kH=new ot(0,0,1),jH={type:"added"},y3e={type:"removed"},ep={type:"childadded",child:null},OA={type:"childremoved",child:null};let eo=class iw extends om{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:g3e++}),this.uuid=Iy(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=iw.DEFAULT_UP.clone();const e=new ot,n=new th,r=new qf,i=new ot(1,1,1);function s(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(s),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ci},normalMatrix:{value:new Tn}}),this.matrix=new Ci,this.matrixWorld=new Ci,this.matrixAutoUpdate=iw.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=iw.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new nJ,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.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 Jm.setFromAxisAngle(e,n),this.quaternion.multiply(Jm),this}rotateOnWorldAxis(e,n){return Jm.setFromAxisAngle(e,n),this.quaternion.premultiply(Jm),this}rotateX(e){return this.rotateOnAxis(CH,e)}rotateY(e){return this.rotateOnAxis(AH,e)}rotateZ(e){return this.rotateOnAxis(kH,e)}translateOnAxis(e,n){return TH.copy(e).applyQuaternion(this.quaternion),this.position.add(TH.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(CH,e)}translateY(e){return this.translateOnAxis(AH,e)}translateZ(e){return this.translateOnAxis(kH,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(wc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?P_.copy(e):P_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),hb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?wc.lookAt(hb,P_,this.up):wc.lookAt(P_,hb,this.up),this.quaternion.setFromRotationMatrix(wc),i&&(wc.extractRotation(i.matrixWorld),Jm.setFromRotationMatrix(wc),this.quaternion.premultiply(Jm.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(hi("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(jH),ep.child=e,this.dispatchEvent(ep),ep.child=null):hi("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(y3e),OA.child=e,this.dispatchEvent(OA),OA.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),wc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),wc.multiply(e.parent.matrixWorld)),e.applyMatrix4(wc),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(jH),ep.child=e,this.dispatchEvent(ep),ep.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hb,e,x3e),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hb,b3e,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(e)}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(l=>({...l,boundingBox:l.boundingBox?l.boundingBox.toJSON():void 0,boundingSphere:l.boundingSphere?l.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(l=>({...l})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];s(e.shapes,f)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(s(e.materials,this.material[c]));i.material=l}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(s(e.animations,c))}}if(n){const l=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),f=o(e.shapes),m=o(e.skeletons),g=o(e.animations),x=o(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),m.length>0&&(r.skeletons=m),g.length>0&&(r.animations=g),x.length>0&&(r.nodes=x)}return r.object=i,r;function o(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}};eo.DEFAULT_UP=new ot(0,1,0);eo.DEFAULT_MATRIX_AUTO_UPDATE=!0;eo.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Wo=new ot,Sc=new ot,LA=new ot,Nc=new ot,tp=new ot,np=new ot,PH=new ot,IA=new ot,FA=new ot,UA=new ot,zA=new Si,BA=new Si,$A=new Si;let fb=class Dp{constructor(e=new ot,n=new ot,r=new ot){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Wo.subVectors(e,n),i.cross(Wo);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,n,r,i,s){Wo.subVectors(i,n),Sc.subVectors(r,n),LA.subVectors(e,n);const o=Wo.dot(Wo),l=Wo.dot(Sc),c=Wo.dot(LA),u=Sc.dot(Sc),d=Sc.dot(LA),f=o*u-l*l;if(f===0)return s.set(0,0,0),null;const m=1/f,g=(u*c-l*d)*m,x=(o*d-l*c)*m;return s.set(1-g-x,x,g)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Nc)===null?!1:Nc.x>=0&&Nc.y>=0&&Nc.x+Nc.y<=1}static getInterpolation(e,n,r,i,s,o,l,c){return this.getBarycoord(e,n,r,i,Nc)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,Nc.x),c.addScaledVector(o,Nc.y),c.addScaledVector(l,Nc.z),c)}static getInterpolatedAttribute(e,n,r,i,s,o){return zA.setScalar(0),BA.setScalar(0),$A.setScalar(0),zA.fromBufferAttribute(e,n),BA.fromBufferAttribute(e,r),$A.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(zA,s.x),o.addScaledVector(BA,s.y),o.addScaledVector($A,s.z),o}static isFrontFacing(e,n,r,i){return Wo.subVectors(r,n),Sc.subVectors(e,n),Wo.cross(Sc).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Wo.subVectors(this.c,this.b),Sc.subVectors(this.a,this.b),Wo.cross(Sc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Dp.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Dp.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,s){return Dp.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return Dp.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Dp.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,s=this.c;let o,l;tp.subVectors(i,r),np.subVectors(s,r),IA.subVectors(e,r);const c=tp.dot(IA),u=np.dot(IA);if(c<=0&&u<=0)return n.copy(r);FA.subVectors(e,i);const d=tp.dot(FA),f=np.dot(FA);if(d>=0&&f<=d)return n.copy(i);const m=c*f-d*u;if(m<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(tp,o);UA.subVectors(e,s);const g=tp.dot(UA),x=np.dot(UA);if(x>=0&&g<=x)return n.copy(s);const y=g*u-c*x;if(y<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(np,l);const b=d*x-g*f;if(b<=0&&f-d>=0&&g-x>=0)return PH.subVectors(s,i),l=(f-d)/(f-d+(g-x)),n.copy(i).addScaledVector(PH,l);const v=1/(b+y+m);return o=y*v,l=m*v,n.copy(r).addScaledVector(tp,o).addScaledVector(np,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const rJ={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},Ju={h:0,s:0,l:0},R_={h:0,s:0,l:0};function HA(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 Rn=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=vo){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Yn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=Yn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Yn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=Yn.workingColorSpace){if(e=a3e(e,1),n=Pn(n,0,1),r=Pn(r,0,1),n===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+n):r+n-r*n,o=2*r-s;this.r=HA(o,s,e+1/3),this.g=HA(o,s,e),this.b=HA(o,s,e-1/3)}return Yn.colorSpaceToWorking(this,i),this}setStyle(e,n=vo){function r(s){s!==void 0&&parseFloat(s)<1&&mn("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=i[1],l=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,n);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:mn("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(s,16),n);mn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=vo){const r=rJ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):mn("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=nu(e.r),this.g=nu(e.g),this.b=nu(e.b),this}copyLinearToSRGB(e){return this.r=eg(e.r),this.g=eg(e.g),this.b=eg(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=vo){return Yn.workingToColorSpace(Aa.copy(this),e),Math.round(Pn(Aa.r*255,0,255))*65536+Math.round(Pn(Aa.g*255,0,255))*256+Math.round(Pn(Aa.b*255,0,255))}getHexString(e=vo){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Yn.workingColorSpace){Yn.workingToColorSpace(Aa.copy(this),n);const r=Aa.r,i=Aa.g,s=Aa.b,o=Math.max(r,i,s),l=Math.min(r,i,s);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const f=o-l;switch(u=d<=.5?f/(o+l):f/(2-o-l),o){case r:c=(i-s)/f+(i<s?6:0);break;case i:c=(s-r)/f+2;break;case s:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=Yn.workingColorSpace){return Yn.workingToColorSpace(Aa.copy(this),n),e.r=Aa.r,e.g=Aa.g,e.b=Aa.b,e}getStyle(e=vo){Yn.workingToColorSpace(Aa.copy(this),e);const n=Aa.r,r=Aa.g,i=Aa.b;return e!==vo?`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(Ju),this.setHSL(Ju.h+e,Ju.s+n,Ju.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(Ju),e.getHSL(R_);const r=MA(Ju.h,R_.h,n),i=MA(Ju.s,R_.s,n),s=MA(Ju.l,R_.l,n);return this.setHSL(r,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,s=e.elements;return this.r=s[0]*n+s[3]*r+s[6]*i,this.g=s[1]*n+s[4]*r+s[7]*i,this.b=s[2]*n+s[5]*r+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const Aa=new Rn;Rn.NAMES=rJ;let v3e=0,tx=class extends om{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:v3e++}),this.uuid=Iy(),this.name="",this.type="Material",this.blending=Jp,this.side=eh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=iP,this.blendDst=aP,this.blendEquation=Zh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Rn(0,0,0),this.blendAlpha=0,this.depthFunc=yg,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=xH,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Wm,this.stencilZFail=Wm,this.stencilZPass=Wm,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){mn(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){mn(`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!==Jp&&(r.blending=this.blending),this.side!==eh&&(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!==iP&&(r.blendSrc=this.blendSrc),this.blendDst!==aP&&(r.blendDst=this.blendDst),this.blendEquation!==Zh&&(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!==yg&&(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!==xH&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Wm&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Wm&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Wm&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const o=[];for(const l in s){const c=s[l];delete c.metadata,o.push(c)}return o}if(n){const s=i(e.textures),o=i(e.images);s.length>0&&(r.textures=s),o.length>0&&(r.images=o)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=n[s].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},RO=class extends tx{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Rn(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 th,this.combine=SO,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 yi=new ot,D_=new Nn;let _3e=0,ko=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:_3e++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=bH,this.updateRanges=[],this.gpuType=Kc,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)D_.fromBufferAttribute(this,n),D_.applyMatrix3(e),this.setXY(n,D_.x,D_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)yi.fromBufferAttribute(this,n),yi.applyMatrix3(e),this.setXYZ(n,yi.x,yi.y,yi.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)yi.fromBufferAttribute(this,n),yi.applyMatrix4(e),this.setXYZ(n,yi.x,yi.y,yi.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)yi.fromBufferAttribute(this,n),yi.applyNormalMatrix(e),this.setXYZ(n,yi.x,yi.y,yi.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)yi.fromBufferAttribute(this,n),yi.transformDirection(e),this.setXYZ(n,yi.x,yi.y,yi.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=cb(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=hs(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=cb(n,this.array)),n}setX(e,n){return this.normalized&&(n=hs(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=cb(n,this.array)),n}setY(e,n){return this.normalized&&(n=hs(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=cb(n,this.array)),n}setZ(e,n){return this.normalized&&(n=hs(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=cb(n,this.array)),n}setW(e,n){return this.normalized&&(n=hs(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=hs(n,this.array),r=hs(r,this.array)),this.array[e+0]=n,this.array[e+1]=r,this}setXYZ(e,n,r,i){return e*=this.itemSize,this.normalized&&(n=hs(n,this.array),r=hs(r,this.array),i=hs(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e*=this.itemSize,this.normalized&&(n=hs(n,this.array),r=hs(r,this.array),i=hs(i,this.array),s=hs(s,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==bH&&(e.usage=this.usage),e}},iJ=class extends ko{constructor(e,n,r){super(new Uint16Array(e),n,r)}},aJ=class extends ko{constructor(e,n,r){super(new Uint32Array(e),n,r)}},ol=class extends ko{constructor(e,n,r){super(new Float32Array(e),n,r)}},w3e=0;const fo=new Ci,VA=new eo,rp=new ot,Fs=new Kf,mb=new Kf,Ki=new ot;let ec=class sJ extends om{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:w3e++}),this.uuid=Iy(),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(XZ(e)?aJ:iJ)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new Tn().getNormalMatrix(e);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return fo.makeRotationFromQuaternion(e),this.applyMatrix4(fo),this}rotateX(e){return fo.makeRotationX(e),this.applyMatrix4(fo),this}rotateY(e){return fo.makeRotationY(e),this.applyMatrix4(fo),this}rotateZ(e){return fo.makeRotationZ(e),this.applyMatrix4(fo),this}translate(e,n,r){return fo.makeTranslation(e,n,r),this.applyMatrix4(fo),this}scale(e,n,r){return fo.makeScale(e,n,r),this.applyMatrix4(fo),this}lookAt(e){return VA.lookAt(e),VA.updateMatrix(),this.applyMatrix4(VA.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(rp).negate(),this.translate(rp.x,rp.y,rp.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,s=e.length;i<s;i++){const o=e[i];r.push(o.x,o.y,o.z||0)}this.setAttribute("position",new ol(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const s=e[i];n.setXYZ(i,s.x,s.y,s.z||0)}e.length>n.count&&mn("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 Kf);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){hi("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new ot(-1/0,-1/0,-1/0),new ot(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const s=n[r];Fs.setFromBufferAttribute(s),this.morphTargetsRelative?(Ki.addVectors(this.boundingBox.min,Fs.min),this.boundingBox.expandByPoint(Ki),Ki.addVectors(this.boundingBox.max,Fs.max),this.boundingBox.expandByPoint(Ki)):(this.boundingBox.expandByPoint(Fs.min),this.boundingBox.expandByPoint(Fs.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&hi('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 HN);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){hi("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new ot,1/0);return}if(e){const r=this.boundingSphere.center;if(Fs.setFromBufferAttribute(e),n)for(let s=0,o=n.length;s<o;s++){const l=n[s];mb.setFromBufferAttribute(l),this.morphTargetsRelative?(Ki.addVectors(Fs.min,mb.min),Fs.expandByPoint(Ki),Ki.addVectors(Fs.max,mb.max),Fs.expandByPoint(Ki)):(Fs.expandByPoint(mb.min),Fs.expandByPoint(mb.max))}Fs.getCenter(r);let i=0;for(let s=0,o=e.count;s<o;s++)Ki.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Ki));if(n)for(let s=0,o=n.length;s<o;s++){const l=n[s],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)Ki.fromBufferAttribute(l,u),c&&(rp.fromBufferAttribute(e,u),Ki.add(rp)),i=Math.max(i,r.distanceToSquared(Ki))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&hi('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){hi("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,s=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ko(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let D=0;D<r.count;D++)l[D]=new ot,c[D]=new ot;const u=new ot,d=new ot,f=new ot,m=new Nn,g=new Nn,x=new Nn,y=new ot,b=new ot;function v(D,A,R){u.fromBufferAttribute(r,D),d.fromBufferAttribute(r,A),f.fromBufferAttribute(r,R),m.fromBufferAttribute(s,D),g.fromBufferAttribute(s,A),x.fromBufferAttribute(s,R),d.sub(u),f.sub(u),g.sub(m),x.sub(m);const F=1/(g.x*x.y-x.x*g.y);isFinite(F)&&(y.copy(d).multiplyScalar(x.y).addScaledVector(f,-g.y).multiplyScalar(F),b.copy(f).multiplyScalar(g.x).addScaledVector(d,-x.x).multiplyScalar(F),l[D].add(y),l[A].add(y),l[R].add(y),c[D].add(b),c[A].add(b),c[R].add(b))}let N=this.groups;N.length===0&&(N=[{start:0,count:e.count}]);for(let D=0,A=N.length;D<A;++D){const R=N[D],F=R.start,O=R.count;for(let q=F,j=F+O;q<j;q+=3)v(e.getX(q+0),e.getX(q+1),e.getX(q+2))}const S=new ot,T=new ot,E=new ot,k=new ot;function C(D){E.fromBufferAttribute(i,D),k.copy(E);const A=l[D];S.copy(A),S.sub(E.multiplyScalar(E.dot(A))).normalize(),T.crossVectors(k,A);const F=T.dot(c[D])<0?-1:1;o.setXYZW(D,S.x,S.y,S.z,F)}for(let D=0,A=N.length;D<A;++D){const R=N[D],F=R.start,O=R.count;for(let q=F,j=F+O;q<j;q+=3)C(e.getX(q+0)),C(e.getX(q+1)),C(e.getX(q+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new ko(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,g=r.count;m<g;m++)r.setXYZ(m,0,0,0);const i=new ot,s=new ot,o=new ot,l=new ot,c=new ot,u=new ot,d=new ot,f=new ot;if(e)for(let m=0,g=e.count;m<g;m+=3){const x=e.getX(m+0),y=e.getX(m+1),b=e.getX(m+2);i.fromBufferAttribute(n,x),s.fromBufferAttribute(n,y),o.fromBufferAttribute(n,b),d.subVectors(o,s),f.subVectors(i,s),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,b),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(y,c.x,c.y,c.z),r.setXYZ(b,u.x,u.y,u.z)}else for(let m=0,g=n.count;m<g;m+=3)i.fromBufferAttribute(n,m+0),s.fromBufferAttribute(n,m+1),o.fromBufferAttribute(n,m+2),d.subVectors(o,s),f.subVectors(i,s),d.cross(f),r.setXYZ(m+0,d.x,d.y,d.z),r.setXYZ(m+1,d.x,d.y,d.z),r.setXYZ(m+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Ki.fromBufferAttribute(e,n),Ki.normalize(),e.setXYZ(n,Ki.x,Ki.y,Ki.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,m=new u.constructor(c.length*d);let g=0,x=0;for(let y=0,b=c.length;y<b;y++){l.isInterleavedBufferAttribute?g=c[y]*l.data.stride+l.offset:g=c[y]*d;for(let v=0;v<d;v++)m[x++]=u[g++]}return new ko(m,d,f)}if(this.index===null)return mn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new sJ,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const s=this.morphAttributes;for(const l in s){const c=[],u=s[l];for(let d=0,f=u.length;d<f;d++){const m=u[d],g=e(m,r);c.push(g)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let s=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,m=u.length;f<m;f++){const g=u[f];d.push(g.toJSON(e.data))}d.length>0&&(i[c]=d,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere=l.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const s=e.morphAttributes;for(const u in s){const d=[],f=s[u];for(let m=0,g=f.length;m<g;m++)d.push(f[m].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let u=0,d=o.length;u<d;u++){const f=o[u];this.addGroup(f.start,f.count,f.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const RH=new Ci,Ih=new PO,O_=new HN,DH=new ot,L_=new ot,I_=new ot,F_=new ot,GA=new ot,U_=new ot,OH=new ot,z_=new ot;let ql=class extends eo{constructor(e=new ec,n=new RO){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const l=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(s&&l){U_.set(0,0,0);for(let c=0,u=s.length;c<u;c++){const d=l[c],f=s[c];d!==0&&(GA.fromBufferAttribute(f,e),o?U_.addScaledVector(GA,d):U_.addScaledVector(GA.sub(n),d))}n.add(U_)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),O_.copy(r.boundingSphere),O_.applyMatrix4(s),Ih.copy(e.ray).recast(e.near),!(O_.containsPoint(Ih.origin)===!1&&(Ih.intersectSphere(O_,DH)===null||Ih.origin.distanceToSquared(DH)>(e.far-e.near)**2))&&(RH.copy(s).invert(),Ih.copy(e.ray).applyMatrix4(RH),!(r.boundingBox!==null&&Ih.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Ih)))}_computeIntersections(e,n,r){let i;const s=this.geometry,o=this.material,l=s.index,c=s.attributes.position,u=s.attributes.uv,d=s.attributes.uv1,f=s.attributes.normal,m=s.groups,g=s.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,y=m.length;x<y;x++){const b=m[x],v=o[b.materialIndex],N=Math.max(b.start,g.start),S=Math.min(l.count,Math.min(b.start+b.count,g.start+g.count));for(let T=N,E=S;T<E;T+=3){const k=l.getX(T),C=l.getX(T+1),D=l.getX(T+2);i=B_(this,v,e,r,u,d,f,k,C,D),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,g.start),y=Math.min(l.count,g.start+g.count);for(let b=x,v=y;b<v;b+=3){const N=l.getX(b),S=l.getX(b+1),T=l.getX(b+2);i=B_(this,o,e,r,u,d,f,N,S,T),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,y=m.length;x<y;x++){const b=m[x],v=o[b.materialIndex],N=Math.max(b.start,g.start),S=Math.min(c.count,Math.min(b.start+b.count,g.start+g.count));for(let T=N,E=S;T<E;T+=3){const k=T,C=T+1,D=T+2;i=B_(this,v,e,r,u,d,f,k,C,D),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,g.start),y=Math.min(c.count,g.start+g.count);for(let b=x,v=y;b<v;b+=3){const N=b,S=b+1,T=b+2;i=B_(this,o,e,r,u,d,f,N,S,T),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}};function S3e(t,e,n,r,i,s,o,l){let c;if(e.side===_s?c=r.intersectTriangle(o,s,i,!0,l):c=r.intersectTriangle(i,s,o,e.side===eh,l),c===null)return null;z_.copy(l),z_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(z_);return u<n.near||u>n.far?null:{distance:u,point:z_.clone(),object:t}}function B_(t,e,n,r,i,s,o,l,c,u){t.getVertexPosition(l,L_),t.getVertexPosition(c,I_),t.getVertexPosition(u,F_);const d=S3e(t,e,n,r,L_,I_,F_,OH);if(d){const f=new ot;fb.getBarycoord(OH,L_,I_,F_,f),i&&(d.uv=fb.getInterpolatedAttribute(i,l,c,u,f,new Nn)),s&&(d.uv1=fb.getInterpolatedAttribute(s,l,c,u,f,new Nn)),o&&(d.normal=fb.getInterpolatedAttribute(o,l,c,u,f,new ot),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const m={a:l,b:c,c:u,normal:new ot,materialIndex:0};fb.getNormal(L_,I_,F_,m.normal),d.face=m,d.barycoord=f}return d}let DO=class oJ extends ec{constructor(e=1,n=1,r=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:s,depthSegments:o};const l=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const c=[],u=[],d=[],f=[];let m=0,g=0;x("z","y","x",-1,-1,r,n,e,o,s,0),x("z","y","x",1,-1,r,n,-e,o,s,1),x("x","z","y",1,1,e,r,n,i,o,2),x("x","z","y",1,-1,e,r,-n,i,o,3),x("x","y","z",1,-1,e,n,r,i,s,4),x("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(c),this.setAttribute("position",new ol(u,3)),this.setAttribute("normal",new ol(d,3)),this.setAttribute("uv",new ol(f,2));function x(y,b,v,N,S,T,E,k,C,D,A){const R=T/C,F=E/D,O=T/2,q=E/2,j=k/2,G=C+1,Y=D+1;let K=0,Z=0;const te=new ot;for(let ne=0;ne<Y;ne++){const z=ne*F-q;for(let W=0;W<G;W++){const se=W*R-O;te[y]=se*N,te[b]=z*S,te[v]=j,u.push(te.x,te.y,te.z),te[y]=0,te[b]=0,te[v]=k>0?1:-1,d.push(te.x,te.y,te.z),f.push(W/C),f.push(1-ne/D),K+=1}}for(let ne=0;ne<D;ne++)for(let z=0;z<C;z++){const W=m+z+G*ne,se=m+z+G*(ne+1),ae=m+(z+1)+G*(ne+1),de=m+(z+1)+G*ne;c.push(W,se,de),c.push(se,ae,de),Z+=6}l.addGroup(g,Z,A),g+=Z,m+=K}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new oJ(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Sg(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?(mn("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 Ga(t){const e={};for(let n=0;n<t.length;n++){const r=Sg(t[n]);for(const i in r)e[i]=r[i]}return e}function N3e(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function lJ(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Yn.workingColorSpace}const M3e={clone:Sg,merge:Ga};var E3e=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,T3e=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let xu=class extends tx{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=E3e,this.fragmentShader=T3e,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=Sg(e.uniforms),this.uniformsGroups=N3e(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?n.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?n.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?n.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?n.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?n.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?n.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?n.uniforms[i]={type:"m4",value:o.toArray()}:n.uniforms[i]={value:o}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const r={};for(const i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(n.extensions=r),n}},cJ=class extends eo{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ci,this.projectionMatrix=new Ci,this.projectionMatrixInverse=new Ci,this.coordinateSystem=Rl,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 ed=new ot,LH=new Nn,IH=new Nn;let So=class extends cJ{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=GP*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(nw*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return GP*2*Math.atan(Math.tan(nw*.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){ed.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ed.x,ed.y).multiplyScalar(-e/ed.z),ed.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(ed.x,ed.y).multiplyScalar(-e/ed.z)}getViewSize(e,n){return this.getViewBounds(e,LH,IH),n.subVectors(IH,LH)}setViewOffset(e,n,r,i,s,o){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(nw*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,s=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;s+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.height/u}const l=this.filmOffset;l!==0&&(s+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,n,n-r,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}};const ip=-90,ap=1;let C3e=class extends eo{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new So(ip,ap,e,n);i.layers=this.layers,this.add(i);const s=new So(ip,ap,e,n);s.layers=this.layers,this.add(s);const o=new So(ip,ap,e,n);o.layers=this.layers,this.add(o);const l=new So(ip,ap,e,n);l.layers=this.layers,this.add(l);const c=new So(ip,ap,e,n);c.layers=this.layers,this.add(c);const u=new So(ip,ap,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,o,l,c]=n;for(const u of n)this.remove(u);if(e===Rl)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===NS)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,o,l,c,u,d]=this.children,f=e.getRenderTarget(),m=e.getActiveCubeFace(),g=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,s),e.setRenderTarget(r,1,i),e.render(n,o),e.setRenderTarget(r,2,i),e.render(n,l),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,m,g),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},uJ=class extends pl{constructor(e=[],n=vg,r,i,s,o,l,c,u,d){super(e,n,r,i,s,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},A3e=class extends Wf{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 uJ(i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new DO(5,5,5),s=new xu({name:"CubemapFromEquirect",uniforms:Sg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:_s,blending:tu});s.uniforms.tEquirect.value=n;const o=new ql(i,s),l=n.minFilter;return n.minFilter===df&&(n.minFilter=Ao),new C3e(1,10,this).update(e,o),n.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,n=!0,r=!0,i=!0){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(s)}},jb=class extends eo{constructor(){super(),this.isGroup=!0,this.type="Group"}};const k3e={type:"move"};let qA=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new jb,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 jb,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ot,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ot),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new jb,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ot,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ot),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,s=null,o=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(const y of e.hand.values()){const b=n.getJointPose(y,r),v=this._getHandJoint(u,y);b!==null&&(v.matrix.fromArray(b.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=b.radius),v.visible=b!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],m=d.position.distanceTo(f.position),g=.02,x=.005;u.inputState.pinching&&m>g+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=g-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(k3e)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new jb;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},j3e=class extends eo{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 th,this.environmentIntensity=1,this.environmentRotation=new th,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}},P3e=class extends pl{constructor(e=null,n=1,r=1,i,s,o,l,c,u=Xs,d=Xs,f,m){super(null,o,l,c,u,d,i,s,f,m),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const WA=new ot,R3e=new ot,D3e=new Tn;let fd=class{constructor(e=new ot(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=WA.subVectors(r,n).cross(R3e.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(WA),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:n.copy(e.start).addScaledVector(r,s)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||D3e.getNormalMatrix(e),i=this.coplanarPoint(WA).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};const Fh=new HN,O3e=new Nn(.5,.5),$_=new ot;let OO=class{constructor(e=new fd,n=new fd,r=new fd,i=new fd,s=new fd,o=new fd){this.planes=[e,n,r,i,s,o]}set(e,n,r,i,s,o){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(s),l[5].copy(o),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=Rl,r=!1){const i=this.planes,s=e.elements,o=s[0],l=s[1],c=s[2],u=s[3],d=s[4],f=s[5],m=s[6],g=s[7],x=s[8],y=s[9],b=s[10],v=s[11],N=s[12],S=s[13],T=s[14],E=s[15];if(i[0].setComponents(u-o,g-d,v-x,E-N).normalize(),i[1].setComponents(u+o,g+d,v+x,E+N).normalize(),i[2].setComponents(u+l,g+f,v+y,E+S).normalize(),i[3].setComponents(u-l,g-f,v-y,E-S).normalize(),r)i[4].setComponents(c,m,b,T).normalize(),i[5].setComponents(u-c,g-m,v-b,E-T).normalize();else if(i[4].setComponents(u-c,g-m,v-b,E-T).normalize(),n===Rl)i[5].setComponents(u+c,g+m,v+b,E+T).normalize();else if(n===NS)i[5].setComponents(c,m,b,T).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Fh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Fh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Fh)}intersectsSprite(e){Fh.center.set(0,0,0);const n=O3e.distanceTo(e.center);return Fh.radius=.7071067811865476+n,Fh.applyMatrix4(e.matrixWorld),this.intersectsSphere(Fh)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(n[s].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if($_.x=i.normal.x>0?e.max.x:e.min.x,$_.y=i.normal.y>0?e.max.y:e.min.y,$_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint($_)<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)}},dJ=class extends tx{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Rn(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 ES=new ot,TS=new ot,FH=new Ci,pb=new PO,H_=new HN,KA=new ot,UH=new ot;let L3e=class extends eo{constructor(e=new ec,n=new dJ){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,s=n.count;i<s;i++)ES.fromBufferAttribute(n,i-1),TS.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=ES.distanceTo(TS);e.setAttribute("lineDistance",new ol(r,1))}else mn("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),H_.copy(r.boundingSphere),H_.applyMatrix4(i),H_.radius+=s,e.ray.intersectsSphere(H_)===!1)return;FH.copy(i).invert(),pb.copy(e.ray).applyMatrix4(FH);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=this.isLineSegments?2:1,d=r.index,m=r.attributes.position;if(d!==null){const g=Math.max(0,o.start),x=Math.min(d.count,o.start+o.count);for(let y=g,b=x-1;y<b;y+=u){const v=d.getX(y),N=d.getX(y+1),S=V_(this,e,pb,c,v,N,y);S&&n.push(S)}if(this.isLineLoop){const y=d.getX(x-1),b=d.getX(g),v=V_(this,e,pb,c,y,b,x-1);v&&n.push(v)}}else{const g=Math.max(0,o.start),x=Math.min(m.count,o.start+o.count);for(let y=g,b=x-1;y<b;y+=u){const v=V_(this,e,pb,c,y,y+1,y);v&&n.push(v)}if(this.isLineLoop){const y=V_(this,e,pb,c,x-1,g,x-1);y&&n.push(y)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const l=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}};function V_(t,e,n,r,i,s,o){const l=t.geometry.attributes.position;if(ES.fromBufferAttribute(l,i),TS.fromBufferAttribute(l,s),n.distanceSqToSegment(ES,TS,KA,UH)>r)return;KA.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(KA);if(!(u<e.near||u>e.far))return{distance:u,point:UH.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const zH=new ot,BH=new ot;let I3e=class extends L3e{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,s=n.count;i<s;i+=2)zH.fromBufferAttribute(n,i),BH.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+zH.distanceTo(BH);e.setAttribute("lineDistance",new ol(r,1))}else mn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},hJ=class extends pl{constructor(e,n,r=Gf,i,s,o,l=Xs,c=Xs,u,d=F0,f=1){if(d!==F0&&d!==U0)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const m={width:e,height:n,depth:f};super(m,i,s,o,l,c,d,r,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new jO(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 fJ extends pl{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let LO=class mJ extends ec{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const s=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,m=n/c,g=[],x=[],y=[],b=[];for(let v=0;v<d;v++){const N=v*m-o;for(let S=0;S<u;S++){const T=S*f-s;x.push(T,-N,0),y.push(0,0,1),b.push(S/l),b.push(1-v/c)}}for(let v=0;v<c;v++)for(let N=0;N<l;N++){const S=N+u*v,T=N+u*(v+1),E=N+1+u*(v+1),k=N+1+u*v;g.push(S,T,k),g.push(T,E,k)}this.setIndex(g),this.setAttribute("position",new ol(x,3)),this.setAttribute("normal",new ol(y,3)),this.setAttribute("uv",new ol(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mJ(e.width,e.height,e.widthSegments,e.heightSegments)}};class F3e extends tx{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Rn(16777215),this.specular=new Rn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Rn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=WZ,this.normalScale=new Nn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new th,this.combine=SO,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 U3e=class extends tx{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Wje,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}},z3e=class extends tx{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}},pJ=class extends eo{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Rn(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 XA=new Ci,$H=new ot,HH=new ot;let B3e=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Nn(512,512),this.mapType=Gl,this.map=null,this.mapPass=null,this.matrix=new Ci,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new OO,this._frameExtents=new Nn(1,1),this._viewportCount=1,this._viewports=[new Si(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;$H.setFromMatrixPosition(e.matrixWorld),n.position.copy($H),HH.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(HH),n.updateMatrixWorld(),XA.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(XA,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(XA)}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}},gJ=class extends cJ{constructor(e=-1,n=1,r=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=r-e,o=r+e,l=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=u*this.view.offsetX,o=s+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(s,o,l,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}};class $3e extends B3e{constructor(){super(new gJ(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class VH extends pJ{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(eo.DEFAULT_UP),this.updateMatrix(),this.target=new eo,this.shadow=new $3e}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let H3e=class extends pJ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},V3e=class extends So{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},GH=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=Pn(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(Pn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class G3e extends I3e{constructor(e=10,n=10,r=4473924,i=8947848){r=new Rn(r),i=new Rn(i);const s=n/2,o=e/n,l=e/2,c=[],u=[];for(let m=0,g=0,x=-l;m<=n;m++,x+=o){c.push(-l,0,x,l,0,x),c.push(x,0,-l,x,0,l);const y=m===s?r:i;y.toArray(u,g),g+=3,y.toArray(u,g),g+=3,y.toArray(u,g),g+=3,y.toArray(u,g),g+=3}const d=new ec;d.setAttribute("position",new ol(c,3)),d.setAttribute("color",new ol(u,3));const f=new dJ({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class q3e extends om{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){mn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function qH(t,e,n,r){const i=W3e(r);switch(n){case VZ:return t*e;case qZ:return t*e/i.components*i.byteLength;case TO:return t*e/i.components*i.byteLength;case CO:return t*e*2/i.components*i.byteLength;case AO:return t*e*2/i.components*i.byteLength;case GZ:return t*e*3/i.components*i.byteLength;case rl:return t*e*4/i.components*i.byteLength;case kO:return t*e*4/i.components*i.byteLength;case Z1:case J1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case ew:case tw:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case bP:case vP:return Math.max(t,16)*Math.max(e,8)/4;case xP:case yP:return Math.max(t,8)*Math.max(e,8)/2;case _P:case wP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case SP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case NP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case MP:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case EP:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case TP:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case CP:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case AP:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case kP:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case jP:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case PP:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case RP:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case DP:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case OP:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case LP:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case IP:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case FP:case UP:case zP:return Math.ceil(t/4)*Math.ceil(e/4)*16;case BP:case $P:return Math.ceil(t/4)*Math.ceil(e/4)*8;case HP:case VP:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function W3e(t){switch(t){case Gl:case zZ:return{byteLength:1,components:1};case L0:case BZ:case ex:return{byteLength:2,components:1};case MO:case EO:return{byteLength:2,components:4};case Gf:case NO:case Kc:return{byteLength:4,components:1};case $Z:case HZ:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:wO}}));typeof window<"u"&&(window.__THREE__?mn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=wO);function xJ(){let t=null,e=!1,n=null,r=null;function i(s,o){n(s,o),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(s){n=s},setContext:function(s){t=s}}}function K3e(t){const e=new WeakMap;function n(l,c){const u=l.array,d=l.usage,f=u.byteLength,m=t.createBuffer();t.bindBuffer(c,m),t.bufferData(c,u,d),l.onUploadCallback();let g;if(u instanceof Float32Array)g=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)g=t.HALF_FLOAT;else if(u instanceof Uint16Array)l.isFloat16BufferAttribute?g=t.HALF_FLOAT:g=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)g=t.SHORT;else if(u instanceof Uint32Array)g=t.UNSIGNED_INT;else if(u instanceof Int32Array)g=t.INT;else if(u instanceof Int8Array)g=t.BYTE;else if(u instanceof Uint8Array)g=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)g=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:m,type:g,bytesPerElement:u.BYTES_PER_ELEMENT,version:l.version,size:f}}function r(l,c,u){const d=c.array,f=c.updateRanges;if(t.bindBuffer(u,l),f.length===0)t.bufferSubData(u,0,d);else{f.sort((g,x)=>g.start-x.start);let m=0;for(let g=1;g<f.length;g++){const x=f[m],y=f[g];y.start<=x.start+x.count+1?x.count=Math.max(x.count,y.start+y.count-x.start):(++m,f[m]=y)}f.length=m+1;for(let g=0,x=f.length;g<x;g++){const y=f[g];t.bufferSubData(u,y.start*d.BYTES_PER_ELEMENT,d,y.start,y.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(l){return l.isInterleavedBufferAttribute&&(l=l.data),e.get(l)}function s(l){l.isInterleavedBufferAttribute&&(l=l.data);const c=e.get(l);c&&(t.deleteBuffer(c.buffer),e.delete(l))}function o(l,c){if(l.isInterleavedBufferAttribute&&(l=l.data),l.isGLBufferAttribute){const d=e.get(l);(!d||d.version<l.version)&&e.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}const u=e.get(l);if(u===void 0)e.set(l,n(l,c));else if(u.version<l.version){if(u.size!==l.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");r(u.buffer,l,c),u.version=l.version}}return{get:i,remove:s,update:o}}var X3e=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,Y3e=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,Q3e=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,Z3e=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,J3e=`#ifdef USE_ALPHATEST
- #ifdef ALPHA_TO_COVERAGE
- diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- if ( diffuseColor.a < alphaTest ) discard;
- #endif
- #endif`,ePe=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,tPe=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,nPe=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,rPe=`#ifdef USE_BATCHING
- #if ! defined( GL_ANGLE_multi_draw )
- #define gl_DrawID _gl_DrawID
- uniform int _gl_DrawID;
- #endif
- uniform highp sampler2D batchingTexture;
- uniform highp usampler2D batchingIdTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- float getIndirectIndex( const in int i ) {
- int size = textureSize( batchingIdTexture, 0 ).x;
- int x = i % size;
- int y = i / size;
- return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
- }
- #endif
- #ifdef USE_BATCHING_COLOR
- uniform sampler2D batchingColorTexture;
- vec3 getBatchingColor( const in float i ) {
- int size = textureSize( batchingColorTexture, 0 ).x;
- int j = int( i );
- int x = j % size;
- int y = j / size;
- return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
- }
- #endif`,iPe=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,aPe=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,sPe=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,oPe=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,lPe=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,cPe=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,uPe=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #ifdef ALPHA_TO_COVERAGE
- float distanceToPlane, distanceGradient;
- float clipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- if ( clipOpacity == 0.0 ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- float unionClipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- }
- #pragma unroll_loop_end
- clipOpacity *= 1.0 - unionClipOpacity;
- #endif
- diffuseColor.a *= clipOpacity;
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif
- #endif`,dPe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,hPe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,fPe=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,mPe=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,pPe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,gPe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,xPe=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif
- #ifdef USE_BATCHING_COLOR
- vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
- vColor.xyz *= batchingColor.xyz;
- #endif`,bPe=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,yPe=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,vPe=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,_Pe=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,wPe=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,SPe=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,NPe=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,MPe="gl_FragColor = linearToOutputTexel( gl_FragColor );",EPe=`vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferEOTF( in vec4 value ) {
- return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }`,TPe=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,CPe=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- uniform mat3 envMapRotation;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
- #endif`,APe=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,kPe=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,jPe=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,PPe=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,RPe=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,DPe=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,OPe=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,LPe=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,IPe=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,FPe=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,UPe=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,zPe=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,BPe=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,$Pe=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,HPe=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,VPe=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,GPe=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,qPe=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_DISPERSION
- material.dispersion = dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,WPe=`uniform sampler2D dfgLUT;
- struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- float dispersion;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 uv = vec2( roughness, dotNV );
- return texture2D( dfgLUT, uv ).rg;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
- vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
- vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
- vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
- float Ess_V = dfgV.x + dfgV.y;
- float Ess_L = dfgL.x + dfgL.y;
- float Ems_V = 1.0 - Ess_V;
- float Ems_L = 1.0 - Ess_L;
- vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
- vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
- float compensationFactor = Ems_V * Ems_L;
- vec3 multiScatter = Fms * compensationFactor;
- return singleScatter + multiScatter;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,KPe=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,XPe=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,YPe=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,QPe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,ZPe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,JPe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,eRe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,tRe=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,nRe=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,rRe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,iRe=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,aRe=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,sRe=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,oRe=`#ifdef USE_INSTANCING_MORPH
- float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
- }
- #endif`,lRe=`#if defined( USE_MORPHCOLORS )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,cRe=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,uRe=`#ifdef USE_MORPHTARGETS
- #ifndef USE_INSTANCING_MORPH
- uniform float morphTargetBaseInfluence;
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- #endif
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #endif`,dRe=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,hRe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,fRe=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,mRe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,pRe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,gRe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,xRe=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,bRe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,yRe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,vRe=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,_Re=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,wRe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,SRe=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
- const float Inv255 = 1. / 255.;
- const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
- const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
- const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
- const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
- vec4 packDepthToRGBA( const in float v ) {
- if( v <= 0.0 )
- return vec4( 0., 0., 0., 0. );
- if( v >= 1.0 )
- return vec4( 1., 1., 1., 1. );
- float vuf;
- float af = modf( v * PackFactors.a, vuf );
- float bf = modf( vuf * ShiftRight8, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
- }
- vec3 packDepthToRGB( const in float v ) {
- if( v <= 0.0 )
- return vec3( 0., 0., 0. );
- if( v >= 1.0 )
- return vec3( 1., 1., 1. );
- float vuf;
- float bf = modf( v * PackFactors.b, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec3( vuf * Inv255, gf * PackUpscale, bf );
- }
- vec2 packDepthToRG( const in float v ) {
- if( v <= 0.0 )
- return vec2( 0., 0. );
- if( v >= 1.0 )
- return vec2( 1., 1. );
- float vuf;
- float gf = modf( v * 256., vuf );
- return vec2( vuf * Inv255, gf );
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors4 );
- }
- float unpackRGBToDepth( const in vec3 v ) {
- return dot( v, UnpackFactors3 );
- }
- float unpackRGToDepth( const in vec2 v ) {
- return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
- }
- vec4 pack2HalfToRGBA( const in vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( const in vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,NRe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,MRe=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,ERe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,TRe=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,CRe=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,ARe=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,kRe=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
- float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- return step( depth, compare );
- #else
- return step( compare, depth );
- #endif
- }
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
- }
- float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
- float occlusion = 1.0;
- vec2 distribution = texture2DDistribution( shadow, uv );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float hard_shadow = step( distribution.x, compare );
- #else
- float hard_shadow = step( compare, distribution.x );
- #endif
- if ( hard_shadow != 1.0 ) {
- float distance = compare - distribution.x;
- float variance = max( 0.00000, distribution.y * distribution.y );
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
- }
- return occlusion;
- }
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- #if defined( SHADOWMAP_TYPE_PCF )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx0 = - texelSize.x * shadowRadius;
- float dy0 = - texelSize.y * shadowRadius;
- float dx1 = + texelSize.x * shadowRadius;
- float dy1 = + texelSize.y * shadowRadius;
- float dx2 = dx0 / 2.0;
- float dy2 = dy0 / 2.0;
- float dx3 = dx1 / 2.0;
- float dy3 = dy1 / 2.0;
- shadow = (
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
- ) * ( 1.0 / 17.0 );
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx = texelSize.x;
- float dy = texelSize.y;
- vec2 uv = shadowCoord.xy;
- vec2 f = fract( uv * shadowMapSize + 0.5 );
- uv -= f * texelSize;
- shadow = (
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
- f.x ),
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
- f.x ),
- f.y )
- ) * ( 1.0 / 9.0 );
- #elif defined( SHADOWMAP_TYPE_VSM )
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
- #else
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
- vec3 absV = abs( v );
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
- absV *= scaleToCube;
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
- vec2 planar = v.xy;
- float almostATexel = 1.5 * texelSizeY;
- float almostOne = 1.0 - almostATexel;
- if ( absV.z >= almostOne ) {
- if ( v.z > 0.0 )
- planar.x = 4.0 - v.x;
- } else if ( absV.x >= almostOne ) {
- float signX = sign( v.x );
- planar.x = v.z * signX + 2.0 * signX;
- } else if ( absV.y >= almostOne ) {
- float signY = sign( v.y );
- planar.x = v.x + 2.0 * signY + 2.0;
- planar.y = v.z * signY - 2.0;
- }
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
- }
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- float shadow = 1.0;
- vec3 lightToPosition = shadowCoord.xyz;
-
- float lightToPositionLength = length( lightToPosition );
- if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
- float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- shadow = (
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
- ) * ( 1.0 / 9.0 );
- #else
- shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- #endif`,jRe=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,PRe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,RRe=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,DRe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,ORe=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,LRe=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,IRe=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,FRe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,URe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,zRe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,BRe=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 CineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
- vec3( 1.6605, - 0.1246, - 0.0182 ),
- vec3( - 0.5876, 1.1329, - 0.1006 ),
- vec3( - 0.0728, - 0.0083, 1.1187 )
- );
- const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
- vec3( 0.6274, 0.0691, 0.0164 ),
- vec3( 0.3293, 0.9195, 0.0880 ),
- vec3( 0.0433, 0.0113, 0.8956 )
- );
- vec3 agxDefaultContrastApprox( vec3 x ) {
- vec3 x2 = x * x;
- vec3 x4 = x2 * x2;
- return + 15.5 * x4 * x2
- - 40.14 * x4 * x
- + 31.96 * x4
- - 6.868 * x2 * x
- + 0.4298 * x2
- + 0.1191 * x
- - 0.00232;
- }
- vec3 AgXToneMapping( vec3 color ) {
- const mat3 AgXInsetMatrix = mat3(
- vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
- vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
- vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
- );
- const mat3 AgXOutsetMatrix = mat3(
- vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
- vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
- vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
- );
- const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
- color *= toneMappingExposure;
- color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
- color = AgXInsetMatrix * color;
- color = max( color, 1e-10 ); color = log2( color );
- color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
- color = clamp( color, 0.0, 1.0 );
- color = agxDefaultContrastApprox( color );
- color = AgXOutsetMatrix * color;
- color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
- color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
- color = clamp( color, 0.0, 1.0 );
- return color;
- }
- vec3 NeutralToneMapping( vec3 color ) {
- const float StartCompression = 0.8 - 0.04;
- const float Desaturation = 0.15;
- color *= toneMappingExposure;
- float x = min( color.r, min( color.g, color.b ) );
- float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
- color -= offset;
- float peak = max( color.r, max( color.g, color.b ) );
- if ( peak < StartCompression ) return color;
- float d = 1. - StartCompression;
- float newPeak = 1. - d * d / ( peak + d - StartCompression );
- color *= newPeak / peak;
- float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
- return mix( color, vec3( newPeak ), g );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,$Re=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,HRe=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec4 transmittedLight;
- vec3 transmittance;
- #ifdef USE_DISPERSION
- float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
- vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
- for ( int i = 0; i < 3; i ++ ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
- transmittedLight[ i ] = transmissionSample[ i ];
- transmittedLight.a += transmissionSample.a;
- transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
- }
- transmittedLight.a /= 3.0;
- #else
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- #endif
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,VRe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,GRe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,qRe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,WRe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const KRe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,XRe=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,YRe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,QRe=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- uniform mat3 backgroundRotation;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,ZRe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,JRe=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,eDe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,tDe=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
- #else
- float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
- #endif
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #elif DEPTH_PACKING == 3202
- gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
- #elif DEPTH_PACKING == 3203
- gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
- #endif
- }`,nDe=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,rDe=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,iDe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,aDe=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,sDe=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,oDe=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,lDe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,cDe=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,uDe=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,dDe=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,hDe=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,fDe=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,mDe=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,pDe=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <packing>
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,gDe=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,xDe=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,bDe=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,yDe=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_DISPERSION
- uniform float dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,vDe=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,_De=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,wDe=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,SDe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,NDe=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,MDe=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,EDe=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix[ 3 ];
- vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,TDe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,_n={alphahash_fragment:X3e,alphahash_pars_fragment:Y3e,alphamap_fragment:Q3e,alphamap_pars_fragment:Z3e,alphatest_fragment:J3e,alphatest_pars_fragment:ePe,aomap_fragment:tPe,aomap_pars_fragment:nPe,batching_pars_vertex:rPe,batching_vertex:iPe,begin_vertex:aPe,beginnormal_vertex:sPe,bsdfs:oPe,iridescence_fragment:lPe,bumpmap_pars_fragment:cPe,clipping_planes_fragment:uPe,clipping_planes_pars_fragment:dPe,clipping_planes_pars_vertex:hPe,clipping_planes_vertex:fPe,color_fragment:mPe,color_pars_fragment:pPe,color_pars_vertex:gPe,color_vertex:xPe,common:bPe,cube_uv_reflection_fragment:yPe,defaultnormal_vertex:vPe,displacementmap_pars_vertex:_Pe,displacementmap_vertex:wPe,emissivemap_fragment:SPe,emissivemap_pars_fragment:NPe,colorspace_fragment:MPe,colorspace_pars_fragment:EPe,envmap_fragment:TPe,envmap_common_pars_fragment:CPe,envmap_pars_fragment:APe,envmap_pars_vertex:kPe,envmap_physical_pars_fragment:BPe,envmap_vertex:jPe,fog_vertex:PPe,fog_pars_vertex:RPe,fog_fragment:DPe,fog_pars_fragment:OPe,gradientmap_pars_fragment:LPe,lightmap_pars_fragment:IPe,lights_lambert_fragment:FPe,lights_lambert_pars_fragment:UPe,lights_pars_begin:zPe,lights_toon_fragment:$Pe,lights_toon_pars_fragment:HPe,lights_phong_fragment:VPe,lights_phong_pars_fragment:GPe,lights_physical_fragment:qPe,lights_physical_pars_fragment:WPe,lights_fragment_begin:KPe,lights_fragment_maps:XPe,lights_fragment_end:YPe,logdepthbuf_fragment:QPe,logdepthbuf_pars_fragment:ZPe,logdepthbuf_pars_vertex:JPe,logdepthbuf_vertex:eRe,map_fragment:tRe,map_pars_fragment:nRe,map_particle_fragment:rRe,map_particle_pars_fragment:iRe,metalnessmap_fragment:aRe,metalnessmap_pars_fragment:sRe,morphinstance_vertex:oRe,morphcolor_vertex:lRe,morphnormal_vertex:cRe,morphtarget_pars_vertex:uRe,morphtarget_vertex:dRe,normal_fragment_begin:hRe,normal_fragment_maps:fRe,normal_pars_fragment:mRe,normal_pars_vertex:pRe,normal_vertex:gRe,normalmap_pars_fragment:xRe,clearcoat_normal_fragment_begin:bRe,clearcoat_normal_fragment_maps:yRe,clearcoat_pars_fragment:vRe,iridescence_pars_fragment:_Re,opaque_fragment:wRe,packing:SRe,premultiplied_alpha_fragment:NRe,project_vertex:MRe,dithering_fragment:ERe,dithering_pars_fragment:TRe,roughnessmap_fragment:CRe,roughnessmap_pars_fragment:ARe,shadowmap_pars_fragment:kRe,shadowmap_pars_vertex:jRe,shadowmap_vertex:PRe,shadowmask_pars_fragment:RRe,skinbase_vertex:DRe,skinning_pars_vertex:ORe,skinning_vertex:LRe,skinnormal_vertex:IRe,specularmap_fragment:FRe,specularmap_pars_fragment:URe,tonemapping_fragment:zRe,tonemapping_pars_fragment:BRe,transmission_fragment:$Re,transmission_pars_fragment:HRe,uv_pars_fragment:VRe,uv_pars_vertex:GRe,uv_vertex:qRe,worldpos_vertex:WRe,background_vert:KRe,background_frag:XRe,backgroundCube_vert:YRe,backgroundCube_frag:QRe,cube_vert:ZRe,cube_frag:JRe,depth_vert:eDe,depth_frag:tDe,distanceRGBA_vert:nDe,distanceRGBA_frag:rDe,equirect_vert:iDe,equirect_frag:aDe,linedashed_vert:sDe,linedashed_frag:oDe,meshbasic_vert:lDe,meshbasic_frag:cDe,meshlambert_vert:uDe,meshlambert_frag:dDe,meshmatcap_vert:hDe,meshmatcap_frag:fDe,meshnormal_vert:mDe,meshnormal_frag:pDe,meshphong_vert:gDe,meshphong_frag:xDe,meshphysical_vert:bDe,meshphysical_frag:yDe,meshtoon_vert:vDe,meshtoon_frag:_De,points_vert:wDe,points_frag:SDe,shadow_vert:NDe,shadow_frag:MDe,sprite_vert:EDe,sprite_frag:TDe},Dt={common:{diffuse:{value:new Rn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Tn},alphaMap:{value:null},alphaMapTransform:{value:new Tn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Tn}},envmap:{envMap:{value:null},envMapRotation:{value:new Tn},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 Tn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Tn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Tn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Tn},normalScale:{value:new Nn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Tn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Tn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Tn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Tn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Rn(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 Rn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Tn},alphaTest:{value:0},uvTransform:{value:new Tn}},sprite:{diffuse:{value:new Rn(16777215)},opacity:{value:1},center:{value:new Nn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Tn},alphaMap:{value:null},alphaMapTransform:{value:new Tn},alphaTest:{value:0}}},Cl={basic:{uniforms:Ga([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.fog]),vertexShader:_n.meshbasic_vert,fragmentShader:_n.meshbasic_frag},lambert:{uniforms:Ga([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,Dt.lights,{emissive:{value:new Rn(0)}}]),vertexShader:_n.meshlambert_vert,fragmentShader:_n.meshlambert_frag},phong:{uniforms:Ga([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,Dt.lights,{emissive:{value:new Rn(0)},specular:{value:new Rn(1118481)},shininess:{value:30}}]),vertexShader:_n.meshphong_vert,fragmentShader:_n.meshphong_frag},standard:{uniforms:Ga([Dt.common,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.roughnessmap,Dt.metalnessmap,Dt.fog,Dt.lights,{emissive:{value:new Rn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:_n.meshphysical_vert,fragmentShader:_n.meshphysical_frag},toon:{uniforms:Ga([Dt.common,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.gradientmap,Dt.fog,Dt.lights,{emissive:{value:new Rn(0)}}]),vertexShader:_n.meshtoon_vert,fragmentShader:_n.meshtoon_frag},matcap:{uniforms:Ga([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,{matcap:{value:null}}]),vertexShader:_n.meshmatcap_vert,fragmentShader:_n.meshmatcap_frag},points:{uniforms:Ga([Dt.points,Dt.fog]),vertexShader:_n.points_vert,fragmentShader:_n.points_frag},dashed:{uniforms:Ga([Dt.common,Dt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:_n.linedashed_vert,fragmentShader:_n.linedashed_frag},depth:{uniforms:Ga([Dt.common,Dt.displacementmap]),vertexShader:_n.depth_vert,fragmentShader:_n.depth_frag},normal:{uniforms:Ga([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,{opacity:{value:1}}]),vertexShader:_n.meshnormal_vert,fragmentShader:_n.meshnormal_frag},sprite:{uniforms:Ga([Dt.sprite,Dt.fog]),vertexShader:_n.sprite_vert,fragmentShader:_n.sprite_frag},background:{uniforms:{uvTransform:{value:new Tn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:_n.background_vert,fragmentShader:_n.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Tn}},vertexShader:_n.backgroundCube_vert,fragmentShader:_n.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:_n.cube_vert,fragmentShader:_n.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:_n.equirect_vert,fragmentShader:_n.equirect_frag},distanceRGBA:{uniforms:Ga([Dt.common,Dt.displacementmap,{referencePosition:{value:new ot},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:_n.distanceRGBA_vert,fragmentShader:_n.distanceRGBA_frag},shadow:{uniforms:Ga([Dt.lights,Dt.fog,{color:{value:new Rn(0)},opacity:{value:1}}]),vertexShader:_n.shadow_vert,fragmentShader:_n.shadow_frag}};Cl.physical={uniforms:Ga([Cl.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Tn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Tn},clearcoatNormalScale:{value:new Nn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Tn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Tn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Tn},sheen:{value:0},sheenColor:{value:new Rn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Tn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Tn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Tn},transmissionSamplerSize:{value:new Nn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Tn},attenuationDistance:{value:0},attenuationColor:{value:new Rn(0)},specularColor:{value:new Rn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Tn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Tn},anisotropyVector:{value:new Nn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Tn}}]),vertexShader:_n.meshphysical_vert,fragmentShader:_n.meshphysical_frag};const G_={r:0,b:0,g:0},Uh=new th,CDe=new Ci;function ADe(t,e,n,r,i,s,o){const l=new Rn(0);let c=s===!0?0:1,u,d,f=null,m=0,g=null;function x(S){let T=S.isScene===!0?S.background:null;return T&&T.isTexture&&(T=(S.backgroundBlurriness>0?n:e).get(T)),T}function y(S){let T=!1;const E=x(S);E===null?v(l,c):E&&E.isColor&&(v(E,1),T=!0);const k=t.xr.getEnvironmentBlendMode();k==="additive"?r.buffers.color.setClear(0,0,0,1,o):k==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||T)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function b(S,T){const E=x(T);E&&(E.isCubeTexture||E.mapping===$N)?(d===void 0&&(d=new ql(new DO(1,1,1),new xu({name:"BackgroundCubeMaterial",uniforms:Sg(Cl.backgroundCube.uniforms),vertexShader:Cl.backgroundCube.vertexShader,fragmentShader:Cl.backgroundCube.fragmentShader,side:_s,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(k,C,D){this.matrixWorld.copyPosition(D.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),Uh.copy(T.backgroundRotation),Uh.x*=-1,Uh.y*=-1,Uh.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(Uh.y*=-1,Uh.z*=-1),d.material.uniforms.envMap.value=E,d.material.uniforms.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(CDe.makeRotationFromEuler(Uh)),d.material.toneMapped=Yn.getTransfer(E.colorSpace)!==pr,(f!==E||m!==E.version||g!==t.toneMapping)&&(d.material.needsUpdate=!0,f=E,m=E.version,g=t.toneMapping),d.layers.enableAll(),S.unshift(d,d.geometry,d.material,0,0,null)):E&&E.isTexture&&(u===void 0&&(u=new ql(new LO(2,2),new xu({name:"BackgroundMaterial",uniforms:Sg(Cl.background.uniforms),vertexShader:Cl.background.vertexShader,fragmentShader:Cl.background.fragmentShader,side:eh,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=E,u.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,u.material.toneMapped=Yn.getTransfer(E.colorSpace)!==pr,E.matrixAutoUpdate===!0&&E.updateMatrix(),u.material.uniforms.uvTransform.value.copy(E.matrix),(f!==E||m!==E.version||g!==t.toneMapping)&&(u.material.needsUpdate=!0,f=E,m=E.version,g=t.toneMapping),u.layers.enableAll(),S.unshift(u,u.geometry,u.material,0,0,null))}function v(S,T){S.getRGB(G_,lJ(t)),r.buffers.color.setClear(G_.r,G_.g,G_.b,T,o)}function N(){d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0),u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0)}return{getClearColor:function(){return l},setClearColor:function(S,T=1){l.set(S),c=T,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(S){c=S,v(l,c)},render:y,addToRenderList:b,dispose:N}}function kDe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=m(null);let s=i,o=!1;function l(R,F,O,q,j){let G=!1;const Y=f(q,O,F);s!==Y&&(s=Y,u(s.object)),G=g(R,q,O,j),G&&x(R,q,O,j),j!==null&&e.update(j,t.ELEMENT_ARRAY_BUFFER),(G||o)&&(o=!1,T(R,F,O,q),j!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(j).buffer))}function c(){return t.createVertexArray()}function u(R){return t.bindVertexArray(R)}function d(R){return t.deleteVertexArray(R)}function f(R,F,O){const q=O.wireframe===!0;let j=r[R.id];j===void 0&&(j={},r[R.id]=j);let G=j[F.id];G===void 0&&(G={},j[F.id]=G);let Y=G[q];return Y===void 0&&(Y=m(c()),G[q]=Y),Y}function m(R){const F=[],O=[],q=[];for(let j=0;j<n;j++)F[j]=0,O[j]=0,q[j]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:O,attributeDivisors:q,object:R,attributes:{},index:null}}function g(R,F,O,q){const j=s.attributes,G=F.attributes;let Y=0;const K=O.getAttributes();for(const Z in K)if(K[Z].location>=0){const ne=j[Z];let z=G[Z];if(z===void 0&&(Z==="instanceMatrix"&&R.instanceMatrix&&(z=R.instanceMatrix),Z==="instanceColor"&&R.instanceColor&&(z=R.instanceColor)),ne===void 0||ne.attribute!==z||z&&ne.data!==z.data)return!0;Y++}return s.attributesNum!==Y||s.index!==q}function x(R,F,O,q){const j={},G=F.attributes;let Y=0;const K=O.getAttributes();for(const Z in K)if(K[Z].location>=0){let ne=G[Z];ne===void 0&&(Z==="instanceMatrix"&&R.instanceMatrix&&(ne=R.instanceMatrix),Z==="instanceColor"&&R.instanceColor&&(ne=R.instanceColor));const z={};z.attribute=ne,ne&&ne.data&&(z.data=ne.data),j[Z]=z,Y++}s.attributes=j,s.attributesNum=Y,s.index=q}function y(){const R=s.newAttributes;for(let F=0,O=R.length;F<O;F++)R[F]=0}function b(R){v(R,0)}function v(R,F){const O=s.newAttributes,q=s.enabledAttributes,j=s.attributeDivisors;O[R]=1,q[R]===0&&(t.enableVertexAttribArray(R),q[R]=1),j[R]!==F&&(t.vertexAttribDivisor(R,F),j[R]=F)}function N(){const R=s.newAttributes,F=s.enabledAttributes;for(let O=0,q=F.length;O<q;O++)F[O]!==R[O]&&(t.disableVertexAttribArray(O),F[O]=0)}function S(R,F,O,q,j,G,Y){Y===!0?t.vertexAttribIPointer(R,F,O,j,G):t.vertexAttribPointer(R,F,O,q,j,G)}function T(R,F,O,q){y();const j=q.attributes,G=O.getAttributes(),Y=F.defaultAttributeValues;for(const K in G){const Z=G[K];if(Z.location>=0){let te=j[K];if(te===void 0&&(K==="instanceMatrix"&&R.instanceMatrix&&(te=R.instanceMatrix),K==="instanceColor"&&R.instanceColor&&(te=R.instanceColor)),te!==void 0){const ne=te.normalized,z=te.itemSize,W=e.get(te);if(W===void 0)continue;const se=W.buffer,ae=W.type,de=W.bytesPerElement,me=ae===t.INT||ae===t.UNSIGNED_INT||te.gpuType===NO;if(te.isInterleavedBufferAttribute){const xe=te.data,be=xe.stride,fe=te.offset;if(xe.isInstancedInterleavedBuffer){for(let Ce=0;Ce<Z.locationSize;Ce++)v(Z.location+Ce,xe.meshPerAttribute);R.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=xe.meshPerAttribute*xe.count)}else for(let Ce=0;Ce<Z.locationSize;Ce++)b(Z.location+Ce);t.bindBuffer(t.ARRAY_BUFFER,se);for(let Ce=0;Ce<Z.locationSize;Ce++)S(Z.location+Ce,z/Z.locationSize,ae,ne,be*de,(fe+z/Z.locationSize*Ce)*de,me)}else{if(te.isInstancedBufferAttribute){for(let xe=0;xe<Z.locationSize;xe++)v(Z.location+xe,te.meshPerAttribute);R.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=te.meshPerAttribute*te.count)}else for(let xe=0;xe<Z.locationSize;xe++)b(Z.location+xe);t.bindBuffer(t.ARRAY_BUFFER,se);for(let xe=0;xe<Z.locationSize;xe++)S(Z.location+xe,z/Z.locationSize,ae,ne,z*de,z/Z.locationSize*xe*de,me)}}else if(Y!==void 0){const ne=Y[K];if(ne!==void 0)switch(ne.length){case 2:t.vertexAttrib2fv(Z.location,ne);break;case 3:t.vertexAttrib3fv(Z.location,ne);break;case 4:t.vertexAttrib4fv(Z.location,ne);break;default:t.vertexAttrib1fv(Z.location,ne)}}}}N()}function E(){D();for(const R in r){const F=r[R];for(const O in F){const q=F[O];for(const j in q)d(q[j].object),delete q[j];delete F[O]}delete r[R]}}function k(R){if(r[R.id]===void 0)return;const F=r[R.id];for(const O in F){const q=F[O];for(const j in q)d(q[j].object),delete q[j];delete F[O]}delete r[R.id]}function C(R){for(const F in r){const O=r[F];if(O[R.id]===void 0)continue;const q=O[R.id];for(const j in q)d(q[j].object),delete q[j];delete O[R.id]}}function D(){A(),o=!0,s!==i&&(s=i,u(s.object))}function A(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:D,resetDefaultState:A,dispose:E,releaseStatesOfGeometry:k,releaseStatesOfProgram:C,initAttributes:y,enableAttribute:b,disableUnusedAttributes:N}}function jDe(t,e,n){let r;function i(u){r=u}function s(u,d){t.drawArrays(r,u,d),n.update(d,r,1)}function o(u,d,f){f!==0&&(t.drawArraysInstanced(r,u,d,f),n.update(d,r,f))}function l(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,u,0,d,0,f);let g=0;for(let x=0;x<f;x++)g+=d[x];n.update(g,r,1)}function c(u,d,f,m){if(f===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let x=0;x<u.length;x++)o(u[x],d[x],m[x]);else{g.multiDrawArraysInstancedWEBGL(r,u,0,d,0,m,0,f);let x=0;for(let y=0;y<f;y++)x+=d[y]*m[y];n.update(x,r,1)}}this.setMode=i,this.render=s,this.renderInstances=o,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function PDe(t,e,n,r){let i;function s(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(C){return!(C!==rl&&r.convert(C)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(C){const D=C===ex&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==Gl&&r.convert(C)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==Kc&&!D)}function c(C){if(C==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let u=n.precision!==void 0?n.precision:"highp";const d=c(u);d!==u&&(mn("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,m=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),g=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),x=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=t.getParameter(t.MAX_TEXTURE_SIZE),b=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),N=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),S=t.getParameter(t.MAX_VARYING_VECTORS),T=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),E=x>0,k=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:l,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:m,maxTextures:g,maxVertexTextures:x,maxTextureSize:y,maxCubemapSize:b,maxAttributes:v,maxVertexUniforms:N,maxVaryings:S,maxFragmentUniforms:T,vertexTextures:E,maxSamples:k}}function RDe(t){const e=this;let n=null,r=0,i=!1,s=!1;const o=new fd,l=new Tn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,m){const g=f.length!==0||m||r!==0||i;return i=m,r=f.length,g},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,m){n=d(f,m,0)},this.setState=function(f,m,g){const x=f.clippingPlanes,y=f.clipIntersection,b=f.clipShadows,v=t.get(f);if(!i||x===null||x.length===0||s&&!b)s?d(null):u();else{const N=s?0:r,S=N*4;let T=v.clippingState||null;c.value=T,T=d(x,m,S,g);for(let E=0;E!==S;++E)T[E]=n[E];v.clippingState=T,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=N}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,m,g,x){const y=f!==null?f.length:0;let b=null;if(y!==0){if(b=c.value,x!==!0||b===null){const v=g+y*4,N=m.matrixWorldInverse;l.getNormalMatrix(N),(b===null||b.length<v)&&(b=new Float32Array(v));for(let S=0,T=g;S!==y;++S,T+=4)o.copy(f[S]).applyMatrix4(N,l),o.normal.toArray(b,T),b[T+3]=o.constant}c.value=b,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,b}}function DDe(t){let e=new WeakMap;function n(o,l){return l===fP?o.mapping=vg:l===mP&&(o.mapping=_g),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===fP||l===mP)if(e.has(o)){const c=e.get(o).texture;return n(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const u=new A3e(c.height);return u.fromEquirectangularTexture(t,o),e.set(o,u),o.addEventListener("dispose",i),n(u.texture,o.mapping)}else return null}}return o}function i(o){const l=o.target;l.removeEventListener("dispose",i);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}const Md=4,WH=[.125,.215,.35,.446,.526,.582],Jh=20,ODe=256,gb=new gJ,KH=new Rn;let YA=null,QA=0,ZA=0,JA=!1;const LDe=new ot;let XH=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,n=0,r=.1,i=100,s={}){const{size:o=256,position:l=LDe}=s;YA=this._renderer.getRenderTarget(),QA=this._renderer.getActiveCubeFace(),ZA=this._renderer.getActiveMipmapLevel(),JA=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,r,i,c,l),n>0&&this._blur(c,0,0,n),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ZH(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=QH(),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(YA,QA,ZA),this._renderer.xr.enabled=JA,e.scissorTest=!1,sp(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===vg||e.mapping===_g?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),YA=this._renderer.getRenderTarget(),QA=this._renderer.getActiveCubeFace(),ZA=this._renderer.getActiveMipmapLevel(),JA=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:Ao,minFilter:Ao,generateMipmaps:!1,type:ex,format:rl,colorSpace:wg,depthBuffer:!1},i=YH(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=YH(e,n,r);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=IDe(s)),this._blurMaterial=UDe(s,e,n),this._ggxMaterial=FDe(s,e,n)}return i}_compileMaterial(e){const n=new ql(new ec,e);this._renderer.compile(n,gb)}_sceneToCubeUV(e,n,r,i,s){const c=new So(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,m=f.autoClear,g=f.toneMapping;f.getClearColor(KH),f.toneMapping=Ld,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new ql(new DO,new RO({name:"PMREM.Background",side:_s,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,b=y.material;let v=!1;const N=e.background;N?N.isColor&&(b.color.copy(N),e.background=null,v=!0):(b.color.copy(KH),v=!0);for(let S=0;S<6;S++){const T=S%3;T===0?(c.up.set(0,u[S],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+d[S],s.y,s.z)):T===1?(c.up.set(0,0,u[S]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+d[S],s.z)):(c.up.set(0,u[S],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+d[S]));const E=this._cubeSize;sp(i,T*E,S>2?E:0,E,E),f.setRenderTarget(i),v&&f.render(y,c),f.render(e,c)}f.toneMapping=g,f.autoClear=m,e.background=N}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===vg||e.mapping===_g;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=ZH()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=QH());const s=i?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=s;const l=s.uniforms;l.envMap.value=e;const c=this._cubeSize;sp(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,gb)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;const i=this._lodMeshes.length;for(let s=1;s<i;s++)this._applyGGXFilter(e,s-1,s);n.autoClear=r}_applyGGXFilter(e,n,r){const i=this._renderer,s=this._pingPongRenderTarget,o=this._ggxMaterial,l=this._lodMeshes[r];l.material=o;const c=o.uniforms,u=r/(this._lodMeshes.length-1),d=n/(this._lodMeshes.length-1),f=Math.sqrt(u*u-d*d),m=.05+u*.95,g=f*m,{_lodMax:x}=this,y=this._sizeLods[r],b=3*y*(r>x-Md?r-x+Md:0),v=4*(this._cubeSize-y);c.envMap.value=e.texture,c.roughness.value=g,c.mipInt.value=x-n,sp(s,b,v,3*y,2*y),i.setRenderTarget(s),i.render(l,gb),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=x-r,sp(e,b,v,3*y,2*y),i.setRenderTarget(e),i.render(l,gb)}_blur(e,n,r,i,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",s),this._halfBlur(o,e,r,r,i,"longitudinal",s)}_halfBlur(e,n,r,i,s,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&hi("blur direction must be either latitudinal or longitudinal!");const d=3,f=this._lodMeshes[i];f.material=u;const m=u.uniforms,g=this._sizeLods[r]-1,x=isFinite(s)?Math.PI/(2*g):2*Math.PI/(2*Jh-1),y=s/x,b=isFinite(s)?1+Math.floor(d*y):Jh;b>Jh&&mn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${Jh}`);const v=[];let N=0;for(let C=0;C<Jh;++C){const D=C/y,A=Math.exp(-D*D/2);v.push(A),C===0?N+=A:C<b&&(N+=2*A)}for(let C=0;C<v.length;C++)v[C]=v[C]/N;m.envMap.value=e.texture,m.samples.value=b,m.weights.value=v,m.latitudinal.value=o==="latitudinal",l&&(m.poleAxis.value=l);const{_lodMax:S}=this;m.dTheta.value=x,m.mipInt.value=S-r;const T=this._sizeLods[i],E=3*T*(i>S-Md?i-S+Md:0),k=4*(this._cubeSize-T);sp(n,E,k,3*T,2*T),c.setRenderTarget(n),c.render(f,gb)}};function IDe(t){const e=[],n=[],r=[];let i=t;const s=t-Md+1+WH.length;for(let o=0;o<s;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-Md?c=WH[o-t+Md-1]:o===0&&(c=0),n.push(c);const u=1/(l-2),d=-u,f=1+u,m=[d,d,f,d,f,f,d,d,f,f,d,f],g=6,x=6,y=3,b=2,v=1,N=new Float32Array(y*x*g),S=new Float32Array(b*x*g),T=new Float32Array(v*x*g);for(let k=0;k<g;k++){const C=k%3*2/3-1,D=k>2?0:-1,A=[C,D,0,C+2/3,D,0,C+2/3,D+1,0,C,D,0,C+2/3,D+1,0,C,D+1,0];N.set(A,y*x*k),S.set(m,b*x*k);const R=[k,k,k,k,k,k];T.set(R,v*x*k)}const E=new ec;E.setAttribute("position",new ko(N,y)),E.setAttribute("uv",new ko(S,b)),E.setAttribute("faceIndex",new ko(T,v)),r.push(new ql(E,null)),i>Md&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function YH(t,e,n){const r=new Wf(t,e,n);return r.texture.mapping=$N,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function sp(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function FDe(t,e,n){return new xu({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:ODe,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:VN(),fragmentShader:`
- precision highp float;
- precision highp int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform float roughness;
- uniform float mipInt;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- #define PI 3.14159265359
- // Van der Corput radical inverse
- float radicalInverse_VdC(uint bits) {
- bits = (bits << 16u) | (bits >> 16u);
- bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
- bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
- bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
- bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
- return float(bits) * 2.3283064365386963e-10; // / 0x100000000
- }
- // Hammersley sequence
- vec2 hammersley(uint i, uint N) {
- return vec2(float(i) / float(N), radicalInverse_VdC(i));
- }
- // GGX VNDF importance sampling (Eric Heitz 2018)
- // "Sampling the GGX Distribution of Visible Normals"
- // https://jcgt.org/published/0007/04/01/
- vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
- float alpha = roughness * roughness;
- // Section 3.2: Transform view direction to hemisphere configuration
- vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
- // Section 4.1: Orthonormal basis
- float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
- vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
- vec3 T2 = cross(Vh, T1);
- // Section 4.2: Parameterization of projected area
- float r = sqrt(Xi.x);
- float phi = 2.0 * PI * Xi.y;
- float t1 = r * cos(phi);
- float t2 = r * sin(phi);
- float s = 0.5 * (1.0 + Vh.z);
- t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
- // Section 4.3: Reprojection onto hemisphere
- vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
- // Section 3.4: Transform back to ellipsoid configuration
- return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
- }
- void main() {
- vec3 N = normalize(vOutputDirection);
- vec3 V = N; // Assume view direction equals normal for pre-filtering
- vec3 prefilteredColor = vec3(0.0);
- float totalWeight = 0.0;
- // For very low roughness, just sample the environment directly
- if (roughness < 0.001) {
- gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
- return;
- }
- // Tangent space basis for VNDF sampling
- vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
- vec3 tangent = normalize(cross(up, N));
- vec3 bitangent = cross(N, tangent);
- for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
- vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
- // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
- vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
- // Transform H back to world space
- vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
- vec3 L = normalize(2.0 * dot(V, H) * H - V);
- float NdotL = max(dot(N, L), 0.0);
- if(NdotL > 0.0) {
- // Sample environment at fixed mip level
- // VNDF importance sampling handles the distribution filtering
- vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
- // Weight by NdotL for the split-sum approximation
- // VNDF PDF naturally accounts for the visible microfacet distribution
- prefilteredColor += sampleColor * NdotL;
- totalWeight += NdotL;
- }
- }
- if (totalWeight > 0.0) {
- prefilteredColor = prefilteredColor / totalWeight;
- }
- gl_FragColor = vec4(prefilteredColor, 1.0);
- }
- `,blending:tu,depthTest:!1,depthWrite:!1})}function UDe(t,e,n){const r=new Float32Array(Jh),i=new ot(0,1,0);return new xu({name:"SphericalGaussianBlur",defines:{n:Jh,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:VN(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:tu,depthTest:!1,depthWrite:!1})}function QH(){return new xu({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:VN(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:tu,depthTest:!1,depthWrite:!1})}function ZH(){return new xu({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:VN(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:tu,depthTest:!1,depthWrite:!1})}function VN(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function zDe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===fP||c===mP,d=c===vg||c===_g;if(u||d){let f=e.get(l);const m=f!==void 0?f.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==m)return n===null&&(n=new XH(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),f.texture;if(f!==void 0)return f.texture;{const g=l.image;return u&&g&&g.height>0||d&&g&&i(g)?(n===null&&(n=new XH(t)),f=u?n.fromEquirectangular(l):n.fromCubemap(l),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),l.addEventListener("dispose",s),f.texture):null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function s(l){const c=l.target;c.removeEventListener("dispose",s);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function BDe(t){const e={};function n(r){if(e[r]!==void 0)return e[r];const i=t.getExtension(r);return e[r]=i,i}return{has:function(r){return n(r)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(r){const i=n(r);return i===null&&z0("WebGLRenderer: "+r+" extension not supported."),i}}}function $De(t,e,n,r){const i={},s=new WeakMap;function o(f){const m=f.target;m.index!==null&&e.remove(m.index);for(const x in m.attributes)e.remove(m.attributes[x]);m.removeEventListener("dispose",o),delete i[m.id];const g=s.get(m);g&&(e.remove(g),s.delete(m)),r.releaseStatesOfGeometry(m),m.isInstancedBufferGeometry===!0&&delete m._maxInstanceCount,n.memory.geometries--}function l(f,m){return i[m.id]===!0||(m.addEventListener("dispose",o),i[m.id]=!0,n.memory.geometries++),m}function c(f){const m=f.attributes;for(const g in m)e.update(m[g],t.ARRAY_BUFFER)}function u(f){const m=[],g=f.index,x=f.attributes.position;let y=0;if(g!==null){const N=g.array;y=g.version;for(let S=0,T=N.length;S<T;S+=3){const E=N[S+0],k=N[S+1],C=N[S+2];m.push(E,k,k,C,C,E)}}else if(x!==void 0){const N=x.array;y=x.version;for(let S=0,T=N.length/3-1;S<T;S+=3){const E=S+0,k=S+1,C=S+2;m.push(E,k,k,C,C,E)}}else return;const b=new(XZ(m)?aJ:iJ)(m,1);b.version=y;const v=s.get(f);v&&e.remove(v),s.set(f,b)}function d(f){const m=s.get(f);if(m){const g=f.index;g!==null&&m.version<g.version&&u(f)}else u(f);return s.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function HDe(t,e,n){let r;function i(m){r=m}let s,o;function l(m){s=m.type,o=m.bytesPerElement}function c(m,g){t.drawElements(r,g,s,m*o),n.update(g,r,1)}function u(m,g,x){x!==0&&(t.drawElementsInstanced(r,g,s,m*o,x),n.update(g,r,x))}function d(m,g,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,g,0,s,m,0,x);let b=0;for(let v=0;v<x;v++)b+=g[v];n.update(b,r,1)}function f(m,g,x,y){if(x===0)return;const b=e.get("WEBGL_multi_draw");if(b===null)for(let v=0;v<m.length;v++)u(m[v]/o,g[v],y[v]);else{b.multiDrawElementsInstancedWEBGL(r,g,0,s,m,0,y,0,x);let v=0;for(let N=0;N<x;N++)v+=g[N]*y[N];n.update(v,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function VDe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,o,l){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=l*(s/3);break;case t.LINES:n.lines+=l*(s/2);break;case t.LINE_STRIP:n.lines+=l*(s-1);break;case t.LINE_LOOP:n.lines+=l*s;break;case t.POINTS:n.points+=l*s;break;default:hi("WebGLInfo: Unknown draw mode:",o);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function GDe(t,e,n){const r=new WeakMap,i=new Si;function s(o,l,c){const u=o.morphTargetInfluences,d=l.morphAttributes.position||l.morphAttributes.normal||l.morphAttributes.color,f=d!==void 0?d.length:0;let m=r.get(l);if(m===void 0||m.count!==f){let R=function(){D.dispose(),r.delete(l),l.removeEventListener("dispose",R)};var g=R;m!==void 0&&m.texture.dispose();const x=l.morphAttributes.position!==void 0,y=l.morphAttributes.normal!==void 0,b=l.morphAttributes.color!==void 0,v=l.morphAttributes.position||[],N=l.morphAttributes.normal||[],S=l.morphAttributes.color||[];let T=0;x===!0&&(T=1),y===!0&&(T=2),b===!0&&(T=3);let E=l.attributes.position.count*T,k=1;E>e.maxTextureSize&&(k=Math.ceil(E/e.maxTextureSize),E=e.maxTextureSize);const C=new Float32Array(E*k*4*f),D=new eJ(C,E,k,f);D.type=Kc,D.needsUpdate=!0;const A=T*4;for(let F=0;F<f;F++){const O=v[F],q=N[F],j=S[F],G=E*k*4*F;for(let Y=0;Y<O.count;Y++){const K=Y*A;x===!0&&(i.fromBufferAttribute(O,Y),C[G+K+0]=i.x,C[G+K+1]=i.y,C[G+K+2]=i.z,C[G+K+3]=0),y===!0&&(i.fromBufferAttribute(q,Y),C[G+K+4]=i.x,C[G+K+5]=i.y,C[G+K+6]=i.z,C[G+K+7]=0),b===!0&&(i.fromBufferAttribute(j,Y),C[G+K+8]=i.x,C[G+K+9]=i.y,C[G+K+10]=i.z,C[G+K+11]=j.itemSize===4?i.w:1)}}m={count:f,texture:D,size:new Nn(E,k)},r.set(l,m),l.addEventListener("dispose",R)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(t,"morphTexture",o.morphTexture,n);else{let x=0;for(let b=0;b<u.length;b++)x+=u[b];const y=l.morphTargetsRelative?1:1-x;c.getUniforms().setValue(t,"morphTargetBaseInfluence",y),c.getUniforms().setValue(t,"morphTargetInfluences",u)}c.getUniforms().setValue(t,"morphTargetsTexture",m.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",m.size)}return{update:s}}function qDe(t,e,n,r){let i=new WeakMap;function s(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const m=c.skeleton;i.get(m)!==u&&(m.update(),i.set(m,u))}return f}function o(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:s,dispose:o}}const bJ=new pl,JH=new hJ(1,1),yJ=new eJ,vJ=new h3e,_J=new uJ,eV=[],tV=[],nV=new Float32Array(16),rV=new Float32Array(9),iV=new Float32Array(4);function nx(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=eV[i];if(s===void 0&&(s=new Float32Array(i),eV[i]=s),e!==0){r.toArray(s,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(s,l)}return s}function Li(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 Ii(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function GN(t,e){let n=tV[e];n===void 0&&(n=new Int32Array(e),tV[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function WDe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function KDe(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(Li(n,e))return;t.uniform2fv(this.addr,e),Ii(n,e)}}function XDe(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(Li(n,e))return;t.uniform3fv(this.addr,e),Ii(n,e)}}function YDe(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(Li(n,e))return;t.uniform4fv(this.addr,e),Ii(n,e)}}function QDe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Li(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Ii(n,e)}else{if(Li(n,r))return;iV.set(r),t.uniformMatrix2fv(this.addr,!1,iV),Ii(n,r)}}function ZDe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Li(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Ii(n,e)}else{if(Li(n,r))return;rV.set(r),t.uniformMatrix3fv(this.addr,!1,rV),Ii(n,r)}}function JDe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Li(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Ii(n,e)}else{if(Li(n,r))return;nV.set(r),t.uniformMatrix4fv(this.addr,!1,nV),Ii(n,r)}}function e4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function t4e(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(Li(n,e))return;t.uniform2iv(this.addr,e),Ii(n,e)}}function n4e(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(Li(n,e))return;t.uniform3iv(this.addr,e),Ii(n,e)}}function r4e(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(Li(n,e))return;t.uniform4iv(this.addr,e),Ii(n,e)}}function i4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function a4e(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(Li(n,e))return;t.uniform2uiv(this.addr,e),Ii(n,e)}}function s4e(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(Li(n,e))return;t.uniform3uiv(this.addr,e),Ii(n,e)}}function o4e(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(Li(n,e))return;t.uniform4uiv(this.addr,e),Ii(n,e)}}function l4e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);let s;this.type===t.SAMPLER_2D_SHADOW?(JH.compareFunction=KZ,s=JH):s=bJ,n.setTexture2D(e||s,i)}function c4e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||vJ,i)}function u4e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||_J,i)}function d4e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||yJ,i)}function h4e(t){switch(t){case 5126:return WDe;case 35664:return KDe;case 35665:return XDe;case 35666:return YDe;case 35674:return QDe;case 35675:return ZDe;case 35676:return JDe;case 5124:case 35670:return e4e;case 35667:case 35671:return t4e;case 35668:case 35672:return n4e;case 35669:case 35673:return r4e;case 5125:return i4e;case 36294:return a4e;case 36295:return s4e;case 36296:return o4e;case 35678:case 36198:case 36298:case 36306:case 35682:return l4e;case 35679:case 36299:case 36307:return c4e;case 35680:case 36300:case 36308:case 36293:return u4e;case 36289:case 36303:case 36311:case 36292:return d4e}}function f4e(t,e){t.uniform1fv(this.addr,e)}function m4e(t,e){const n=nx(e,this.size,2);t.uniform2fv(this.addr,n)}function p4e(t,e){const n=nx(e,this.size,3);t.uniform3fv(this.addr,n)}function g4e(t,e){const n=nx(e,this.size,4);t.uniform4fv(this.addr,n)}function x4e(t,e){const n=nx(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function b4e(t,e){const n=nx(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function y4e(t,e){const n=nx(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function v4e(t,e){t.uniform1iv(this.addr,e)}function _4e(t,e){t.uniform2iv(this.addr,e)}function w4e(t,e){t.uniform3iv(this.addr,e)}function S4e(t,e){t.uniform4iv(this.addr,e)}function N4e(t,e){t.uniform1uiv(this.addr,e)}function M4e(t,e){t.uniform2uiv(this.addr,e)}function E4e(t,e){t.uniform3uiv(this.addr,e)}function T4e(t,e){t.uniform4uiv(this.addr,e)}function C4e(t,e,n){const r=this.cache,i=e.length,s=GN(n,i);Li(r,s)||(t.uniform1iv(this.addr,s),Ii(r,s));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||bJ,s[o])}function A4e(t,e,n){const r=this.cache,i=e.length,s=GN(n,i);Li(r,s)||(t.uniform1iv(this.addr,s),Ii(r,s));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||vJ,s[o])}function k4e(t,e,n){const r=this.cache,i=e.length,s=GN(n,i);Li(r,s)||(t.uniform1iv(this.addr,s),Ii(r,s));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||_J,s[o])}function j4e(t,e,n){const r=this.cache,i=e.length,s=GN(n,i);Li(r,s)||(t.uniform1iv(this.addr,s),Ii(r,s));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||yJ,s[o])}function P4e(t){switch(t){case 5126:return f4e;case 35664:return m4e;case 35665:return p4e;case 35666:return g4e;case 35674:return x4e;case 35675:return b4e;case 35676:return y4e;case 5124:case 35670:return v4e;case 35667:case 35671:return _4e;case 35668:case 35672:return w4e;case 35669:case 35673:return S4e;case 5125:return N4e;case 36294:return M4e;case 36295:return E4e;case 36296:return T4e;case 35678:case 36198:case 36298:case 36306:case 35682:return C4e;case 35679:case 36299:case 36307:return A4e;case 35680:case 36300:case 36308:case 36293:return k4e;case 36289:case 36303:case 36311:case 36292:return j4e}}let R4e=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=h4e(n.type)}},D4e=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=P4e(n.type)}},O4e=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let s=0,o=i.length;s!==o;++s){const l=i[s];l.setValue(e,n[l.id],r)}}};const ek=/(\w+)(\])?(\[|\.)?/g;function aV(t,e){t.seq.push(e),t.map[e.id]=e}function L4e(t,e,n){const r=t.name,i=r.length;for(ek.lastIndex=0;;){const s=ek.exec(r),o=ek.lastIndex;let l=s[1];const c=s[2]==="]",u=s[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){aV(n,u===void 0?new R4e(l,t,e):new D4e(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new O4e(l),aV(n,f)),n=f}}}let aw=class{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const s=e.getActiveUniform(n,i),o=e.getUniformLocation(n,s.name);L4e(s,o,this)}}setValue(e,n,r,i){const s=this.map[n];s!==void 0&&s.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let s=0,o=n.length;s!==o;++s){const l=n[s],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,s=e.length;i!==s;++i){const o=e[i];o.id in n&&r.push(o)}return r}};function sV(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const I4e=37297;let F4e=0;function U4e(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let o=i;o<s;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
- `)}const oV=new Tn;function z4e(t){Yn._getMatrix(oV,Yn.workingColorSpace,t);const e=`mat3( ${oV.elements.map(n=>n.toFixed(4))} )`;switch(Yn.getTransfer(t)){case SS:return[e,"LinearTransferOETF"];case pr:return[e,"sRGBTransferOETF"];default:return mn("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function lV(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),s=(t.getShaderInfoLog(e)||"").trim();if(r&&s==="")return"";const o=/ERROR: 0:(\d+)/.exec(s);if(o){const l=parseInt(o[1]);return n.toUpperCase()+`
- `+s+`
- `+U4e(t.getShaderSource(e),l)}else return s}function B4e(t,e){const n=z4e(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}function $4e(t,e){let n;switch(e){case Uje:n="Linear";break;case zje:n="Reinhard";break;case Bje:n="Cineon";break;case $je:n="ACESFilmic";break;case Vje:n="AgX";break;case Gje:n="Neutral";break;case Hje:n="Custom";break;default:mn("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const q_=new ot;function H4e(){Yn.getLuminanceCoefficients(q_);const t=q_.x.toFixed(4),e=q_.y.toFixed(4),n=q_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function V4e(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Pb).join(`
- `)}function G4e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function q4e(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const s=t.getActiveAttrib(e,i),o=s.name;let l=1;s.type===t.FLOAT_MAT2&&(l=2),s.type===t.FLOAT_MAT3&&(l=3),s.type===t.FLOAT_MAT4&&(l=4),n[o]={type:s.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function Pb(t){return t!==""}function cV(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 uV(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const W4e=/^[ \t]*#include +<([\w\d./]+)>/gm;function WP(t){return t.replace(W4e,X4e)}const K4e=new Map;function X4e(t,e){let n=_n[e];if(n===void 0){const r=K4e.get(e);if(r!==void 0)n=_n[r],mn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return WP(n)}const Y4e=/#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 dV(t){return t.replace(Y4e,Q4e)}function Q4e(t,e,n,r){let i="";for(let s=parseInt(e);s<parseInt(n);s++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function hV(t){let e=`precision ${t.precision} float;
- precision ${t.precision} int;
- precision ${t.precision} sampler2D;
- precision ${t.precision} samplerCube;
- precision ${t.precision} sampler3D;
- precision ${t.precision} sampler2DArray;
- precision ${t.precision} sampler2DShadow;
- precision ${t.precision} samplerCubeShadow;
- precision ${t.precision} sampler2DArrayShadow;
- precision ${t.precision} isampler2D;
- precision ${t.precision} isampler3D;
- precision ${t.precision} isamplerCube;
- precision ${t.precision} isampler2DArray;
- precision ${t.precision} usampler2D;
- precision ${t.precision} usampler3D;
- precision ${t.precision} usamplerCube;
- precision ${t.precision} usampler2DArray;
- `;return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function Z4e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===FZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===bje?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Oc&&(e="SHADOWMAP_TYPE_VSM"),e}function J4e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case vg:case _g:e="ENVMAP_TYPE_CUBE";break;case $N:e="ENVMAP_TYPE_CUBE_UV";break}return e}function eOe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case _g:e="ENVMAP_MODE_REFRACTION";break}return e}function tOe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case SO:e="ENVMAP_BLENDING_MULTIPLY";break;case Ije:e="ENVMAP_BLENDING_MIX";break;case Fje:e="ENVMAP_BLENDING_ADD";break}return e}function nOe(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 rOe(t,e,n,r){const i=t.getContext(),s=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=Z4e(n),u=J4e(n),d=eOe(n),f=tOe(n),m=nOe(n),g=V4e(n),x=G4e(s),y=i.createProgram();let b,v,N=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Pb).join(`
- `),b.length>0&&(b+=`
- `),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Pb).join(`
- `),v.length>0&&(v+=`
- `)):(b=[hV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(Pb).join(`
- `),v=[hV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Ld?"#define TONE_MAPPING":"",n.toneMapping!==Ld?_n.tonemapping_pars_fragment:"",n.toneMapping!==Ld?$4e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",_n.colorspace_pars_fragment,B4e("linearToOutputTexel",n.outputColorSpace),H4e(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Pb).join(`
- `)),o=WP(o),o=cV(o,n),o=uV(o,n),l=WP(l),l=cV(l,n),l=uV(l,n),o=dV(o),l=dV(l),n.isRawShaderMaterial!==!0&&(N=`#version 300 es
- `,b=[g,"#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+b,v=["#define varying in",n.glslVersion===yH?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===yH?"":"#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(`
- `)+`
- `+v);const S=N+b+o,T=N+v+l,E=sV(i,i.VERTEX_SHADER,S),k=sV(i,i.FRAGMENT_SHADER,T);i.attachShader(y,E),i.attachShader(y,k),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function C(F){if(t.debug.checkShaderErrors){const O=i.getProgramInfoLog(y)||"",q=i.getShaderInfoLog(E)||"",j=i.getShaderInfoLog(k)||"",G=O.trim(),Y=q.trim(),K=j.trim();let Z=!0,te=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(Z=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,E,k);else{const ne=lV(i,E,"vertex"),z=lV(i,k,"fragment");hi("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
- Material Name: `+F.name+`
- Material Type: `+F.type+`
- Program Info Log: `+G+`
- `+ne+`
- `+z)}else G!==""?mn("WebGLProgram: Program Info Log:",G):(Y===""||K==="")&&(te=!1);te&&(F.diagnostics={runnable:Z,programLog:G,vertexShader:{log:Y,prefix:b},fragmentShader:{log:K,prefix:v}})}i.deleteShader(E),i.deleteShader(k),D=new aw(i,y),A=q4e(i,y)}let D;this.getUniforms=function(){return D===void 0&&C(this),D};let A;this.getAttributes=function(){return A===void 0&&C(this),A};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(y,I4e)),R},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=F4e++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=E,this.fragmentShader=k,this}let iOe=0,aOe=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),s=this._getShaderStage(r),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new sOe(e),n.set(e,r)),r}},sOe=class{constructor(e){this.id=iOe++,this.code=e,this.usedTimes=0}};function oOe(t,e,n,r,i,s,o){const l=new nJ,c=new aOe,u=new Set,d=[],f=i.logarithmicDepthBuffer,m=i.vertexTextures;let g=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(A){return u.add(A),A===0?"uv":`uv${A}`}function b(A,R,F,O,q){const j=O.fog,G=q.geometry,Y=A.isMeshStandardMaterial?O.environment:null,K=(A.isMeshStandardMaterial?n:e).get(A.envMap||Y),Z=K&&K.mapping===$N?K.image.height:null,te=x[A.type];A.precision!==null&&(g=i.getMaxPrecision(A.precision),g!==A.precision&&mn("WebGLProgram.getParameters:",A.precision,"not supported, using",g,"instead."));const ne=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,z=ne!==void 0?ne.length:0;let W=0;G.morphAttributes.position!==void 0&&(W=1),G.morphAttributes.normal!==void 0&&(W=2),G.morphAttributes.color!==void 0&&(W=3);let se,ae,de,me;if(te){const jt=Cl[te];se=jt.vertexShader,ae=jt.fragmentShader}else se=A.vertexShader,ae=A.fragmentShader,c.update(A),de=c.getVertexShaderID(A),me=c.getFragmentShaderID(A);const xe=t.getRenderTarget(),be=t.state.buffers.depth.getReversed(),fe=q.isInstancedMesh===!0,Ce=q.isBatchedMesh===!0,Ne=!!A.map,re=!!A.matcap,He=!!K,H=!!A.aoMap,B=!!A.lightMap,X=!!A.bumpMap,U=!!A.normalMap,Q=!!A.displacementMap,le=!!A.emissiveMap,Pe=!!A.metalnessMap,Oe=!!A.roughnessMap,je=A.anisotropy>0,$=A.clearcoat>0,I=A.dispersion>0,V=A.iridescence>0,ie=A.sheen>0,Se=A.transmission>0,ye=je&&!!A.anisotropyMap,$e=$&&!!A.clearcoatMap,Ue=$&&!!A.clearcoatNormalMap,Ge=$&&!!A.clearcoatRoughnessMap,We=V&&!!A.iridescenceMap,Ye=V&&!!A.iridescenceThicknessMap,oe=ie&&!!A.sheenColorMap,ve=ie&&!!A.sheenRoughnessMap,Le=!!A.specularMap,Ke=!!A.specularColorMap,lt=!!A.specularIntensityMap,_e=Se&&!!A.transmissionMap,ce=Se&&!!A.thicknessMap,ee=!!A.gradientMap,ke=!!A.alphaMap,De=A.alphaTest>0,Ae=!!A.alphaHash,Je=!!A.extensions;let gt=Ld;A.toneMapped&&(xe===null||xe.isXRRenderTarget===!0)&&(gt=t.toneMapping);const At={shaderID:te,shaderType:A.type,shaderName:A.name,vertexShader:se,fragmentShader:ae,defines:A.defines,customVertexShaderID:de,customFragmentShaderID:me,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:g,batching:Ce,batchingColor:Ce&&q._colorsTexture!==null,instancing:fe,instancingColor:fe&&q.instanceColor!==null,instancingMorph:fe&&q.morphTexture!==null,supportsVertexTextures:m,outputColorSpace:xe===null?t.outputColorSpace:xe.isXRRenderTarget===!0?xe.texture.colorSpace:wg,alphaToCoverage:!!A.alphaToCoverage,map:Ne,matcap:re,envMap:He,envMapMode:He&&K.mapping,envMapCubeUVHeight:Z,aoMap:H,lightMap:B,bumpMap:X,normalMap:U,displacementMap:m&&Q,emissiveMap:le,normalMapObjectSpace:U&&A.normalMapType===Xje,normalMapTangentSpace:U&&A.normalMapType===WZ,metalnessMap:Pe,roughnessMap:Oe,anisotropy:je,anisotropyMap:ye,clearcoat:$,clearcoatMap:$e,clearcoatNormalMap:Ue,clearcoatRoughnessMap:Ge,dispersion:I,iridescence:V,iridescenceMap:We,iridescenceThicknessMap:Ye,sheen:ie,sheenColorMap:oe,sheenRoughnessMap:ve,specularMap:Le,specularColorMap:Ke,specularIntensityMap:lt,transmission:Se,transmissionMap:_e,thicknessMap:ce,gradientMap:ee,opaque:A.transparent===!1&&A.blending===Jp&&A.alphaToCoverage===!1,alphaMap:ke,alphaTest:De,alphaHash:Ae,combine:A.combine,mapUv:Ne&&y(A.map.channel),aoMapUv:H&&y(A.aoMap.channel),lightMapUv:B&&y(A.lightMap.channel),bumpMapUv:X&&y(A.bumpMap.channel),normalMapUv:U&&y(A.normalMap.channel),displacementMapUv:Q&&y(A.displacementMap.channel),emissiveMapUv:le&&y(A.emissiveMap.channel),metalnessMapUv:Pe&&y(A.metalnessMap.channel),roughnessMapUv:Oe&&y(A.roughnessMap.channel),anisotropyMapUv:ye&&y(A.anisotropyMap.channel),clearcoatMapUv:$e&&y(A.clearcoatMap.channel),clearcoatNormalMapUv:Ue&&y(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ge&&y(A.clearcoatRoughnessMap.channel),iridescenceMapUv:We&&y(A.iridescenceMap.channel),iridescenceThicknessMapUv:Ye&&y(A.iridescenceThicknessMap.channel),sheenColorMapUv:oe&&y(A.sheenColorMap.channel),sheenRoughnessMapUv:ve&&y(A.sheenRoughnessMap.channel),specularMapUv:Le&&y(A.specularMap.channel),specularColorMapUv:Ke&&y(A.specularColorMap.channel),specularIntensityMapUv:lt&&y(A.specularIntensityMap.channel),transmissionMapUv:_e&&y(A.transmissionMap.channel),thicknessMapUv:ce&&y(A.thicknessMap.channel),alphaMapUv:ke&&y(A.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(U||je),vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,pointsUvs:q.isPoints===!0&&!!G.attributes.uv&&(Ne||ke),fog:!!j,useFog:A.fog===!0,fogExp2:!!j&&j.isFogExp2,flatShading:A.flatShading===!0&&A.wireframe===!1,sizeAttenuation:A.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:be,skinning:q.isSkinnedMesh===!0,morphTargets:G.morphAttributes.position!==void 0,morphNormals:G.morphAttributes.normal!==void 0,morphColors:G.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:W,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numSpotLightMaps:R.spotLightMap.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numSpotLightShadowsWithMaps:R.numSpotLightShadowsWithMaps,numLightProbes:R.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:A.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:gt,decodeVideoTexture:Ne&&A.map.isVideoTexture===!0&&Yn.getTransfer(A.map.colorSpace)===pr,decodeVideoTextureEmissive:le&&A.emissiveMap.isVideoTexture===!0&&Yn.getTransfer(A.emissiveMap.colorSpace)===pr,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===Al,flipSided:A.side===_s,useDepthPacking:A.depthPacking>=0,depthPacking:A.depthPacking||0,index0AttributeName:A.index0AttributeName,extensionClipCullDistance:Je&&A.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Je&&A.extensions.multiDraw===!0||Ce)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:A.customProgramCacheKey()};return At.vertexUv1s=u.has(1),At.vertexUv2s=u.has(2),At.vertexUv3s=u.has(3),u.clear(),At}function v(A){const R=[];if(A.shaderID?R.push(A.shaderID):(R.push(A.customVertexShaderID),R.push(A.customFragmentShaderID)),A.defines!==void 0)for(const F in A.defines)R.push(F),R.push(A.defines[F]);return A.isRawShaderMaterial===!1&&(N(R,A),S(R,A),R.push(t.outputColorSpace)),R.push(A.customProgramCacheKey),R.join()}function N(A,R){A.push(R.precision),A.push(R.outputColorSpace),A.push(R.envMapMode),A.push(R.envMapCubeUVHeight),A.push(R.mapUv),A.push(R.alphaMapUv),A.push(R.lightMapUv),A.push(R.aoMapUv),A.push(R.bumpMapUv),A.push(R.normalMapUv),A.push(R.displacementMapUv),A.push(R.emissiveMapUv),A.push(R.metalnessMapUv),A.push(R.roughnessMapUv),A.push(R.anisotropyMapUv),A.push(R.clearcoatMapUv),A.push(R.clearcoatNormalMapUv),A.push(R.clearcoatRoughnessMapUv),A.push(R.iridescenceMapUv),A.push(R.iridescenceThicknessMapUv),A.push(R.sheenColorMapUv),A.push(R.sheenRoughnessMapUv),A.push(R.specularMapUv),A.push(R.specularColorMapUv),A.push(R.specularIntensityMapUv),A.push(R.transmissionMapUv),A.push(R.thicknessMapUv),A.push(R.combine),A.push(R.fogExp2),A.push(R.sizeAttenuation),A.push(R.morphTargetsCount),A.push(R.morphAttributeCount),A.push(R.numDirLights),A.push(R.numPointLights),A.push(R.numSpotLights),A.push(R.numSpotLightMaps),A.push(R.numHemiLights),A.push(R.numRectAreaLights),A.push(R.numDirLightShadows),A.push(R.numPointLightShadows),A.push(R.numSpotLightShadows),A.push(R.numSpotLightShadowsWithMaps),A.push(R.numLightProbes),A.push(R.shadowMapType),A.push(R.toneMapping),A.push(R.numClippingPlanes),A.push(R.numClipIntersection),A.push(R.depthPacking)}function S(A,R){l.disableAll(),R.supportsVertexTextures&&l.enable(0),R.instancing&&l.enable(1),R.instancingColor&&l.enable(2),R.instancingMorph&&l.enable(3),R.matcap&&l.enable(4),R.envMap&&l.enable(5),R.normalMapObjectSpace&&l.enable(6),R.normalMapTangentSpace&&l.enable(7),R.clearcoat&&l.enable(8),R.iridescence&&l.enable(9),R.alphaTest&&l.enable(10),R.vertexColors&&l.enable(11),R.vertexAlphas&&l.enable(12),R.vertexUv1s&&l.enable(13),R.vertexUv2s&&l.enable(14),R.vertexUv3s&&l.enable(15),R.vertexTangents&&l.enable(16),R.anisotropy&&l.enable(17),R.alphaHash&&l.enable(18),R.batching&&l.enable(19),R.dispersion&&l.enable(20),R.batchingColor&&l.enable(21),R.gradientMap&&l.enable(22),A.push(l.mask),l.disableAll(),R.fog&&l.enable(0),R.useFog&&l.enable(1),R.flatShading&&l.enable(2),R.logarithmicDepthBuffer&&l.enable(3),R.reversedDepthBuffer&&l.enable(4),R.skinning&&l.enable(5),R.morphTargets&&l.enable(6),R.morphNormals&&l.enable(7),R.morphColors&&l.enable(8),R.premultipliedAlpha&&l.enable(9),R.shadowMapEnabled&&l.enable(10),R.doubleSided&&l.enable(11),R.flipSided&&l.enable(12),R.useDepthPacking&&l.enable(13),R.dithering&&l.enable(14),R.transmission&&l.enable(15),R.sheen&&l.enable(16),R.opaque&&l.enable(17),R.pointsUvs&&l.enable(18),R.decodeVideoTexture&&l.enable(19),R.decodeVideoTextureEmissive&&l.enable(20),R.alphaToCoverage&&l.enable(21),A.push(l.mask)}function T(A){const R=x[A.type];let F;if(R){const O=Cl[R];F=M3e.clone(O.uniforms)}else F=A.uniforms;return F}function E(A,R){let F;for(let O=0,q=d.length;O<q;O++){const j=d[O];if(j.cacheKey===R){F=j,++F.usedTimes;break}}return F===void 0&&(F=new rOe(t,R,A,s),d.push(F)),F}function k(A){if(--A.usedTimes===0){const R=d.indexOf(A);d[R]=d[d.length-1],d.pop(),A.destroy()}}function C(A){c.remove(A)}function D(){c.dispose()}return{getParameters:b,getProgramCacheKey:v,getUniforms:T,acquireProgram:E,releaseProgram:k,releaseShaderCache:C,programs:d,dispose:D}}function lOe(){let t=new WeakMap;function e(o){return t.has(o)}function n(o){let l=t.get(o);return l===void 0&&(l={},t.set(o,l)),l}function r(o){t.delete(o)}function i(o,l,c){t.get(o)[l]=c}function s(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:s}}function cOe(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 fV(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 mV(){const t=[];let e=0;const n=[],r=[],i=[];function s(){e=0,n.length=0,r.length=0,i.length=0}function o(f,m,g,x,y,b){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:m,material:g,groupOrder:x,renderOrder:f.renderOrder,z:y,group:b},t[e]=v):(v.id=f.id,v.object=f,v.geometry=m,v.material=g,v.groupOrder=x,v.renderOrder=f.renderOrder,v.z=y,v.group=b),e++,v}function l(f,m,g,x,y,b){const v=o(f,m,g,x,y,b);g.transmission>0?r.push(v):g.transparent===!0?i.push(v):n.push(v)}function c(f,m,g,x,y,b){const v=o(f,m,g,x,y,b);g.transmission>0?r.unshift(v):g.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,m){n.length>1&&n.sort(f||cOe),r.length>1&&r.sort(m||fV),i.length>1&&i.sort(m||fV)}function d(){for(let f=e,m=t.length;f<m;f++){const g=t[f];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:n,transmissive:r,transparent:i,init:s,push:l,unshift:c,finish:d,sort:u}}function uOe(){let t=new WeakMap;function e(r,i){const s=t.get(r);let o;return s===void 0?(o=new mV,t.set(r,[o])):i>=s.length?(o=new mV,s.push(o)):o=s[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function dOe(){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 ot,color:new Rn};break;case"SpotLight":n={position:new ot,direction:new ot,color:new Rn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new ot,color:new Rn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new ot,skyColor:new Rn,groundColor:new Rn};break;case"RectAreaLight":n={color:new Rn,position:new ot,halfWidth:new ot,halfHeight:new ot};break}return t[e.id]=n,n}}}function hOe(){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 Nn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let fOe=0;function mOe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function pOe(t){const e=new dOe,n=hOe(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let u=0;u<9;u++)r.probe.push(new ot);const i=new ot,s=new Ci,o=new Ci;function l(u){let d=0,f=0,m=0;for(let A=0;A<9;A++)r.probe[A].set(0,0,0);let g=0,x=0,y=0,b=0,v=0,N=0,S=0,T=0,E=0,k=0,C=0;u.sort(mOe);for(let A=0,R=u.length;A<R;A++){const F=u[A],O=F.color,q=F.intensity,j=F.distance,G=F.shadow&&F.shadow.map?F.shadow.map.texture:null;if(F.isAmbientLight)d+=O.r*q,f+=O.g*q,m+=O.b*q;else if(F.isLightProbe){for(let Y=0;Y<9;Y++)r.probe[Y].addScaledVector(F.sh.coefficients[Y],q);C++}else if(F.isDirectionalLight){const Y=e.get(F);if(Y.color.copy(F.color).multiplyScalar(F.intensity),F.castShadow){const K=F.shadow,Z=n.get(F);Z.shadowIntensity=K.intensity,Z.shadowBias=K.bias,Z.shadowNormalBias=K.normalBias,Z.shadowRadius=K.radius,Z.shadowMapSize=K.mapSize,r.directionalShadow[g]=Z,r.directionalShadowMap[g]=G,r.directionalShadowMatrix[g]=F.shadow.matrix,N++}r.directional[g]=Y,g++}else if(F.isSpotLight){const Y=e.get(F);Y.position.setFromMatrixPosition(F.matrixWorld),Y.color.copy(O).multiplyScalar(q),Y.distance=j,Y.coneCos=Math.cos(F.angle),Y.penumbraCos=Math.cos(F.angle*(1-F.penumbra)),Y.decay=F.decay,r.spot[y]=Y;const K=F.shadow;if(F.map&&(r.spotLightMap[E]=F.map,E++,K.updateMatrices(F),F.castShadow&&k++),r.spotLightMatrix[y]=K.matrix,F.castShadow){const Z=n.get(F);Z.shadowIntensity=K.intensity,Z.shadowBias=K.bias,Z.shadowNormalBias=K.normalBias,Z.shadowRadius=K.radius,Z.shadowMapSize=K.mapSize,r.spotShadow[y]=Z,r.spotShadowMap[y]=G,T++}y++}else if(F.isRectAreaLight){const Y=e.get(F);Y.color.copy(O).multiplyScalar(q),Y.halfWidth.set(F.width*.5,0,0),Y.halfHeight.set(0,F.height*.5,0),r.rectArea[b]=Y,b++}else if(F.isPointLight){const Y=e.get(F);if(Y.color.copy(F.color).multiplyScalar(F.intensity),Y.distance=F.distance,Y.decay=F.decay,F.castShadow){const K=F.shadow,Z=n.get(F);Z.shadowIntensity=K.intensity,Z.shadowBias=K.bias,Z.shadowNormalBias=K.normalBias,Z.shadowRadius=K.radius,Z.shadowMapSize=K.mapSize,Z.shadowCameraNear=K.camera.near,Z.shadowCameraFar=K.camera.far,r.pointShadow[x]=Z,r.pointShadowMap[x]=G,r.pointShadowMatrix[x]=F.shadow.matrix,S++}r.point[x]=Y,x++}else if(F.isHemisphereLight){const Y=e.get(F);Y.skyColor.copy(F.color).multiplyScalar(q),Y.groundColor.copy(F.groundColor).multiplyScalar(q),r.hemi[v]=Y,v++}}b>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Dt.LTC_FLOAT_1,r.rectAreaLTC2=Dt.LTC_FLOAT_2):(r.rectAreaLTC1=Dt.LTC_HALF_1,r.rectAreaLTC2=Dt.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=m;const D=r.hash;(D.directionalLength!==g||D.pointLength!==x||D.spotLength!==y||D.rectAreaLength!==b||D.hemiLength!==v||D.numDirectionalShadows!==N||D.numPointShadows!==S||D.numSpotShadows!==T||D.numSpotMaps!==E||D.numLightProbes!==C)&&(r.directional.length=g,r.spot.length=y,r.rectArea.length=b,r.point.length=x,r.hemi.length=v,r.directionalShadow.length=N,r.directionalShadowMap.length=N,r.pointShadow.length=S,r.pointShadowMap.length=S,r.spotShadow.length=T,r.spotShadowMap.length=T,r.directionalShadowMatrix.length=N,r.pointShadowMatrix.length=S,r.spotLightMatrix.length=T+E-k,r.spotLightMap.length=E,r.numSpotLightShadowsWithMaps=k,r.numLightProbes=C,D.directionalLength=g,D.pointLength=x,D.spotLength=y,D.rectAreaLength=b,D.hemiLength=v,D.numDirectionalShadows=N,D.numPointShadows=S,D.numSpotShadows=T,D.numSpotMaps=E,D.numLightProbes=C,r.version=fOe++)}function c(u,d){let f=0,m=0,g=0,x=0,y=0;const b=d.matrixWorldInverse;for(let v=0,N=u.length;v<N;v++){const S=u[v];if(S.isDirectionalLight){const T=r.directional[f];T.direction.setFromMatrixPosition(S.matrixWorld),i.setFromMatrixPosition(S.target.matrixWorld),T.direction.sub(i),T.direction.transformDirection(b),f++}else if(S.isSpotLight){const T=r.spot[g];T.position.setFromMatrixPosition(S.matrixWorld),T.position.applyMatrix4(b),T.direction.setFromMatrixPosition(S.matrixWorld),i.setFromMatrixPosition(S.target.matrixWorld),T.direction.sub(i),T.direction.transformDirection(b),g++}else if(S.isRectAreaLight){const T=r.rectArea[x];T.position.setFromMatrixPosition(S.matrixWorld),T.position.applyMatrix4(b),o.identity(),s.copy(S.matrixWorld),s.premultiply(b),o.extractRotation(s),T.halfWidth.set(S.width*.5,0,0),T.halfHeight.set(0,S.height*.5,0),T.halfWidth.applyMatrix4(o),T.halfHeight.applyMatrix4(o),x++}else if(S.isPointLight){const T=r.point[m];T.position.setFromMatrixPosition(S.matrixWorld),T.position.applyMatrix4(b),m++}else if(S.isHemisphereLight){const T=r.hemi[y];T.direction.setFromMatrixPosition(S.matrixWorld),T.direction.transformDirection(b),y++}}}return{setup:l,setupView:c,state:r}}function pV(t){const e=new pOe(t),n=[],r=[];function i(d){u.camera=d,n.length=0,r.length=0}function s(d){n.push(d)}function o(d){r.push(d)}function l(){e.setup(n)}function c(d){e.setupView(n,d)}const u={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:u,setupLights:l,setupLightsView:c,pushLight:s,pushShadow:o}}function gOe(t){let e=new WeakMap;function n(i,s=0){const o=e.get(i);let l;return o===void 0?(l=new pV(t),e.set(i,[l])):s>=o.length?(l=new pV(t),o.push(l)):l=o[s],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const xOe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,bOe=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function yOe(t,e,n){let r=new OO;const i=new Nn,s=new Nn,o=new Si,l=new U3e({depthPacking:Kje}),c=new z3e,u={},d=n.maxTextureSize,f={[eh]:_s,[_s]:eh,[Al]:Al},m=new xu({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Nn},radius:{value:4}},vertexShader:xOe,fragmentShader:bOe}),g=m.clone();g.defines.HORIZONTAL_PASS=1;const x=new ec;x.setAttribute("position",new ko(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new ql(x,m),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=FZ;let v=this.type;this.render=function(k,C,D){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||k.length===0)return;const A=t.getRenderTarget(),R=t.getActiveCubeFace(),F=t.getActiveMipmapLevel(),O=t.state;O.setBlending(tu),O.buffers.depth.getReversed()===!0?O.buffers.color.setClear(0,0,0,0):O.buffers.color.setClear(1,1,1,1),O.buffers.depth.setTest(!0),O.setScissorTest(!1);const q=v!==Oc&&this.type===Oc,j=v===Oc&&this.type!==Oc;for(let G=0,Y=k.length;G<Y;G++){const K=k[G],Z=K.shadow;if(Z===void 0){mn("WebGLShadowMap:",K,"has no shadow.");continue}if(Z.autoUpdate===!1&&Z.needsUpdate===!1)continue;i.copy(Z.mapSize);const te=Z.getFrameExtents();if(i.multiply(te),s.copy(Z.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/te.x),i.x=s.x*te.x,Z.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/te.y),i.y=s.y*te.y,Z.mapSize.y=s.y)),Z.map===null||q===!0||j===!0){const z=this.type!==Oc?{minFilter:Xs,magFilter:Xs}:{};Z.map!==null&&Z.map.dispose(),Z.map=new Wf(i.x,i.y,z),Z.map.texture.name=K.name+".shadowMap",Z.camera.updateProjectionMatrix()}t.setRenderTarget(Z.map),t.clear();const ne=Z.getViewportCount();for(let z=0;z<ne;z++){const W=Z.getViewport(z);o.set(s.x*W.x,s.y*W.y,s.x*W.z,s.y*W.w),O.viewport(o),Z.updateMatrices(K,z),r=Z.getFrustum(),T(C,D,Z.camera,K,this.type)}Z.isPointLightShadow!==!0&&this.type===Oc&&N(Z,D),Z.needsUpdate=!1}v=this.type,b.needsUpdate=!1,t.setRenderTarget(A,R,F)};function N(k,C){const D=e.update(y);m.defines.VSM_SAMPLES!==k.blurSamples&&(m.defines.VSM_SAMPLES=k.blurSamples,g.defines.VSM_SAMPLES=k.blurSamples,m.needsUpdate=!0,g.needsUpdate=!0),k.mapPass===null&&(k.mapPass=new Wf(i.x,i.y)),m.uniforms.shadow_pass.value=k.map.texture,m.uniforms.resolution.value=k.mapSize,m.uniforms.radius.value=k.radius,t.setRenderTarget(k.mapPass),t.clear(),t.renderBufferDirect(C,null,D,m,y,null),g.uniforms.shadow_pass.value=k.mapPass.texture,g.uniforms.resolution.value=k.mapSize,g.uniforms.radius.value=k.radius,t.setRenderTarget(k.map),t.clear(),t.renderBufferDirect(C,null,D,g,y,null)}function S(k,C,D,A){let R=null;const F=D.isPointLight===!0?k.customDistanceMaterial:k.customDepthMaterial;if(F!==void 0)R=F;else if(R=D.isPointLight===!0?c:l,t.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0||C.alphaToCoverage===!0){const O=R.uuid,q=C.uuid;let j=u[O];j===void 0&&(j={},u[O]=j);let G=j[q];G===void 0&&(G=R.clone(),j[q]=G,C.addEventListener("dispose",E)),R=G}if(R.visible=C.visible,R.wireframe=C.wireframe,A===Oc?R.side=C.shadowSide!==null?C.shadowSide:C.side:R.side=C.shadowSide!==null?C.shadowSide:f[C.side],R.alphaMap=C.alphaMap,R.alphaTest=C.alphaToCoverage===!0?.5:C.alphaTest,R.map=C.map,R.clipShadows=C.clipShadows,R.clippingPlanes=C.clippingPlanes,R.clipIntersection=C.clipIntersection,R.displacementMap=C.displacementMap,R.displacementScale=C.displacementScale,R.displacementBias=C.displacementBias,R.wireframeLinewidth=C.wireframeLinewidth,R.linewidth=C.linewidth,D.isPointLight===!0&&R.isMeshDistanceMaterial===!0){const O=t.properties.get(R);O.light=D}return R}function T(k,C,D,A,R){if(k.visible===!1)return;if(k.layers.test(C.layers)&&(k.isMesh||k.isLine||k.isPoints)&&(k.castShadow||k.receiveShadow&&R===Oc)&&(!k.frustumCulled||r.intersectsObject(k))){k.modelViewMatrix.multiplyMatrices(D.matrixWorldInverse,k.matrixWorld);const q=e.update(k),j=k.material;if(Array.isArray(j)){const G=q.groups;for(let Y=0,K=G.length;Y<K;Y++){const Z=G[Y],te=j[Z.materialIndex];if(te&&te.visible){const ne=S(k,te,A,R);k.onBeforeShadow(t,k,C,D,q,ne,Z),t.renderBufferDirect(D,null,q,ne,k,Z),k.onAfterShadow(t,k,C,D,q,ne,Z)}}}else if(j.visible){const G=S(k,j,A,R);k.onBeforeShadow(t,k,C,D,q,G,null),t.renderBufferDirect(D,null,q,G,k,null),k.onAfterShadow(t,k,C,D,q,G,null)}}const O=k.children;for(let q=0,j=O.length;q<j;q++)T(O[q],C,D,A,R)}function E(k){k.target.removeEventListener("dispose",E);for(const D in u){const A=u[D],R=k.target.uuid;R in A&&(A[R].dispose(),delete A[R])}}}const vOe={[sP]:oP,[lP]:dP,[cP]:hP,[yg]:uP,[oP]:sP,[dP]:lP,[hP]:cP,[uP]:yg};function _Oe(t,e){function n(){let _e=!1;const ce=new Si;let ee=null;const ke=new Si(0,0,0,0);return{setMask:function(De){ee!==De&&!_e&&(t.colorMask(De,De,De,De),ee=De)},setLocked:function(De){_e=De},setClear:function(De,Ae,Je,gt,At){At===!0&&(De*=gt,Ae*=gt,Je*=gt),ce.set(De,Ae,Je,gt),ke.equals(ce)===!1&&(t.clearColor(De,Ae,Je,gt),ke.copy(ce))},reset:function(){_e=!1,ee=null,ke.set(-1,0,0,0)}}}function r(){let _e=!1,ce=!1,ee=null,ke=null,De=null;return{setReversed:function(Ae){if(ce!==Ae){const Je=e.get("EXT_clip_control");Ae?Je.clipControlEXT(Je.LOWER_LEFT_EXT,Je.ZERO_TO_ONE_EXT):Je.clipControlEXT(Je.LOWER_LEFT_EXT,Je.NEGATIVE_ONE_TO_ONE_EXT),ce=Ae;const gt=De;De=null,this.setClear(gt)}},getReversed:function(){return ce},setTest:function(Ae){Ae?xe(t.DEPTH_TEST):be(t.DEPTH_TEST)},setMask:function(Ae){ee!==Ae&&!_e&&(t.depthMask(Ae),ee=Ae)},setFunc:function(Ae){if(ce&&(Ae=vOe[Ae]),ke!==Ae){switch(Ae){case sP:t.depthFunc(t.NEVER);break;case oP:t.depthFunc(t.ALWAYS);break;case lP:t.depthFunc(t.LESS);break;case yg:t.depthFunc(t.LEQUAL);break;case cP:t.depthFunc(t.EQUAL);break;case uP:t.depthFunc(t.GEQUAL);break;case dP:t.depthFunc(t.GREATER);break;case hP:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}ke=Ae}},setLocked:function(Ae){_e=Ae},setClear:function(Ae){De!==Ae&&(ce&&(Ae=1-Ae),t.clearDepth(Ae),De=Ae)},reset:function(){_e=!1,ee=null,ke=null,De=null,ce=!1}}}function i(){let _e=!1,ce=null,ee=null,ke=null,De=null,Ae=null,Je=null,gt=null,At=null;return{setTest:function(jt){_e||(jt?xe(t.STENCIL_TEST):be(t.STENCIL_TEST))},setMask:function(jt){ce!==jt&&!_e&&(t.stencilMask(jt),ce=jt)},setFunc:function(jt,ln,Lt){(ee!==jt||ke!==ln||De!==Lt)&&(t.stencilFunc(jt,ln,Lt),ee=jt,ke=ln,De=Lt)},setOp:function(jt,ln,Lt){(Ae!==jt||Je!==ln||gt!==Lt)&&(t.stencilOp(jt,ln,Lt),Ae=jt,Je=ln,gt=Lt)},setLocked:function(jt){_e=jt},setClear:function(jt){At!==jt&&(t.clearStencil(jt),At=jt)},reset:function(){_e=!1,ce=null,ee=null,ke=null,De=null,Ae=null,Je=null,gt=null,At=null}}}const s=new n,o=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},f={},m=new WeakMap,g=[],x=null,y=!1,b=null,v=null,N=null,S=null,T=null,E=null,k=null,C=new Rn(0,0,0),D=0,A=!1,R=null,F=null,O=null,q=null,j=null;const G=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Y=!1,K=0;const Z=t.getParameter(t.VERSION);Z.indexOf("WebGL")!==-1?(K=parseFloat(/^WebGL (\d)/.exec(Z)[1]),Y=K>=1):Z.indexOf("OpenGL ES")!==-1&&(K=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),Y=K>=2);let te=null,ne={};const z=t.getParameter(t.SCISSOR_BOX),W=t.getParameter(t.VIEWPORT),se=new Si().fromArray(z),ae=new Si().fromArray(W);function de(_e,ce,ee,ke){const De=new Uint8Array(4),Ae=t.createTexture();t.bindTexture(_e,Ae),t.texParameteri(_e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(_e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Je=0;Je<ee;Je++)_e===t.TEXTURE_3D||_e===t.TEXTURE_2D_ARRAY?t.texImage3D(ce,0,t.RGBA,1,1,ke,0,t.RGBA,t.UNSIGNED_BYTE,De):t.texImage2D(ce+Je,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,De);return Ae}const me={};me[t.TEXTURE_2D]=de(t.TEXTURE_2D,t.TEXTURE_2D,1),me[t.TEXTURE_CUBE_MAP]=de(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),me[t.TEXTURE_2D_ARRAY]=de(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),me[t.TEXTURE_3D]=de(t.TEXTURE_3D,t.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),l.setClear(0),xe(t.DEPTH_TEST),o.setFunc(yg),X(!1),U(fH),xe(t.CULL_FACE),H(tu);function xe(_e){d[_e]!==!0&&(t.enable(_e),d[_e]=!0)}function be(_e){d[_e]!==!1&&(t.disable(_e),d[_e]=!1)}function fe(_e,ce){return f[_e]!==ce?(t.bindFramebuffer(_e,ce),f[_e]=ce,_e===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=ce),_e===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=ce),!0):!1}function Ce(_e,ce){let ee=g,ke=!1;if(_e){ee=m.get(ce),ee===void 0&&(ee=[],m.set(ce,ee));const De=_e.textures;if(ee.length!==De.length||ee[0]!==t.COLOR_ATTACHMENT0){for(let Ae=0,Je=De.length;Ae<Je;Ae++)ee[Ae]=t.COLOR_ATTACHMENT0+Ae;ee.length=De.length,ke=!0}}else ee[0]!==t.BACK&&(ee[0]=t.BACK,ke=!0);ke&&t.drawBuffers(ee)}function Ne(_e){return x!==_e?(t.useProgram(_e),x=_e,!0):!1}const re={[Zh]:t.FUNC_ADD,[vje]:t.FUNC_SUBTRACT,[_je]:t.FUNC_REVERSE_SUBTRACT};re[wje]=t.MIN,re[Sje]=t.MAX;const He={[Nje]:t.ZERO,[Mje]:t.ONE,[Eje]:t.SRC_COLOR,[iP]:t.SRC_ALPHA,[Pje]:t.SRC_ALPHA_SATURATE,[kje]:t.DST_COLOR,[Cje]:t.DST_ALPHA,[Tje]:t.ONE_MINUS_SRC_COLOR,[aP]:t.ONE_MINUS_SRC_ALPHA,[jje]:t.ONE_MINUS_DST_COLOR,[Aje]:t.ONE_MINUS_DST_ALPHA,[Rje]:t.CONSTANT_COLOR,[Dje]:t.ONE_MINUS_CONSTANT_COLOR,[Oje]:t.CONSTANT_ALPHA,[Lje]:t.ONE_MINUS_CONSTANT_ALPHA};function H(_e,ce,ee,ke,De,Ae,Je,gt,At,jt){if(_e===tu){y===!0&&(be(t.BLEND),y=!1);return}if(y===!1&&(xe(t.BLEND),y=!0),_e!==yje){if(_e!==b||jt!==A){if((v!==Zh||T!==Zh)&&(t.blendEquation(t.FUNC_ADD),v=Zh,T=Zh),jt)switch(_e){case Jp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case mH:t.blendFunc(t.ONE,t.ONE);break;case pH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case gH:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:hi("WebGLState: Invalid blending: ",_e);break}else switch(_e){case Jp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case mH:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case pH:hi("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case gH:hi("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:hi("WebGLState: Invalid blending: ",_e);break}N=null,S=null,E=null,k=null,C.set(0,0,0),D=0,b=_e,A=jt}return}De=De||ce,Ae=Ae||ee,Je=Je||ke,(ce!==v||De!==T)&&(t.blendEquationSeparate(re[ce],re[De]),v=ce,T=De),(ee!==N||ke!==S||Ae!==E||Je!==k)&&(t.blendFuncSeparate(He[ee],He[ke],He[Ae],He[Je]),N=ee,S=ke,E=Ae,k=Je),(gt.equals(C)===!1||At!==D)&&(t.blendColor(gt.r,gt.g,gt.b,At),C.copy(gt),D=At),b=_e,A=!1}function B(_e,ce){_e.side===Al?be(t.CULL_FACE):xe(t.CULL_FACE);let ee=_e.side===_s;ce&&(ee=!ee),X(ee),_e.blending===Jp&&_e.transparent===!1?H(tu):H(_e.blending,_e.blendEquation,_e.blendSrc,_e.blendDst,_e.blendEquationAlpha,_e.blendSrcAlpha,_e.blendDstAlpha,_e.blendColor,_e.blendAlpha,_e.premultipliedAlpha),o.setFunc(_e.depthFunc),o.setTest(_e.depthTest),o.setMask(_e.depthWrite),s.setMask(_e.colorWrite);const ke=_e.stencilWrite;l.setTest(ke),ke&&(l.setMask(_e.stencilWriteMask),l.setFunc(_e.stencilFunc,_e.stencilRef,_e.stencilFuncMask),l.setOp(_e.stencilFail,_e.stencilZFail,_e.stencilZPass)),le(_e.polygonOffset,_e.polygonOffsetFactor,_e.polygonOffsetUnits),_e.alphaToCoverage===!0?xe(t.SAMPLE_ALPHA_TO_COVERAGE):be(t.SAMPLE_ALPHA_TO_COVERAGE)}function X(_e){R!==_e&&(_e?t.frontFace(t.CW):t.frontFace(t.CCW),R=_e)}function U(_e){_e!==gje?(xe(t.CULL_FACE),_e!==F&&(_e===fH?t.cullFace(t.BACK):_e===xje?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):be(t.CULL_FACE),F=_e}function Q(_e){_e!==O&&(Y&&t.lineWidth(_e),O=_e)}function le(_e,ce,ee){_e?(xe(t.POLYGON_OFFSET_FILL),(q!==ce||j!==ee)&&(t.polygonOffset(ce,ee),q=ce,j=ee)):be(t.POLYGON_OFFSET_FILL)}function Pe(_e){_e?xe(t.SCISSOR_TEST):be(t.SCISSOR_TEST)}function Oe(_e){_e===void 0&&(_e=t.TEXTURE0+G-1),te!==_e&&(t.activeTexture(_e),te=_e)}function je(_e,ce,ee){ee===void 0&&(te===null?ee=t.TEXTURE0+G-1:ee=te);let ke=ne[ee];ke===void 0&&(ke={type:void 0,texture:void 0},ne[ee]=ke),(ke.type!==_e||ke.texture!==ce)&&(te!==ee&&(t.activeTexture(ee),te=ee),t.bindTexture(_e,ce||me[_e]),ke.type=_e,ke.texture=ce)}function $(){const _e=ne[te];_e!==void 0&&_e.type!==void 0&&(t.bindTexture(_e.type,null),_e.type=void 0,_e.texture=void 0)}function I(){try{t.compressedTexImage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function V(){try{t.compressedTexImage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function ie(){try{t.texSubImage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function Se(){try{t.texSubImage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function ye(){try{t.compressedTexSubImage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function $e(){try{t.compressedTexSubImage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function Ue(){try{t.texStorage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function Ge(){try{t.texStorage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function We(){try{t.texImage2D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function Ye(){try{t.texImage3D(...arguments)}catch(_e){_e("WebGLState:",_e)}}function oe(_e){se.equals(_e)===!1&&(t.scissor(_e.x,_e.y,_e.z,_e.w),se.copy(_e))}function ve(_e){ae.equals(_e)===!1&&(t.viewport(_e.x,_e.y,_e.z,_e.w),ae.copy(_e))}function Le(_e,ce){let ee=u.get(ce);ee===void 0&&(ee=new WeakMap,u.set(ce,ee));let ke=ee.get(_e);ke===void 0&&(ke=t.getUniformBlockIndex(ce,_e.name),ee.set(_e,ke))}function Ke(_e,ce){const ke=u.get(ce).get(_e);c.get(ce)!==ke&&(t.uniformBlockBinding(ce,ke,_e.__bindingPointIndex),c.set(ce,ke))}function lt(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),o.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),d={},te=null,ne={},f={},m=new WeakMap,g=[],x=null,y=!1,b=null,v=null,N=null,S=null,T=null,E=null,k=null,C=new Rn(0,0,0),D=0,A=!1,R=null,F=null,O=null,q=null,j=null,se.set(0,0,t.canvas.width,t.canvas.height),ae.set(0,0,t.canvas.width,t.canvas.height),s.reset(),o.reset(),l.reset()}return{buffers:{color:s,depth:o,stencil:l},enable:xe,disable:be,bindFramebuffer:fe,drawBuffers:Ce,useProgram:Ne,setBlending:H,setMaterial:B,setFlipSided:X,setCullFace:U,setLineWidth:Q,setPolygonOffset:le,setScissorTest:Pe,activeTexture:Oe,bindTexture:je,unbindTexture:$,compressedTexImage2D:I,compressedTexImage3D:V,texImage2D:We,texImage3D:Ye,updateUBOMapping:Le,uniformBlockBinding:Ke,texStorage2D:Ue,texStorage3D:Ge,texSubImage2D:ie,texSubImage3D:Se,compressedTexSubImage2D:ye,compressedTexSubImage3D:$e,scissor:oe,viewport:ve,reset:lt}}function wOe(t,e,n,r,i,s,o){const l=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),u=new Nn,d=new WeakMap;let f;const m=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x($,I){return g?new OffscreenCanvas($,I):MS("canvas")}function y($,I,V){let ie=1;const Se=je($);if((Se.width>V||Se.height>V)&&(ie=V/Math.max(Se.width,Se.height)),ie<1)if(typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&$ instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&$ instanceof ImageBitmap||typeof VideoFrame<"u"&&$ instanceof VideoFrame){const ye=Math.floor(ie*Se.width),$e=Math.floor(ie*Se.height);f===void 0&&(f=x(ye,$e));const Ue=I?x(ye,$e):f;return Ue.width=ye,Ue.height=$e,Ue.getContext("2d").drawImage($,0,0,ye,$e),mn("WebGLRenderer: Texture has been resized from ("+Se.width+"x"+Se.height+") to ("+ye+"x"+$e+")."),Ue}else return"data"in $&&mn("WebGLRenderer: Image in DataTexture is too big ("+Se.width+"x"+Se.height+")."),$;return $}function b($){return $.generateMipmaps}function v($){t.generateMipmap($)}function N($){return $.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:$.isWebGL3DRenderTarget?t.TEXTURE_3D:$.isWebGLArrayRenderTarget||$.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function S($,I,V,ie,Se=!1){if($!==null){if(t[$]!==void 0)return t[$];mn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+$+"'")}let ye=I;if(I===t.RED&&(V===t.FLOAT&&(ye=t.R32F),V===t.HALF_FLOAT&&(ye=t.R16F),V===t.UNSIGNED_BYTE&&(ye=t.R8)),I===t.RED_INTEGER&&(V===t.UNSIGNED_BYTE&&(ye=t.R8UI),V===t.UNSIGNED_SHORT&&(ye=t.R16UI),V===t.UNSIGNED_INT&&(ye=t.R32UI),V===t.BYTE&&(ye=t.R8I),V===t.SHORT&&(ye=t.R16I),V===t.INT&&(ye=t.R32I)),I===t.RG&&(V===t.FLOAT&&(ye=t.RG32F),V===t.HALF_FLOAT&&(ye=t.RG16F),V===t.UNSIGNED_BYTE&&(ye=t.RG8)),I===t.RG_INTEGER&&(V===t.UNSIGNED_BYTE&&(ye=t.RG8UI),V===t.UNSIGNED_SHORT&&(ye=t.RG16UI),V===t.UNSIGNED_INT&&(ye=t.RG32UI),V===t.BYTE&&(ye=t.RG8I),V===t.SHORT&&(ye=t.RG16I),V===t.INT&&(ye=t.RG32I)),I===t.RGB_INTEGER&&(V===t.UNSIGNED_BYTE&&(ye=t.RGB8UI),V===t.UNSIGNED_SHORT&&(ye=t.RGB16UI),V===t.UNSIGNED_INT&&(ye=t.RGB32UI),V===t.BYTE&&(ye=t.RGB8I),V===t.SHORT&&(ye=t.RGB16I),V===t.INT&&(ye=t.RGB32I)),I===t.RGBA_INTEGER&&(V===t.UNSIGNED_BYTE&&(ye=t.RGBA8UI),V===t.UNSIGNED_SHORT&&(ye=t.RGBA16UI),V===t.UNSIGNED_INT&&(ye=t.RGBA32UI),V===t.BYTE&&(ye=t.RGBA8I),V===t.SHORT&&(ye=t.RGBA16I),V===t.INT&&(ye=t.RGBA32I)),I===t.RGB&&(V===t.UNSIGNED_INT_5_9_9_9_REV&&(ye=t.RGB9_E5),V===t.UNSIGNED_INT_10F_11F_11F_REV&&(ye=t.R11F_G11F_B10F)),I===t.RGBA){const $e=Se?SS:Yn.getTransfer(ie);V===t.FLOAT&&(ye=t.RGBA32F),V===t.HALF_FLOAT&&(ye=t.RGBA16F),V===t.UNSIGNED_BYTE&&(ye=$e===pr?t.SRGB8_ALPHA8:t.RGBA8),V===t.UNSIGNED_SHORT_4_4_4_4&&(ye=t.RGBA4),V===t.UNSIGNED_SHORT_5_5_5_1&&(ye=t.RGB5_A1)}return(ye===t.R16F||ye===t.R32F||ye===t.RG16F||ye===t.RG32F||ye===t.RGBA16F||ye===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ye}function T($,I){let V;return $?I===null||I===Gf||I===I0?V=t.DEPTH24_STENCIL8:I===Kc?V=t.DEPTH32F_STENCIL8:I===L0&&(V=t.DEPTH24_STENCIL8,mn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):I===null||I===Gf||I===I0?V=t.DEPTH_COMPONENT24:I===Kc?V=t.DEPTH_COMPONENT32F:I===L0&&(V=t.DEPTH_COMPONENT16),V}function E($,I){return b($)===!0||$.isFramebufferTexture&&$.minFilter!==Xs&&$.minFilter!==Ao?Math.log2(Math.max(I.width,I.height))+1:$.mipmaps!==void 0&&$.mipmaps.length>0?$.mipmaps.length:$.isCompressedTexture&&Array.isArray($.image)?I.mipmaps.length:1}function k($){const I=$.target;I.removeEventListener("dispose",k),D(I),I.isVideoTexture&&d.delete(I)}function C($){const I=$.target;I.removeEventListener("dispose",C),R(I)}function D($){const I=r.get($);if(I.__webglInit===void 0)return;const V=$.source,ie=m.get(V);if(ie){const Se=ie[I.__cacheKey];Se.usedTimes--,Se.usedTimes===0&&A($),Object.keys(ie).length===0&&m.delete(V)}r.remove($)}function A($){const I=r.get($);t.deleteTexture(I.__webglTexture);const V=$.source,ie=m.get(V);delete ie[I.__cacheKey],o.memory.textures--}function R($){const I=r.get($);if($.depthTexture&&($.depthTexture.dispose(),r.remove($.depthTexture)),$.isWebGLCubeRenderTarget)for(let ie=0;ie<6;ie++){if(Array.isArray(I.__webglFramebuffer[ie]))for(let Se=0;Se<I.__webglFramebuffer[ie].length;Se++)t.deleteFramebuffer(I.__webglFramebuffer[ie][Se]);else t.deleteFramebuffer(I.__webglFramebuffer[ie]);I.__webglDepthbuffer&&t.deleteRenderbuffer(I.__webglDepthbuffer[ie])}else{if(Array.isArray(I.__webglFramebuffer))for(let ie=0;ie<I.__webglFramebuffer.length;ie++)t.deleteFramebuffer(I.__webglFramebuffer[ie]);else t.deleteFramebuffer(I.__webglFramebuffer);if(I.__webglDepthbuffer&&t.deleteRenderbuffer(I.__webglDepthbuffer),I.__webglMultisampledFramebuffer&&t.deleteFramebuffer(I.__webglMultisampledFramebuffer),I.__webglColorRenderbuffer)for(let ie=0;ie<I.__webglColorRenderbuffer.length;ie++)I.__webglColorRenderbuffer[ie]&&t.deleteRenderbuffer(I.__webglColorRenderbuffer[ie]);I.__webglDepthRenderbuffer&&t.deleteRenderbuffer(I.__webglDepthRenderbuffer)}const V=$.textures;for(let ie=0,Se=V.length;ie<Se;ie++){const ye=r.get(V[ie]);ye.__webglTexture&&(t.deleteTexture(ye.__webglTexture),o.memory.textures--),r.remove(V[ie])}r.remove($)}let F=0;function O(){F=0}function q(){const $=F;return $>=i.maxTextures&&mn("WebGLTextures: Trying to use "+$+" texture units while this GPU supports only "+i.maxTextures),F+=1,$}function j($){const I=[];return I.push($.wrapS),I.push($.wrapT),I.push($.wrapR||0),I.push($.magFilter),I.push($.minFilter),I.push($.anisotropy),I.push($.internalFormat),I.push($.format),I.push($.type),I.push($.generateMipmaps),I.push($.premultiplyAlpha),I.push($.flipY),I.push($.unpackAlignment),I.push($.colorSpace),I.join()}function G($,I){const V=r.get($);if($.isVideoTexture&&Pe($),$.isRenderTargetTexture===!1&&$.isExternalTexture!==!0&&$.version>0&&V.__version!==$.version){const ie=$.image;if(ie===null)mn("WebGLRenderer: Texture marked for update but no image data found.");else if(ie.complete===!1)mn("WebGLRenderer: Texture marked for update but image is incomplete");else{me(V,$,I);return}}else $.isExternalTexture&&(V.__webglTexture=$.sourceTexture?$.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,V.__webglTexture,t.TEXTURE0+I)}function Y($,I){const V=r.get($);if($.isRenderTargetTexture===!1&&$.version>0&&V.__version!==$.version){me(V,$,I);return}else $.isExternalTexture&&(V.__webglTexture=$.sourceTexture?$.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,V.__webglTexture,t.TEXTURE0+I)}function K($,I){const V=r.get($);if($.isRenderTargetTexture===!1&&$.version>0&&V.__version!==$.version){me(V,$,I);return}n.bindTexture(t.TEXTURE_3D,V.__webglTexture,t.TEXTURE0+I)}function Z($,I){const V=r.get($);if($.version>0&&V.__version!==$.version){xe(V,$,I);return}n.bindTexture(t.TEXTURE_CUBE_MAP,V.__webglTexture,t.TEXTURE0+I)}const te={[pP]:t.REPEAT,[Wc]:t.CLAMP_TO_EDGE,[gP]:t.MIRRORED_REPEAT},ne={[Xs]:t.NEAREST,[qje]:t.NEAREST_MIPMAP_NEAREST,[M_]:t.NEAREST_MIPMAP_LINEAR,[Ao]:t.LINEAR,[NA]:t.LINEAR_MIPMAP_NEAREST,[df]:t.LINEAR_MIPMAP_LINEAR},z={[Yje]:t.NEVER,[n3e]:t.ALWAYS,[Qje]:t.LESS,[KZ]:t.LEQUAL,[Zje]:t.EQUAL,[t3e]:t.GEQUAL,[Jje]:t.GREATER,[e3e]:t.NOTEQUAL};function W($,I){if(I.type===Kc&&e.has("OES_texture_float_linear")===!1&&(I.magFilter===Ao||I.magFilter===NA||I.magFilter===M_||I.magFilter===df||I.minFilter===Ao||I.minFilter===NA||I.minFilter===M_||I.minFilter===df)&&mn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri($,t.TEXTURE_WRAP_S,te[I.wrapS]),t.texParameteri($,t.TEXTURE_WRAP_T,te[I.wrapT]),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,te[I.wrapR]),t.texParameteri($,t.TEXTURE_MAG_FILTER,ne[I.magFilter]),t.texParameteri($,t.TEXTURE_MIN_FILTER,ne[I.minFilter]),I.compareFunction&&(t.texParameteri($,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri($,t.TEXTURE_COMPARE_FUNC,z[I.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(I.magFilter===Xs||I.minFilter!==M_&&I.minFilter!==df||I.type===Kc&&e.has("OES_texture_float_linear")===!1)return;if(I.anisotropy>1||r.get(I).__currentAnisotropy){const V=e.get("EXT_texture_filter_anisotropic");t.texParameterf($,V.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,i.getMaxAnisotropy())),r.get(I).__currentAnisotropy=I.anisotropy}}}function se($,I){let V=!1;$.__webglInit===void 0&&($.__webglInit=!0,I.addEventListener("dispose",k));const ie=I.source;let Se=m.get(ie);Se===void 0&&(Se={},m.set(ie,Se));const ye=j(I);if(ye!==$.__cacheKey){Se[ye]===void 0&&(Se[ye]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,V=!0),Se[ye].usedTimes++;const $e=Se[$.__cacheKey];$e!==void 0&&(Se[$.__cacheKey].usedTimes--,$e.usedTimes===0&&A(I)),$.__cacheKey=ye,$.__webglTexture=Se[ye].texture}return V}function ae($,I,V){return Math.floor(Math.floor($/V)/I)}function de($,I,V,ie){const ye=$.updateRanges;if(ye.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,I.width,I.height,V,ie,I.data);else{ye.sort((Ye,oe)=>Ye.start-oe.start);let $e=0;for(let Ye=1;Ye<ye.length;Ye++){const oe=ye[$e],ve=ye[Ye],Le=oe.start+oe.count,Ke=ae(ve.start,I.width,4),lt=ae(oe.start,I.width,4);ve.start<=Le+1&&Ke===lt&&ae(ve.start+ve.count-1,I.width,4)===Ke?oe.count=Math.max(oe.count,ve.start+ve.count-oe.start):(++$e,ye[$e]=ve)}ye.length=$e+1;const Ue=t.getParameter(t.UNPACK_ROW_LENGTH),Ge=t.getParameter(t.UNPACK_SKIP_PIXELS),We=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,I.width);for(let Ye=0,oe=ye.length;Ye<oe;Ye++){const ve=ye[Ye],Le=Math.floor(ve.start/4),Ke=Math.ceil(ve.count/4),lt=Le%I.width,_e=Math.floor(Le/I.width),ce=Ke,ee=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,lt),t.pixelStorei(t.UNPACK_SKIP_ROWS,_e),n.texSubImage2D(t.TEXTURE_2D,0,lt,_e,ce,ee,V,ie,I.data)}$.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Ue),t.pixelStorei(t.UNPACK_SKIP_PIXELS,Ge),t.pixelStorei(t.UNPACK_SKIP_ROWS,We)}}function me($,I,V){let ie=t.TEXTURE_2D;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(ie=t.TEXTURE_2D_ARRAY),I.isData3DTexture&&(ie=t.TEXTURE_3D);const Se=se($,I),ye=I.source;n.bindTexture(ie,$.__webglTexture,t.TEXTURE0+V);const $e=r.get(ye);if(ye.version!==$e.__version||Se===!0){n.activeTexture(t.TEXTURE0+V);const Ue=Yn.getPrimaries(Yn.workingColorSpace),Ge=I.colorSpace===vd?null:Yn.getPrimaries(I.colorSpace),We=I.colorSpace===vd||Ue===Ge?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,I.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,I.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,We);let Ye=y(I.image,!1,i.maxTextureSize);Ye=Oe(I,Ye);const oe=s.convert(I.format,I.colorSpace),ve=s.convert(I.type);let Le=S(I.internalFormat,oe,ve,I.colorSpace,I.isVideoTexture);W(ie,I);let Ke;const lt=I.mipmaps,_e=I.isVideoTexture!==!0,ce=$e.__version===void 0||Se===!0,ee=ye.dataReady,ke=E(I,Ye);if(I.isDepthTexture)Le=T(I.format===U0,I.type),ce&&(_e?n.texStorage2D(t.TEXTURE_2D,1,Le,Ye.width,Ye.height):n.texImage2D(t.TEXTURE_2D,0,Le,Ye.width,Ye.height,0,oe,ve,null));else if(I.isDataTexture)if(lt.length>0){_e&&ce&&n.texStorage2D(t.TEXTURE_2D,ke,Le,lt[0].width,lt[0].height);for(let De=0,Ae=lt.length;De<Ae;De++)Ke=lt[De],_e?ee&&n.texSubImage2D(t.TEXTURE_2D,De,0,0,Ke.width,Ke.height,oe,ve,Ke.data):n.texImage2D(t.TEXTURE_2D,De,Le,Ke.width,Ke.height,0,oe,ve,Ke.data);I.generateMipmaps=!1}else _e?(ce&&n.texStorage2D(t.TEXTURE_2D,ke,Le,Ye.width,Ye.height),ee&&de(I,Ye,oe,ve)):n.texImage2D(t.TEXTURE_2D,0,Le,Ye.width,Ye.height,0,oe,ve,Ye.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){_e&&ce&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ke,Le,lt[0].width,lt[0].height,Ye.depth);for(let De=0,Ae=lt.length;De<Ae;De++)if(Ke=lt[De],I.format!==rl)if(oe!==null)if(_e){if(ee)if(I.layerUpdates.size>0){const Je=qH(Ke.width,Ke.height,I.format,I.type);for(const gt of I.layerUpdates){const At=Ke.data.subarray(gt*Je/Ke.data.BYTES_PER_ELEMENT,(gt+1)*Je/Ke.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,De,0,0,gt,Ke.width,Ke.height,1,oe,At)}I.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,De,0,0,0,Ke.width,Ke.height,Ye.depth,oe,Ke.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,De,Le,Ke.width,Ke.height,Ye.depth,0,Ke.data,0,0);else mn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else _e?ee&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,De,0,0,0,Ke.width,Ke.height,Ye.depth,oe,ve,Ke.data):n.texImage3D(t.TEXTURE_2D_ARRAY,De,Le,Ke.width,Ke.height,Ye.depth,0,oe,ve,Ke.data)}else{_e&&ce&&n.texStorage2D(t.TEXTURE_2D,ke,Le,lt[0].width,lt[0].height);for(let De=0,Ae=lt.length;De<Ae;De++)Ke=lt[De],I.format!==rl?oe!==null?_e?ee&&n.compressedTexSubImage2D(t.TEXTURE_2D,De,0,0,Ke.width,Ke.height,oe,Ke.data):n.compressedTexImage2D(t.TEXTURE_2D,De,Le,Ke.width,Ke.height,0,Ke.data):mn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):_e?ee&&n.texSubImage2D(t.TEXTURE_2D,De,0,0,Ke.width,Ke.height,oe,ve,Ke.data):n.texImage2D(t.TEXTURE_2D,De,Le,Ke.width,Ke.height,0,oe,ve,Ke.data)}else if(I.isDataArrayTexture)if(_e){if(ce&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ke,Le,Ye.width,Ye.height,Ye.depth),ee)if(I.layerUpdates.size>0){const De=qH(Ye.width,Ye.height,I.format,I.type);for(const Ae of I.layerUpdates){const Je=Ye.data.subarray(Ae*De/Ye.data.BYTES_PER_ELEMENT,(Ae+1)*De/Ye.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,Ae,Ye.width,Ye.height,1,oe,ve,Je)}I.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Ye.width,Ye.height,Ye.depth,oe,ve,Ye.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,Le,Ye.width,Ye.height,Ye.depth,0,oe,ve,Ye.data);else if(I.isData3DTexture)_e?(ce&&n.texStorage3D(t.TEXTURE_3D,ke,Le,Ye.width,Ye.height,Ye.depth),ee&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Ye.width,Ye.height,Ye.depth,oe,ve,Ye.data)):n.texImage3D(t.TEXTURE_3D,0,Le,Ye.width,Ye.height,Ye.depth,0,oe,ve,Ye.data);else if(I.isFramebufferTexture){if(ce)if(_e)n.texStorage2D(t.TEXTURE_2D,ke,Le,Ye.width,Ye.height);else{let De=Ye.width,Ae=Ye.height;for(let Je=0;Je<ke;Je++)n.texImage2D(t.TEXTURE_2D,Je,Le,De,Ae,0,oe,ve,null),De>>=1,Ae>>=1}}else if(lt.length>0){if(_e&&ce){const De=je(lt[0]);n.texStorage2D(t.TEXTURE_2D,ke,Le,De.width,De.height)}for(let De=0,Ae=lt.length;De<Ae;De++)Ke=lt[De],_e?ee&&n.texSubImage2D(t.TEXTURE_2D,De,0,0,oe,ve,Ke):n.texImage2D(t.TEXTURE_2D,De,Le,oe,ve,Ke);I.generateMipmaps=!1}else if(_e){if(ce){const De=je(Ye);n.texStorage2D(t.TEXTURE_2D,ke,Le,De.width,De.height)}ee&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,oe,ve,Ye)}else n.texImage2D(t.TEXTURE_2D,0,Le,oe,ve,Ye);b(I)&&v(ie),$e.__version=ye.version,I.onUpdate&&I.onUpdate(I)}$.__version=I.version}function xe($,I,V){if(I.image.length!==6)return;const ie=se($,I),Se=I.source;n.bindTexture(t.TEXTURE_CUBE_MAP,$.__webglTexture,t.TEXTURE0+V);const ye=r.get(Se);if(Se.version!==ye.__version||ie===!0){n.activeTexture(t.TEXTURE0+V);const $e=Yn.getPrimaries(Yn.workingColorSpace),Ue=I.colorSpace===vd?null:Yn.getPrimaries(I.colorSpace),Ge=I.colorSpace===vd||$e===Ue?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,I.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,I.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ge);const We=I.isCompressedTexture||I.image[0].isCompressedTexture,Ye=I.image[0]&&I.image[0].isDataTexture,oe=[];for(let Ae=0;Ae<6;Ae++)!We&&!Ye?oe[Ae]=y(I.image[Ae],!0,i.maxCubemapSize):oe[Ae]=Ye?I.image[Ae].image:I.image[Ae],oe[Ae]=Oe(I,oe[Ae]);const ve=oe[0],Le=s.convert(I.format,I.colorSpace),Ke=s.convert(I.type),lt=S(I.internalFormat,Le,Ke,I.colorSpace),_e=I.isVideoTexture!==!0,ce=ye.__version===void 0||ie===!0,ee=Se.dataReady;let ke=E(I,ve);W(t.TEXTURE_CUBE_MAP,I);let De;if(We){_e&&ce&&n.texStorage2D(t.TEXTURE_CUBE_MAP,ke,lt,ve.width,ve.height);for(let Ae=0;Ae<6;Ae++){De=oe[Ae].mipmaps;for(let Je=0;Je<De.length;Je++){const gt=De[Je];I.format!==rl?Le!==null?_e?ee&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je,0,0,gt.width,gt.height,Le,gt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je,lt,gt.width,gt.height,0,gt.data):mn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):_e?ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je,0,0,gt.width,gt.height,Le,Ke,gt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je,lt,gt.width,gt.height,0,Le,Ke,gt.data)}}}else{if(De=I.mipmaps,_e&&ce){De.length>0&&ke++;const Ae=je(oe[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,ke,lt,Ae.width,Ae.height)}for(let Ae=0;Ae<6;Ae++)if(Ye){_e?ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,0,0,oe[Ae].width,oe[Ae].height,Le,Ke,oe[Ae].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,lt,oe[Ae].width,oe[Ae].height,0,Le,Ke,oe[Ae].data);for(let Je=0;Je<De.length;Je++){const At=De[Je].image[Ae].image;_e?ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je+1,0,0,At.width,At.height,Le,Ke,At.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je+1,lt,At.width,At.height,0,Le,Ke,At.data)}}else{_e?ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,0,0,Le,Ke,oe[Ae]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,lt,Le,Ke,oe[Ae]);for(let Je=0;Je<De.length;Je++){const gt=De[Je];_e?ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je+1,0,0,Le,Ke,gt.image[Ae]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je+1,lt,Le,Ke,gt.image[Ae])}}}b(I)&&v(t.TEXTURE_CUBE_MAP),ye.__version=Se.version,I.onUpdate&&I.onUpdate(I)}$.__version=I.version}function be($,I,V,ie,Se,ye){const $e=s.convert(V.format,V.colorSpace),Ue=s.convert(V.type),Ge=S(V.internalFormat,$e,Ue,V.colorSpace),We=r.get(I),Ye=r.get(V);if(Ye.__renderTarget=I,!We.__hasExternalTextures){const oe=Math.max(1,I.width>>ye),ve=Math.max(1,I.height>>ye);Se===t.TEXTURE_3D||Se===t.TEXTURE_2D_ARRAY?n.texImage3D(Se,ye,Ge,oe,ve,I.depth,0,$e,Ue,null):n.texImage2D(Se,ye,Ge,oe,ve,0,$e,Ue,null)}n.bindFramebuffer(t.FRAMEBUFFER,$),le(I)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ie,Se,Ye.__webglTexture,0,Q(I)):(Se===t.TEXTURE_2D||Se>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Se<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ie,Se,Ye.__webglTexture,ye),n.bindFramebuffer(t.FRAMEBUFFER,null)}function fe($,I,V){if(t.bindRenderbuffer(t.RENDERBUFFER,$),I.depthBuffer){const ie=I.depthTexture,Se=ie&&ie.isDepthTexture?ie.type:null,ye=T(I.stencilBuffer,Se),$e=I.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ue=Q(I);le(I)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ue,ye,I.width,I.height):V?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ue,ye,I.width,I.height):t.renderbufferStorage(t.RENDERBUFFER,ye,I.width,I.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,$e,t.RENDERBUFFER,$)}else{const ie=I.textures;for(let Se=0;Se<ie.length;Se++){const ye=ie[Se],$e=s.convert(ye.format,ye.colorSpace),Ue=s.convert(ye.type),Ge=S(ye.internalFormat,$e,Ue,ye.colorSpace),We=Q(I);V&&le(I)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,We,Ge,I.width,I.height):le(I)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,We,Ge,I.width,I.height):t.renderbufferStorage(t.RENDERBUFFER,Ge,I.width,I.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Ce($,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,$),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ie=r.get(I.depthTexture);ie.__renderTarget=I,(!ie.__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),G(I.depthTexture,0);const Se=ie.__webglTexture,ye=Q(I);if(I.depthTexture.format===F0)le(I)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,Se,0,ye):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,Se,0);else if(I.depthTexture.format===U0)le(I)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,Se,0,ye):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,Se,0);else throw new Error("Unknown depthTexture format")}function Ne($){const I=r.get($),V=$.isWebGLCubeRenderTarget===!0;if(I.__boundDepthTexture!==$.depthTexture){const ie=$.depthTexture;if(I.__depthDisposeCallback&&I.__depthDisposeCallback(),ie){const Se=()=>{delete I.__boundDepthTexture,delete I.__depthDisposeCallback,ie.removeEventListener("dispose",Se)};ie.addEventListener("dispose",Se),I.__depthDisposeCallback=Se}I.__boundDepthTexture=ie}if($.depthTexture&&!I.__autoAllocateDepthBuffer){if(V)throw new Error("target.depthTexture not supported in Cube render targets");const ie=$.texture.mipmaps;ie&&ie.length>0?Ce(I.__webglFramebuffer[0],$):Ce(I.__webglFramebuffer,$)}else if(V){I.__webglDepthbuffer=[];for(let ie=0;ie<6;ie++)if(n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer[ie]),I.__webglDepthbuffer[ie]===void 0)I.__webglDepthbuffer[ie]=t.createRenderbuffer(),fe(I.__webglDepthbuffer[ie],$,!1);else{const Se=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ye=I.__webglDepthbuffer[ie];t.bindRenderbuffer(t.RENDERBUFFER,ye),t.framebufferRenderbuffer(t.FRAMEBUFFER,Se,t.RENDERBUFFER,ye)}}else{const ie=$.texture.mipmaps;if(ie&&ie.length>0?n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer),I.__webglDepthbuffer===void 0)I.__webglDepthbuffer=t.createRenderbuffer(),fe(I.__webglDepthbuffer,$,!1);else{const Se=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ye=I.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ye),t.framebufferRenderbuffer(t.FRAMEBUFFER,Se,t.RENDERBUFFER,ye)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function re($,I,V){const ie=r.get($);I!==void 0&&be(ie.__webglFramebuffer,$,$.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),V!==void 0&&Ne($)}function He($){const I=$.texture,V=r.get($),ie=r.get(I);$.addEventListener("dispose",C);const Se=$.textures,ye=$.isWebGLCubeRenderTarget===!0,$e=Se.length>1;if($e||(ie.__webglTexture===void 0&&(ie.__webglTexture=t.createTexture()),ie.__version=I.version,o.memory.textures++),ye){V.__webglFramebuffer=[];for(let Ue=0;Ue<6;Ue++)if(I.mipmaps&&I.mipmaps.length>0){V.__webglFramebuffer[Ue]=[];for(let Ge=0;Ge<I.mipmaps.length;Ge++)V.__webglFramebuffer[Ue][Ge]=t.createFramebuffer()}else V.__webglFramebuffer[Ue]=t.createFramebuffer()}else{if(I.mipmaps&&I.mipmaps.length>0){V.__webglFramebuffer=[];for(let Ue=0;Ue<I.mipmaps.length;Ue++)V.__webglFramebuffer[Ue]=t.createFramebuffer()}else V.__webglFramebuffer=t.createFramebuffer();if($e)for(let Ue=0,Ge=Se.length;Ue<Ge;Ue++){const We=r.get(Se[Ue]);We.__webglTexture===void 0&&(We.__webglTexture=t.createTexture(),o.memory.textures++)}if($.samples>0&&le($)===!1){V.__webglMultisampledFramebuffer=t.createFramebuffer(),V.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,V.__webglMultisampledFramebuffer);for(let Ue=0;Ue<Se.length;Ue++){const Ge=Se[Ue];V.__webglColorRenderbuffer[Ue]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,V.__webglColorRenderbuffer[Ue]);const We=s.convert(Ge.format,Ge.colorSpace),Ye=s.convert(Ge.type),oe=S(Ge.internalFormat,We,Ye,Ge.colorSpace,$.isXRRenderTarget===!0),ve=Q($);t.renderbufferStorageMultisample(t.RENDERBUFFER,ve,oe,$.width,$.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ue,t.RENDERBUFFER,V.__webglColorRenderbuffer[Ue])}t.bindRenderbuffer(t.RENDERBUFFER,null),$.depthBuffer&&(V.__webglDepthRenderbuffer=t.createRenderbuffer(),fe(V.__webglDepthRenderbuffer,$,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ye){n.bindTexture(t.TEXTURE_CUBE_MAP,ie.__webglTexture),W(t.TEXTURE_CUBE_MAP,I);for(let Ue=0;Ue<6;Ue++)if(I.mipmaps&&I.mipmaps.length>0)for(let Ge=0;Ge<I.mipmaps.length;Ge++)be(V.__webglFramebuffer[Ue][Ge],$,I,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ue,Ge);else be(V.__webglFramebuffer[Ue],$,I,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ue,0);b(I)&&v(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if($e){for(let Ue=0,Ge=Se.length;Ue<Ge;Ue++){const We=Se[Ue],Ye=r.get(We);let oe=t.TEXTURE_2D;($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(oe=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(oe,Ye.__webglTexture),W(oe,We),be(V.__webglFramebuffer,$,We,t.COLOR_ATTACHMENT0+Ue,oe,0),b(We)&&v(oe)}n.unbindTexture()}else{let Ue=t.TEXTURE_2D;if(($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(Ue=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Ue,ie.__webglTexture),W(Ue,I),I.mipmaps&&I.mipmaps.length>0)for(let Ge=0;Ge<I.mipmaps.length;Ge++)be(V.__webglFramebuffer[Ge],$,I,t.COLOR_ATTACHMENT0,Ue,Ge);else be(V.__webglFramebuffer,$,I,t.COLOR_ATTACHMENT0,Ue,0);b(I)&&v(Ue),n.unbindTexture()}$.depthBuffer&&Ne($)}function H($){const I=$.textures;for(let V=0,ie=I.length;V<ie;V++){const Se=I[V];if(b(Se)){const ye=N($),$e=r.get(Se).__webglTexture;n.bindTexture(ye,$e),v(ye),n.unbindTexture()}}}const B=[],X=[];function U($){if($.samples>0){if(le($)===!1){const I=$.textures,V=$.width,ie=$.height;let Se=t.COLOR_BUFFER_BIT;const ye=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,$e=r.get($),Ue=I.length>1;if(Ue)for(let We=0;We<I.length;We++)n.bindFramebuffer(t.FRAMEBUFFER,$e.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+We,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,$e.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+We,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,$e.__webglMultisampledFramebuffer);const Ge=$.texture.mipmaps;Ge&&Ge.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,$e.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,$e.__webglFramebuffer);for(let We=0;We<I.length;We++){if($.resolveDepthBuffer&&($.depthBuffer&&(Se|=t.DEPTH_BUFFER_BIT),$.stencilBuffer&&$.resolveStencilBuffer&&(Se|=t.STENCIL_BUFFER_BIT)),Ue){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,$e.__webglColorRenderbuffer[We]);const Ye=r.get(I[We]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Ye,0)}t.blitFramebuffer(0,0,V,ie,0,0,V,ie,Se,t.NEAREST),c===!0&&(B.length=0,X.length=0,B.push(t.COLOR_ATTACHMENT0+We),$.depthBuffer&&$.resolveDepthBuffer===!1&&(B.push(ye),X.push(ye),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,X)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,B))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ue)for(let We=0;We<I.length;We++){n.bindFramebuffer(t.FRAMEBUFFER,$e.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+We,t.RENDERBUFFER,$e.__webglColorRenderbuffer[We]);const Ye=r.get(I[We]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,$e.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+We,t.TEXTURE_2D,Ye,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,$e.__webglMultisampledFramebuffer)}else if($.depthBuffer&&$.resolveDepthBuffer===!1&&c){const I=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[I])}}}function Q($){return Math.min(i.maxSamples,$.samples)}function le($){const I=r.get($);return $.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function Pe($){const I=o.render.frame;d.get($)!==I&&(d.set($,I),$.update())}function Oe($,I){const V=$.colorSpace,ie=$.format,Se=$.type;return $.isCompressedTexture===!0||$.isVideoTexture===!0||V!==wg&&V!==vd&&(Yn.getTransfer(V)===pr?(ie!==rl||Se!==Gl)&&mn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):hi("WebGLTextures: Unsupported texture color space:",V)),I}function je($){return typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement?(u.width=$.naturalWidth||$.width,u.height=$.naturalHeight||$.height):typeof VideoFrame<"u"&&$ instanceof VideoFrame?(u.width=$.displayWidth,u.height=$.displayHeight):(u.width=$.width,u.height=$.height),u}this.allocateTextureUnit=q,this.resetTextureUnits=O,this.setTexture2D=G,this.setTexture2DArray=Y,this.setTexture3D=K,this.setTextureCube=Z,this.rebindTextures=re,this.setupRenderTarget=He,this.updateRenderTargetMipmap=H,this.updateMultisampleRenderTarget=U,this.setupDepthRenderbuffer=Ne,this.setupFrameBufferTexture=be,this.useMultisampledRTT=le}function SOe(t,e){function n(r,i=vd){let s;const o=Yn.getTransfer(i);if(r===Gl)return t.UNSIGNED_BYTE;if(r===MO)return t.UNSIGNED_SHORT_4_4_4_4;if(r===EO)return t.UNSIGNED_SHORT_5_5_5_1;if(r===$Z)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===HZ)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===zZ)return t.BYTE;if(r===BZ)return t.SHORT;if(r===L0)return t.UNSIGNED_SHORT;if(r===NO)return t.INT;if(r===Gf)return t.UNSIGNED_INT;if(r===Kc)return t.FLOAT;if(r===ex)return t.HALF_FLOAT;if(r===VZ)return t.ALPHA;if(r===GZ)return t.RGB;if(r===rl)return t.RGBA;if(r===F0)return t.DEPTH_COMPONENT;if(r===U0)return t.DEPTH_STENCIL;if(r===qZ)return t.RED;if(r===TO)return t.RED_INTEGER;if(r===CO)return t.RG;if(r===AO)return t.RG_INTEGER;if(r===kO)return t.RGBA_INTEGER;if(r===Z1||r===J1||r===ew||r===tw)if(o===pr)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(r===Z1)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===J1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===ew)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===tw)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(r===Z1)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===J1)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===ew)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===tw)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===xP||r===bP||r===yP||r===vP)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(r===xP)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===bP)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===yP)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===vP)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===_P||r===wP||r===SP)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(r===_P||r===wP)return o===pr?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(r===SP)return o===pr?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===NP||r===MP||r===EP||r===TP||r===CP||r===AP||r===kP||r===jP||r===PP||r===RP||r===DP||r===OP||r===LP||r===IP)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(r===NP)return o===pr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===MP)return o===pr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===EP)return o===pr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===TP)return o===pr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===CP)return o===pr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===AP)return o===pr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===kP)return o===pr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===jP)return o===pr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===PP)return o===pr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===RP)return o===pr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===DP)return o===pr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===OP)return o===pr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===LP)return o===pr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===IP)return o===pr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===FP||r===UP||r===zP)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(r===FP)return o===pr?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===UP)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===zP)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===BP||r===$P||r===HP||r===VP)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(r===BP)return s.COMPRESSED_RED_RGTC1_EXT;if(r===$P)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===HP)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===VP)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===I0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const NOe=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,MOe=`
- uniform sampler2DArray depthColor;
- uniform float depthWidth;
- uniform float depthHeight;
- void main() {
- vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
- if ( coord.x >= 1.0 ) {
- gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
- } else {
- gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
- }
- }`;class EOe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new fJ(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 xu({vertexShader:NOe,fragmentShader:MOe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new ql(new LO(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let TOe=class extends om{constructor(e,n){super();const r=this;let i=null,s=1,o=null,l="local-floor",c=1,u=null,d=null,f=null,m=null,g=null,x=null;const y=typeof XRWebGLBinding<"u",b=new EOe,v={},N=n.getContextAttributes();let S=null,T=null;const E=[],k=[],C=new Nn;let D=null;const A=new So;A.viewport=new Si;const R=new So;R.viewport=new Si;const F=[A,R],O=new V3e;let q=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(me){let xe=E[me];return xe===void 0&&(xe=new qA,E[me]=xe),xe.getTargetRaySpace()},this.getControllerGrip=function(me){let xe=E[me];return xe===void 0&&(xe=new qA,E[me]=xe),xe.getGripSpace()},this.getHand=function(me){let xe=E[me];return xe===void 0&&(xe=new qA,E[me]=xe),xe.getHandSpace()};function G(me){const xe=k.indexOf(me.inputSource);if(xe===-1)return;const be=E[xe];be!==void 0&&(be.update(me.inputSource,me.frame,u||o),be.dispatchEvent({type:me.type,data:me.inputSource}))}function Y(){i.removeEventListener("select",G),i.removeEventListener("selectstart",G),i.removeEventListener("selectend",G),i.removeEventListener("squeeze",G),i.removeEventListener("squeezestart",G),i.removeEventListener("squeezeend",G),i.removeEventListener("end",Y),i.removeEventListener("inputsourceschange",K);for(let me=0;me<E.length;me++){const xe=k[me];xe!==null&&(k[me]=null,E[me].disconnect(xe))}q=null,j=null,b.reset();for(const me in v)delete v[me];e.setRenderTarget(S),g=null,m=null,f=null,i=null,T=null,de.stop(),r.isPresenting=!1,e.setPixelRatio(D),e.setSize(C.width,C.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(me){s=me,r.isPresenting===!0&&mn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(me){l=me,r.isPresenting===!0&&mn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(me){u=me},this.getBaseLayer=function(){return m!==null?m:g},this.getBinding=function(){return f===null&&y&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(me){if(i=me,i!==null){if(S=e.getRenderTarget(),i.addEventListener("select",G),i.addEventListener("selectstart",G),i.addEventListener("selectend",G),i.addEventListener("squeeze",G),i.addEventListener("squeezestart",G),i.addEventListener("squeezeend",G),i.addEventListener("end",Y),i.addEventListener("inputsourceschange",K),N.xrCompatible!==!0&&await n.makeXRCompatible(),D=e.getPixelRatio(),e.getSize(C),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let be=null,fe=null,Ce=null;N.depth&&(Ce=N.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,be=N.stencil?U0:F0,fe=N.stencil?I0:Gf);const Ne={colorFormat:n.RGBA8,depthFormat:Ce,scaleFactor:s};f=this.getBinding(),m=f.createProjectionLayer(Ne),i.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),T=new Wf(m.textureWidth,m.textureHeight,{format:rl,type:Gl,depthTexture:new hJ(m.textureWidth,m.textureHeight,fe,void 0,void 0,void 0,void 0,void 0,void 0,be),stencilBuffer:N.stencil,colorSpace:e.outputColorSpace,samples:N.antialias?4:0,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}else{const be={antialias:N.antialias,alpha:!0,depth:N.depth,stencil:N.stencil,framebufferScaleFactor:s};g=new XRWebGLLayer(i,n,be),i.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),T=new Wf(g.framebufferWidth,g.framebufferHeight,{format:rl,type:Gl,colorSpace:e.outputColorSpace,stencilBuffer:N.stencil,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),de.setContext(i),de.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return b.getDepthTexture()};function K(me){for(let xe=0;xe<me.removed.length;xe++){const be=me.removed[xe],fe=k.indexOf(be);fe>=0&&(k[fe]=null,E[fe].disconnect(be))}for(let xe=0;xe<me.added.length;xe++){const be=me.added[xe];let fe=k.indexOf(be);if(fe===-1){for(let Ne=0;Ne<E.length;Ne++)if(Ne>=k.length){k.push(be),fe=Ne;break}else if(k[Ne]===null){k[Ne]=be,fe=Ne;break}if(fe===-1)break}const Ce=E[fe];Ce&&Ce.connect(be)}}const Z=new ot,te=new ot;function ne(me,xe,be){Z.setFromMatrixPosition(xe.matrixWorld),te.setFromMatrixPosition(be.matrixWorld);const fe=Z.distanceTo(te),Ce=xe.projectionMatrix.elements,Ne=be.projectionMatrix.elements,re=Ce[14]/(Ce[10]-1),He=Ce[14]/(Ce[10]+1),H=(Ce[9]+1)/Ce[5],B=(Ce[9]-1)/Ce[5],X=(Ce[8]-1)/Ce[0],U=(Ne[8]+1)/Ne[0],Q=re*X,le=re*U,Pe=fe/(-X+U),Oe=Pe*-X;if(xe.matrixWorld.decompose(me.position,me.quaternion,me.scale),me.translateX(Oe),me.translateZ(Pe),me.matrixWorld.compose(me.position,me.quaternion,me.scale),me.matrixWorldInverse.copy(me.matrixWorld).invert(),Ce[10]===-1)me.projectionMatrix.copy(xe.projectionMatrix),me.projectionMatrixInverse.copy(xe.projectionMatrixInverse);else{const je=re+Pe,$=He+Pe,I=Q-Oe,V=le+(fe-Oe),ie=H*He/$*je,Se=B*He/$*je;me.projectionMatrix.makePerspective(I,V,ie,Se,je,$),me.projectionMatrixInverse.copy(me.projectionMatrix).invert()}}function z(me,xe){xe===null?me.matrixWorld.copy(me.matrix):me.matrixWorld.multiplyMatrices(xe.matrixWorld,me.matrix),me.matrixWorldInverse.copy(me.matrixWorld).invert()}this.updateCamera=function(me){if(i===null)return;let xe=me.near,be=me.far;b.texture!==null&&(b.depthNear>0&&(xe=b.depthNear),b.depthFar>0&&(be=b.depthFar)),O.near=R.near=A.near=xe,O.far=R.far=A.far=be,(q!==O.near||j!==O.far)&&(i.updateRenderState({depthNear:O.near,depthFar:O.far}),q=O.near,j=O.far),O.layers.mask=me.layers.mask|6,A.layers.mask=O.layers.mask&3,R.layers.mask=O.layers.mask&5;const fe=me.parent,Ce=O.cameras;z(O,fe);for(let Ne=0;Ne<Ce.length;Ne++)z(Ce[Ne],fe);Ce.length===2?ne(O,A,R):O.projectionMatrix.copy(A.projectionMatrix),W(me,O,fe)};function W(me,xe,be){be===null?me.matrix.copy(xe.matrixWorld):(me.matrix.copy(be.matrixWorld),me.matrix.invert(),me.matrix.multiply(xe.matrixWorld)),me.matrix.decompose(me.position,me.quaternion,me.scale),me.updateMatrixWorld(!0),me.projectionMatrix.copy(xe.projectionMatrix),me.projectionMatrixInverse.copy(xe.projectionMatrixInverse),me.isPerspectiveCamera&&(me.fov=GP*2*Math.atan(1/me.projectionMatrix.elements[5]),me.zoom=1)}this.getCamera=function(){return O},this.getFoveation=function(){if(!(m===null&&g===null))return c},this.setFoveation=function(me){c=me,m!==null&&(m.fixedFoveation=me),g!==null&&g.fixedFoveation!==void 0&&(g.fixedFoveation=me)},this.hasDepthSensing=function(){return b.texture!==null},this.getDepthSensingMesh=function(){return b.getMesh(O)},this.getCameraTexture=function(me){return v[me]};let se=null;function ae(me,xe){if(d=xe.getViewerPose(u||o),x=xe,d!==null){const be=d.views;g!==null&&(e.setRenderTargetFramebuffer(T,g.framebuffer),e.setRenderTarget(T));let fe=!1;be.length!==O.cameras.length&&(O.cameras.length=0,fe=!0);for(let He=0;He<be.length;He++){const H=be[He];let B=null;if(g!==null)B=g.getViewport(H);else{const U=f.getViewSubImage(m,H);B=U.viewport,He===0&&(e.setRenderTargetTextures(T,U.colorTexture,U.depthStencilTexture),e.setRenderTarget(T))}let X=F[He];X===void 0&&(X=new So,X.layers.enable(He),X.viewport=new Si,F[He]=X),X.matrix.fromArray(H.transform.matrix),X.matrix.decompose(X.position,X.quaternion,X.scale),X.projectionMatrix.fromArray(H.projectionMatrix),X.projectionMatrixInverse.copy(X.projectionMatrix).invert(),X.viewport.set(B.x,B.y,B.width,B.height),He===0&&(O.matrix.copy(X.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale)),fe===!0&&O.cameras.push(X)}const Ce=i.enabledFeatures;if(Ce&&Ce.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){f=r.getBinding();const He=f.getDepthInformation(be[0]);He&&He.isValid&&He.texture&&b.init(He,i.renderState)}if(Ce&&Ce.includes("camera-access")&&y){e.state.unbindTexture(),f=r.getBinding();for(let He=0;He<be.length;He++){const H=be[He].camera;if(H){let B=v[H];B||(B=new fJ,v[H]=B);const X=f.getCameraImage(H);B.sourceTexture=X}}}}for(let be=0;be<E.length;be++){const fe=k[be],Ce=E[be];fe!==null&&Ce!==void 0&&Ce.update(fe,xe,u||o)}se&&se(me,xe),xe.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:xe}),x=null}const de=new xJ;de.setAnimationLoop(ae),this.setAnimationLoop=function(me){se=me},this.dispose=function(){}}};const zh=new th,COe=new Ci;function AOe(t,e){function n(b,v){b.matrixAutoUpdate===!0&&b.updateMatrix(),v.value.copy(b.matrix)}function r(b,v){v.color.getRGB(b.fogColor.value,lJ(t)),v.isFog?(b.fogNear.value=v.near,b.fogFar.value=v.far):v.isFogExp2&&(b.fogDensity.value=v.density)}function i(b,v,N,S,T){v.isMeshBasicMaterial||v.isMeshLambertMaterial?s(b,v):v.isMeshToonMaterial?(s(b,v),f(b,v)):v.isMeshPhongMaterial?(s(b,v),d(b,v)):v.isMeshStandardMaterial?(s(b,v),m(b,v),v.isMeshPhysicalMaterial&&g(b,v,T)):v.isMeshMatcapMaterial?(s(b,v),x(b,v)):v.isMeshDepthMaterial?s(b,v):v.isMeshDistanceMaterial?(s(b,v),y(b,v)):v.isMeshNormalMaterial?s(b,v):v.isLineBasicMaterial?(o(b,v),v.isLineDashedMaterial&&l(b,v)):v.isPointsMaterial?c(b,v,N,S):v.isSpriteMaterial?u(b,v):v.isShadowMaterial?(b.color.value.copy(v.color),b.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function s(b,v){b.opacity.value=v.opacity,v.color&&b.diffuse.value.copy(v.color),v.emissive&&b.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(b.map.value=v.map,n(v.map,b.mapTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.bumpMap&&(b.bumpMap.value=v.bumpMap,n(v.bumpMap,b.bumpMapTransform),b.bumpScale.value=v.bumpScale,v.side===_s&&(b.bumpScale.value*=-1)),v.normalMap&&(b.normalMap.value=v.normalMap,n(v.normalMap,b.normalMapTransform),b.normalScale.value.copy(v.normalScale),v.side===_s&&b.normalScale.value.negate()),v.displacementMap&&(b.displacementMap.value=v.displacementMap,n(v.displacementMap,b.displacementMapTransform),b.displacementScale.value=v.displacementScale,b.displacementBias.value=v.displacementBias),v.emissiveMap&&(b.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,b.emissiveMapTransform)),v.specularMap&&(b.specularMap.value=v.specularMap,n(v.specularMap,b.specularMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest);const N=e.get(v),S=N.envMap,T=N.envMapRotation;S&&(b.envMap.value=S,zh.copy(T),zh.x*=-1,zh.y*=-1,zh.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(zh.y*=-1,zh.z*=-1),b.envMapRotation.value.setFromMatrix4(COe.makeRotationFromEuler(zh)),b.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,b.reflectivity.value=v.reflectivity,b.ior.value=v.ior,b.refractionRatio.value=v.refractionRatio),v.lightMap&&(b.lightMap.value=v.lightMap,b.lightMapIntensity.value=v.lightMapIntensity,n(v.lightMap,b.lightMapTransform)),v.aoMap&&(b.aoMap.value=v.aoMap,b.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,b.aoMapTransform))}function o(b,v){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,v.map&&(b.map.value=v.map,n(v.map,b.mapTransform))}function l(b,v){b.dashSize.value=v.dashSize,b.totalSize.value=v.dashSize+v.gapSize,b.scale.value=v.scale}function c(b,v,N,S){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.size.value=v.size*N,b.scale.value=S*.5,v.map&&(b.map.value=v.map,n(v.map,b.uvTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest)}function u(b,v){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.rotation.value=v.rotation,v.map&&(b.map.value=v.map,n(v.map,b.mapTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest)}function d(b,v){b.specular.value.copy(v.specular),b.shininess.value=Math.max(v.shininess,1e-4)}function f(b,v){v.gradientMap&&(b.gradientMap.value=v.gradientMap)}function m(b,v){b.metalness.value=v.metalness,v.metalnessMap&&(b.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,b.metalnessMapTransform)),b.roughness.value=v.roughness,v.roughnessMap&&(b.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,b.roughnessMapTransform)),v.envMap&&(b.envMapIntensity.value=v.envMapIntensity)}function g(b,v,N){b.ior.value=v.ior,v.sheen>0&&(b.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),b.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(b.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,b.sheenColorMapTransform)),v.sheenRoughnessMap&&(b.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,b.sheenRoughnessMapTransform))),v.clearcoat>0&&(b.clearcoat.value=v.clearcoat,b.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(b.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,b.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(b.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,b.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(b.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,b.clearcoatNormalMapTransform),b.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===_s&&b.clearcoatNormalScale.value.negate())),v.dispersion>0&&(b.dispersion.value=v.dispersion),v.iridescence>0&&(b.iridescence.value=v.iridescence,b.iridescenceIOR.value=v.iridescenceIOR,b.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],b.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(b.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,b.iridescenceMapTransform)),v.iridescenceThicknessMap&&(b.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,b.iridescenceThicknessMapTransform))),v.transmission>0&&(b.transmission.value=v.transmission,b.transmissionSamplerMap.value=N.texture,b.transmissionSamplerSize.value.set(N.width,N.height),v.transmissionMap&&(b.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,b.transmissionMapTransform)),b.thickness.value=v.thickness,v.thicknessMap&&(b.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,b.thicknessMapTransform)),b.attenuationDistance.value=v.attenuationDistance,b.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(b.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(b.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,b.anisotropyMapTransform))),b.specularIntensity.value=v.specularIntensity,b.specularColor.value.copy(v.specularColor),v.specularColorMap&&(b.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,b.specularColorMapTransform)),v.specularIntensityMap&&(b.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,b.specularIntensityMapTransform))}function x(b,v){v.matcap&&(b.matcap.value=v.matcap)}function y(b,v){const N=e.get(v).light;b.referencePosition.value.setFromMatrixPosition(N.matrixWorld),b.nearDistance.value=N.shadow.camera.near,b.farDistance.value=N.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function kOe(t,e,n,r){let i={},s={},o=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(N,S){const T=S.program;r.uniformBlockBinding(N,T)}function u(N,S){let T=i[N.id];T===void 0&&(x(N),T=d(N),i[N.id]=T,N.addEventListener("dispose",b));const E=S.program;r.updateUBOMapping(N,E);const k=e.render.frame;s[N.id]!==k&&(m(N),s[N.id]=k)}function d(N){const S=f();N.__bindingPointIndex=S;const T=t.createBuffer(),E=N.__size,k=N.usage;return t.bindBuffer(t.UNIFORM_BUFFER,T),t.bufferData(t.UNIFORM_BUFFER,E,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,S,T),T}function f(){for(let N=0;N<l;N++)if(o.indexOf(N)===-1)return o.push(N),N;return hi("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(N){const S=i[N.id],T=N.uniforms,E=N.__cache;t.bindBuffer(t.UNIFORM_BUFFER,S);for(let k=0,C=T.length;k<C;k++){const D=Array.isArray(T[k])?T[k]:[T[k]];for(let A=0,R=D.length;A<R;A++){const F=D[A];if(g(F,k,A,E)===!0){const O=F.__offset,q=Array.isArray(F.value)?F.value:[F.value];let j=0;for(let G=0;G<q.length;G++){const Y=q[G],K=y(Y);typeof Y=="number"||typeof Y=="boolean"?(F.__data[0]=Y,t.bufferSubData(t.UNIFORM_BUFFER,O+j,F.__data)):Y.isMatrix3?(F.__data[0]=Y.elements[0],F.__data[1]=Y.elements[1],F.__data[2]=Y.elements[2],F.__data[3]=0,F.__data[4]=Y.elements[3],F.__data[5]=Y.elements[4],F.__data[6]=Y.elements[5],F.__data[7]=0,F.__data[8]=Y.elements[6],F.__data[9]=Y.elements[7],F.__data[10]=Y.elements[8],F.__data[11]=0):(Y.toArray(F.__data,j),j+=K.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,O,F.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function g(N,S,T,E){const k=N.value,C=S+"_"+T;if(E[C]===void 0)return typeof k=="number"||typeof k=="boolean"?E[C]=k:E[C]=k.clone(),!0;{const D=E[C];if(typeof k=="number"||typeof k=="boolean"){if(D!==k)return E[C]=k,!0}else if(D.equals(k)===!1)return D.copy(k),!0}return!1}function x(N){const S=N.uniforms;let T=0;const E=16;for(let C=0,D=S.length;C<D;C++){const A=Array.isArray(S[C])?S[C]:[S[C]];for(let R=0,F=A.length;R<F;R++){const O=A[R],q=Array.isArray(O.value)?O.value:[O.value];for(let j=0,G=q.length;j<G;j++){const Y=q[j],K=y(Y),Z=T%E,te=Z%K.boundary,ne=Z+te;T+=te,ne!==0&&E-ne<K.storage&&(T+=E-ne),O.__data=new Float32Array(K.storage/Float32Array.BYTES_PER_ELEMENT),O.__offset=T,T+=K.storage}}}const k=T%E;return k>0&&(T+=E-k),N.__size=T,N.__cache={},this}function y(N){const S={boundary:0,storage:0};return typeof N=="number"||typeof N=="boolean"?(S.boundary=4,S.storage=4):N.isVector2?(S.boundary=8,S.storage=8):N.isVector3||N.isColor?(S.boundary=16,S.storage=12):N.isVector4?(S.boundary=16,S.storage=16):N.isMatrix3?(S.boundary=48,S.storage=48):N.isMatrix4?(S.boundary=64,S.storage=64):N.isTexture?mn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):mn("WebGLRenderer: Unsupported uniform value type.",N),S}function b(N){const S=N.target;S.removeEventListener("dispose",b);const T=o.indexOf(S.__bindingPointIndex);o.splice(T,1),t.deleteBuffer(i[S.id]),delete i[S.id],delete s[S.id]}function v(){for(const N in i)t.deleteBuffer(i[N]);o=[],i={},s={}}return{bind:c,update:u,dispose:v}}const jOe=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 Mc=null;function POe(){return Mc===null&&(Mc=new P3e(jOe,32,32,CO,ex),Mc.minFilter=Ao,Mc.magFilter=Ao,Mc.wrapS=Wc,Mc.wrapT=Wc,Mc.generateMipmaps=!1,Mc.needsUpdate=!0),Mc}let ROe=class{constructor(e={}){const{canvas:n=r3e(),context:r=null,depth:i=!0,stencil:s=!1,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:m=!1}=e;this.isWebGLRenderer=!0;let g;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=r.getContextAttributes().alpha}else g=o;const x=new Set([kO,AO,TO]),y=new Set([Gl,Gf,L0,I0,MO,EO]),b=new Uint32Array(4),v=new Int32Array(4);let N=null,S=null;const T=[],E=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Ld,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const k=this;let C=!1;this._outputColorSpace=vo;let D=0,A=0,R=null,F=-1,O=null;const q=new Si,j=new Si;let G=null;const Y=new Rn(0);let K=0,Z=n.width,te=n.height,ne=1,z=null,W=null;const se=new Si(0,0,Z,te),ae=new Si(0,0,Z,te);let de=!1;const me=new OO;let xe=!1,be=!1;const fe=new Ci,Ce=new ot,Ne=new Si,re={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let He=!1;function H(){return R===null?ne:1}let B=r;function X(ue,ge){return n.getContext(ue,ge)}try{const ue={alpha:!0,depth:i,stencil:s,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${wO}`),n.addEventListener("webglcontextlost",De,!1),n.addEventListener("webglcontextrestored",Ae,!1),n.addEventListener("webglcontextcreationerror",Je,!1),B===null){const ge="webgl2";if(B=X(ge,ue),B===null)throw X(ge)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ue){throw ue("WebGLRenderer: "+ue.message),ue}let U,Q,le,Pe,Oe,je,$,I,V,ie,Se,ye,$e,Ue,Ge,We,Ye,oe,ve,Le,Ke,lt,_e,ce;function ee(){U=new BDe(B),U.init(),lt=new SOe(B,U),Q=new PDe(B,U,e,lt),le=new _Oe(B,U),Q.reversedDepthBuffer&&m&&le.buffers.depth.setReversed(!0),Pe=new VDe(B),Oe=new lOe,je=new wOe(B,U,le,Oe,Q,lt,Pe),$=new DDe(k),I=new zDe(k),V=new K3e(B),_e=new kDe(B,V),ie=new $De(B,V,Pe,_e),Se=new qDe(B,ie,V,Pe),ve=new GDe(B,Q,je),We=new RDe(Oe),ye=new oOe(k,$,I,U,Q,_e,We),$e=new AOe(k,Oe),Ue=new uOe,Ge=new gOe(U),oe=new ADe(k,$,I,le,Se,g,c),Ye=new yOe(k,Se,Q),ce=new kOe(B,Pe,Q,le),Le=new jDe(B,U,Pe),Ke=new HDe(B,U,Pe),Pe.programs=ye.programs,k.capabilities=Q,k.extensions=U,k.properties=Oe,k.renderLists=Ue,k.shadowMap=Ye,k.state=le,k.info=Pe}ee();const ke=new TOe(k,B);this.xr=ke,this.getContext=function(){return B},this.getContextAttributes=function(){return B.getContextAttributes()},this.forceContextLoss=function(){const ue=U.get("WEBGL_lose_context");ue&&ue.loseContext()},this.forceContextRestore=function(){const ue=U.get("WEBGL_lose_context");ue&&ue.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(ue){ue!==void 0&&(ne=ue,this.setSize(Z,te,!1))},this.getSize=function(ue){return ue.set(Z,te)},this.setSize=function(ue,ge,Fe=!0){if(ke.isPresenting){mn("WebGLRenderer: Can't change size while VR device is presenting.");return}Z=ue,te=ge,n.width=Math.floor(ue*ne),n.height=Math.floor(ge*ne),Fe===!0&&(n.style.width=ue+"px",n.style.height=ge+"px"),this.setViewport(0,0,ue,ge)},this.getDrawingBufferSize=function(ue){return ue.set(Z*ne,te*ne).floor()},this.setDrawingBufferSize=function(ue,ge,Fe){Z=ue,te=ge,ne=Fe,n.width=Math.floor(ue*Fe),n.height=Math.floor(ge*Fe),this.setViewport(0,0,ue,ge)},this.getCurrentViewport=function(ue){return ue.copy(q)},this.getViewport=function(ue){return ue.copy(se)},this.setViewport=function(ue,ge,Fe,Ie){ue.isVector4?se.set(ue.x,ue.y,ue.z,ue.w):se.set(ue,ge,Fe,Ie),le.viewport(q.copy(se).multiplyScalar(ne).round())},this.getScissor=function(ue){return ue.copy(ae)},this.setScissor=function(ue,ge,Fe,Ie){ue.isVector4?ae.set(ue.x,ue.y,ue.z,ue.w):ae.set(ue,ge,Fe,Ie),le.scissor(j.copy(ae).multiplyScalar(ne).round())},this.getScissorTest=function(){return de},this.setScissorTest=function(ue){le.setScissorTest(de=ue)},this.setOpaqueSort=function(ue){z=ue},this.setTransparentSort=function(ue){W=ue},this.getClearColor=function(ue){return ue.copy(oe.getClearColor())},this.setClearColor=function(){oe.setClearColor(...arguments)},this.getClearAlpha=function(){return oe.getClearAlpha()},this.setClearAlpha=function(){oe.setClearAlpha(...arguments)},this.clear=function(ue=!0,ge=!0,Fe=!0){let Ie=0;if(ue){let Me=!1;if(R!==null){const mt=R.texture.format;Me=x.has(mt)}if(Me){const mt=R.texture.type,wt=y.has(mt),kt=oe.getClearColor(),pt=oe.getClearAlpha(),zt=kt.r,Pt=kt.g,Mt=kt.b;wt?(b[0]=zt,b[1]=Pt,b[2]=Mt,b[3]=pt,B.clearBufferuiv(B.COLOR,0,b)):(v[0]=zt,v[1]=Pt,v[2]=Mt,v[3]=pt,B.clearBufferiv(B.COLOR,0,v))}else Ie|=B.COLOR_BUFFER_BIT}ge&&(Ie|=B.DEPTH_BUFFER_BIT),Fe&&(Ie|=B.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B.clear(Ie)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",De,!1),n.removeEventListener("webglcontextrestored",Ae,!1),n.removeEventListener("webglcontextcreationerror",Je,!1),oe.dispose(),Ue.dispose(),Ge.dispose(),Oe.dispose(),$.dispose(),I.dispose(),Se.dispose(),_e.dispose(),ce.dispose(),ye.dispose(),ke.dispose(),ke.removeEventListener("sessionstart",en),ke.removeEventListener("sessionend",er),ur.stop()};function De(ue){ue.preventDefault(),_H("WebGLRenderer: Context Lost."),C=!0}function Ae(){_H("WebGLRenderer: Context Restored."),C=!1;const ue=Pe.autoReset,ge=Ye.enabled,Fe=Ye.autoUpdate,Ie=Ye.needsUpdate,Me=Ye.type;ee(),Pe.autoReset=ue,Ye.enabled=ge,Ye.autoUpdate=Fe,Ye.needsUpdate=Ie,Ye.type=Me}function Je(ue){hi("WebGLRenderer: A WebGL context could not be created. Reason: ",ue.statusMessage)}function gt(ue){const ge=ue.target;ge.removeEventListener("dispose",gt),At(ge)}function At(ue){jt(ue),Oe.remove(ue)}function jt(ue){const ge=Oe.get(ue).programs;ge!==void 0&&(ge.forEach(function(Fe){ye.releaseProgram(Fe)}),ue.isShaderMaterial&&ye.releaseShaderCache(ue))}this.renderBufferDirect=function(ue,ge,Fe,Ie,Me,mt){ge===null&&(ge=re);const wt=Me.isMesh&&Me.matrixWorld.determinant()<0,kt=Ee(ue,ge,Fe,Ie,Me);le.setMaterial(Ie,wt);let pt=Fe.index,zt=1;if(Ie.wireframe===!0){if(pt=ie.getWireframeAttribute(Fe),pt===void 0)return;zt=2}const Pt=Fe.drawRange,Mt=Fe.attributes.position;let nn=Pt.start*zt,Bt=(Pt.start+Pt.count)*zt;mt!==null&&(nn=Math.max(nn,mt.start*zt),Bt=Math.min(Bt,(mt.start+mt.count)*zt)),pt!==null?(nn=Math.max(nn,0),Bt=Math.min(Bt,pt.count)):Mt!=null&&(nn=Math.max(nn,0),Bt=Math.min(Bt,Mt.count));const tn=Bt-nn;if(tn<0||tn===1/0)return;_e.setup(Me,Ie,kt,Fe,pt);let cn,we=Le;if(pt!==null&&(cn=V.get(pt),we=Ke,we.setIndex(cn)),Me.isMesh)Ie.wireframe===!0?(le.setLineWidth(Ie.wireframeLinewidth*H()),we.setMode(B.LINES)):we.setMode(B.TRIANGLES);else if(Me.isLine){let bt=Ie.linewidth;bt===void 0&&(bt=1),le.setLineWidth(bt*H()),Me.isLineSegments?we.setMode(B.LINES):Me.isLineLoop?we.setMode(B.LINE_LOOP):we.setMode(B.LINE_STRIP)}else Me.isPoints?we.setMode(B.POINTS):Me.isSprite&&we.setMode(B.TRIANGLES);if(Me.isBatchedMesh)if(Me._multiDrawInstances!==null)z0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),we.renderMultiDrawInstances(Me._multiDrawStarts,Me._multiDrawCounts,Me._multiDrawCount,Me._multiDrawInstances);else if(U.get("WEBGL_multi_draw"))we.renderMultiDraw(Me._multiDrawStarts,Me._multiDrawCounts,Me._multiDrawCount);else{const bt=Me._multiDrawStarts,$t=Me._multiDrawCounts,Be=Me._multiDrawCount,Et=pt?V.get(pt).bytesPerElement:1,Wt=Oe.get(Ie).currentProgram.getUniforms();for(let dt=0;dt<Be;dt++)Wt.setValue(B,"_gl_DrawID",dt),we.render(bt[dt]/Et,$t[dt])}else if(Me.isInstancedMesh)we.renderInstances(nn,tn,Me.count);else if(Fe.isInstancedBufferGeometry){const bt=Fe._maxInstanceCount!==void 0?Fe._maxInstanceCount:1/0,$t=Math.min(Fe.instanceCount,bt);we.renderInstances(nn,tn,$t)}else we.render(nn,tn)};function ln(ue,ge,Fe){ue.transparent===!0&&ue.side===Al&&ue.forceSinglePass===!1?(ue.side=_s,ue.needsUpdate=!0,zn(ue,ge,Fe),ue.side=eh,ue.needsUpdate=!0,zn(ue,ge,Fe),ue.side=Al):zn(ue,ge,Fe)}this.compile=function(ue,ge,Fe=null){Fe===null&&(Fe=ue),S=Ge.get(Fe),S.init(ge),E.push(S),Fe.traverseVisible(function(Me){Me.isLight&&Me.layers.test(ge.layers)&&(S.pushLight(Me),Me.castShadow&&S.pushShadow(Me))}),ue!==Fe&&ue.traverseVisible(function(Me){Me.isLight&&Me.layers.test(ge.layers)&&(S.pushLight(Me),Me.castShadow&&S.pushShadow(Me))}),S.setupLights();const Ie=new Set;return ue.traverse(function(Me){if(!(Me.isMesh||Me.isPoints||Me.isLine||Me.isSprite))return;const mt=Me.material;if(mt)if(Array.isArray(mt))for(let wt=0;wt<mt.length;wt++){const kt=mt[wt];ln(kt,Fe,Me),Ie.add(kt)}else ln(mt,Fe,Me),Ie.add(mt)}),S=E.pop(),Ie},this.compileAsync=function(ue,ge,Fe=null){const Ie=this.compile(ue,ge,Fe);return new Promise(Me=>{function mt(){if(Ie.forEach(function(wt){Oe.get(wt).currentProgram.isReady()&&Ie.delete(wt)}),Ie.size===0){Me(ue);return}setTimeout(mt,10)}U.get("KHR_parallel_shader_compile")!==null?mt():setTimeout(mt,10)})};let Lt=null;function Cn(ue){Lt&&Lt(ue)}function en(){ur.stop()}function er(){ur.start()}const ur=new xJ;ur.setAnimationLoop(Cn),typeof self<"u"&&ur.setContext(self),this.setAnimationLoop=function(ue){Lt=ue,ke.setAnimationLoop(ue),ue===null?ur.stop():ur.start()},ke.addEventListener("sessionstart",en),ke.addEventListener("sessionend",er),this.render=function(ue,ge){if(ge!==void 0&&ge.isCamera!==!0){hi("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;if(ue.matrixWorldAutoUpdate===!0&&ue.updateMatrixWorld(),ge.parent===null&&ge.matrixWorldAutoUpdate===!0&&ge.updateMatrixWorld(),ke.enabled===!0&&ke.isPresenting===!0&&(ke.cameraAutoUpdate===!0&&ke.updateCamera(ge),ge=ke.getCamera()),ue.isScene===!0&&ue.onBeforeRender(k,ue,ge,R),S=Ge.get(ue,E.length),S.init(ge),E.push(S),fe.multiplyMatrices(ge.projectionMatrix,ge.matrixWorldInverse),me.setFromProjectionMatrix(fe,Rl,ge.reversedDepth),be=this.localClippingEnabled,xe=We.init(this.clippingPlanes,be),N=Ue.get(ue,T.length),N.init(),T.push(N),ke.enabled===!0&&ke.isPresenting===!0){const mt=k.xr.getDepthSensingMesh();mt!==null&&Un(mt,ge,-1/0,k.sortObjects)}Un(ue,ge,0,k.sortObjects),N.finish(),k.sortObjects===!0&&N.sort(z,W),He=ke.enabled===!1||ke.isPresenting===!1||ke.hasDepthSensing()===!1,He&&oe.addToRenderList(N,ue),this.info.render.frame++,xe===!0&&We.beginShadows();const Fe=S.state.shadowsArray;Ye.render(Fe,ue,ge),xe===!0&&We.endShadows(),this.info.autoReset===!0&&this.info.reset();const Ie=N.opaque,Me=N.transmissive;if(S.setupLights(),ge.isArrayCamera){const mt=ge.cameras;if(Me.length>0)for(let wt=0,kt=mt.length;wt<kt;wt++){const pt=mt[wt];jr(Ie,Me,ue,pt)}He&&oe.render(ue);for(let wt=0,kt=mt.length;wt<kt;wt++){const pt=mt[wt];wr(N,ue,pt,pt.viewport)}}else Me.length>0&&jr(Ie,Me,ue,ge),He&&oe.render(ue),wr(N,ue,ge);R!==null&&A===0&&(je.updateMultisampleRenderTarget(R),je.updateRenderTargetMipmap(R)),ue.isScene===!0&&ue.onAfterRender(k,ue,ge),_e.resetDefaultState(),F=-1,O=null,E.pop(),E.length>0?(S=E[E.length-1],xe===!0&&We.setGlobalState(k.clippingPlanes,S.state.camera)):S=null,T.pop(),T.length>0?N=T[T.length-1]:N=null};function Un(ue,ge,Fe,Ie){if(ue.visible===!1)return;if(ue.layers.test(ge.layers)){if(ue.isGroup)Fe=ue.renderOrder;else if(ue.isLOD)ue.autoUpdate===!0&&ue.update(ge);else if(ue.isLight)S.pushLight(ue),ue.castShadow&&S.pushShadow(ue);else if(ue.isSprite){if(!ue.frustumCulled||me.intersectsSprite(ue)){Ie&&Ne.setFromMatrixPosition(ue.matrixWorld).applyMatrix4(fe);const wt=Se.update(ue),kt=ue.material;kt.visible&&N.push(ue,wt,kt,Fe,Ne.z,null)}}else if((ue.isMesh||ue.isLine||ue.isPoints)&&(!ue.frustumCulled||me.intersectsObject(ue))){const wt=Se.update(ue),kt=ue.material;if(Ie&&(ue.boundingSphere!==void 0?(ue.boundingSphere===null&&ue.computeBoundingSphere(),Ne.copy(ue.boundingSphere.center)):(wt.boundingSphere===null&&wt.computeBoundingSphere(),Ne.copy(wt.boundingSphere.center)),Ne.applyMatrix4(ue.matrixWorld).applyMatrix4(fe)),Array.isArray(kt)){const pt=wt.groups;for(let zt=0,Pt=pt.length;zt<Pt;zt++){const Mt=pt[zt],nn=kt[Mt.materialIndex];nn&&nn.visible&&N.push(ue,wt,nn,Fe,Ne.z,Mt)}}else kt.visible&&N.push(ue,wt,kt,Fe,Ne.z,null)}}const mt=ue.children;for(let wt=0,kt=mt.length;wt<kt;wt++)Un(mt[wt],ge,Fe,Ie)}function wr(ue,ge,Fe,Ie){const{opaque:Me,transmissive:mt,transparent:wt}=ue;S.setupLightsView(Fe),xe===!0&&We.setGlobalState(k.clippingPlanes,Fe),Ie&&le.viewport(q.copy(Ie)),Me.length>0&&Zn(Me,ge,Fe),mt.length>0&&Zn(mt,ge,Fe),wt.length>0&&Zn(wt,ge,Fe),le.buffers.depth.setTest(!0),le.buffers.depth.setMask(!0),le.buffers.color.setMask(!0),le.setPolygonOffset(!1)}function jr(ue,ge,Fe,Ie){if((Fe.isScene===!0?Fe.overrideMaterial:null)!==null)return;S.state.transmissionRenderTarget[Ie.id]===void 0&&(S.state.transmissionRenderTarget[Ie.id]=new Wf(1,1,{generateMipmaps:!0,type:U.has("EXT_color_buffer_half_float")||U.has("EXT_color_buffer_float")?ex:Gl,minFilter:df,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Yn.workingColorSpace}));const mt=S.state.transmissionRenderTarget[Ie.id],wt=Ie.viewport||q;mt.setSize(wt.z*k.transmissionResolutionScale,wt.w*k.transmissionResolutionScale);const kt=k.getRenderTarget(),pt=k.getActiveCubeFace(),zt=k.getActiveMipmapLevel();k.setRenderTarget(mt),k.getClearColor(Y),K=k.getClearAlpha(),K<1&&k.setClearColor(16777215,.5),k.clear(),He&&oe.render(Fe);const Pt=k.toneMapping;k.toneMapping=Ld;const Mt=Ie.viewport;if(Ie.viewport!==void 0&&(Ie.viewport=void 0),S.setupLightsView(Ie),xe===!0&&We.setGlobalState(k.clippingPlanes,Ie),Zn(ue,Fe,Ie),je.updateMultisampleRenderTarget(mt),je.updateRenderTargetMipmap(mt),U.has("WEBGL_multisampled_render_to_texture")===!1){let nn=!1;for(let Bt=0,tn=ge.length;Bt<tn;Bt++){const cn=ge[Bt],{object:we,geometry:bt,material:$t,group:Be}=cn;if($t.side===Al&&we.layers.test(Ie.layers)){const Et=$t.side;$t.side=_s,$t.needsUpdate=!0,Xt(we,Fe,Ie,bt,$t,Be),$t.side=Et,$t.needsUpdate=!0,nn=!0}}nn===!0&&(je.updateMultisampleRenderTarget(mt),je.updateRenderTargetMipmap(mt))}k.setRenderTarget(kt,pt,zt),k.setClearColor(Y,K),Mt!==void 0&&(Ie.viewport=Mt),k.toneMapping=Pt}function Zn(ue,ge,Fe){const Ie=ge.isScene===!0?ge.overrideMaterial:null;for(let Me=0,mt=ue.length;Me<mt;Me++){const wt=ue[Me],{object:kt,geometry:pt,group:zt}=wt;let Pt=wt.material;Pt.allowOverride===!0&&Ie!==null&&(Pt=Ie),kt.layers.test(Fe.layers)&&Xt(kt,ge,Fe,pt,Pt,zt)}}function Xt(ue,ge,Fe,Ie,Me,mt){ue.onBeforeRender(k,ge,Fe,Ie,Me,mt),ue.modelViewMatrix.multiplyMatrices(Fe.matrixWorldInverse,ue.matrixWorld),ue.normalMatrix.getNormalMatrix(ue.modelViewMatrix),Me.onBeforeRender(k,ge,Fe,Ie,ue,mt),Me.transparent===!0&&Me.side===Al&&Me.forceSinglePass===!1?(Me.side=_s,Me.needsUpdate=!0,k.renderBufferDirect(Fe,ge,Ie,Me,ue,mt),Me.side=eh,Me.needsUpdate=!0,k.renderBufferDirect(Fe,ge,Ie,Me,ue,mt),Me.side=Al):k.renderBufferDirect(Fe,ge,Ie,Me,ue,mt),ue.onAfterRender(k,ge,Fe,Ie,Me,mt)}function zn(ue,ge,Fe){ge.isScene!==!0&&(ge=re);const Ie=Oe.get(ue),Me=S.state.lights,mt=S.state.shadowsArray,wt=Me.state.version,kt=ye.getParameters(ue,Me.state,mt,ge,Fe),pt=ye.getProgramCacheKey(kt);let zt=Ie.programs;Ie.environment=ue.isMeshStandardMaterial?ge.environment:null,Ie.fog=ge.fog,Ie.envMap=(ue.isMeshStandardMaterial?I:$).get(ue.envMap||Ie.environment),Ie.envMapRotation=Ie.environment!==null&&ue.envMap===null?ge.environmentRotation:ue.envMapRotation,zt===void 0&&(ue.addEventListener("dispose",gt),zt=new Map,Ie.programs=zt);let Pt=zt.get(pt);if(Pt!==void 0){if(Ie.currentProgram===Pt&&Ie.lightsStateVersion===wt)return Zr(ue,kt),Pt}else kt.uniforms=ye.getUniforms(ue),ue.onBeforeCompile(kt,k),Pt=ye.acquireProgram(kt,pt),zt.set(pt,Pt),Ie.uniforms=kt.uniforms;const Mt=Ie.uniforms;return(!ue.isShaderMaterial&&!ue.isRawShaderMaterial||ue.clipping===!0)&&(Mt.clippingPlanes=We.uniform),Zr(ue,kt),Ie.needsLights=it(ue),Ie.lightsStateVersion=wt,Ie.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),Ie.currentProgram=Pt,Ie.uniformsList=null,Pt}function Wn(ue){if(ue.uniformsList===null){const ge=ue.currentProgram.getUniforms();ue.uniformsList=aw.seqWithValue(ge.seq,ue.uniforms)}return ue.uniformsList}function Zr(ue,ge){const Fe=Oe.get(ue);Fe.outputColorSpace=ge.outputColorSpace,Fe.batching=ge.batching,Fe.batchingColor=ge.batchingColor,Fe.instancing=ge.instancing,Fe.instancingColor=ge.instancingColor,Fe.instancingMorph=ge.instancingMorph,Fe.skinning=ge.skinning,Fe.morphTargets=ge.morphTargets,Fe.morphNormals=ge.morphNormals,Fe.morphColors=ge.morphColors,Fe.morphTargetsCount=ge.morphTargetsCount,Fe.numClippingPlanes=ge.numClippingPlanes,Fe.numIntersection=ge.numClipIntersection,Fe.vertexAlphas=ge.vertexAlphas,Fe.vertexTangents=ge.vertexTangents,Fe.toneMapping=ge.toneMapping}function Ee(ue,ge,Fe,Ie,Me){ge.isScene!==!0&&(ge=re),je.resetTextureUnits();const mt=ge.fog,wt=Ie.isMeshStandardMaterial?ge.environment:null,kt=R===null?k.outputColorSpace:R.isXRRenderTarget===!0?R.texture.colorSpace:wg,pt=(Ie.isMeshStandardMaterial?I:$).get(Ie.envMap||wt),zt=Ie.vertexColors===!0&&!!Fe.attributes.color&&Fe.attributes.color.itemSize===4,Pt=!!Fe.attributes.tangent&&(!!Ie.normalMap||Ie.anisotropy>0),Mt=!!Fe.morphAttributes.position,nn=!!Fe.morphAttributes.normal,Bt=!!Fe.morphAttributes.color;let tn=Ld;Ie.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(tn=k.toneMapping);const cn=Fe.morphAttributes.position||Fe.morphAttributes.normal||Fe.morphAttributes.color,we=cn!==void 0?cn.length:0,bt=Oe.get(Ie),$t=S.state.lights;if(xe===!0&&(be===!0||ue!==O)){const Tr=ue===O&&Ie.id===F;We.setState(Ie,ue,Tr)}let Be=!1;Ie.version===bt.__version?(bt.needsLights&&bt.lightsStateVersion!==$t.state.version||bt.outputColorSpace!==kt||Me.isBatchedMesh&&bt.batching===!1||!Me.isBatchedMesh&&bt.batching===!0||Me.isBatchedMesh&&bt.batchingColor===!0&&Me.colorTexture===null||Me.isBatchedMesh&&bt.batchingColor===!1&&Me.colorTexture!==null||Me.isInstancedMesh&&bt.instancing===!1||!Me.isInstancedMesh&&bt.instancing===!0||Me.isSkinnedMesh&&bt.skinning===!1||!Me.isSkinnedMesh&&bt.skinning===!0||Me.isInstancedMesh&&bt.instancingColor===!0&&Me.instanceColor===null||Me.isInstancedMesh&&bt.instancingColor===!1&&Me.instanceColor!==null||Me.isInstancedMesh&&bt.instancingMorph===!0&&Me.morphTexture===null||Me.isInstancedMesh&&bt.instancingMorph===!1&&Me.morphTexture!==null||bt.envMap!==pt||Ie.fog===!0&&bt.fog!==mt||bt.numClippingPlanes!==void 0&&(bt.numClippingPlanes!==We.numPlanes||bt.numIntersection!==We.numIntersection)||bt.vertexAlphas!==zt||bt.vertexTangents!==Pt||bt.morphTargets!==Mt||bt.morphNormals!==nn||bt.morphColors!==Bt||bt.toneMapping!==tn||bt.morphTargetsCount!==we)&&(Be=!0):(Be=!0,bt.__version=Ie.version);let Et=bt.currentProgram;Be===!0&&(Et=zn(Ie,ge,Me));let Wt=!1,dt=!1,Kt=!1;const sn=Et.getUniforms(),En=bt.uniforms;if(le.useProgram(Et.program)&&(Wt=!0,dt=!0,Kt=!0),Ie.id!==F&&(F=Ie.id,dt=!0),Wt||O!==ue){le.buffers.depth.getReversed()&&ue.reversedDepth!==!0&&(ue._reversedDepth=!0,ue.updateProjectionMatrix()),sn.setValue(B,"projectionMatrix",ue.projectionMatrix),sn.setValue(B,"viewMatrix",ue.matrixWorldInverse);const Gt=sn.map.cameraPosition;Gt!==void 0&&Gt.setValue(B,Ce.setFromMatrixPosition(ue.matrixWorld)),Q.logarithmicDepthBuffer&&sn.setValue(B,"logDepthBufFC",2/(Math.log(ue.far+1)/Math.LN2)),(Ie.isMeshPhongMaterial||Ie.isMeshToonMaterial||Ie.isMeshLambertMaterial||Ie.isMeshBasicMaterial||Ie.isMeshStandardMaterial||Ie.isShaderMaterial)&&sn.setValue(B,"isOrthographic",ue.isOrthographicCamera===!0),O!==ue&&(O=ue,dt=!0,Kt=!0)}if(Me.isSkinnedMesh){sn.setOptional(B,Me,"bindMatrix"),sn.setOptional(B,Me,"bindMatrixInverse");const Tr=Me.skeleton;Tr&&(Tr.boneTexture===null&&Tr.computeBoneTexture(),sn.setValue(B,"boneTexture",Tr.boneTexture,je))}Me.isBatchedMesh&&(sn.setOptional(B,Me,"batchingTexture"),sn.setValue(B,"batchingTexture",Me._matricesTexture,je),sn.setOptional(B,Me,"batchingIdTexture"),sn.setValue(B,"batchingIdTexture",Me._indirectTexture,je),sn.setOptional(B,Me,"batchingColorTexture"),Me._colorsTexture!==null&&sn.setValue(B,"batchingColorTexture",Me._colorsTexture,je));const On=Fe.morphAttributes;if((On.position!==void 0||On.normal!==void 0||On.color!==void 0)&&ve.update(Me,Fe,Et),(dt||bt.receiveShadow!==Me.receiveShadow)&&(bt.receiveShadow=Me.receiveShadow,sn.setValue(B,"receiveShadow",Me.receiveShadow)),Ie.isMeshGouraudMaterial&&Ie.envMap!==null&&(En.envMap.value=pt,En.flipEnvMap.value=pt.isCubeTexture&&pt.isRenderTargetTexture===!1?-1:1),Ie.isMeshStandardMaterial&&Ie.envMap===null&&ge.environment!==null&&(En.envMapIntensity.value=ge.environmentIntensity),En.dfgLUT!==void 0&&(En.dfgLUT.value=POe()),dt&&(sn.setValue(B,"toneMappingExposure",k.toneMappingExposure),bt.needsLights&&Xe(En,Kt),mt&&Ie.fog===!0&&$e.refreshFogUniforms(En,mt),$e.refreshMaterialUniforms(En,Ie,ne,te,S.state.transmissionRenderTarget[ue.id]),aw.upload(B,Wn(bt),En,je)),Ie.isShaderMaterial&&Ie.uniformsNeedUpdate===!0&&(aw.upload(B,Wn(bt),En,je),Ie.uniformsNeedUpdate=!1),Ie.isSpriteMaterial&&sn.setValue(B,"center",Me.center),sn.setValue(B,"modelViewMatrix",Me.modelViewMatrix),sn.setValue(B,"normalMatrix",Me.normalMatrix),sn.setValue(B,"modelMatrix",Me.matrixWorld),Ie.isShaderMaterial||Ie.isRawShaderMaterial){const Tr=Ie.uniformsGroups;for(let Gt=0,hn=Tr.length;Gt<hn;Gt++){const ki=Tr[Gt];ce.update(ki,Et),ce.bind(ki,Et)}}return Et}function Xe(ue,ge){ue.ambientLightColor.needsUpdate=ge,ue.lightProbe.needsUpdate=ge,ue.directionalLights.needsUpdate=ge,ue.directionalLightShadows.needsUpdate=ge,ue.pointLights.needsUpdate=ge,ue.pointLightShadows.needsUpdate=ge,ue.spotLights.needsUpdate=ge,ue.spotLightShadows.needsUpdate=ge,ue.rectAreaLights.needsUpdate=ge,ue.hemisphereLights.needsUpdate=ge}function it(ue){return ue.isMeshLambertMaterial||ue.isMeshToonMaterial||ue.isMeshPhongMaterial||ue.isMeshStandardMaterial||ue.isShadowMaterial||ue.isShaderMaterial&&ue.lights===!0}this.getActiveCubeFace=function(){return D},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return R},this.setRenderTargetTextures=function(ue,ge,Fe){const Ie=Oe.get(ue);Ie.__autoAllocateDepthBuffer=ue.resolveDepthBuffer===!1,Ie.__autoAllocateDepthBuffer===!1&&(Ie.__useRenderToTexture=!1),Oe.get(ue.texture).__webglTexture=ge,Oe.get(ue.depthTexture).__webglTexture=Ie.__autoAllocateDepthBuffer?void 0:Fe,Ie.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(ue,ge){const Fe=Oe.get(ue);Fe.__webglFramebuffer=ge,Fe.__useDefaultFramebuffer=ge===void 0};const st=B.createFramebuffer();this.setRenderTarget=function(ue,ge=0,Fe=0){R=ue,D=ge,A=Fe;let Ie=!0,Me=null,mt=!1,wt=!1;if(ue){const pt=Oe.get(ue);if(pt.__useDefaultFramebuffer!==void 0)le.bindFramebuffer(B.FRAMEBUFFER,null),Ie=!1;else if(pt.__webglFramebuffer===void 0)je.setupRenderTarget(ue);else if(pt.__hasExternalTextures)je.rebindTextures(ue,Oe.get(ue.texture).__webglTexture,Oe.get(ue.depthTexture).__webglTexture);else if(ue.depthBuffer){const Mt=ue.depthTexture;if(pt.__boundDepthTexture!==Mt){if(Mt!==null&&Oe.has(Mt)&&(ue.width!==Mt.image.width||ue.height!==Mt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");je.setupDepthRenderbuffer(ue)}}const zt=ue.texture;(zt.isData3DTexture||zt.isDataArrayTexture||zt.isCompressedArrayTexture)&&(wt=!0);const Pt=Oe.get(ue).__webglFramebuffer;ue.isWebGLCubeRenderTarget?(Array.isArray(Pt[ge])?Me=Pt[ge][Fe]:Me=Pt[ge],mt=!0):ue.samples>0&&je.useMultisampledRTT(ue)===!1?Me=Oe.get(ue).__webglMultisampledFramebuffer:Array.isArray(Pt)?Me=Pt[Fe]:Me=Pt,q.copy(ue.viewport),j.copy(ue.scissor),G=ue.scissorTest}else q.copy(se).multiplyScalar(ne).floor(),j.copy(ae).multiplyScalar(ne).floor(),G=de;if(Fe!==0&&(Me=st),le.bindFramebuffer(B.FRAMEBUFFER,Me)&&Ie&&le.drawBuffers(ue,Me),le.viewport(q),le.scissor(j),le.setScissorTest(G),mt){const pt=Oe.get(ue.texture);B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_CUBE_MAP_POSITIVE_X+ge,pt.__webglTexture,Fe)}else if(wt){const pt=ge;for(let zt=0;zt<ue.textures.length;zt++){const Pt=Oe.get(ue.textures[zt]);B.framebufferTextureLayer(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0+zt,Pt.__webglTexture,Fe,pt)}}else if(ue!==null&&Fe!==0){const pt=Oe.get(ue.texture);B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_2D,pt.__webglTexture,Fe)}F=-1},this.readRenderTargetPixels=function(ue,ge,Fe,Ie,Me,mt,wt,kt=0){if(!(ue&&ue.isWebGLRenderTarget)){hi("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let pt=Oe.get(ue).__webglFramebuffer;if(ue.isWebGLCubeRenderTarget&&wt!==void 0&&(pt=pt[wt]),pt){le.bindFramebuffer(B.FRAMEBUFFER,pt);try{const zt=ue.textures[kt],Pt=zt.format,Mt=zt.type;if(!Q.textureFormatReadable(Pt)){hi("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Q.textureTypeReadable(Mt)){hi("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ge>=0&&ge<=ue.width-Ie&&Fe>=0&&Fe<=ue.height-Me&&(ue.textures.length>1&&B.readBuffer(B.COLOR_ATTACHMENT0+kt),B.readPixels(ge,Fe,Ie,Me,lt.convert(Pt),lt.convert(Mt),mt))}finally{const zt=R!==null?Oe.get(R).__webglFramebuffer:null;le.bindFramebuffer(B.FRAMEBUFFER,zt)}}},this.readRenderTargetPixelsAsync=async function(ue,ge,Fe,Ie,Me,mt,wt,kt=0){if(!(ue&&ue.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let pt=Oe.get(ue).__webglFramebuffer;if(ue.isWebGLCubeRenderTarget&&wt!==void 0&&(pt=pt[wt]),pt)if(ge>=0&&ge<=ue.width-Ie&&Fe>=0&&Fe<=ue.height-Me){le.bindFramebuffer(B.FRAMEBUFFER,pt);const zt=ue.textures[kt],Pt=zt.format,Mt=zt.type;if(!Q.textureFormatReadable(Pt))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 nn=B.createBuffer();B.bindBuffer(B.PIXEL_PACK_BUFFER,nn),B.bufferData(B.PIXEL_PACK_BUFFER,mt.byteLength,B.STREAM_READ),ue.textures.length>1&&B.readBuffer(B.COLOR_ATTACHMENT0+kt),B.readPixels(ge,Fe,Ie,Me,lt.convert(Pt),lt.convert(Mt),0);const Bt=R!==null?Oe.get(R).__webglFramebuffer:null;le.bindFramebuffer(B.FRAMEBUFFER,Bt);const tn=B.fenceSync(B.SYNC_GPU_COMMANDS_COMPLETE,0);return B.flush(),await i3e(B,tn,4),B.bindBuffer(B.PIXEL_PACK_BUFFER,nn),B.getBufferSubData(B.PIXEL_PACK_BUFFER,0,mt),B.deleteBuffer(nn),B.deleteSync(tn),mt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(ue,ge=null,Fe=0){const Ie=Math.pow(2,-Fe),Me=Math.floor(ue.image.width*Ie),mt=Math.floor(ue.image.height*Ie),wt=ge!==null?ge.x:0,kt=ge!==null?ge.y:0;je.setTexture2D(ue,0),B.copyTexSubImage2D(B.TEXTURE_2D,Fe,0,0,wt,kt,Me,mt),le.unbindTexture()};const et=B.createFramebuffer(),Ct=B.createFramebuffer();this.copyTextureToTexture=function(ue,ge,Fe=null,Ie=null,Me=0,mt=null){mt===null&&(Me!==0?(z0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),mt=Me,Me=0):mt=0);let wt,kt,pt,zt,Pt,Mt,nn,Bt,tn;const cn=ue.isCompressedTexture?ue.mipmaps[mt]:ue.image;if(Fe!==null)wt=Fe.max.x-Fe.min.x,kt=Fe.max.y-Fe.min.y,pt=Fe.isBox3?Fe.max.z-Fe.min.z:1,zt=Fe.min.x,Pt=Fe.min.y,Mt=Fe.isBox3?Fe.min.z:0;else{const On=Math.pow(2,-Me);wt=Math.floor(cn.width*On),kt=Math.floor(cn.height*On),ue.isDataArrayTexture?pt=cn.depth:ue.isData3DTexture?pt=Math.floor(cn.depth*On):pt=1,zt=0,Pt=0,Mt=0}Ie!==null?(nn=Ie.x,Bt=Ie.y,tn=Ie.z):(nn=0,Bt=0,tn=0);const we=lt.convert(ge.format),bt=lt.convert(ge.type);let $t;ge.isData3DTexture?(je.setTexture3D(ge,0),$t=B.TEXTURE_3D):ge.isDataArrayTexture||ge.isCompressedArrayTexture?(je.setTexture2DArray(ge,0),$t=B.TEXTURE_2D_ARRAY):(je.setTexture2D(ge,0),$t=B.TEXTURE_2D),B.pixelStorei(B.UNPACK_FLIP_Y_WEBGL,ge.flipY),B.pixelStorei(B.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ge.premultiplyAlpha),B.pixelStorei(B.UNPACK_ALIGNMENT,ge.unpackAlignment);const Be=B.getParameter(B.UNPACK_ROW_LENGTH),Et=B.getParameter(B.UNPACK_IMAGE_HEIGHT),Wt=B.getParameter(B.UNPACK_SKIP_PIXELS),dt=B.getParameter(B.UNPACK_SKIP_ROWS),Kt=B.getParameter(B.UNPACK_SKIP_IMAGES);B.pixelStorei(B.UNPACK_ROW_LENGTH,cn.width),B.pixelStorei(B.UNPACK_IMAGE_HEIGHT,cn.height),B.pixelStorei(B.UNPACK_SKIP_PIXELS,zt),B.pixelStorei(B.UNPACK_SKIP_ROWS,Pt),B.pixelStorei(B.UNPACK_SKIP_IMAGES,Mt);const sn=ue.isDataArrayTexture||ue.isData3DTexture,En=ge.isDataArrayTexture||ge.isData3DTexture;if(ue.isDepthTexture){const On=Oe.get(ue),Tr=Oe.get(ge),Gt=Oe.get(On.__renderTarget),hn=Oe.get(Tr.__renderTarget);le.bindFramebuffer(B.READ_FRAMEBUFFER,Gt.__webglFramebuffer),le.bindFramebuffer(B.DRAW_FRAMEBUFFER,hn.__webglFramebuffer);for(let ki=0;ki<pt;ki++)sn&&(B.framebufferTextureLayer(B.READ_FRAMEBUFFER,B.COLOR_ATTACHMENT0,Oe.get(ue).__webglTexture,Me,Mt+ki),B.framebufferTextureLayer(B.DRAW_FRAMEBUFFER,B.COLOR_ATTACHMENT0,Oe.get(ge).__webglTexture,mt,tn+ki)),B.blitFramebuffer(zt,Pt,wt,kt,nn,Bt,wt,kt,B.DEPTH_BUFFER_BIT,B.NEAREST);le.bindFramebuffer(B.READ_FRAMEBUFFER,null),le.bindFramebuffer(B.DRAW_FRAMEBUFFER,null)}else if(Me!==0||ue.isRenderTargetTexture||Oe.has(ue)){const On=Oe.get(ue),Tr=Oe.get(ge);le.bindFramebuffer(B.READ_FRAMEBUFFER,et),le.bindFramebuffer(B.DRAW_FRAMEBUFFER,Ct);for(let Gt=0;Gt<pt;Gt++)sn?B.framebufferTextureLayer(B.READ_FRAMEBUFFER,B.COLOR_ATTACHMENT0,On.__webglTexture,Me,Mt+Gt):B.framebufferTexture2D(B.READ_FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_2D,On.__webglTexture,Me),En?B.framebufferTextureLayer(B.DRAW_FRAMEBUFFER,B.COLOR_ATTACHMENT0,Tr.__webglTexture,mt,tn+Gt):B.framebufferTexture2D(B.DRAW_FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_2D,Tr.__webglTexture,mt),Me!==0?B.blitFramebuffer(zt,Pt,wt,kt,nn,Bt,wt,kt,B.COLOR_BUFFER_BIT,B.NEAREST):En?B.copyTexSubImage3D($t,mt,nn,Bt,tn+Gt,zt,Pt,wt,kt):B.copyTexSubImage2D($t,mt,nn,Bt,zt,Pt,wt,kt);le.bindFramebuffer(B.READ_FRAMEBUFFER,null),le.bindFramebuffer(B.DRAW_FRAMEBUFFER,null)}else En?ue.isDataTexture||ue.isData3DTexture?B.texSubImage3D($t,mt,nn,Bt,tn,wt,kt,pt,we,bt,cn.data):ge.isCompressedArrayTexture?B.compressedTexSubImage3D($t,mt,nn,Bt,tn,wt,kt,pt,we,cn.data):B.texSubImage3D($t,mt,nn,Bt,tn,wt,kt,pt,we,bt,cn):ue.isDataTexture?B.texSubImage2D(B.TEXTURE_2D,mt,nn,Bt,wt,kt,we,bt,cn.data):ue.isCompressedTexture?B.compressedTexSubImage2D(B.TEXTURE_2D,mt,nn,Bt,cn.width,cn.height,we,cn.data):B.texSubImage2D(B.TEXTURE_2D,mt,nn,Bt,wt,kt,we,bt,cn);B.pixelStorei(B.UNPACK_ROW_LENGTH,Be),B.pixelStorei(B.UNPACK_IMAGE_HEIGHT,Et),B.pixelStorei(B.UNPACK_SKIP_PIXELS,Wt),B.pixelStorei(B.UNPACK_SKIP_ROWS,dt),B.pixelStorei(B.UNPACK_SKIP_IMAGES,Kt),mt===0&&ge.generateMipmaps&&B.generateMipmap($t),le.unbindTexture()},this.initRenderTarget=function(ue){Oe.get(ue).__webglFramebuffer===void 0&&je.setupRenderTarget(ue)},this.initTexture=function(ue){ue.isCubeTexture?je.setTextureCube(ue,0):ue.isData3DTexture?je.setTexture3D(ue,0):ue.isDataArrayTexture||ue.isCompressedArrayTexture?je.setTexture2DArray(ue,0):je.setTexture2D(ue,0),le.unbindTexture()},this.resetState=function(){D=0,A=0,R=null,le.reset(),_e.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Rl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=Yn._getDrawingBufferColorSpace(e),n.unpackColorSpace=Yn._getUnpackColorSpace()}};const gV={type:"change"},IO={type:"start"},wJ={type:"end"},W_=new PO,xV=new fd,DOe=Math.cos(70*s3e.DEG2RAD),Pi=new ot,fs=2*Math.PI,br={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},tk=1e-6;class OOe extends q3e{constructor(e,n=null){super(e,n),this.state=br.NONE,this.target=new ot,this.cursor=new ot,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:Zp.ROTATE,MIDDLE:Zp.DOLLY,RIGHT:Zp.PAN},this.touches={ONE:Hp.ROTATE,TWO:Hp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new ot,this._lastQuaternion=new qf,this._lastTargetPosition=new ot,this._quat=new qf().setFromUnitVectors(e.up,new ot(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new GH,this._sphericalDelta=new GH,this._scale=1,this._panOffset=new ot,this._rotateStart=new Nn,this._rotateEnd=new Nn,this._rotateDelta=new Nn,this._panStart=new Nn,this._panEnd=new Nn,this._panDelta=new Nn,this._dollyStart=new Nn,this._dollyEnd=new Nn,this._dollyDelta=new Nn,this._dollyDirection=new ot,this._mouse=new Nn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=IOe.bind(this),this._onPointerDown=LOe.bind(this),this._onPointerUp=FOe.bind(this),this._onContextMenu=GOe.bind(this),this._onMouseWheel=BOe.bind(this),this._onKeyDown=$Oe.bind(this),this._onTouchStart=HOe.bind(this),this._onTouchMove=VOe.bind(this),this._onMouseDown=UOe.bind(this),this._onMouseMove=zOe.bind(this),this._interceptControlDown=qOe.bind(this),this._interceptControlUp=WOe.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(gV),this.update(),this.state=br.NONE}update(e=null){const n=this.object.position;Pi.copy(n).sub(this.target),Pi.applyQuaternion(this._quat),this._spherical.setFromVector3(Pi),this.autoRotate&&this.state===br.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+=fs:r>Math.PI&&(r-=fs),i<-Math.PI?i+=fs:i>Math.PI&&(i-=fs),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=o!=this._spherical.radius}if(Pi.setFromSpherical(this._spherical),Pi.applyQuaternion(this._quatInverse),n.copy(this.target).add(Pi),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const l=Pi.length();o=this._clampDistance(l*this._scale);const c=l-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),s=!!c}else if(this.object.isOrthographicCamera){const l=new ot(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=c!==this.object.zoom;const u=new ot(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),o=Pi.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(W_.origin.copy(this.object.position),W_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(W_.direction))<DOe?this.object.lookAt(this.target):(xV.setFromNormalAndCoplanarPoint(this.object.up,this.target),W_.intersectPlane(xV,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>tk||8*(1-this._lastQuaternion.dot(this.object.quaternion))>tk||this._lastTargetPosition.distanceToSquared(this.target)>tk?(this.dispatchEvent(gV),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?fs/60*this.autoRotateSpeed*e:fs/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){Pi.setFromMatrixColumn(n,0),Pi.multiplyScalar(-e),this._panOffset.add(Pi)}_panUp(e,n){this.screenSpacePanning===!0?Pi.setFromMatrixColumn(n,1):(Pi.setFromMatrixColumn(n,0),Pi.crossVectors(this.object.up,Pi)),Pi.multiplyScalar(e),this._panOffset.add(Pi)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Pi.copy(i).sub(this.target);let s=Pi.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/r.clientHeight,this.object.matrix),this._panUp(2*n*s/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),i=e-r.left,s=n-r.top,o=r.width,l=r.height;this._mouse.x=i/o*2-1,this._mouse.y=-(s/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(fs*this._rotateDelta.x/n.clientHeight),this._rotateUp(fs*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(fs*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(-fs*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(fs*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(-fs*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panStart.set(r,i)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,s=Math.sqrt(r*r+i*i);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),i=.5*(e.pageX+r.x),s=.5*(e.pageY+r.y);this._rotateEnd.set(i,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(fs*this._rotateDelta.x/n.clientHeight),this._rotateUp(fs*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panEnd.set(r,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,s=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+n.x)*.5,l=(e.pageY+n.y)*.5;this._updateZoomParameters(o,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new Nn,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 LOe(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 IOe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function FOe(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(wJ),this.state=br.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 UOe(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 Zp.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=br.DOLLY;break;case Zp.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=br.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=br.ROTATE}break;case Zp.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=br.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=br.PAN}break;default:this.state=br.NONE}this.state!==br.NONE&&this.dispatchEvent(IO)}function zOe(t){switch(this.state){case br.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case br.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case br.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function BOe(t){this.enabled===!1||this.enableZoom===!1||this.state!==br.NONE||(t.preventDefault(),this.dispatchEvent(IO),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(wJ))}function $Oe(t){this.enabled!==!1&&this._handleKeyDown(t)}function HOe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case Hp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=br.TOUCH_ROTATE;break;case Hp.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=br.TOUCH_PAN;break;default:this.state=br.NONE}break;case 2:switch(this.touches.TWO){case Hp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=br.TOUCH_DOLLY_PAN;break;case Hp.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=br.TOUCH_DOLLY_ROTATE;break;default:this.state=br.NONE}break;default:this.state=br.NONE}this.state!==br.NONE&&this.dispatchEvent(IO)}function VOe(t){switch(this._trackPointer(t),this.state){case br.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case br.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case br.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case br.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=br.NONE}}function GOe(t){this.enabled!==!1&&t.preventDefault()}function qOe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function WOe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function KOe(t,e=!1){const n=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),s={},o={},l=t[0].morphTargetsRelative,c=new ec;let u=0;for(let d=0;d<t.length;++d){const f=t[d];let m=0;if(n!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const g in f.attributes){if(!r.has(g))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+g+'" attribute exists among all geometries, or in none of them.'),null;s[g]===void 0&&(s[g]=[]),s[g].push(f.attributes[g]),m++}if(m!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(l!==f.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const g in f.morphAttributes){if(!i.has(g))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;o[g]===void 0&&(o[g]=[]),o[g].push(f.morphAttributes[g])}if(e){let g;if(n)g=f.index.count;else if(f.attributes.position!==void 0)g=f.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;c.addGroup(u,g,d),u+=g}}if(n){let d=0;const f=[];for(let m=0;m<t.length;++m){const g=t[m].index;for(let x=0;x<g.count;++x)f.push(g.getX(x)+d);d+=t[m].attributes.position.count}c.setIndex(f)}for(const d in s){const f=bV(s[d]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;c.setAttribute(d,f)}for(const d in o){const f=o[d][0].length;if(f===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[d]=[];for(let m=0;m<f;++m){const g=[];for(let y=0;y<o[d].length;++y)g.push(o[d][y][m]);const x=bV(g);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(x)}}return c}function bV(t){let e,n,r,i=-1,s=0;for(let u=0;u<t.length;++u){const d=t[u];if(e===void 0&&(e=d.array.constructor),e!==d.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=d.itemSize),n!==d.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=d.normalized),r!==d.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=d.gpuType),i!==d.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=d.count*n}const o=new e(s),l=new ko(o,n,r);let c=0;for(let u=0;u<t.length;++u){const d=t[u];if(d.isInterleavedBufferAttribute){const f=c/n;for(let m=0,g=d.count;m<g;m++)for(let x=0;x<n;x++){const y=d.getComponent(m,x);l.setComponent(m+f,x,y)}}else o.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}function K_(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 nk={exports:{}};var yV;function XOe(){return yV||(yV=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,s){function o(u,d){if(!i[u]){if(!r[u]){var f=typeof K_=="function"&&K_;if(!d&&f)return f(u,!0);if(l)return l(u,!0);var m=new Error("Cannot find module '"+u+"'");throw m.code="MODULE_NOT_FOUND",m}var g=i[u]={exports:{}};r[u][0].call(g.exports,function(x){var y=r[u][1][x];return o(y||x)},g,g.exports,n,r,i,s)}return i[u].exports}for(var l=typeof K_=="function"&&K_,c=0;c<s.length;c++)o(s[c]);return o})({1:[function(n,r,i){var s=n("./utils"),o=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(c){for(var u,d,f,m,g,x,y,b=[],v=0,N=c.length,S=N,T=s.getTypeOf(c)!=="string";v<c.length;)S=N-v,f=T?(u=c[v++],d=v<N?c[v++]:0,v<N?c[v++]:0):(u=c.charCodeAt(v++),d=v<N?c.charCodeAt(v++):0,v<N?c.charCodeAt(v++):0),m=u>>2,g=(3&u)<<4|d>>4,x=1<S?(15&d)<<2|f>>6:64,y=2<S?63&f:64,b.push(l.charAt(m)+l.charAt(g)+l.charAt(x)+l.charAt(y));return b.join("")},i.decode=function(c){var u,d,f,m,g,x,y=0,b=0,v="data:";if(c.substr(0,v.length)===v)throw new Error("Invalid base64 input, it looks like a data url.");var N,S=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&S--,c.charAt(c.length-2)===l.charAt(64)&&S--,S%1!=0)throw new Error("Invalid base64 input, bad content length.");for(N=o.uint8array?new Uint8Array(0|S):new Array(0|S);y<c.length;)u=l.indexOf(c.charAt(y++))<<2|(m=l.indexOf(c.charAt(y++)))>>4,d=(15&m)<<4|(g=l.indexOf(c.charAt(y++)))>>2,f=(3&g)<<6|(x=l.indexOf(c.charAt(y++))),N[b++]=u,g!==64&&(N[b++]=d),x!==64&&(N[b++]=f);return N}},{"./support":30,"./utils":32}],2:[function(n,r,i){var s=n("./external"),o=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,f,m,g,x){this.compressedSize=d,this.uncompressedSize=f,this.crc32=m,this.compression=g,this.compressedContent=x}u.prototype={getContentWorker:function(){var d=new o(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new o(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,f,m){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(f.compressWorker(m)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var s=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var s=n("./utils"),o=(function(){for(var l,c=[],u=0;u<256;u++){l=u;for(var d=0;d<8;d++)l=1&l?3988292384^l>>>1:l>>>1;c[u]=l}return c})();r.exports=function(l,c){return l!==void 0&&l.length?s.getTypeOf(l)!=="string"?(function(u,d,f,m){var g=o,x=m+f;u^=-1;for(var y=m;y<x;y++)u=u>>>8^g[255&(u^d[y])];return-1^u})(0|c,l,l.length,0):(function(u,d,f,m){var g=o,x=m+f;u^=-1;for(var y=m;y<x;y++)u=u>>>8^g[255&(u^d.charCodeAt(y))];return-1^u})(0|c,l,l.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var s=null;s=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:s}},{lie:37}],7:[function(n,r,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=n("pako"),l=n("./utils"),c=n("./stream/GenericWorker"),u=s?"uint8array":"array";function d(f,m){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=m,this.meta={}}i.magic="\b\0",l.inherits(d,c),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(l.transformTo(u,f.data),!1)},d.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(m){f.push({data:m,meta:f.meta})}},i.compressWorker=function(f){return new d("Deflate",f)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function s(g,x){var y,b="";for(y=0;y<x;y++)b+=String.fromCharCode(255&g),g>>>=8;return b}function o(g,x,y,b,v,N){var S,T,E=g.file,k=g.compression,C=N!==u.utf8encode,D=l.transformTo("string",N(E.name)),A=l.transformTo("string",u.utf8encode(E.name)),R=E.comment,F=l.transformTo("string",N(R)),O=l.transformTo("string",u.utf8encode(R)),q=A.length!==E.name.length,j=O.length!==R.length,G="",Y="",K="",Z=E.dir,te=E.date,ne={crc32:0,compressedSize:0,uncompressedSize:0};x&&!y||(ne.crc32=g.crc32,ne.compressedSize=g.compressedSize,ne.uncompressedSize=g.uncompressedSize);var z=0;x&&(z|=8),C||!q&&!j||(z|=2048);var W=0,se=0;Z&&(W|=16),v==="UNIX"?(se=798,W|=(function(de,me){var xe=de;return de||(xe=me?16893:33204),(65535&xe)<<16})(E.unixPermissions,Z)):(se=20,W|=(function(de){return 63&(de||0)})(E.dosPermissions)),S=te.getUTCHours(),S<<=6,S|=te.getUTCMinutes(),S<<=5,S|=te.getUTCSeconds()/2,T=te.getUTCFullYear()-1980,T<<=4,T|=te.getUTCMonth()+1,T<<=5,T|=te.getUTCDate(),q&&(Y=s(1,1)+s(d(D),4)+A,G+="up"+s(Y.length,2)+Y),j&&(K=s(1,1)+s(d(F),4)+O,G+="uc"+s(K.length,2)+K);var ae="";return ae+=`
- \0`,ae+=s(z,2),ae+=k.magic,ae+=s(S,2),ae+=s(T,2),ae+=s(ne.crc32,4),ae+=s(ne.compressedSize,4),ae+=s(ne.uncompressedSize,4),ae+=s(D.length,2),ae+=s(G.length,2),{fileRecord:f.LOCAL_FILE_HEADER+ae+D+G,dirRecord:f.CENTRAL_FILE_HEADER+s(se,2)+ae+s(F.length,2)+"\0\0\0\0"+s(W,4)+s(b,4)+D+G+F}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function m(g,x,y,b){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=y,this.encodeFileName=b,this.streamFiles=g,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(m,c),m.prototype.push=function(g){var x=g.meta.percent||0,y=this.entriesCount,b=this._sources.length;this.accumulate?this.contentBuffer.push(g):(this.bytesWritten+=g.data.length,c.prototype.push.call(this,{data:g.data,meta:{currentFile:this.currentFile,percent:y?(x+100*(y-b-1))/y:100}}))},m.prototype.openedSource=function(g){this.currentSourceOffset=this.bytesWritten,this.currentFile=g.file.name;var x=this.streamFiles&&!g.file.dir;if(x){var y=o(g,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:y.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(g){this.accumulate=!1;var x=this.streamFiles&&!g.file.dir,y=o(g,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(y.dirRecord),x)this.push({data:(function(b){return f.DATA_DESCRIPTOR+s(b.crc32,4)+s(b.compressedSize,4)+s(b.uncompressedSize,4)})(g),meta:{percent:100}});else for(this.push({data:y.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var g=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var y=this.bytesWritten-g,b=(function(v,N,S,T,E){var k=l.transformTo("string",E(T));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(v,2)+s(v,2)+s(N,4)+s(S,4)+s(k.length,2)+k})(this.dirRecords.length,y,g,this.zipComment,this.encodeFileName);this.push({data:b,meta:{percent:100}})},m.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},m.prototype.registerPrevious=function(g){this._sources.push(g);var x=this;return g.on("data",function(y){x.processChunk(y)}),g.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),g.on("error",function(y){x.error(y)}),this},m.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},m.prototype.error=function(g){var x=this._sources;if(!c.prototype.error.call(this,g))return!1;for(var y=0;y<x.length;y++)try{x[y].error(g)}catch{}return!0},m.prototype.lock=function(){c.prototype.lock.call(this);for(var g=this._sources,x=0;x<g.length;x++)g[x].lock()},r.exports=m},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var s=n("../compressions"),o=n("./ZipFileWorker");i.generateWorker=function(l,c,u){var d=new o(c.streamFiles,u,c.platform,c.encodeFileName),f=0;try{l.forEach(function(m,g){f++;var x=(function(N,S){var T=N||S,E=s[T];if(!E)throw new Error(T+" is not a valid compression method !");return E})(g.options.compression,c.compression),y=g.options.compressionOptions||c.compressionOptions||{},b=g.dir,v=g.date;g._compressWorker(x,y).withStreamInfo("file",{name:m,dir:b,date:v,comment:g.comment||"",unixPermissions:g.unixPermissions,dosPermissions:g.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(m){d.error(m)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var o=new s;for(var l in this)typeof this[l]!="function"&&(o[l]=this[l]);return o}}(s.prototype=n("./object")).loadAsync=n("./load"),s.support=n("./support"),s.defaults=n("./defaults"),s.version="3.10.1",s.loadAsync=function(o,l){return new s().loadAsync(o,l)},s.external=n("./external"),r.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var s=n("./utils"),o=n("./external"),l=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(m){return new o.Promise(function(g,x){var y=m.decompressed.getContentWorker().pipe(new u);y.on("error",function(b){x(b)}).on("end",function(){y.streamInfo.crc32!==m.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):g()}).resume()})}r.exports=function(m,g){var x=this;return g=s.extend(g||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(m)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",m,!0,g.optimizedBinaryString,g.base64).then(function(y){var b=new c(g);return b.load(y),b}).then(function(y){var b=[o.Promise.resolve(y)],v=y.files;if(g.checkCRC32)for(var N=0;N<v.length;N++)b.push(f(v[N]));return o.Promise.all(b)}).then(function(y){for(var b=y.shift(),v=b.files,N=0;N<v.length;N++){var S=v[N],T=S.fileNameStr,E=s.resolve(S.fileNameStr);x.file(E,S.decompressed,{binary:!0,optimizedBinaryString:!0,date:S.date,dir:S.dir,comment:S.fileCommentStr.length?S.fileCommentStr:null,unixPermissions:S.unixPermissions,dosPermissions:S.dosPermissions,createFolders:g.createFolders}),S.dir||(x.file(E).unsafeOriginalName=T)}return b.zipComment.length&&(x.comment=b.zipComment),x})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var s=n("../utils"),o=n("../stream/GenericWorker");function l(c,u){o.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}s.inherits(l,o),l.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},l.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},l.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=l},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){var s=n("readable-stream").Readable;function o(l,c,u){s.call(this,c),this._helper=l;var d=this;l.on("data",function(f,m){d.push(f)||d._helper.pause(),u&&u(m)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(o,s),o.prototype._read=function(){this._helper.resume()},r.exports=o},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,o);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,o)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var o=new Buffer(s);return o.fill(0),o},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(n,r,i){function s(E,k,C){var D,A=l.getTypeOf(k),R=l.extend(C||{},d);R.date=R.date||new Date,R.compression!==null&&(R.compression=R.compression.toUpperCase()),typeof R.unixPermissions=="string"&&(R.unixPermissions=parseInt(R.unixPermissions,8)),R.unixPermissions&&16384&R.unixPermissions&&(R.dir=!0),R.dosPermissions&&16&R.dosPermissions&&(R.dir=!0),R.dir&&(E=v(E)),R.createFolders&&(D=b(E))&&N.call(this,D,!0);var F=A==="string"&&R.binary===!1&&R.base64===!1;C&&C.binary!==void 0||(R.binary=!F),(k instanceof f&&k.uncompressedSize===0||R.dir||!k||k.length===0)&&(R.base64=!1,R.binary=!0,k="",R.compression="STORE",A="string");var O=null;O=k instanceof f||k instanceof c?k:x.isNode&&x.isStream(k)?new y(E,k):l.prepareContent(E,k,R.binary,R.optimizedBinaryString,R.base64);var q=new m(E,O,R);this.files[E]=q}var o=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),m=n("./zipObject"),g=n("./generate"),x=n("./nodejsUtils"),y=n("./nodejs/NodejsStreamInputAdapter"),b=function(E){E.slice(-1)==="/"&&(E=E.substring(0,E.length-1));var k=E.lastIndexOf("/");return 0<k?E.substring(0,k):""},v=function(E){return E.slice(-1)!=="/"&&(E+="/"),E},N=function(E,k){return k=k!==void 0?k:d.createFolders,E=v(E),this.files[E]||s.call(this,E,null,{dir:!0,createFolders:k}),this.files[E]};function S(E){return Object.prototype.toString.call(E)==="[object RegExp]"}var T={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(E){var k,C,D;for(k in this.files)D=this.files[k],(C=k.slice(this.root.length,k.length))&&k.slice(0,this.root.length)===this.root&&E(C,D)},filter:function(E){var k=[];return this.forEach(function(C,D){E(C,D)&&k.push(D)}),k},file:function(E,k,C){if(arguments.length!==1)return E=this.root+E,s.call(this,E,k,C),this;if(S(E)){var D=E;return this.filter(function(R,F){return!F.dir&&D.test(R)})}var A=this.files[this.root+E];return A&&!A.dir?A:null},folder:function(E){if(!E)return this;if(S(E))return this.filter(function(A,R){return R.dir&&E.test(A)});var k=this.root+E,C=N.call(this,k),D=this.clone();return D.root=C.name,D},remove:function(E){E=this.root+E;var k=this.files[E];if(k||(E.slice(-1)!=="/"&&(E+="/"),k=this.files[E]),k&&!k.dir)delete this.files[E];else for(var C=this.filter(function(A,R){return R.name.slice(0,E.length)===E}),D=0;D<C.length;D++)delete this.files[C[D].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(E){var k,C={};try{if((C=l.extend(E||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=C.type.toLowerCase(),C.compression=C.compression.toUpperCase(),C.type==="binarystring"&&(C.type="string"),!C.type)throw new Error("No output type specified.");l.checkSupport(C.type),C.platform!=="darwin"&&C.platform!=="freebsd"&&C.platform!=="linux"&&C.platform!=="sunos"||(C.platform="UNIX"),C.platform==="win32"&&(C.platform="DOS");var D=C.comment||this.comment||"";k=g.generateWorker(this,C,D)}catch(A){(k=new c("error")).error(A)}return new u(k,C.type||"string",C.mimeType)},generateAsync:function(E,k){return this.generateInternalStream(E).accumulate(k)},generateNodeStream:function(E,k){return(E=E||{}).type||(E.type="nodebuffer"),this.generateInternalStream(E).toNodejsStream(k)}};r.exports=T},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var s=n("./DataReader");function o(l){s.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}n("../utils").inherits(o,s),o.prototype.byteAt=function(l){return this.data[this.zero+l]},o.prototype.lastIndexOfSignature=function(l){for(var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),m=this.length-4;0<=m;--m)if(this.data[m]===c&&this.data[m+1]===u&&this.data[m+2]===d&&this.data[m+3]===f)return m-this.zero;return-1},o.prototype.readAndCheckSignature=function(l){var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),m=this.readData(4);return c===m[0]&&u===m[1]&&d===m[2]&&f===m[3]},o.prototype.readData=function(l){if(this.checkOffset(l),l===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){var s=n("../utils");function o(l){this.data=l,this.length=l.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(l){this.checkIndex(this.index+l)},checkIndex:function(l){if(this.length<this.zero+l||l<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+l+"). Corrupted zip ?")},setIndex:function(l){this.checkIndex(l),this.index=l},skip:function(l){this.setIndex(this.index+l)},byteAt:function(){},readInt:function(l){var c,u=0;for(this.checkOffset(l),c=this.index+l-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=l,u},readString:function(l){return s.transformTo("string",this.readData(l))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var l=this.readInt(4);return new Date(Date.UTC(1980+(l>>25&127),(l>>21&15)-1,l>>16&31,l>>11&31,l>>5&63,(31&l)<<1))}},r.exports=o},{"../utils":32}],19:[function(n,r,i){var s=n("./Uint8ArrayReader");function o(l){s.call(this,l)}n("../utils").inherits(o,s),o.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var s=n("./DataReader");function o(l){s.call(this,l)}n("../utils").inherits(o,s),o.prototype.byteAt=function(l){return this.data.charCodeAt(this.zero+l)},o.prototype.lastIndexOfSignature=function(l){return this.data.lastIndexOf(l)-this.zero},o.prototype.readAndCheckSignature=function(l){return l===this.readData(4)},o.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var s=n("./ArrayReader");function o(l){s.call(this,l)}n("../utils").inherits(o,s),o.prototype.readData=function(l){if(this.checkOffset(l),l===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var s=n("../utils"),o=n("../support"),l=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(f){var m=s.getTypeOf(f);return s.checkSupport(m),m!=="string"||o.uint8array?m==="nodebuffer"?new u(f):o.uint8array?new d(s.transformTo("uint8array",f)):new l(s.transformTo("array",f)):new c(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var s=n("./GenericWorker"),o=n("../utils");function l(c){s.call(this,"ConvertWorker to "+c),this.destType=c}o.inherits(l,s),l.prototype.processChunk=function(c){this.push({data:o.transformTo(this.destType,c.data),meta:c.meta})},r.exports=l},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var s=n("./GenericWorker"),o=n("../crc32");function l(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(l,s),l.prototype.processChunk=function(c){this.streamInfo.crc32=o(c.data,this.streamInfo.crc32||0),this.push(c)},r.exports=l},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var s=n("../utils"),o=n("./GenericWorker");function l(c){o.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}s.inherits(l,o),l.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}o.prototype.processChunk.call(this,c)},r.exports=l},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var s=n("../utils"),o=n("./GenericWorker");function l(c){o.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=s.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}s.inherits(l,o),l.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},l.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},l.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},l.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=l},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function s(o){this.name=o||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,l){return this._listeners[o].push(l),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,l){if(this._listeners[o])for(var c=0;c<this._listeners[o].length;c++)this._listeners[o][c].call(this,l)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var l=this;return o.on("data",function(c){l.processChunk(c)}),o.on("end",function(){l.end()}),o.on("error",function(c){l.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,l){return this.extraStreamInfo[o]=l,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},r.exports=s},{}],29:[function(n,r,i){var s=n("../utils"),o=n("./ConvertWorker"),l=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function m(x,y){return new d.Promise(function(b,v){var N=[],S=x._internalType,T=x._outputType,E=x._mimeType;x.on("data",function(k,C){N.push(k),y&&y(C)}).on("error",function(k){N=[],v(k)}).on("end",function(){try{var k=(function(C,D,A){switch(C){case"blob":return s.newBlob(s.transformTo("arraybuffer",D),A);case"base64":return c.encode(D);default:return s.transformTo(C,D)}})(T,(function(C,D){var A,R=0,F=null,O=0;for(A=0;A<D.length;A++)O+=D[A].length;switch(C){case"string":return D.join("");case"array":return Array.prototype.concat.apply([],D);case"uint8array":for(F=new Uint8Array(O),A=0;A<D.length;A++)F.set(D[A],R),R+=D[A].length;return F;case"nodebuffer":return Buffer.concat(D);default:throw new Error("concat : unsupported type '"+C+"'")}})(S,N),E);b(k)}catch(C){v(C)}N=[]}).resume()})}function g(x,y,b){var v=y;switch(y){case"blob":case"arraybuffer":v="uint8array";break;case"base64":v="string"}try{this._internalType=v,this._outputType=y,this._mimeType=b,s.checkSupport(v),this._worker=x.pipe(new o(v)),x.lock()}catch(N){this._worker=new l("error"),this._worker.error(N)}}g.prototype={accumulate:function(x){return m(this,x)},on:function(x,y){var b=this;return x==="data"?this._worker.on(x,function(v){y.call(b,v.data,v.meta)}):this._worker.on(x,function(){s.delay(y,arguments,b)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(x){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},x)}},r.exports=g},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(s),i.blob=o.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!n("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,i){for(var s=n("./utils"),o=n("./support"),l=n("./nodejsUtils"),c=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){c.call(this,"utf-8 decode"),this.leftOver=null}function m(){c.call(this,"utf-8 encode")}i.utf8encode=function(g){return o.nodebuffer?l.newBufferFrom(g,"utf-8"):(function(x){var y,b,v,N,S,T=x.length,E=0;for(N=0;N<T;N++)(64512&(b=x.charCodeAt(N)))==55296&&N+1<T&&(64512&(v=x.charCodeAt(N+1)))==56320&&(b=65536+(b-55296<<10)+(v-56320),N++),E+=b<128?1:b<2048?2:b<65536?3:4;for(y=o.uint8array?new Uint8Array(E):new Array(E),N=S=0;S<E;N++)(64512&(b=x.charCodeAt(N)))==55296&&N+1<T&&(64512&(v=x.charCodeAt(N+1)))==56320&&(b=65536+(b-55296<<10)+(v-56320),N++),b<128?y[S++]=b:(b<2048?y[S++]=192|b>>>6:(b<65536?y[S++]=224|b>>>12:(y[S++]=240|b>>>18,y[S++]=128|b>>>12&63),y[S++]=128|b>>>6&63),y[S++]=128|63&b);return y})(g)},i.utf8decode=function(g){return o.nodebuffer?s.transformTo("nodebuffer",g).toString("utf-8"):(function(x){var y,b,v,N,S=x.length,T=new Array(2*S);for(y=b=0;y<S;)if((v=x[y++])<128)T[b++]=v;else if(4<(N=u[v]))T[b++]=65533,y+=N-1;else{for(v&=N===2?31:N===3?15:7;1<N&&y<S;)v=v<<6|63&x[y++],N--;1<N?T[b++]=65533:v<65536?T[b++]=v:(v-=65536,T[b++]=55296|v>>10&1023,T[b++]=56320|1023&v)}return T.length!==b&&(T.subarray?T=T.subarray(0,b):T.length=b),s.applyFromCharCode(T)})(g=s.transformTo(o.uint8array?"uint8array":"array",g))},s.inherits(f,c),f.prototype.processChunk=function(g){var x=s.transformTo(o.uint8array?"uint8array":"array",g.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var y=x;(x=new Uint8Array(y.length+this.leftOver.length)).set(this.leftOver,0),x.set(y,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var b=(function(N,S){var T;for((S=S||N.length)>N.length&&(S=N.length),T=S-1;0<=T&&(192&N[T])==128;)T--;return T<0||T===0?S:T+u[N[T]]>S?T:S})(x),v=x;b!==x.length&&(o.uint8array?(v=x.subarray(0,b),this.leftOver=x.subarray(b,x.length)):(v=x.slice(0,b),this.leftOver=x.slice(b,x.length))),this.push({data:i.utf8decode(v),meta:g.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=f,s.inherits(m,c),m.prototype.processChunk=function(g){this.push({data:i.utf8encode(g.data),meta:g.meta})},i.Utf8EncodeWorker=m},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){var s=n("./support"),o=n("./base64"),l=n("./nodejsUtils"),c=n("./external");function u(y){return y}function d(y,b){for(var v=0;v<y.length;++v)b[v]=255&y.charCodeAt(v);return b}n("setimmediate"),i.newBlob=function(y,b){i.checkSupport("blob");try{return new Blob([y],{type:b})}catch{try{var v=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return v.append(y),v.getBlob(b)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(y,b,v){var N=[],S=0,T=y.length;if(T<=v)return String.fromCharCode.apply(null,y);for(;S<T;)b==="array"||b==="nodebuffer"?N.push(String.fromCharCode.apply(null,y.slice(S,Math.min(S+v,T)))):N.push(String.fromCharCode.apply(null,y.subarray(S,Math.min(S+v,T)))),S+=v;return N.join("")},stringifyByChar:function(y){for(var b="",v=0;v<y.length;v++)b+=String.fromCharCode(y[v]);return b},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,l.allocBuffer(1)).length===1}catch{return!1}})()}};function m(y){var b=65536,v=i.getTypeOf(y),N=!0;if(v==="uint8array"?N=f.applyCanBeUsed.uint8array:v==="nodebuffer"&&(N=f.applyCanBeUsed.nodebuffer),N)for(;1<b;)try{return f.stringifyByChunk(y,v,b)}catch{b=Math.floor(b/2)}return f.stringifyByChar(y)}function g(y,b){for(var v=0;v<y.length;v++)b[v]=y[v];return b}i.applyFromCharCode=m;var x={};x.string={string:u,array:function(y){return d(y,new Array(y.length))},arraybuffer:function(y){return x.string.uint8array(y).buffer},uint8array:function(y){return d(y,new Uint8Array(y.length))},nodebuffer:function(y){return d(y,l.allocBuffer(y.length))}},x.array={string:m,array:u,arraybuffer:function(y){return new Uint8Array(y).buffer},uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return l.newBufferFrom(y)}},x.arraybuffer={string:function(y){return m(new Uint8Array(y))},array:function(y){return g(new Uint8Array(y),new Array(y.byteLength))},arraybuffer:u,uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return l.newBufferFrom(new Uint8Array(y))}},x.uint8array={string:m,array:function(y){return g(y,new Array(y.length))},arraybuffer:function(y){return y.buffer},uint8array:u,nodebuffer:function(y){return l.newBufferFrom(y)}},x.nodebuffer={string:m,array:function(y){return g(y,new Array(y.length))},arraybuffer:function(y){return x.nodebuffer.uint8array(y).buffer},uint8array:function(y){return g(y,new Uint8Array(y.length))},nodebuffer:u},i.transformTo=function(y,b){if(b=b||"",!y)return b;i.checkSupport(y);var v=i.getTypeOf(b);return x[v][y](b)},i.resolve=function(y){for(var b=y.split("/"),v=[],N=0;N<b.length;N++){var S=b[N];S==="."||S===""&&N!==0&&N!==b.length-1||(S===".."?v.pop():v.push(S))}return v.join("/")},i.getTypeOf=function(y){return typeof y=="string"?"string":Object.prototype.toString.call(y)==="[object Array]"?"array":s.nodebuffer&&l.isBuffer(y)?"nodebuffer":s.uint8array&&y instanceof Uint8Array?"uint8array":s.arraybuffer&&y instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(y){if(!s[y.toLowerCase()])throw new Error(y+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(y){var b,v,N="";for(v=0;v<(y||"").length;v++)N+="\\x"+((b=y.charCodeAt(v))<16?"0":"")+b.toString(16).toUpperCase();return N},i.delay=function(y,b,v){setImmediate(function(){y.apply(v||null,b||[])})},i.inherits=function(y,b){function v(){}v.prototype=b.prototype,y.prototype=new v},i.extend=function(){var y,b,v={};for(y=0;y<arguments.length;y++)for(b in arguments[y])Object.prototype.hasOwnProperty.call(arguments[y],b)&&v[b]===void 0&&(v[b]=arguments[y][b]);return v},i.prepareContent=function(y,b,v,N,S){return c.Promise.resolve(b).then(function(T){return s.blob&&(T instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(T))!==-1)&&typeof FileReader<"u"?new c.Promise(function(E,k){var C=new FileReader;C.onload=function(D){E(D.target.result)},C.onerror=function(D){k(D.target.error)},C.readAsArrayBuffer(T)}):T}).then(function(T){var E=i.getTypeOf(T);return E?(E==="arraybuffer"?T=i.transformTo("uint8array",T):E==="string"&&(S?T=o.decode(T):v&&N!==!0&&(T=(function(k){return d(k,s.uint8array?new Uint8Array(k.length):new Array(k.length))})(T))),T):c.Promise.reject(new Error("Can't read the data of '"+y+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var s=n("./reader/readerFor"),o=n("./utils"),l=n("./signature"),c=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var m=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(m)+", expected "+o.pretty(f)+")")}},isSignature:function(f,m){var g=this.reader.index;this.reader.setIndex(f);var x=this.reader.readString(4)===m;return this.reader.setIndex(g),x},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),m=u.uint8array?"uint8array":"array",g=o.transformTo(m,f);this.zipComment=this.loadOptions.decodeFileName(g)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,m,g,x=this.zip64EndOfCentralSize-44;0<x;)f=this.reader.readInt(2),m=this.reader.readInt(4),g=this.reader.readData(m),this.zip64ExtensibleData[f]={id:f,length:m,value:g}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,m;for(f=0;f<this.files.length;f++)m=this.files[f],this.reader.setIndex(m.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),m.readLocalPart(this.reader),m.handleUTF8(),m.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.CENTRAL_FILE_HEADER);)(f=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(l.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,l.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var m=f;if(this.checkSignature(l.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,l.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var g=this.centralDirOffset+this.centralDirSize;this.zip64&&(g+=20,g+=12+this.zip64EndOfCentralSize);var x=m-g;if(0<x)this.isSignature(m,l.CENTRAL_FILE_HEADER)||(this.reader.zero=x);else if(x<0)throw new Error("Corrupted zip: missing "+Math.abs(x)+" bytes.")},prepareReader:function(f){this.reader=s(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var s=n("./reader/readerFor"),o=n("./utils"),l=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function m(g,x){this.options=g,this.loadOptions=x}m.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(g){var x,y;if(g.skip(22),this.fileNameLength=g.readInt(2),y=g.readInt(2),this.fileName=g.readData(this.fileNameLength),g.skip(y),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((x=(function(b){for(var v in d)if(Object.prototype.hasOwnProperty.call(d,v)&&d[v].magic===b)return d[v];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new l(this.compressedSize,this.uncompressedSize,this.crc32,x,g.readData(this.compressedSize))},readCentralPart:function(g){this.versionMadeBy=g.readInt(2),g.skip(2),this.bitFlag=g.readInt(2),this.compressionMethod=g.readString(2),this.date=g.readDate(),this.crc32=g.readInt(4),this.compressedSize=g.readInt(4),this.uncompressedSize=g.readInt(4);var x=g.readInt(2);if(this.extraFieldsLength=g.readInt(2),this.fileCommentLength=g.readInt(2),this.diskNumberStart=g.readInt(2),this.internalFileAttributes=g.readInt(2),this.externalFileAttributes=g.readInt(4),this.localHeaderOffset=g.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");g.skip(x),this.readExtraFields(g),this.parseZIP64ExtraField(g),this.fileComment=g.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var g=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),g==0&&(this.dosPermissions=63&this.externalFileAttributes),g==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var g=s(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=g.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=g.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=g.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=g.readInt(4))}},readExtraFields:function(g){var x,y,b,v=g.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});g.index+4<v;)x=g.readInt(2),y=g.readInt(2),b=g.readData(y),this.extraFields[x]={id:x,length:y,value:b};g.setIndex(v)},handleUTF8:function(){var g=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var x=this.findExtraFieldUnicodePath();if(x!==null)this.fileNameStr=x;else{var y=o.transformTo(g,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(y)}var b=this.findExtraFieldUnicodeComment();if(b!==null)this.fileCommentStr=b;else{var v=o.transformTo(g,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(v)}}},findExtraFieldUnicodePath:function(){var g=this.extraFields[28789];if(g){var x=s(g.value);return x.readInt(1)!==1||c(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(g.length-5))}return null},findExtraFieldUnicodeComment:function(){var g=this.extraFields[25461];if(g){var x=s(g.value);return x.readInt(1)!==1||c(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(g.length-5))}return null}},r.exports=m},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function s(x,y,b){this.name=x,this.dir=b.dir,this.date=b.date,this.comment=b.comment,this.unixPermissions=b.unixPermissions,this.dosPermissions=b.dosPermissions,this._data=y,this._dataBinary=b.binary,this.options={compression:b.compression,compressionOptions:b.compressionOptions}}var o=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");s.prototype={internalStream:function(x){var y=null,b="string";try{if(!x)throw new Error("No output type specified.");var v=(b=x.toLowerCase())==="string"||b==="text";b!=="binarystring"&&b!=="text"||(b="string"),y=this._decompressWorker();var N=!this._dataBinary;N&&!v&&(y=y.pipe(new c.Utf8EncodeWorker)),!N&&v&&(y=y.pipe(new c.Utf8DecodeWorker))}catch(S){(y=new d("error")).error(S)}return new o(y,b,"")},async:function(x,y){return this.internalStream(x).accumulate(y)},nodeStream:function(x,y){return this.internalStream(x||"nodebuffer").toNodejsStream(y)},_compressWorker:function(x,y){if(this._data instanceof u&&this._data.compression.magic===x.magic)return this._data.getCompressedWorker();var b=this._decompressWorker();return this._dataBinary||(b=b.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(b,x,y)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new l(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],m=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},g=0;g<f.length;g++)s.prototype[f[g]]=m;r.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(s){var o,l,c=s.MutationObserver||s.WebKitMutationObserver;if(c){var u=0,d=new c(x),f=s.document.createTextNode("");d.observe(f,{characterData:!0}),o=function(){f.data=u=++u%2}}else if(s.setImmediate||s.MessageChannel===void 0)o="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var y=s.document.createElement("script");y.onreadystatechange=function(){x(),y.onreadystatechange=null,y.parentNode.removeChild(y),y=null},s.document.documentElement.appendChild(y)}:function(){setTimeout(x,0)};else{var m=new s.MessageChannel;m.port1.onmessage=x,o=function(){m.port2.postMessage(0)}}var g=[];function x(){var y,b;l=!0;for(var v=g.length;v;){for(b=g,g=[],y=-1;++y<v;)b[y]();v=g.length}l=!1}r.exports=function(y){g.push(y)!==1||l||o()}}).call(this,typeof n_<"u"?n_:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var s=n("immediate");function o(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(v){if(typeof v!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,v!==o&&y(this,v)}function m(v,N,S){this.promise=v,typeof N=="function"&&(this.onFulfilled=N,this.callFulfilled=this.otherCallFulfilled),typeof S=="function"&&(this.onRejected=S,this.callRejected=this.otherCallRejected)}function g(v,N,S){s(function(){var T;try{T=N(S)}catch(E){return l.reject(v,E)}T===v?l.reject(v,new TypeError("Cannot resolve promise with itself")):l.resolve(v,T)})}function x(v){var N=v&&v.then;if(v&&(typeof v=="object"||typeof v=="function")&&typeof N=="function")return function(){N.apply(v,arguments)}}function y(v,N){var S=!1;function T(C){S||(S=!0,l.reject(v,C))}function E(C){S||(S=!0,l.resolve(v,C))}var k=b(function(){N(E,T)});k.status==="error"&&T(k.value)}function b(v,N){var S={};try{S.value=v(N),S.status="success"}catch(T){S.status="error",S.value=T}return S}(r.exports=f).prototype.finally=function(v){if(typeof v!="function")return this;var N=this.constructor;return this.then(function(S){return N.resolve(v()).then(function(){return S})},function(S){return N.resolve(v()).then(function(){throw S})})},f.prototype.catch=function(v){return this.then(null,v)},f.prototype.then=function(v,N){if(typeof v!="function"&&this.state===u||typeof N!="function"&&this.state===c)return this;var S=new this.constructor(o);return this.state!==d?g(S,this.state===u?v:N,this.outcome):this.queue.push(new m(S,v,N)),S},m.prototype.callFulfilled=function(v){l.resolve(this.promise,v)},m.prototype.otherCallFulfilled=function(v){g(this.promise,this.onFulfilled,v)},m.prototype.callRejected=function(v){l.reject(this.promise,v)},m.prototype.otherCallRejected=function(v){g(this.promise,this.onRejected,v)},l.resolve=function(v,N){var S=b(x,N);if(S.status==="error")return l.reject(v,S.value);var T=S.value;if(T)y(v,T);else{v.state=u,v.outcome=N;for(var E=-1,k=v.queue.length;++E<k;)v.queue[E].callFulfilled(N)}return v},l.reject=function(v,N){v.state=c,v.outcome=N;for(var S=-1,T=v.queue.length;++S<T;)v.queue[S].callRejected(N);return v},f.resolve=function(v){return v instanceof this?v:l.resolve(new this(o),v)},f.reject=function(v){var N=new this(o);return l.reject(N,v)},f.all=function(v){var N=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=v.length,T=!1;if(!S)return this.resolve([]);for(var E=new Array(S),k=0,C=-1,D=new this(o);++C<S;)A(v[C],C);return D;function A(R,F){N.resolve(R).then(function(O){E[F]=O,++k!==S||T||(T=!0,l.resolve(D,E))},function(O){T||(T=!0,l.reject(D,O))})}},f.race=function(v){var N=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=v.length,T=!1;if(!S)return this.resolve([]);for(var E=-1,k=new this(o);++E<S;)C=v[E],N.resolve(C).then(function(D){T||(T=!0,l.resolve(k,D))},function(D){T||(T=!0,l.reject(k,D))});var C;return k}},{immediate:36}],38:[function(n,r,i){var s={};(0,n("./lib/utils/common").assign)(s,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var s=n("./zlib/deflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,m=-1,g=0,x=8;function y(v){if(!(this instanceof y))return new y(v);this.options=o.assign({level:m,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:g,to:""},v||{});var N=this.options;N.raw&&0<N.windowBits?N.windowBits=-N.windowBits:N.gzip&&0<N.windowBits&&N.windowBits<16&&(N.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var S=s.deflateInit2(this.strm,N.level,N.method,N.windowBits,N.memLevel,N.strategy);if(S!==f)throw new Error(c[S]);if(N.header&&s.deflateSetHeader(this.strm,N.header),N.dictionary){var T;if(T=typeof N.dictionary=="string"?l.string2buf(N.dictionary):d.call(N.dictionary)==="[object ArrayBuffer]"?new Uint8Array(N.dictionary):N.dictionary,(S=s.deflateSetDictionary(this.strm,T))!==f)throw new Error(c[S]);this._dict_set=!0}}function b(v,N){var S=new y(N);if(S.push(v,!0),S.err)throw S.msg||c[S.err];return S.result}y.prototype.push=function(v,N){var S,T,E=this.strm,k=this.options.chunkSize;if(this.ended)return!1;T=N===~~N?N:N===!0?4:0,typeof v=="string"?E.input=l.string2buf(v):d.call(v)==="[object ArrayBuffer]"?E.input=new Uint8Array(v):E.input=v,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new o.Buf8(k),E.next_out=0,E.avail_out=k),(S=s.deflate(E,T))!==1&&S!==f)return this.onEnd(S),!(this.ended=!0);E.avail_out!==0&&(E.avail_in!==0||T!==4&&T!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(o.shrinkBuf(E.output,E.next_out))):this.onData(o.shrinkBuf(E.output,E.next_out)))}while((0<E.avail_in||E.avail_out===0)&&S!==1);return T===4?(S=s.deflateEnd(this.strm),this.onEnd(S),this.ended=!0,S===f):T!==2||(this.onEnd(f),!(E.avail_out=0))},y.prototype.onData=function(v){this.chunks.push(v)},y.prototype.onEnd=function(v){v===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},i.Deflate=y,i.deflate=b,i.deflateRaw=function(v,N){return(N=N||{}).raw=!0,b(v,N)},i.gzip=function(v,N){return(N=N||{}).gzip=!0,b(v,N)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){var s=n("./zlib/inflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),f=n("./zlib/gzheader"),m=Object.prototype.toString;function g(y){if(!(this instanceof g))return new g(y);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},y||{});var b=this.options;b.raw&&0<=b.windowBits&&b.windowBits<16&&(b.windowBits=-b.windowBits,b.windowBits===0&&(b.windowBits=-15)),!(0<=b.windowBits&&b.windowBits<16)||y&&y.windowBits||(b.windowBits+=32),15<b.windowBits&&b.windowBits<48&&(15&b.windowBits)==0&&(b.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var v=s.inflateInit2(this.strm,b.windowBits);if(v!==c.Z_OK)throw new Error(u[v]);this.header=new f,s.inflateGetHeader(this.strm,this.header)}function x(y,b){var v=new g(b);if(v.push(y,!0),v.err)throw v.msg||u[v.err];return v.result}g.prototype.push=function(y,b){var v,N,S,T,E,k,C=this.strm,D=this.options.chunkSize,A=this.options.dictionary,R=!1;if(this.ended)return!1;N=b===~~b?b:b===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof y=="string"?C.input=l.binstring2buf(y):m.call(y)==="[object ArrayBuffer]"?C.input=new Uint8Array(y):C.input=y,C.next_in=0,C.avail_in=C.input.length;do{if(C.avail_out===0&&(C.output=new o.Buf8(D),C.next_out=0,C.avail_out=D),(v=s.inflate(C,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&A&&(k=typeof A=="string"?l.string2buf(A):m.call(A)==="[object ArrayBuffer]"?new Uint8Array(A):A,v=s.inflateSetDictionary(this.strm,k)),v===c.Z_BUF_ERROR&&R===!0&&(v=c.Z_OK,R=!1),v!==c.Z_STREAM_END&&v!==c.Z_OK)return this.onEnd(v),!(this.ended=!0);C.next_out&&(C.avail_out!==0&&v!==c.Z_STREAM_END&&(C.avail_in!==0||N!==c.Z_FINISH&&N!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(S=l.utf8border(C.output,C.next_out),T=C.next_out-S,E=l.buf2string(C.output,S),C.next_out=T,C.avail_out=D-T,T&&o.arraySet(C.output,C.output,S,T,0),this.onData(E)):this.onData(o.shrinkBuf(C.output,C.next_out)))),C.avail_in===0&&C.avail_out===0&&(R=!0)}while((0<C.avail_in||C.avail_out===0)&&v!==c.Z_STREAM_END);return v===c.Z_STREAM_END&&(N=c.Z_FINISH),N===c.Z_FINISH?(v=s.inflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===c.Z_OK):N!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(C.avail_out=0))},g.prototype.onData=function(y){this.chunks.push(y)},g.prototype.onEnd=function(y){y===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Inflate=g,i.inflate=x,i.inflateRaw=function(y,b){return(b=b||{}).raw=!0,x(y,b)},i.ungzip=x},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(c[f]=d[f])}}return c},i.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var o={arraySet:function(c,u,d,f,m){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),m);else for(var g=0;g<f;g++)c[m+g]=u[d+g]},flattenChunks:function(c){var u,d,f,m,g,x;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(x=new Uint8Array(f),u=m=0,d=c.length;u<d;u++)g=c[u],x.set(g,m),m+=g.length;return x}},l={arraySet:function(c,u,d,f,m){for(var g=0;g<f;g++)c[m+g]=u[d+g]},flattenChunks:function(c){return[].concat.apply([],c)}};i.setTyped=function(c){c?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,o)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,l))},i.setTyped(s)},{}],42:[function(n,r,i){var s=n("./common"),o=!0,l=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{l=!1}for(var c=new s.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,m){if(m<65537&&(f.subarray&&l||!f.subarray&&o))return String.fromCharCode.apply(null,s.shrinkBuf(f,m));for(var g="",x=0;x<m;x++)g+=String.fromCharCode(f[x]);return g}c[254]=c[254]=1,i.string2buf=function(f){var m,g,x,y,b,v=f.length,N=0;for(y=0;y<v;y++)(64512&(g=f.charCodeAt(y)))==55296&&y+1<v&&(64512&(x=f.charCodeAt(y+1)))==56320&&(g=65536+(g-55296<<10)+(x-56320),y++),N+=g<128?1:g<2048?2:g<65536?3:4;for(m=new s.Buf8(N),y=b=0;b<N;y++)(64512&(g=f.charCodeAt(y)))==55296&&y+1<v&&(64512&(x=f.charCodeAt(y+1)))==56320&&(g=65536+(g-55296<<10)+(x-56320),y++),g<128?m[b++]=g:(g<2048?m[b++]=192|g>>>6:(g<65536?m[b++]=224|g>>>12:(m[b++]=240|g>>>18,m[b++]=128|g>>>12&63),m[b++]=128|g>>>6&63),m[b++]=128|63&g);return m},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var m=new s.Buf8(f.length),g=0,x=m.length;g<x;g++)m[g]=f.charCodeAt(g);return m},i.buf2string=function(f,m){var g,x,y,b,v=m||f.length,N=new Array(2*v);for(g=x=0;g<v;)if((y=f[g++])<128)N[x++]=y;else if(4<(b=c[y]))N[x++]=65533,g+=b-1;else{for(y&=b===2?31:b===3?15:7;1<b&&g<v;)y=y<<6|63&f[g++],b--;1<b?N[x++]=65533:y<65536?N[x++]=y:(y-=65536,N[x++]=55296|y>>10&1023,N[x++]=56320|1023&y)}return d(N,x)},i.utf8border=function(f,m){var g;for((m=m||f.length)>f.length&&(m=f.length),g=m-1;0<=g&&(192&f[g])==128;)g--;return g<0||g===0?m:g+c[f[g]]>m?g:m}},{"./common":41}],43:[function(n,r,i){r.exports=function(s,o,l,c){for(var u=65535&s|0,d=s>>>16&65535|0,f=0;l!==0;){for(l-=f=2e3<l?2e3:l;d=d+(u=u+o[c++]|0)|0,--f;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,r,i){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){var s=(function(){for(var o,l=[],c=0;c<256;c++){o=c;for(var u=0;u<8;u++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l})();r.exports=function(o,l,c,u){var d=s,f=u+c;o^=-1;for(var m=u;m<f;m++)o=o>>>8^d[255&(o^l[m])];return-1^o}},{}],46:[function(n,r,i){var s,o=n("../utils/common"),l=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,m=4,g=0,x=-2,y=-1,b=4,v=2,N=8,S=9,T=286,E=30,k=19,C=2*T+1,D=15,A=3,R=258,F=R+A+1,O=42,q=113,j=1,G=2,Y=3,K=4;function Z(H,B){return H.msg=d[B],B}function te(H){return(H<<1)-(4<H?9:0)}function ne(H){for(var B=H.length;0<=--B;)H[B]=0}function z(H){var B=H.state,X=B.pending;X>H.avail_out&&(X=H.avail_out),X!==0&&(o.arraySet(H.output,B.pending_buf,B.pending_out,X,H.next_out),H.next_out+=X,B.pending_out+=X,H.total_out+=X,H.avail_out-=X,B.pending-=X,B.pending===0&&(B.pending_out=0))}function W(H,B){l._tr_flush_block(H,0<=H.block_start?H.block_start:-1,H.strstart-H.block_start,B),H.block_start=H.strstart,z(H.strm)}function se(H,B){H.pending_buf[H.pending++]=B}function ae(H,B){H.pending_buf[H.pending++]=B>>>8&255,H.pending_buf[H.pending++]=255&B}function de(H,B){var X,U,Q=H.max_chain_length,le=H.strstart,Pe=H.prev_length,Oe=H.nice_match,je=H.strstart>H.w_size-F?H.strstart-(H.w_size-F):0,$=H.window,I=H.w_mask,V=H.prev,ie=H.strstart+R,Se=$[le+Pe-1],ye=$[le+Pe];H.prev_length>=H.good_match&&(Q>>=2),Oe>H.lookahead&&(Oe=H.lookahead);do if($[(X=B)+Pe]===ye&&$[X+Pe-1]===Se&&$[X]===$[le]&&$[++X]===$[le+1]){le+=2,X++;do;while($[++le]===$[++X]&&$[++le]===$[++X]&&$[++le]===$[++X]&&$[++le]===$[++X]&&$[++le]===$[++X]&&$[++le]===$[++X]&&$[++le]===$[++X]&&$[++le]===$[++X]&&le<ie);if(U=R-(ie-le),le=ie-R,Pe<U){if(H.match_start=B,Oe<=(Pe=U))break;Se=$[le+Pe-1],ye=$[le+Pe]}}while((B=V[B&I])>je&&--Q!=0);return Pe<=H.lookahead?Pe:H.lookahead}function me(H){var B,X,U,Q,le,Pe,Oe,je,$,I,V=H.w_size;do{if(Q=H.window_size-H.lookahead-H.strstart,H.strstart>=V+(V-F)){for(o.arraySet(H.window,H.window,V,V,0),H.match_start-=V,H.strstart-=V,H.block_start-=V,B=X=H.hash_size;U=H.head[--B],H.head[B]=V<=U?U-V:0,--X;);for(B=X=V;U=H.prev[--B],H.prev[B]=V<=U?U-V:0,--X;);Q+=V}if(H.strm.avail_in===0)break;if(Pe=H.strm,Oe=H.window,je=H.strstart+H.lookahead,$=Q,I=void 0,I=Pe.avail_in,$<I&&(I=$),X=I===0?0:(Pe.avail_in-=I,o.arraySet(Oe,Pe.input,Pe.next_in,I,je),Pe.state.wrap===1?Pe.adler=c(Pe.adler,Oe,I,je):Pe.state.wrap===2&&(Pe.adler=u(Pe.adler,Oe,I,je)),Pe.next_in+=I,Pe.total_in+=I,I),H.lookahead+=X,H.lookahead+H.insert>=A)for(le=H.strstart-H.insert,H.ins_h=H.window[le],H.ins_h=(H.ins_h<<H.hash_shift^H.window[le+1])&H.hash_mask;H.insert&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[le+A-1])&H.hash_mask,H.prev[le&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=le,le++,H.insert--,!(H.lookahead+H.insert<A)););}while(H.lookahead<F&&H.strm.avail_in!==0)}function xe(H,B){for(var X,U;;){if(H.lookahead<F){if(me(H),H.lookahead<F&&B===f)return j;if(H.lookahead===0)break}if(X=0,H.lookahead>=A&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+A-1])&H.hash_mask,X=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart),X!==0&&H.strstart-X<=H.w_size-F&&(H.match_length=de(H,X)),H.match_length>=A)if(U=l._tr_tally(H,H.strstart-H.match_start,H.match_length-A),H.lookahead-=H.match_length,H.match_length<=H.max_lazy_match&&H.lookahead>=A){for(H.match_length--;H.strstart++,H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+A-1])&H.hash_mask,X=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart,--H.match_length!=0;);H.strstart++}else H.strstart+=H.match_length,H.match_length=0,H.ins_h=H.window[H.strstart],H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+1])&H.hash_mask;else U=l._tr_tally(H,0,H.window[H.strstart]),H.lookahead--,H.strstart++;if(U&&(W(H,!1),H.strm.avail_out===0))return j}return H.insert=H.strstart<A-1?H.strstart:A-1,B===m?(W(H,!0),H.strm.avail_out===0?Y:K):H.last_lit&&(W(H,!1),H.strm.avail_out===0)?j:G}function be(H,B){for(var X,U,Q;;){if(H.lookahead<F){if(me(H),H.lookahead<F&&B===f)return j;if(H.lookahead===0)break}if(X=0,H.lookahead>=A&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+A-1])&H.hash_mask,X=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart),H.prev_length=H.match_length,H.prev_match=H.match_start,H.match_length=A-1,X!==0&&H.prev_length<H.max_lazy_match&&H.strstart-X<=H.w_size-F&&(H.match_length=de(H,X),H.match_length<=5&&(H.strategy===1||H.match_length===A&&4096<H.strstart-H.match_start)&&(H.match_length=A-1)),H.prev_length>=A&&H.match_length<=H.prev_length){for(Q=H.strstart+H.lookahead-A,U=l._tr_tally(H,H.strstart-1-H.prev_match,H.prev_length-A),H.lookahead-=H.prev_length-1,H.prev_length-=2;++H.strstart<=Q&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+A-1])&H.hash_mask,X=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart),--H.prev_length!=0;);if(H.match_available=0,H.match_length=A-1,H.strstart++,U&&(W(H,!1),H.strm.avail_out===0))return j}else if(H.match_available){if((U=l._tr_tally(H,0,H.window[H.strstart-1]))&&W(H,!1),H.strstart++,H.lookahead--,H.strm.avail_out===0)return j}else H.match_available=1,H.strstart++,H.lookahead--}return H.match_available&&(U=l._tr_tally(H,0,H.window[H.strstart-1]),H.match_available=0),H.insert=H.strstart<A-1?H.strstart:A-1,B===m?(W(H,!0),H.strm.avail_out===0?Y:K):H.last_lit&&(W(H,!1),H.strm.avail_out===0)?j:G}function fe(H,B,X,U,Q){this.good_length=H,this.max_lazy=B,this.nice_length=X,this.max_chain=U,this.func=Q}function Ce(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=N,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new o.Buf16(2*C),this.dyn_dtree=new o.Buf16(2*(2*E+1)),this.bl_tree=new o.Buf16(2*(2*k+1)),ne(this.dyn_ltree),ne(this.dyn_dtree),ne(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(D+1),this.heap=new o.Buf16(2*T+1),ne(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*T+1),ne(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 Ne(H){var B;return H&&H.state?(H.total_in=H.total_out=0,H.data_type=v,(B=H.state).pending=0,B.pending_out=0,B.wrap<0&&(B.wrap=-B.wrap),B.status=B.wrap?O:q,H.adler=B.wrap===2?0:1,B.last_flush=f,l._tr_init(B),g):Z(H,x)}function re(H){var B=Ne(H);return B===g&&(function(X){X.window_size=2*X.w_size,ne(X.head),X.max_lazy_match=s[X.level].max_lazy,X.good_match=s[X.level].good_length,X.nice_match=s[X.level].nice_length,X.max_chain_length=s[X.level].max_chain,X.strstart=0,X.block_start=0,X.lookahead=0,X.insert=0,X.match_length=X.prev_length=A-1,X.match_available=0,X.ins_h=0})(H.state),B}function He(H,B,X,U,Q,le){if(!H)return x;var Pe=1;if(B===y&&(B=6),U<0?(Pe=0,U=-U):15<U&&(Pe=2,U-=16),Q<1||S<Q||X!==N||U<8||15<U||B<0||9<B||le<0||b<le)return Z(H,x);U===8&&(U=9);var Oe=new Ce;return(H.state=Oe).strm=H,Oe.wrap=Pe,Oe.gzhead=null,Oe.w_bits=U,Oe.w_size=1<<Oe.w_bits,Oe.w_mask=Oe.w_size-1,Oe.hash_bits=Q+7,Oe.hash_size=1<<Oe.hash_bits,Oe.hash_mask=Oe.hash_size-1,Oe.hash_shift=~~((Oe.hash_bits+A-1)/A),Oe.window=new o.Buf8(2*Oe.w_size),Oe.head=new o.Buf16(Oe.hash_size),Oe.prev=new o.Buf16(Oe.w_size),Oe.lit_bufsize=1<<Q+6,Oe.pending_buf_size=4*Oe.lit_bufsize,Oe.pending_buf=new o.Buf8(Oe.pending_buf_size),Oe.d_buf=1*Oe.lit_bufsize,Oe.l_buf=3*Oe.lit_bufsize,Oe.level=B,Oe.strategy=le,Oe.method=X,re(H)}s=[new fe(0,0,0,0,function(H,B){var X=65535;for(X>H.pending_buf_size-5&&(X=H.pending_buf_size-5);;){if(H.lookahead<=1){if(me(H),H.lookahead===0&&B===f)return j;if(H.lookahead===0)break}H.strstart+=H.lookahead,H.lookahead=0;var U=H.block_start+X;if((H.strstart===0||H.strstart>=U)&&(H.lookahead=H.strstart-U,H.strstart=U,W(H,!1),H.strm.avail_out===0)||H.strstart-H.block_start>=H.w_size-F&&(W(H,!1),H.strm.avail_out===0))return j}return H.insert=0,B===m?(W(H,!0),H.strm.avail_out===0?Y:K):(H.strstart>H.block_start&&(W(H,!1),H.strm.avail_out),j)}),new fe(4,4,8,4,xe),new fe(4,5,16,8,xe),new fe(4,6,32,32,xe),new fe(4,4,16,16,be),new fe(8,16,32,32,be),new fe(8,16,128,128,be),new fe(8,32,128,256,be),new fe(32,128,258,1024,be),new fe(32,258,258,4096,be)],i.deflateInit=function(H,B){return He(H,B,N,15,8,0)},i.deflateInit2=He,i.deflateReset=re,i.deflateResetKeep=Ne,i.deflateSetHeader=function(H,B){return H&&H.state?H.state.wrap!==2?x:(H.state.gzhead=B,g):x},i.deflate=function(H,B){var X,U,Q,le;if(!H||!H.state||5<B||B<0)return H?Z(H,x):x;if(U=H.state,!H.output||!H.input&&H.avail_in!==0||U.status===666&&B!==m)return Z(H,H.avail_out===0?-5:x);if(U.strm=H,X=U.last_flush,U.last_flush=B,U.status===O)if(U.wrap===2)H.adler=0,se(U,31),se(U,139),se(U,8),U.gzhead?(se(U,(U.gzhead.text?1:0)+(U.gzhead.hcrc?2:0)+(U.gzhead.extra?4:0)+(U.gzhead.name?8:0)+(U.gzhead.comment?16:0)),se(U,255&U.gzhead.time),se(U,U.gzhead.time>>8&255),se(U,U.gzhead.time>>16&255),se(U,U.gzhead.time>>24&255),se(U,U.level===9?2:2<=U.strategy||U.level<2?4:0),se(U,255&U.gzhead.os),U.gzhead.extra&&U.gzhead.extra.length&&(se(U,255&U.gzhead.extra.length),se(U,U.gzhead.extra.length>>8&255)),U.gzhead.hcrc&&(H.adler=u(H.adler,U.pending_buf,U.pending,0)),U.gzindex=0,U.status=69):(se(U,0),se(U,0),se(U,0),se(U,0),se(U,0),se(U,U.level===9?2:2<=U.strategy||U.level<2?4:0),se(U,3),U.status=q);else{var Pe=N+(U.w_bits-8<<4)<<8;Pe|=(2<=U.strategy||U.level<2?0:U.level<6?1:U.level===6?2:3)<<6,U.strstart!==0&&(Pe|=32),Pe+=31-Pe%31,U.status=q,ae(U,Pe),U.strstart!==0&&(ae(U,H.adler>>>16),ae(U,65535&H.adler)),H.adler=1}if(U.status===69)if(U.gzhead.extra){for(Q=U.pending;U.gzindex<(65535&U.gzhead.extra.length)&&(U.pending!==U.pending_buf_size||(U.gzhead.hcrc&&U.pending>Q&&(H.adler=u(H.adler,U.pending_buf,U.pending-Q,Q)),z(H),Q=U.pending,U.pending!==U.pending_buf_size));)se(U,255&U.gzhead.extra[U.gzindex]),U.gzindex++;U.gzhead.hcrc&&U.pending>Q&&(H.adler=u(H.adler,U.pending_buf,U.pending-Q,Q)),U.gzindex===U.gzhead.extra.length&&(U.gzindex=0,U.status=73)}else U.status=73;if(U.status===73)if(U.gzhead.name){Q=U.pending;do{if(U.pending===U.pending_buf_size&&(U.gzhead.hcrc&&U.pending>Q&&(H.adler=u(H.adler,U.pending_buf,U.pending-Q,Q)),z(H),Q=U.pending,U.pending===U.pending_buf_size)){le=1;break}le=U.gzindex<U.gzhead.name.length?255&U.gzhead.name.charCodeAt(U.gzindex++):0,se(U,le)}while(le!==0);U.gzhead.hcrc&&U.pending>Q&&(H.adler=u(H.adler,U.pending_buf,U.pending-Q,Q)),le===0&&(U.gzindex=0,U.status=91)}else U.status=91;if(U.status===91)if(U.gzhead.comment){Q=U.pending;do{if(U.pending===U.pending_buf_size&&(U.gzhead.hcrc&&U.pending>Q&&(H.adler=u(H.adler,U.pending_buf,U.pending-Q,Q)),z(H),Q=U.pending,U.pending===U.pending_buf_size)){le=1;break}le=U.gzindex<U.gzhead.comment.length?255&U.gzhead.comment.charCodeAt(U.gzindex++):0,se(U,le)}while(le!==0);U.gzhead.hcrc&&U.pending>Q&&(H.adler=u(H.adler,U.pending_buf,U.pending-Q,Q)),le===0&&(U.status=103)}else U.status=103;if(U.status===103&&(U.gzhead.hcrc?(U.pending+2>U.pending_buf_size&&z(H),U.pending+2<=U.pending_buf_size&&(se(U,255&H.adler),se(U,H.adler>>8&255),H.adler=0,U.status=q)):U.status=q),U.pending!==0){if(z(H),H.avail_out===0)return U.last_flush=-1,g}else if(H.avail_in===0&&te(B)<=te(X)&&B!==m)return Z(H,-5);if(U.status===666&&H.avail_in!==0)return Z(H,-5);if(H.avail_in!==0||U.lookahead!==0||B!==f&&U.status!==666){var Oe=U.strategy===2?(function(je,$){for(var I;;){if(je.lookahead===0&&(me(je),je.lookahead===0)){if($===f)return j;break}if(je.match_length=0,I=l._tr_tally(je,0,je.window[je.strstart]),je.lookahead--,je.strstart++,I&&(W(je,!1),je.strm.avail_out===0))return j}return je.insert=0,$===m?(W(je,!0),je.strm.avail_out===0?Y:K):je.last_lit&&(W(je,!1),je.strm.avail_out===0)?j:G})(U,B):U.strategy===3?(function(je,$){for(var I,V,ie,Se,ye=je.window;;){if(je.lookahead<=R){if(me(je),je.lookahead<=R&&$===f)return j;if(je.lookahead===0)break}if(je.match_length=0,je.lookahead>=A&&0<je.strstart&&(V=ye[ie=je.strstart-1])===ye[++ie]&&V===ye[++ie]&&V===ye[++ie]){Se=je.strstart+R;do;while(V===ye[++ie]&&V===ye[++ie]&&V===ye[++ie]&&V===ye[++ie]&&V===ye[++ie]&&V===ye[++ie]&&V===ye[++ie]&&V===ye[++ie]&&ie<Se);je.match_length=R-(Se-ie),je.match_length>je.lookahead&&(je.match_length=je.lookahead)}if(je.match_length>=A?(I=l._tr_tally(je,1,je.match_length-A),je.lookahead-=je.match_length,je.strstart+=je.match_length,je.match_length=0):(I=l._tr_tally(je,0,je.window[je.strstart]),je.lookahead--,je.strstart++),I&&(W(je,!1),je.strm.avail_out===0))return j}return je.insert=0,$===m?(W(je,!0),je.strm.avail_out===0?Y:K):je.last_lit&&(W(je,!1),je.strm.avail_out===0)?j:G})(U,B):s[U.level].func(U,B);if(Oe!==Y&&Oe!==K||(U.status=666),Oe===j||Oe===Y)return H.avail_out===0&&(U.last_flush=-1),g;if(Oe===G&&(B===1?l._tr_align(U):B!==5&&(l._tr_stored_block(U,0,0,!1),B===3&&(ne(U.head),U.lookahead===0&&(U.strstart=0,U.block_start=0,U.insert=0))),z(H),H.avail_out===0))return U.last_flush=-1,g}return B!==m?g:U.wrap<=0?1:(U.wrap===2?(se(U,255&H.adler),se(U,H.adler>>8&255),se(U,H.adler>>16&255),se(U,H.adler>>24&255),se(U,255&H.total_in),se(U,H.total_in>>8&255),se(U,H.total_in>>16&255),se(U,H.total_in>>24&255)):(ae(U,H.adler>>>16),ae(U,65535&H.adler)),z(H),0<U.wrap&&(U.wrap=-U.wrap),U.pending!==0?g:1)},i.deflateEnd=function(H){var B;return H&&H.state?(B=H.state.status)!==O&&B!==69&&B!==73&&B!==91&&B!==103&&B!==q&&B!==666?Z(H,x):(H.state=null,B===q?Z(H,-3):g):x},i.deflateSetDictionary=function(H,B){var X,U,Q,le,Pe,Oe,je,$,I=B.length;if(!H||!H.state||(le=(X=H.state).wrap)===2||le===1&&X.status!==O||X.lookahead)return x;for(le===1&&(H.adler=c(H.adler,B,I,0)),X.wrap=0,I>=X.w_size&&(le===0&&(ne(X.head),X.strstart=0,X.block_start=0,X.insert=0),$=new o.Buf8(X.w_size),o.arraySet($,B,I-X.w_size,X.w_size,0),B=$,I=X.w_size),Pe=H.avail_in,Oe=H.next_in,je=H.input,H.avail_in=I,H.next_in=0,H.input=B,me(X);X.lookahead>=A;){for(U=X.strstart,Q=X.lookahead-(A-1);X.ins_h=(X.ins_h<<X.hash_shift^X.window[U+A-1])&X.hash_mask,X.prev[U&X.w_mask]=X.head[X.ins_h],X.head[X.ins_h]=U,U++,--Q;);X.strstart=U,X.lookahead=A-1,me(X)}return X.strstart+=X.lookahead,X.block_start=X.strstart,X.insert=X.lookahead,X.lookahead=0,X.match_length=X.prev_length=A-1,X.match_available=0,H.next_in=Oe,H.input=je,H.avail_in=Pe,X.wrap=le,g},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(s,o){var l,c,u,d,f,m,g,x,y,b,v,N,S,T,E,k,C,D,A,R,F,O,q,j,G;l=s.state,c=s.next_in,j=s.input,u=c+(s.avail_in-5),d=s.next_out,G=s.output,f=d-(o-s.avail_out),m=d+(s.avail_out-257),g=l.dmax,x=l.wsize,y=l.whave,b=l.wnext,v=l.window,N=l.hold,S=l.bits,T=l.lencode,E=l.distcode,k=(1<<l.lenbits)-1,C=(1<<l.distbits)-1;e:do{S<15&&(N+=j[c++]<<S,S+=8,N+=j[c++]<<S,S+=8),D=T[N&k];t:for(;;){if(N>>>=A=D>>>24,S-=A,(A=D>>>16&255)===0)G[d++]=65535&D;else{if(!(16&A)){if((64&A)==0){D=T[(65535&D)+(N&(1<<A)-1)];continue t}if(32&A){l.mode=12;break e}s.msg="invalid literal/length code",l.mode=30;break e}R=65535&D,(A&=15)&&(S<A&&(N+=j[c++]<<S,S+=8),R+=N&(1<<A)-1,N>>>=A,S-=A),S<15&&(N+=j[c++]<<S,S+=8,N+=j[c++]<<S,S+=8),D=E[N&C];n:for(;;){if(N>>>=A=D>>>24,S-=A,!(16&(A=D>>>16&255))){if((64&A)==0){D=E[(65535&D)+(N&(1<<A)-1)];continue n}s.msg="invalid distance code",l.mode=30;break e}if(F=65535&D,S<(A&=15)&&(N+=j[c++]<<S,(S+=8)<A&&(N+=j[c++]<<S,S+=8)),g<(F+=N&(1<<A)-1)){s.msg="invalid distance too far back",l.mode=30;break e}if(N>>>=A,S-=A,(A=d-f)<F){if(y<(A=F-A)&&l.sane){s.msg="invalid distance too far back",l.mode=30;break e}if(q=v,(O=0)===b){if(O+=x-A,A<R){for(R-=A;G[d++]=v[O++],--A;);O=d-F,q=G}}else if(b<A){if(O+=x+b-A,(A-=b)<R){for(R-=A;G[d++]=v[O++],--A;);if(O=0,b<R){for(R-=A=b;G[d++]=v[O++],--A;);O=d-F,q=G}}}else if(O+=b-A,A<R){for(R-=A;G[d++]=v[O++],--A;);O=d-F,q=G}for(;2<R;)G[d++]=q[O++],G[d++]=q[O++],G[d++]=q[O++],R-=3;R&&(G[d++]=q[O++],1<R&&(G[d++]=q[O++]))}else{for(O=d-F;G[d++]=G[O++],G[d++]=G[O++],G[d++]=G[O++],2<(R-=3););R&&(G[d++]=G[O++],1<R&&(G[d++]=G[O++]))}break}}break}}while(c<u&&d<m);c-=R=S>>3,N&=(1<<(S-=R<<3))-1,s.next_in=c,s.next_out=d,s.avail_in=c<u?u-c+5:5-(c-u),s.avail_out=d<m?m-d+257:257-(d-m),l.hold=N,l.bits=S}},{}],49:[function(n,r,i){var s=n("../utils/common"),o=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,f=2,m=0,g=-2,x=1,y=852,b=592;function v(O){return(O>>>24&255)+(O>>>8&65280)+((65280&O)<<8)+((255&O)<<24)}function N(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function S(O){var q;return O&&O.state?(q=O.state,O.total_in=O.total_out=q.total=0,O.msg="",q.wrap&&(O.adler=1&q.wrap),q.mode=x,q.last=0,q.havedict=0,q.dmax=32768,q.head=null,q.hold=0,q.bits=0,q.lencode=q.lendyn=new s.Buf32(y),q.distcode=q.distdyn=new s.Buf32(b),q.sane=1,q.back=-1,m):g}function T(O){var q;return O&&O.state?((q=O.state).wsize=0,q.whave=0,q.wnext=0,S(O)):g}function E(O,q){var j,G;return O&&O.state?(G=O.state,q<0?(j=0,q=-q):(j=1+(q>>4),q<48&&(q&=15)),q&&(q<8||15<q)?g:(G.window!==null&&G.wbits!==q&&(G.window=null),G.wrap=j,G.wbits=q,T(O))):g}function k(O,q){var j,G;return O?(G=new N,(O.state=G).window=null,(j=E(O,q))!==m&&(O.state=null),j):g}var C,D,A=!0;function R(O){if(A){var q;for(C=new s.Buf32(512),D=new s.Buf32(32),q=0;q<144;)O.lens[q++]=8;for(;q<256;)O.lens[q++]=9;for(;q<280;)O.lens[q++]=7;for(;q<288;)O.lens[q++]=8;for(u(d,O.lens,0,288,C,0,O.work,{bits:9}),q=0;q<32;)O.lens[q++]=5;u(f,O.lens,0,32,D,0,O.work,{bits:5}),A=!1}O.lencode=C,O.lenbits=9,O.distcode=D,O.distbits=5}function F(O,q,j,G){var Y,K=O.state;return K.window===null&&(K.wsize=1<<K.wbits,K.wnext=0,K.whave=0,K.window=new s.Buf8(K.wsize)),G>=K.wsize?(s.arraySet(K.window,q,j-K.wsize,K.wsize,0),K.wnext=0,K.whave=K.wsize):(G<(Y=K.wsize-K.wnext)&&(Y=G),s.arraySet(K.window,q,j-G,Y,K.wnext),(G-=Y)?(s.arraySet(K.window,q,j-G,G,0),K.wnext=G,K.whave=K.wsize):(K.wnext+=Y,K.wnext===K.wsize&&(K.wnext=0),K.whave<K.wsize&&(K.whave+=Y))),0}i.inflateReset=T,i.inflateReset2=E,i.inflateResetKeep=S,i.inflateInit=function(O){return k(O,15)},i.inflateInit2=k,i.inflate=function(O,q){var j,G,Y,K,Z,te,ne,z,W,se,ae,de,me,xe,be,fe,Ce,Ne,re,He,H,B,X,U,Q=0,le=new s.Buf8(4),Pe=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!O||!O.state||!O.output||!O.input&&O.avail_in!==0)return g;(j=O.state).mode===12&&(j.mode=13),Z=O.next_out,Y=O.output,ne=O.avail_out,K=O.next_in,G=O.input,te=O.avail_in,z=j.hold,W=j.bits,se=te,ae=ne,B=m;e:for(;;)switch(j.mode){case x:if(j.wrap===0){j.mode=13;break}for(;W<16;){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}if(2&j.wrap&&z===35615){le[j.check=0]=255&z,le[1]=z>>>8&255,j.check=l(j.check,le,2,0),W=z=0,j.mode=2;break}if(j.flags=0,j.head&&(j.head.done=!1),!(1&j.wrap)||(((255&z)<<8)+(z>>8))%31){O.msg="incorrect header check",j.mode=30;break}if((15&z)!=8){O.msg="unknown compression method",j.mode=30;break}if(W-=4,H=8+(15&(z>>>=4)),j.wbits===0)j.wbits=H;else if(H>j.wbits){O.msg="invalid window size",j.mode=30;break}j.dmax=1<<H,O.adler=j.check=1,j.mode=512&z?10:12,W=z=0;break;case 2:for(;W<16;){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}if(j.flags=z,(255&j.flags)!=8){O.msg="unknown compression method",j.mode=30;break}if(57344&j.flags){O.msg="unknown header flags set",j.mode=30;break}j.head&&(j.head.text=z>>8&1),512&j.flags&&(le[0]=255&z,le[1]=z>>>8&255,j.check=l(j.check,le,2,0)),W=z=0,j.mode=3;case 3:for(;W<32;){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}j.head&&(j.head.time=z),512&j.flags&&(le[0]=255&z,le[1]=z>>>8&255,le[2]=z>>>16&255,le[3]=z>>>24&255,j.check=l(j.check,le,4,0)),W=z=0,j.mode=4;case 4:for(;W<16;){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}j.head&&(j.head.xflags=255&z,j.head.os=z>>8),512&j.flags&&(le[0]=255&z,le[1]=z>>>8&255,j.check=l(j.check,le,2,0)),W=z=0,j.mode=5;case 5:if(1024&j.flags){for(;W<16;){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}j.length=z,j.head&&(j.head.extra_len=z),512&j.flags&&(le[0]=255&z,le[1]=z>>>8&255,j.check=l(j.check,le,2,0)),W=z=0}else j.head&&(j.head.extra=null);j.mode=6;case 6:if(1024&j.flags&&(te<(de=j.length)&&(de=te),de&&(j.head&&(H=j.head.extra_len-j.length,j.head.extra||(j.head.extra=new Array(j.head.extra_len)),s.arraySet(j.head.extra,G,K,de,H)),512&j.flags&&(j.check=l(j.check,G,de,K)),te-=de,K+=de,j.length-=de),j.length))break e;j.length=0,j.mode=7;case 7:if(2048&j.flags){if(te===0)break e;for(de=0;H=G[K+de++],j.head&&H&&j.length<65536&&(j.head.name+=String.fromCharCode(H)),H&&de<te;);if(512&j.flags&&(j.check=l(j.check,G,de,K)),te-=de,K+=de,H)break e}else j.head&&(j.head.name=null);j.length=0,j.mode=8;case 8:if(4096&j.flags){if(te===0)break e;for(de=0;H=G[K+de++],j.head&&H&&j.length<65536&&(j.head.comment+=String.fromCharCode(H)),H&&de<te;);if(512&j.flags&&(j.check=l(j.check,G,de,K)),te-=de,K+=de,H)break e}else j.head&&(j.head.comment=null);j.mode=9;case 9:if(512&j.flags){for(;W<16;){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}if(z!==(65535&j.check)){O.msg="header crc mismatch",j.mode=30;break}W=z=0}j.head&&(j.head.hcrc=j.flags>>9&1,j.head.done=!0),O.adler=j.check=0,j.mode=12;break;case 10:for(;W<32;){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}O.adler=j.check=v(z),W=z=0,j.mode=11;case 11:if(j.havedict===0)return O.next_out=Z,O.avail_out=ne,O.next_in=K,O.avail_in=te,j.hold=z,j.bits=W,2;O.adler=j.check=1,j.mode=12;case 12:if(q===5||q===6)break e;case 13:if(j.last){z>>>=7&W,W-=7&W,j.mode=27;break}for(;W<3;){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}switch(j.last=1&z,W-=1,3&(z>>>=1)){case 0:j.mode=14;break;case 1:if(R(j),j.mode=20,q!==6)break;z>>>=2,W-=2;break e;case 2:j.mode=17;break;case 3:O.msg="invalid block type",j.mode=30}z>>>=2,W-=2;break;case 14:for(z>>>=7&W,W-=7&W;W<32;){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}if((65535&z)!=(z>>>16^65535)){O.msg="invalid stored block lengths",j.mode=30;break}if(j.length=65535&z,W=z=0,j.mode=15,q===6)break e;case 15:j.mode=16;case 16:if(de=j.length){if(te<de&&(de=te),ne<de&&(de=ne),de===0)break e;s.arraySet(Y,G,K,de,Z),te-=de,K+=de,ne-=de,Z+=de,j.length-=de;break}j.mode=12;break;case 17:for(;W<14;){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}if(j.nlen=257+(31&z),z>>>=5,W-=5,j.ndist=1+(31&z),z>>>=5,W-=5,j.ncode=4+(15&z),z>>>=4,W-=4,286<j.nlen||30<j.ndist){O.msg="too many length or distance symbols",j.mode=30;break}j.have=0,j.mode=18;case 18:for(;j.have<j.ncode;){for(;W<3;){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}j.lens[Pe[j.have++]]=7&z,z>>>=3,W-=3}for(;j.have<19;)j.lens[Pe[j.have++]]=0;if(j.lencode=j.lendyn,j.lenbits=7,X={bits:j.lenbits},B=u(0,j.lens,0,19,j.lencode,0,j.work,X),j.lenbits=X.bits,B){O.msg="invalid code lengths set",j.mode=30;break}j.have=0,j.mode=19;case 19:for(;j.have<j.nlen+j.ndist;){for(;fe=(Q=j.lencode[z&(1<<j.lenbits)-1])>>>16&255,Ce=65535&Q,!((be=Q>>>24)<=W);){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}if(Ce<16)z>>>=be,W-=be,j.lens[j.have++]=Ce;else{if(Ce===16){for(U=be+2;W<U;){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}if(z>>>=be,W-=be,j.have===0){O.msg="invalid bit length repeat",j.mode=30;break}H=j.lens[j.have-1],de=3+(3&z),z>>>=2,W-=2}else if(Ce===17){for(U=be+3;W<U;){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}W-=be,H=0,de=3+(7&(z>>>=be)),z>>>=3,W-=3}else{for(U=be+7;W<U;){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}W-=be,H=0,de=11+(127&(z>>>=be)),z>>>=7,W-=7}if(j.have+de>j.nlen+j.ndist){O.msg="invalid bit length repeat",j.mode=30;break}for(;de--;)j.lens[j.have++]=H}}if(j.mode===30)break;if(j.lens[256]===0){O.msg="invalid code -- missing end-of-block",j.mode=30;break}if(j.lenbits=9,X={bits:j.lenbits},B=u(d,j.lens,0,j.nlen,j.lencode,0,j.work,X),j.lenbits=X.bits,B){O.msg="invalid literal/lengths set",j.mode=30;break}if(j.distbits=6,j.distcode=j.distdyn,X={bits:j.distbits},B=u(f,j.lens,j.nlen,j.ndist,j.distcode,0,j.work,X),j.distbits=X.bits,B){O.msg="invalid distances set",j.mode=30;break}if(j.mode=20,q===6)break e;case 20:j.mode=21;case 21:if(6<=te&&258<=ne){O.next_out=Z,O.avail_out=ne,O.next_in=K,O.avail_in=te,j.hold=z,j.bits=W,c(O,ae),Z=O.next_out,Y=O.output,ne=O.avail_out,K=O.next_in,G=O.input,te=O.avail_in,z=j.hold,W=j.bits,j.mode===12&&(j.back=-1);break}for(j.back=0;fe=(Q=j.lencode[z&(1<<j.lenbits)-1])>>>16&255,Ce=65535&Q,!((be=Q>>>24)<=W);){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}if(fe&&(240&fe)==0){for(Ne=be,re=fe,He=Ce;fe=(Q=j.lencode[He+((z&(1<<Ne+re)-1)>>Ne)])>>>16&255,Ce=65535&Q,!(Ne+(be=Q>>>24)<=W);){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}z>>>=Ne,W-=Ne,j.back+=Ne}if(z>>>=be,W-=be,j.back+=be,j.length=Ce,fe===0){j.mode=26;break}if(32&fe){j.back=-1,j.mode=12;break}if(64&fe){O.msg="invalid literal/length code",j.mode=30;break}j.extra=15&fe,j.mode=22;case 22:if(j.extra){for(U=j.extra;W<U;){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}j.length+=z&(1<<j.extra)-1,z>>>=j.extra,W-=j.extra,j.back+=j.extra}j.was=j.length,j.mode=23;case 23:for(;fe=(Q=j.distcode[z&(1<<j.distbits)-1])>>>16&255,Ce=65535&Q,!((be=Q>>>24)<=W);){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}if((240&fe)==0){for(Ne=be,re=fe,He=Ce;fe=(Q=j.distcode[He+((z&(1<<Ne+re)-1)>>Ne)])>>>16&255,Ce=65535&Q,!(Ne+(be=Q>>>24)<=W);){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}z>>>=Ne,W-=Ne,j.back+=Ne}if(z>>>=be,W-=be,j.back+=be,64&fe){O.msg="invalid distance code",j.mode=30;break}j.offset=Ce,j.extra=15&fe,j.mode=24;case 24:if(j.extra){for(U=j.extra;W<U;){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}j.offset+=z&(1<<j.extra)-1,z>>>=j.extra,W-=j.extra,j.back+=j.extra}if(j.offset>j.dmax){O.msg="invalid distance too far back",j.mode=30;break}j.mode=25;case 25:if(ne===0)break e;if(de=ae-ne,j.offset>de){if((de=j.offset-de)>j.whave&&j.sane){O.msg="invalid distance too far back",j.mode=30;break}me=de>j.wnext?(de-=j.wnext,j.wsize-de):j.wnext-de,de>j.length&&(de=j.length),xe=j.window}else xe=Y,me=Z-j.offset,de=j.length;for(ne<de&&(de=ne),ne-=de,j.length-=de;Y[Z++]=xe[me++],--de;);j.length===0&&(j.mode=21);break;case 26:if(ne===0)break e;Y[Z++]=j.length,ne--,j.mode=21;break;case 27:if(j.wrap){for(;W<32;){if(te===0)break e;te--,z|=G[K++]<<W,W+=8}if(ae-=ne,O.total_out+=ae,j.total+=ae,ae&&(O.adler=j.check=j.flags?l(j.check,Y,ae,Z-ae):o(j.check,Y,ae,Z-ae)),ae=ne,(j.flags?z:v(z))!==j.check){O.msg="incorrect data check",j.mode=30;break}W=z=0}j.mode=28;case 28:if(j.wrap&&j.flags){for(;W<32;){if(te===0)break e;te--,z+=G[K++]<<W,W+=8}if(z!==(4294967295&j.total)){O.msg="incorrect length check",j.mode=30;break}W=z=0}j.mode=29;case 29:B=1;break e;case 30:B=-3;break e;case 31:return-4;case 32:default:return g}return O.next_out=Z,O.avail_out=ne,O.next_in=K,O.avail_in=te,j.hold=z,j.bits=W,(j.wsize||ae!==O.avail_out&&j.mode<30&&(j.mode<27||q!==4))&&F(O,O.output,O.next_out,ae-O.avail_out)?(j.mode=31,-4):(se-=O.avail_in,ae-=O.avail_out,O.total_in+=se,O.total_out+=ae,j.total+=ae,j.wrap&&ae&&(O.adler=j.check=j.flags?l(j.check,Y,ae,O.next_out-ae):o(j.check,Y,ae,O.next_out-ae)),O.data_type=j.bits+(j.last?64:0)+(j.mode===12?128:0)+(j.mode===20||j.mode===15?256:0),(se==0&&ae===0||q===4)&&B===m&&(B=-5),B)},i.inflateEnd=function(O){if(!O||!O.state)return g;var q=O.state;return q.window&&(q.window=null),O.state=null,m},i.inflateGetHeader=function(O,q){var j;return O&&O.state?(2&(j=O.state).wrap)==0?g:((j.head=q).done=!1,m):g},i.inflateSetDictionary=function(O,q){var j,G=q.length;return O&&O.state?(j=O.state).wrap!==0&&j.mode!==11?g:j.mode===11&&o(1,q,G,0)!==j.check?-3:F(O,q,G,G)?(j.mode=31,-4):(j.havedict=1,m):g},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var s=n("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,m,g,x,y,b,v){var N,S,T,E,k,C,D,A,R,F=v.bits,O=0,q=0,j=0,G=0,Y=0,K=0,Z=0,te=0,ne=0,z=0,W=null,se=0,ae=new s.Buf16(16),de=new s.Buf16(16),me=null,xe=0;for(O=0;O<=15;O++)ae[O]=0;for(q=0;q<g;q++)ae[f[m+q]]++;for(Y=F,G=15;1<=G&&ae[G]===0;G--);if(G<Y&&(Y=G),G===0)return x[y++]=20971520,x[y++]=20971520,v.bits=1,0;for(j=1;j<G&&ae[j]===0;j++);for(Y<j&&(Y=j),O=te=1;O<=15;O++)if(te<<=1,(te-=ae[O])<0)return-1;if(0<te&&(d===0||G!==1))return-1;for(de[1]=0,O=1;O<15;O++)de[O+1]=de[O]+ae[O];for(q=0;q<g;q++)f[m+q]!==0&&(b[de[f[m+q]]++]=q);if(C=d===0?(W=me=b,19):d===1?(W=o,se-=257,me=l,xe-=257,256):(W=c,me=u,-1),O=j,k=y,Z=q=z=0,T=-1,E=(ne=1<<(K=Y))-1,d===1&&852<ne||d===2&&592<ne)return 1;for(;;){for(D=O-Z,R=b[q]<C?(A=0,b[q]):b[q]>C?(A=me[xe+b[q]],W[se+b[q]]):(A=96,0),N=1<<O-Z,j=S=1<<K;x[k+(z>>Z)+(S-=N)]=D<<24|A<<16|R|0,S!==0;);for(N=1<<O-1;z&N;)N>>=1;if(N!==0?(z&=N-1,z+=N):z=0,q++,--ae[O]==0){if(O===G)break;O=f[m+b[q]]}if(Y<O&&(z&E)!==T){for(Z===0&&(Z=Y),k+=j,te=1<<(K=O-Z);K+Z<G&&!((te-=ae[K+Z])<=0);)K++,te<<=1;if(ne+=1<<K,d===1&&852<ne||d===2&&592<ne)return 1;x[T=z&E]=Y<<24|K<<16|k-y|0}}return z!==0&&(x[k+z]=O-Z<<24|64<<16|0),v.bits=Y,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var s=n("../utils/common"),o=0,l=1;function c(Q){for(var le=Q.length;0<=--le;)Q[le]=0}var u=0,d=29,f=256,m=f+1+d,g=30,x=19,y=2*m+1,b=15,v=16,N=7,S=256,T=16,E=17,k=18,C=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],D=[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],A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],R=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],F=new Array(2*(m+2));c(F);var O=new Array(2*g);c(O);var q=new Array(512);c(q);var j=new Array(256);c(j);var G=new Array(d);c(G);var Y,K,Z,te=new Array(g);function ne(Q,le,Pe,Oe,je){this.static_tree=Q,this.extra_bits=le,this.extra_base=Pe,this.elems=Oe,this.max_length=je,this.has_stree=Q&&Q.length}function z(Q,le){this.dyn_tree=Q,this.max_code=0,this.stat_desc=le}function W(Q){return Q<256?q[Q]:q[256+(Q>>>7)]}function se(Q,le){Q.pending_buf[Q.pending++]=255&le,Q.pending_buf[Q.pending++]=le>>>8&255}function ae(Q,le,Pe){Q.bi_valid>v-Pe?(Q.bi_buf|=le<<Q.bi_valid&65535,se(Q,Q.bi_buf),Q.bi_buf=le>>v-Q.bi_valid,Q.bi_valid+=Pe-v):(Q.bi_buf|=le<<Q.bi_valid&65535,Q.bi_valid+=Pe)}function de(Q,le,Pe){ae(Q,Pe[2*le],Pe[2*le+1])}function me(Q,le){for(var Pe=0;Pe|=1&Q,Q>>>=1,Pe<<=1,0<--le;);return Pe>>>1}function xe(Q,le,Pe){var Oe,je,$=new Array(b+1),I=0;for(Oe=1;Oe<=b;Oe++)$[Oe]=I=I+Pe[Oe-1]<<1;for(je=0;je<=le;je++){var V=Q[2*je+1];V!==0&&(Q[2*je]=me($[V]++,V))}}function be(Q){var le;for(le=0;le<m;le++)Q.dyn_ltree[2*le]=0;for(le=0;le<g;le++)Q.dyn_dtree[2*le]=0;for(le=0;le<x;le++)Q.bl_tree[2*le]=0;Q.dyn_ltree[2*S]=1,Q.opt_len=Q.static_len=0,Q.last_lit=Q.matches=0}function fe(Q){8<Q.bi_valid?se(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 Ce(Q,le,Pe,Oe){var je=2*le,$=2*Pe;return Q[je]<Q[$]||Q[je]===Q[$]&&Oe[le]<=Oe[Pe]}function Ne(Q,le,Pe){for(var Oe=Q.heap[Pe],je=Pe<<1;je<=Q.heap_len&&(je<Q.heap_len&&Ce(le,Q.heap[je+1],Q.heap[je],Q.depth)&&je++,!Ce(le,Oe,Q.heap[je],Q.depth));)Q.heap[Pe]=Q.heap[je],Pe=je,je<<=1;Q.heap[Pe]=Oe}function re(Q,le,Pe){var Oe,je,$,I,V=0;if(Q.last_lit!==0)for(;Oe=Q.pending_buf[Q.d_buf+2*V]<<8|Q.pending_buf[Q.d_buf+2*V+1],je=Q.pending_buf[Q.l_buf+V],V++,Oe===0?de(Q,je,le):(de(Q,($=j[je])+f+1,le),(I=C[$])!==0&&ae(Q,je-=G[$],I),de(Q,$=W(--Oe),Pe),(I=D[$])!==0&&ae(Q,Oe-=te[$],I)),V<Q.last_lit;);de(Q,S,le)}function He(Q,le){var Pe,Oe,je,$=le.dyn_tree,I=le.stat_desc.static_tree,V=le.stat_desc.has_stree,ie=le.stat_desc.elems,Se=-1;for(Q.heap_len=0,Q.heap_max=y,Pe=0;Pe<ie;Pe++)$[2*Pe]!==0?(Q.heap[++Q.heap_len]=Se=Pe,Q.depth[Pe]=0):$[2*Pe+1]=0;for(;Q.heap_len<2;)$[2*(je=Q.heap[++Q.heap_len]=Se<2?++Se:0)]=1,Q.depth[je]=0,Q.opt_len--,V&&(Q.static_len-=I[2*je+1]);for(le.max_code=Se,Pe=Q.heap_len>>1;1<=Pe;Pe--)Ne(Q,$,Pe);for(je=ie;Pe=Q.heap[1],Q.heap[1]=Q.heap[Q.heap_len--],Ne(Q,$,1),Oe=Q.heap[1],Q.heap[--Q.heap_max]=Pe,Q.heap[--Q.heap_max]=Oe,$[2*je]=$[2*Pe]+$[2*Oe],Q.depth[je]=(Q.depth[Pe]>=Q.depth[Oe]?Q.depth[Pe]:Q.depth[Oe])+1,$[2*Pe+1]=$[2*Oe+1]=je,Q.heap[1]=je++,Ne(Q,$,1),2<=Q.heap_len;);Q.heap[--Q.heap_max]=Q.heap[1],(function(ye,$e){var Ue,Ge,We,Ye,oe,ve,Le=$e.dyn_tree,Ke=$e.max_code,lt=$e.stat_desc.static_tree,_e=$e.stat_desc.has_stree,ce=$e.stat_desc.extra_bits,ee=$e.stat_desc.extra_base,ke=$e.stat_desc.max_length,De=0;for(Ye=0;Ye<=b;Ye++)ye.bl_count[Ye]=0;for(Le[2*ye.heap[ye.heap_max]+1]=0,Ue=ye.heap_max+1;Ue<y;Ue++)ke<(Ye=Le[2*Le[2*(Ge=ye.heap[Ue])+1]+1]+1)&&(Ye=ke,De++),Le[2*Ge+1]=Ye,Ke<Ge||(ye.bl_count[Ye]++,oe=0,ee<=Ge&&(oe=ce[Ge-ee]),ve=Le[2*Ge],ye.opt_len+=ve*(Ye+oe),_e&&(ye.static_len+=ve*(lt[2*Ge+1]+oe)));if(De!==0){do{for(Ye=ke-1;ye.bl_count[Ye]===0;)Ye--;ye.bl_count[Ye]--,ye.bl_count[Ye+1]+=2,ye.bl_count[ke]--,De-=2}while(0<De);for(Ye=ke;Ye!==0;Ye--)for(Ge=ye.bl_count[Ye];Ge!==0;)Ke<(We=ye.heap[--Ue])||(Le[2*We+1]!==Ye&&(ye.opt_len+=(Ye-Le[2*We+1])*Le[2*We],Le[2*We+1]=Ye),Ge--)}})(Q,le),xe($,Se,Q.bl_count)}function H(Q,le,Pe){var Oe,je,$=-1,I=le[1],V=0,ie=7,Se=4;for(I===0&&(ie=138,Se=3),le[2*(Pe+1)+1]=65535,Oe=0;Oe<=Pe;Oe++)je=I,I=le[2*(Oe+1)+1],++V<ie&&je===I||(V<Se?Q.bl_tree[2*je]+=V:je!==0?(je!==$&&Q.bl_tree[2*je]++,Q.bl_tree[2*T]++):V<=10?Q.bl_tree[2*E]++:Q.bl_tree[2*k]++,$=je,Se=(V=0)===I?(ie=138,3):je===I?(ie=6,3):(ie=7,4))}function B(Q,le,Pe){var Oe,je,$=-1,I=le[1],V=0,ie=7,Se=4;for(I===0&&(ie=138,Se=3),Oe=0;Oe<=Pe;Oe++)if(je=I,I=le[2*(Oe+1)+1],!(++V<ie&&je===I)){if(V<Se)for(;de(Q,je,Q.bl_tree),--V!=0;);else je!==0?(je!==$&&(de(Q,je,Q.bl_tree),V--),de(Q,T,Q.bl_tree),ae(Q,V-3,2)):V<=10?(de(Q,E,Q.bl_tree),ae(Q,V-3,3)):(de(Q,k,Q.bl_tree),ae(Q,V-11,7));$=je,Se=(V=0)===I?(ie=138,3):je===I?(ie=6,3):(ie=7,4)}}c(te);var X=!1;function U(Q,le,Pe,Oe){ae(Q,(u<<1)+(Oe?1:0),3),(function(je,$,I,V){fe(je),se(je,I),se(je,~I),s.arraySet(je.pending_buf,je.window,$,I,je.pending),je.pending+=I})(Q,le,Pe)}i._tr_init=function(Q){X||((function(){var le,Pe,Oe,je,$,I=new Array(b+1);for(je=Oe=0;je<d-1;je++)for(G[je]=Oe,le=0;le<1<<C[je];le++)j[Oe++]=je;for(j[Oe-1]=je,je=$=0;je<16;je++)for(te[je]=$,le=0;le<1<<D[je];le++)q[$++]=je;for($>>=7;je<g;je++)for(te[je]=$<<7,le=0;le<1<<D[je]-7;le++)q[256+$++]=je;for(Pe=0;Pe<=b;Pe++)I[Pe]=0;for(le=0;le<=143;)F[2*le+1]=8,le++,I[8]++;for(;le<=255;)F[2*le+1]=9,le++,I[9]++;for(;le<=279;)F[2*le+1]=7,le++,I[7]++;for(;le<=287;)F[2*le+1]=8,le++,I[8]++;for(xe(F,m+1,I),le=0;le<g;le++)O[2*le+1]=5,O[2*le]=me(le,5);Y=new ne(F,C,f+1,m,b),K=new ne(O,D,0,g,b),Z=new ne(new Array(0),A,0,x,N)})(),X=!0),Q.l_desc=new z(Q.dyn_ltree,Y),Q.d_desc=new z(Q.dyn_dtree,K),Q.bl_desc=new z(Q.bl_tree,Z),Q.bi_buf=0,Q.bi_valid=0,be(Q)},i._tr_stored_block=U,i._tr_flush_block=function(Q,le,Pe,Oe){var je,$,I=0;0<Q.level?(Q.strm.data_type===2&&(Q.strm.data_type=(function(V){var ie,Se=4093624447;for(ie=0;ie<=31;ie++,Se>>>=1)if(1&Se&&V.dyn_ltree[2*ie]!==0)return o;if(V.dyn_ltree[18]!==0||V.dyn_ltree[20]!==0||V.dyn_ltree[26]!==0)return l;for(ie=32;ie<f;ie++)if(V.dyn_ltree[2*ie]!==0)return l;return o})(Q)),He(Q,Q.l_desc),He(Q,Q.d_desc),I=(function(V){var ie;for(H(V,V.dyn_ltree,V.l_desc.max_code),H(V,V.dyn_dtree,V.d_desc.max_code),He(V,V.bl_desc),ie=x-1;3<=ie&&V.bl_tree[2*R[ie]+1]===0;ie--);return V.opt_len+=3*(ie+1)+5+5+4,ie})(Q),je=Q.opt_len+3+7>>>3,($=Q.static_len+3+7>>>3)<=je&&(je=$)):je=$=Pe+5,Pe+4<=je&&le!==-1?U(Q,le,Pe,Oe):Q.strategy===4||$===je?(ae(Q,2+(Oe?1:0),3),re(Q,F,O)):(ae(Q,4+(Oe?1:0),3),(function(V,ie,Se,ye){var $e;for(ae(V,ie-257,5),ae(V,Se-1,5),ae(V,ye-4,4),$e=0;$e<ye;$e++)ae(V,V.bl_tree[2*R[$e]+1],3);B(V,V.dyn_ltree,ie-1),B(V,V.dyn_dtree,Se-1)})(Q,Q.l_desc.max_code+1,Q.d_desc.max_code+1,I+1),re(Q,Q.dyn_ltree,Q.dyn_dtree)),be(Q),Oe&&fe(Q)},i._tr_tally=function(Q,le,Pe){return Q.pending_buf[Q.d_buf+2*Q.last_lit]=le>>>8&255,Q.pending_buf[Q.d_buf+2*Q.last_lit+1]=255&le,Q.pending_buf[Q.l_buf+Q.last_lit]=255&Pe,Q.last_lit++,le===0?Q.dyn_ltree[2*Pe]++:(Q.matches++,le--,Q.dyn_ltree[2*(j[Pe]+f+1)]++,Q.dyn_dtree[2*W(le)]++),Q.last_lit===Q.lit_bufsize-1},i._tr_align=function(Q){ae(Q,2,3),de(Q,S,F),(function(le){le.bi_valid===16?(se(le,le.bi_buf),le.bi_buf=0,le.bi_valid=0):8<=le.bi_valid&&(le.pending_buf[le.pending++]=255&le.bi_buf,le.bi_buf>>=8,le.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(s){(function(o,l){if(!o.setImmediate){var c,u,d,f,m=1,g={},x=!1,y=o.document,b=Object.getPrototypeOf&&Object.getPrototypeOf(o);b=b&&b.setTimeout?b:o,c={}.toString.call(o.process)==="[object process]"?function(T){process.nextTick(function(){N(T)})}:(function(){if(o.postMessage&&!o.importScripts){var T=!0,E=o.onmessage;return o.onmessage=function(){T=!1},o.postMessage("","*"),o.onmessage=E,T}})()?(f="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",S,!1):o.attachEvent("onmessage",S),function(T){o.postMessage(f+T,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(T){N(T.data)},function(T){d.port2.postMessage(T)}):y&&"onreadystatechange"in y.createElement("script")?(u=y.documentElement,function(T){var E=y.createElement("script");E.onreadystatechange=function(){N(T),E.onreadystatechange=null,u.removeChild(E),E=null},u.appendChild(E)}):function(T){setTimeout(N,0,T)},b.setImmediate=function(T){typeof T!="function"&&(T=new Function(""+T));for(var E=new Array(arguments.length-1),k=0;k<E.length;k++)E[k]=arguments[k+1];var C={callback:T,args:E};return g[m]=C,c(m),m++},b.clearImmediate=v}function v(T){delete g[T]}function N(T){if(x)setTimeout(N,0,T);else{var E=g[T];if(E){x=!0;try{(function(k){var C=k.callback,D=k.args;switch(D.length){case 0:C();break;case 1:C(D[0]);break;case 2:C(D[0],D[1]);break;case 3:C(D[0],D[1],D[2]);break;default:C.apply(l,D)}})(E)}finally{v(T),x=!1}}}}function S(T){T.source===o&&typeof T.data=="string"&&T.data.indexOf(f)===0&&N(+T.data.slice(f.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof n_<"u"?n_:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(nk)),nk.exports}var YOe=XOe();const QOe=Uo(YOe);function ZOe(t){const e=new Ci;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 vV=ZOe;async function _V(t,e=0){const n=[],r=t.getElementsByTagName("mesh");for(let i=0;i<r.length;i++){const s=r[i],o=[],l=[],c=s.getElementsByTagName("vertex");for(let d=0;d<c.length;d++){const f=c[d];o.push(parseFloat(f.getAttribute("x")||"0"),parseFloat(f.getAttribute("y")||"0"),parseFloat(f.getAttribute("z")||"0"))}const u=s.getElementsByTagName("triangle");for(let d=0;d<u.length;d++){const f=u[d];l.push(parseInt(f.getAttribute("v1")||"0"),parseInt(f.getAttribute("v2")||"0"),parseInt(f.getAttribute("v3")||"0"))}o.length>0&&l.length>0&&n.push({vertices:o,triangles:l,extruder:e})}return n}async function JOe(t){const e=await QOe.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function s(g){const x=g.startsWith("/")?g.slice(1):g,y=e.files[x];if(!y)return null;const b=await y.async("string");return i.parseFromString(b,"application/xml")}const o=new Map,l=new Map,c=e.files["Metadata/model_settings.config"];if(c)try{const g=await c.async("string"),y=i.parseFromString(g,"application/xml").getElementsByTagName("object");for(let b=0;b<y.length;b++){const v=y[b],N=v.getAttribute("id");if(!N)continue;const S=Array.from(v.children).filter(E=>E.tagName==="metadata"&&E.getAttribute("key")==="extruder");if(S.length>0){const E=S[0].getAttribute("value");E&&o.set(N,Math.max(0,parseInt(E,10)-1))}const T=v.getElementsByTagName("part");for(let E=0;E<T.length;E++){const k=T[E],C=k.getAttribute("id");if(!C)continue;const D=Array.from(k.children).filter(A=>A.tagName==="metadata"&&A.getAttribute("key")==="extruder");if(D.length>0){const A=D[0].getAttribute("value");A&&l.set(`${N}:${C}`,Math.max(0,parseInt(A,10)-1))}}}}catch{}const u=Object.keys(e.files).find(g=>g==="3D/3dmodel.model"||g.endsWith("/3dmodel.model"));if(!u){const g=Object.keys(e.files).find(x=>x.endsWith(".model"));if(g){const x=await s(g);if(x){const y=await _V(x,0);y.length>0&&n.set("1",{id:"1",meshes:y,defaultExtruder:0})}}return{objects:n,buildItems:r}}const d=await s(u);if(!d)return{objects:n,buildItems:r};const f=d.getElementsByTagName("object");for(let g=0;g<f.length;g++){const x=f[g],y=x.getAttribute("id");if(!y)continue;let b=o.get(y)??-1;if(b<0){const T=x.getAttribute("p:extruder")||x.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";b=Math.max(0,parseInt(T,10)-1)}const v=[],N=x.getElementsByTagName("mesh");for(let T=0;T<N.length;T++){const E=N[T],k=[],C=[],D=E.getElementsByTagName("vertex");for(let R=0;R<D.length;R++){const F=D[R];k.push(parseFloat(F.getAttribute("x")||"0"),parseFloat(F.getAttribute("y")||"0"),parseFloat(F.getAttribute("z")||"0"))}const A=E.getElementsByTagName("triangle");for(let R=0;R<A.length;R++){const F=A[R];C.push(parseInt(F.getAttribute("v1")||"0"),parseInt(F.getAttribute("v2")||"0"),parseInt(F.getAttribute("v3")||"0"))}k.length>0&&C.length>0&&v.push({vertices:k,triangles:C,extruder:b})}const S=x.getElementsByTagName("component");for(let T=0;T<S.length;T++){const E=S[T],k=E.getAttribute("p:path")||E.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),C=E.getAttribute("objectid");if(k){const D=await s(k);if(D){const A=C?`${y}:${C}`:null,R=A?l.get(A)??b:b,F=await _V(D,R),O=E.getAttribute("transform"),q=vV(O);for(const j of F)if(O){const G=[];for(let Y=0;Y<j.vertices.length;Y+=3){const K=new ot(j.vertices[Y],j.vertices[Y+1],j.vertices[Y+2]);K.applyMatrix4(q),G.push(K.x,K.y,K.z)}v.push({vertices:G,triangles:j.triangles,extruder:j.extruder})}else v.push(j)}}}v.length>0&&n.set(y,{id:y,meshes:v,defaultExtruder:b})}const m=d.getElementsByTagName("build");if(m.length>0){const g=m[0].getElementsByTagName("item");for(let x=0;x<g.length;x++){const y=g[x],b=y.getAttribute("objectid");if(!b)continue;const v=vV(y.getAttribute("transform"));r.push({objectId:b,transform:v})}}return{objects:n,buildItems:r}}function wV(t){const e=new ec,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 ko(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function eLe({url:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=w.useRef(null),s=w.useRef(null),o=w.useRef(null),l=w.useRef(null),c=w.useRef(null),[u,d]=w.useState(!0),[f,m]=w.useState(null);w.useEffect(()=>{if(!i.current)return;const y=i.current,b=y.clientWidth,v=y.clientHeight,N=new j3e;N.background=new Rn(1710618),o.current=N;const S=new So(45,b/v,.1,1e4);S.position.set(150,150,150),l.current=S;const T=new ROe({antialias:!0});T.setSize(b,v),T.setPixelRatio(window.devicePixelRatio),y.appendChild(T.domElement),s.current=T;const E=new OOe(S,T.domElement);E.enableDamping=!0,E.dampingFactor=.05,c.current=E;const k=new H3e(16777215,.6);N.add(k);const C=new VH(16777215,.8);C.position.set(100,100,100),N.add(C);const D=new VH(16777215,.4);D.position.set(-100,50,-100),N.add(D);const A=Math.max(e.x,e.y),R=Math.ceil(A/16),F=new G3e(A,R,4473924,3355443);N.add(F);const O=new LO(e.x,e.y),q=new RO({color:44610,transparent:!0,opacity:.15,side:Al}),j=new ql(O,q);j.rotation.x=-Math.PI/2,j.position.y=-.5,N.add(j);let G;const Y=()=>{G=requestAnimationFrame(Y),E.update(),T.render(N,S)};Y(),fetch(t).then(Z=>{if(!Z.ok)throw new Error("Failed to load file");return Z.arrayBuffer()}).then(JOe).then(({objects:Z,buildItems:te})=>{if(Z.size===0)throw new Error("No meshes found in 3MF file");const ne=Ce=>{const re=n?.[Ce]||"#00ae42",He=new Rn(re);return new F3e({color:He,shininess:30,flatShading:!1})},z=new jb,W=new Map;if(te.length>0)for(const Ce of te){const Ne=Z.get(Ce.objectId);if(Ne)for(const re of Ne.meshes){const He=Ce.extruder??re.extruder,H=[];for(let X=0;X<re.vertices.length;X+=3){const U=new ot(re.vertices[X],re.vertices[X+1],re.vertices[X+2]);U.applyMatrix4(Ce.transform),H.push(U.x,U.y,U.z)}const B=wV({vertices:H,triangles:re.triangles});W.has(He)||W.set(He,[]),W.get(He).push(B)}}else for(const Ce of Z.values())for(const Ne of Ce.meshes){const re=Ne.extruder,He=wV(Ne);W.has(re)||W.set(re,[]),W.get(re).push(He)}for(const[Ce,Ne]of W){if(Ne.length===0)continue;const re=Ne.length===1?Ne[0]:KOe(Ne,!1);if(re){const He=ne(Ce),H=new ql(re,He);z.add(H)}if(Ne.length>1)for(const He of Ne)He.dispose()}const se=new Kf().setFromObject(z),ae=se.getCenter(new ot);z.position.y=-se.min.y,te.length===0&&(z.position.x=-ae.x,z.position.z=-ae.z),N.add(z);const de=new Kf().setFromObject(z),me=de.getCenter(new ot),xe=de.getSize(new ot),fe=Math.max(xe.x,xe.y,xe.z)*1.8;S.position.set(me.x+fe*.7,me.y+fe*.5,me.z+fe*.7),E.target.copy(me),E.update(),d(!1)}).catch(Z=>{m(Z.message),d(!1)});const K=()=>{if(!y)return;const Z=y.clientWidth,te=y.clientHeight;S.aspect=Z/te,S.updateProjectionMatrix(),T.setSize(Z,te)};return window.addEventListener("resize",K),()=>{window.removeEventListener("resize",K),cancelAnimationFrame(G),E.dispose(),T.dispose(),y.removeChild(T.domElement)}},[t,e,n]);const g=()=>{l.current&&c.current&&(l.current.position.set(150,150,150),c.current.target.set(0,50,0),c.current.update())},x=y=>{l.current&&l.current.position.multiplyScalar(y)};return a.jsxs("div",{className:`relative ${r}`,children:[a.jsx("div",{ref:i,className:"w-full h-full min-h-[400px]"}),u&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsx(ut,{className:"w-8 h-8 text-bambu-green animate-spin"})}),f&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsx("p",{className:"text-red-400",children:f})}),!u&&!f&&a.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[a.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>x(.8),children:a.jsx(xD,{className:"w-4 h-4"})}),a.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>x(1.25),children:a.jsx(bD,{className:"w-4 h-4"})}),a.jsx(Te,{variant:"secondary",size:"sm",onClick:g,children:a.jsx(rm,{className:"w-4 h-4"})})]})]})}const qN="159",op={ROTATE:0,DOLLY:1,PAN:2},lp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},tLe=0,SV=1,nLe=2,SJ=1,rLe=2,Lc=3,nh=0,ws=1,Hc=2,Id=0,tg=1,NV=2,MV=3,EV=4,iLe=5,ef=100,aLe=101,sLe=102,TV=103,CV=104,oLe=200,lLe=201,cLe=202,uLe=203,KP=204,XP=205,dLe=206,hLe=207,fLe=208,mLe=209,pLe=210,gLe=211,xLe=212,bLe=213,yLe=214,vLe=0,_Le=1,wLe=2,CS=3,SLe=4,NLe=5,MLe=6,ELe=7,FO=0,TLe=1,CLe=2,Fd=0,ALe=1,kLe=2,jLe=3,PLe=4,RLe=5,NJ=300,Ng=301,Mg=302,YP=303,QP=304,WN=306,ZP=1e3,tl=1001,JP=1002,va=1003,AV=1004,rk=1005,No=1006,DLe=1007,B0=1008,Ud=1009,OLe=1010,LLe=1011,UO=1012,MJ=1013,Ed=1014,Xc=1015,$0=1016,EJ=1017,TJ=1018,Sf=1020,ILe=1021,Mo=1023,FLe=1024,ULe=1025,Nf=1026,Eg=1027,zLe=1028,CJ=1029,BLe=1030,AJ=1031,kJ=1033,ik=33776,ak=33777,sk=33778,ok=33779,kV=35840,jV=35841,PV=35842,RV=35843,jJ=36196,DV=37492,OV=37496,LV=37808,IV=37809,FV=37810,UV=37811,zV=37812,BV=37813,$V=37814,HV=37815,VV=37816,GV=37817,qV=37818,WV=37819,KV=37820,XV=37821,lk=36492,YV=36494,QV=36495,$Le=36283,ZV=36284,JV=36285,e7=36286,PJ=3e3,Mf=3001,HLe=3200,VLe=3201,RJ=0,GLe=1,Eo="",_a="srgb",bu="srgb-linear",zO="display-p3",KN="display-p3-linear",AS="linear",Dr="srgb",kS="rec709",jS="p3",cp=7680,t7=519,qLe=512,WLe=513,KLe=514,DJ=515,XLe=516,YLe=517,QLe=518,ZLe=519,eR=35044,n7="300 es",tR=1035,Dl=2e3,H0=2001;class lm{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){if(this._listeners===void 0)return!1;const r=this._listeners;return r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(n);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const r=this._listeners[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}}const ka=["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 r7=1234567;const Gb=Math.PI/180,V0=180/Math.PI;function ru(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(ka[t&255]+ka[t>>8&255]+ka[t>>16&255]+ka[t>>24&255]+"-"+ka[e&255]+ka[e>>8&255]+"-"+ka[e>>16&15|64]+ka[e>>24&255]+"-"+ka[n&63|128]+ka[n>>8&255]+"-"+ka[n>>16&255]+ka[n>>24&255]+ka[r&255]+ka[r>>8&255]+ka[r>>16&255]+ka[r>>24&255]).toLowerCase()}function wa(t,e,n){return Math.max(e,Math.min(n,t))}function BO(t,e){return(t%e+e)%e}function JLe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function eIe(t,e,n){return t!==e?(n-t)/(e-t):0}function qb(t,e,n){return(1-n)*t+n*e}function tIe(t,e,n,r){return qb(t,e,1-Math.exp(-n*r))}function nIe(t,e=1){return e-Math.abs(BO(t,e*2)-e)}function rIe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function iIe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function aIe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function sIe(t,e){return t+Math.random()*(e-t)}function oIe(t){return t*(.5-Math.random())}function lIe(t){t!==void 0&&(r7=t);let e=r7+=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 cIe(t){return t*Gb}function uIe(t){return t*V0}function nR(t){return(t&t-1)===0&&t!==0}function dIe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function PS(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function hIe(t,e,n,r,i){const s=Math.cos,o=Math.sin,l=s(n/2),c=o(n/2),u=s((e+r)/2),d=o((e+r)/2),f=s((e-r)/2),m=o((e-r)/2),g=s((r-e)/2),x=o((r-e)/2);switch(i){case"XYX":t.set(l*d,c*f,c*m,l*u);break;case"YZY":t.set(c*m,l*d,c*f,l*u);break;case"ZXZ":t.set(c*f,c*m,l*d,l*u);break;case"XZX":t.set(l*d,c*x,c*g,l*u);break;case"YXY":t.set(c*g,l*d,c*x,l*u);break;case"ZYZ":t.set(c*x,c*g,l*d,l*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function kl(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 gr(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 OJ={DEG2RAD:Gb,RAD2DEG:V0,generateUUID:ru,clamp:wa,euclideanModulo:BO,mapLinear:JLe,inverseLerp:eIe,lerp:qb,damp:tIe,pingpong:nIe,smoothstep:rIe,smootherstep:iIe,randInt:aIe,randFloat:sIe,randFloatSpread:oIe,seededRandom:lIe,degToRad:cIe,radToDeg:uIe,isPowerOfTwo:nR,ceilPowerOfTwo:dIe,floorPowerOfTwo:PS,setQuaternionFromProperEuler:hIe,normalize:gr,denormalize:kl};class pn{constructor(e=0,n=0){pn.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(wa(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),s=this.x-e.x,o=this.y-e.y;return this.x=s*r-o*i+e.x,this.y=s*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class An{constructor(e,n,r,i,s,o,l,c,u){An.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,o,l,c,u)}set(e,n,r,i,s,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=s,d[5]=c,d[6]=r,d[7]=o,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],m=r[2],g=r[5],x=r[8],y=i[0],b=i[3],v=i[6],N=i[1],S=i[4],T=i[7],E=i[2],k=i[5],C=i[8];return s[0]=o*y+l*N+c*E,s[3]=o*b+l*S+c*k,s[6]=o*v+l*T+c*C,s[1]=u*y+d*N+f*E,s[4]=u*b+d*S+f*k,s[7]=u*v+d*T+f*C,s[2]=m*y+g*N+x*E,s[5]=m*b+g*S+x*k,s[8]=m*v+g*T+x*C,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*s*d+r*l*c+i*s*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,m=l*c-d*s,g=u*s-o*c,x=n*f+r*m+i*g;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/x;return e[0]=f*y,e[1]=(i*u-d*r)*y,e[2]=(l*r-i*o)*y,e[3]=m*y,e[4]=(d*n-i*c)*y,e[5]=(i*s-l*n)*y,e[6]=g*y,e[7]=(r*c-u*n)*y,e[8]=(o*n-r*s)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,s,o,l){const c=Math.cos(s),u=Math.sin(s);return this.set(r*c,r*u,-r*(c*o+u*l)+o+e,-i*u,i*c,-i*(-u*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(ck.makeScale(e,n)),this}rotate(e){return this.premultiply(ck.makeRotation(-e)),this}translate(e,n){return this.premultiply(ck.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 ck=new An;function LJ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function RS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function fIe(){const t=RS("canvas");return t.style.display="block",t}const i7={};function Wb(t){t in i7||(i7[t]=!0,console.warn(t))}const a7=new An().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),s7=new An().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),X_={[bu]:{transfer:AS,primaries:kS,toReference:t=>t,fromReference:t=>t},[_a]:{transfer:Dr,primaries:kS,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[KN]:{transfer:AS,primaries:jS,toReference:t=>t.applyMatrix3(s7),fromReference:t=>t.applyMatrix3(a7)},[zO]:{transfer:Dr,primaries:jS,toReference:t=>t.convertSRGBToLinear().applyMatrix3(s7),fromReference:t=>t.applyMatrix3(a7).convertLinearToSRGB()}},mIe=new Set([bu,KN]),xr={enabled:!0,_workingColorSpace:bu,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(!mIe.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=X_[e].toReference,i=X_[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 X_[t].primaries},getTransfer:function(t){return t===Eo?AS:X_[t].transfer}};function ng(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function uk(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let up;class IJ{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{up===void 0&&(up=RS("canvas")),up.width=e.width,up.height=e.height;const r=up.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=up}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=RS("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=ng(s[o]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(ng(n[r]/255)*255):n[r]=ng(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 pIe=0;class FJ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:pIe++}),this.uuid=ru(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,l=i.length;o<l;o++)i[o].isDataTexture?s.push(dk(i[o].image)):s.push(dk(i[o]))}else s=dk(i);r.url=s}return n||(e.images[this.uuid]=r),r}}function dk(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?IJ.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 gIe=0;class Ss extends lm{constructor(e=Ss.DEFAULT_IMAGE,n=Ss.DEFAULT_MAPPING,r=tl,i=tl,s=No,o=B0,l=Mo,c=Ud,u=Ss.DEFAULT_ANISOTROPY,d=Eo){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:gIe++}),this.uuid=ru(),this.name="",this.source=new FJ(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new pn(0,0),this.repeat=new pn(1,1),this.center=new pn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new An,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(Wb("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===Mf?_a:Eo),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!==NJ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case ZP:e.x=e.x-Math.floor(e.x);break;case tl:e.x=e.x<0?0:1;break;case JP:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case ZP:e.y=e.y-Math.floor(e.y);break;case tl:e.y=e.y<0?0:1;break;case JP:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return Wb("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===_a?Mf:PJ}set encoding(e){Wb("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Mf?_a:Eo}}Ss.DEFAULT_IMAGE=null;Ss.DEFAULT_MAPPING=NJ;Ss.DEFAULT_ANISOTROPY=1;class yr{constructor(e=0,n=0,r=0,i=1){yr.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*s,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*s,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*s,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,s;const c=e.elements,u=c[0],d=c[4],f=c[8],m=c[1],g=c[5],x=c[9],y=c[2],b=c[6],v=c[10];if(Math.abs(d-m)<.01&&Math.abs(f-y)<.01&&Math.abs(x-b)<.01){if(Math.abs(d+m)<.1&&Math.abs(f+y)<.1&&Math.abs(x+b)<.1&&Math.abs(u+g+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const S=(u+1)/2,T=(g+1)/2,E=(v+1)/2,k=(d+m)/4,C=(f+y)/4,D=(x+b)/4;return S>T&&S>E?S<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(S),i=k/r,s=C/r):T>E?T<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(T),r=k/i,s=D/i):E<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(E),r=C/s,i=D/s),this.set(r,i,s,n),this}let N=Math.sqrt((b-x)*(b-x)+(f-y)*(f-y)+(m-d)*(m-d));return Math.abs(N)<.001&&(N=1),this.x=(b-x)/N,this.y=(f-y)/N,this.z=(m-d)/N,this.w=Math.acos((u+g+v-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class xIe extends lm{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new yr(0,0,e,n),this.scissorTest=!1,this.viewport=new yr(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(Wb("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Mf?_a:Eo),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:No,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new Ss(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 FJ(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 Xf extends xIe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class UJ extends Ss{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=va,this.minFilter=va,this.wrapR=tl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class bIe extends Ss{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=va,this.minFilter=va,this.wrapR=tl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Yf{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,s,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3];const m=s[o+0],g=s[o+1],x=s[o+2],y=s[o+3];if(l===0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l===1){e[n+0]=m,e[n+1]=g,e[n+2]=x,e[n+3]=y;return}if(f!==y||c!==m||u!==g||d!==x){let b=1-l;const v=c*m+u*g+d*x+f*y,N=v>=0?1:-1,S=1-v*v;if(S>Number.EPSILON){const E=Math.sqrt(S),k=Math.atan2(E,v*N);b=Math.sin(b*k)/E,l=Math.sin(l*k)/E}const T=l*N;if(c=c*b+m*T,u=u*b+g*T,d=d*b+x*T,f=f*b+y*T,b===1-l){const E=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=E,u*=E,d*=E,f*=E}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,s,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=s[o],m=s[o+1],g=s[o+2],x=s[o+3];return e[n]=l*x+d*f+c*g-u*m,e[n+1]=c*x+d*m+u*f-l*g,e[n+2]=u*x+d*g+l*m-c*f,e[n+3]=d*x-l*f-c*m-u*g,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){const r=e._x,i=e._y,s=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(s/2),m=c(r/2),g=c(i/2),x=c(s/2);switch(o){case"XYZ":this._x=m*d*f+u*g*x,this._y=u*g*f-m*d*x,this._z=u*d*x+m*g*f,this._w=u*d*f-m*g*x;break;case"YXZ":this._x=m*d*f+u*g*x,this._y=u*g*f-m*d*x,this._z=u*d*x-m*g*f,this._w=u*d*f+m*g*x;break;case"ZXY":this._x=m*d*f-u*g*x,this._y=u*g*f+m*d*x,this._z=u*d*x+m*g*f,this._w=u*d*f-m*g*x;break;case"ZYX":this._x=m*d*f-u*g*x,this._y=u*g*f+m*d*x,this._z=u*d*x-m*g*f,this._w=u*d*f+m*g*x;break;case"YZX":this._x=m*d*f+u*g*x,this._y=u*g*f+m*d*x,this._z=u*d*x-m*g*f,this._w=u*d*f-m*g*x;break;case"XZY":this._x=m*d*f-u*g*x,this._y=u*g*f-m*d*x,this._z=u*d*x+m*g*f,this._w=u*d*f+m*g*x;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return n!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],s=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],m=r+l+f;if(m>0){const g=.5/Math.sqrt(m+1);this._w=.25/g,this._x=(d-c)*g,this._y=(s-u)*g,this._z=(o-i)*g}else if(r>l&&r>f){const g=2*Math.sqrt(1+r-l-f);this._w=(d-c)/g,this._x=.25*g,this._y=(i+o)/g,this._z=(s+u)/g}else if(l>f){const g=2*Math.sqrt(1+l-r-f);this._w=(s-u)/g,this._x=(i+o)/g,this._y=.25*g,this._z=(c+d)/g}else{const g=2*Math.sqrt(1+f-r-l);this._w=(o-i)/g,this._x=(s+u)/g,this._y=(c+d)/g,this._z=.25*g}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(wa(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,s=e._z,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-s*c,this._y=i*d+o*c+s*l-r*u,this._z=s*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-s*u,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,s=this._z,o=this._w;let l=o*e._w+r*e._x+i*e._y+s*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=o,this._x=r,this._y=i,this._z=s,this;const c=1-l*l;if(c<=Number.EPSILON){const g=1-n;return this._w=g*o+n*this._w,this._x=g*r+n*this._x,this._y=g*i+n*this._y,this._z=g*s+n*this._z,this.normalize(),this._onChangeCallback(),this}const u=Math.sqrt(c),d=Math.atan2(u,l),f=Math.sin((1-n)*d)/u,m=Math.sin(n*d)/u;return this._w=o*f+this._w*m,this._x=r*f+this._x*m,this._y=i*f+this._y*m,this._z=s*f+this._z*m,this._onChangeCallback(),this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=Math.random(),n=Math.sqrt(1-e),r=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(n*Math.cos(i),r*Math.sin(s),r*Math.cos(s),n*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class qe{constructor(e=0,n=0,r=0){qe.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(o7.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(o7.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[3]*r+s[6]*i,this.y=s[1]*n+s[4]*r+s[7]*i,this.z=s[2]*n+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=e.elements,o=1/(s[3]*n+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*n+s[4]*r+s[8]*i+s[12])*o,this.y=(s[1]*n+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*n+s[6]*r+s[10]*i+s[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,s=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-s*i),f=2*(s*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-s*f,this.z=i+c*f+s*d-o*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i,this.y=s[1]*n+s[5]*r+s[9]*i,this.z=s[2]*n+s[6]*r+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,s=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-s*l,this.y=s*o-r*c,this.z=r*l-i*o,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return hk.copy(this).projectOnVector(e),this.sub(hk)}reflect(e){return this.sub(hk.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(wa(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 hk=new qe,o7=new Yf;class jo{constructor(e=new qe(1/0,1/0,1/0),n=new qe(-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(Ko.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Ko.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=Ko.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const s=r.getAttribute("position");if(n===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,l=s.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,Ko):Ko.fromBufferAttribute(s,o),Ko.applyMatrix4(e.matrixWorld),this.expandByPoint(Ko);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Y_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Y_.copy(r.boundingBox)),Y_.applyMatrix4(e.matrixWorld),this.union(Y_)}const i=e.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],n);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Ko),Ko.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(xb),Q_.subVectors(this.max,xb),dp.subVectors(e.a,xb),hp.subVectors(e.b,xb),fp.subVectors(e.c,xb),td.subVectors(hp,dp),nd.subVectors(fp,hp),Bh.subVectors(dp,fp);let n=[0,-td.z,td.y,0,-nd.z,nd.y,0,-Bh.z,Bh.y,td.z,0,-td.x,nd.z,0,-nd.x,Bh.z,0,-Bh.x,-td.y,td.x,0,-nd.y,nd.x,0,-Bh.y,Bh.x,0];return!fk(n,dp,hp,fp,Q_)||(n=[1,0,0,0,1,0,0,0,1],!fk(n,dp,hp,fp,Q_))?!1:(Z_.crossVectors(td,nd),n=[Z_.x,Z_.y,Z_.z],fk(n,dp,hp,fp,Q_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ko).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ko).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:(Ec[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ec[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ec[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ec[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ec[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ec[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ec[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ec[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ec),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 Ec=[new qe,new qe,new qe,new qe,new qe,new qe,new qe,new qe],Ko=new qe,Y_=new jo,dp=new qe,hp=new qe,fp=new qe,td=new qe,nd=new qe,Bh=new qe,xb=new qe,Q_=new qe,Z_=new qe,$h=new qe;function fk(t,e,n,r,i){for(let s=0,o=t.length-3;s<=o;s+=3){$h.fromArray(t,s);const l=i.x*Math.abs($h.x)+i.y*Math.abs($h.y)+i.z*Math.abs($h.z),c=e.dot($h),u=n.dot($h),d=r.dot($h);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const yIe=new jo,bb=new qe,mk=new qe;class Il{constructor(e=new qe,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):yIe.setFromPoints(e).getCenter(r);let i=0;for(let s=0,o=e.length;s<o;s++)i=Math.max(i,r.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;bb.subVectors(e,this.center);const n=bb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(bb,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):(mk.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(bb.copy(e.center).add(mk)),this.expandByPoint(bb.copy(e.center).sub(mk))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Tc=new qe,pk=new qe,J_=new qe,rd=new qe,gk=new qe,e1=new qe,xk=new qe;class $O{constructor(e=new qe,n=new qe(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,Tc)),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=Tc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Tc.copy(this.origin).addScaledVector(this.direction,n),Tc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){pk.copy(e).add(n).multiplyScalar(.5),J_.copy(n).sub(e).normalize(),rd.copy(this.origin).sub(pk);const s=e.distanceTo(n)*.5,o=-this.direction.dot(J_),l=rd.dot(this.direction),c=-rd.dot(J_),u=rd.lengthSq(),d=Math.abs(1-o*o);let f,m,g,x;if(d>0)if(f=o*c-l,m=o*l-c,x=s*d,f>=0)if(m>=-x)if(m<=x){const y=1/d;f*=y,m*=y,g=f*(f+o*m+2*l)+m*(o*f+m+2*c)+u}else m=s,f=Math.max(0,-(o*m+l)),g=-f*f+m*(m+2*c)+u;else m=-s,f=Math.max(0,-(o*m+l)),g=-f*f+m*(m+2*c)+u;else m<=-x?(f=Math.max(0,-(-o*s+l)),m=f>0?-s:Math.min(Math.max(-s,-c),s),g=-f*f+m*(m+2*c)+u):m<=x?(f=0,m=Math.min(Math.max(-s,-c),s),g=m*(m+2*c)+u):(f=Math.max(0,-(o*s+l)),m=f>0?s:Math.min(Math.max(-s,-c),s),g=-f*f+m*(m+2*c)+u);else m=o>0?-s:s,f=Math.max(0,-(o*m+l)),g=-f*f+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(pk).addScaledVector(J_,m),g}intersectSphere(e,n){Tc.subVectors(e.center,this.origin);const r=Tc.dot(this.direction),i=Tc.dot(Tc)-r*r,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-i),l=r-o,c=r+o;return c<0?null:l<0?this.at(c,n):this.at(l,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,s,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,m=this.origin;return u>=0?(r=(e.min.x-m.x)*u,i=(e.max.x-m.x)*u):(r=(e.max.x-m.x)*u,i=(e.min.x-m.x)*u),d>=0?(s=(e.min.y-m.y)*d,o=(e.max.y-m.y)*d):(s=(e.max.y-m.y)*d,o=(e.min.y-m.y)*d),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-m.z)*f,c=(e.max.z-m.z)*f):(l=(e.max.z-m.z)*f,c=(e.min.z-m.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Tc)!==null}intersectTriangle(e,n,r,i,s){gk.subVectors(n,e),e1.subVectors(r,e),xk.crossVectors(gk,e1);let o=this.direction.dot(xk),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;rd.subVectors(this.origin,e);const c=l*this.direction.dot(e1.crossVectors(rd,e1));if(c<0)return null;const u=l*this.direction.dot(gk.cross(rd));if(u<0||c+u>o)return null;const d=-l*rd.dot(xk);return d<0?null:this.at(d/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class kr{constructor(e,n,r,i,s,o,l,c,u,d,f,m,g,x,y,b){kr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,o,l,c,u,d,f,m,g,x,y,b)}set(e,n,r,i,s,o,l,c,u,d,f,m,g,x,y,b){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=s,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=f,v[14]=m,v[3]=g,v[7]=x,v[11]=y,v[15]=b,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new kr().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/mp.setFromMatrixColumn(e,0).length(),s=1/mp.setFromMatrixColumn(e,1).length(),o=1/mp.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*s,n[5]=r[5]*s,n[6]=r[6]*s,n[7]=0,n[8]=r[8]*o,n[9]=r[9]*o,n[10]=r[10]*o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,s=e.z,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const m=o*d,g=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=g+x*u,n[5]=m-y*u,n[9]=-l*c,n[2]=y-m*u,n[6]=x+g*u,n[10]=o*c}else if(e.order==="YXZ"){const m=c*d,g=c*f,x=u*d,y=u*f;n[0]=m+y*l,n[4]=x*l-g,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=g*l-x,n[6]=y+m*l,n[10]=o*c}else if(e.order==="ZXY"){const m=c*d,g=c*f,x=u*d,y=u*f;n[0]=m-y*l,n[4]=-o*f,n[8]=x+g*l,n[1]=g+x*l,n[5]=o*d,n[9]=y-m*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const m=o*d,g=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=x*u-g,n[8]=m*u+y,n[1]=c*f,n[5]=y*u+m,n[9]=g*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const m=o*c,g=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=y-m*f,n[8]=x*f+g,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=g*f+x,n[10]=m-y*f}else if(e.order==="XZY"){const m=o*c,g=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=m*f+y,n[5]=o*d,n[9]=g*f-x,n[2]=x*f-g,n[6]=l*d,n[10]=y*f+m}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(vIe,e,_Ie)}lookAt(e,n,r){const i=this.elements;return Us.subVectors(e,n),Us.lengthSq()===0&&(Us.z=1),Us.normalize(),id.crossVectors(r,Us),id.lengthSq()===0&&(Math.abs(r.z)===1?Us.x+=1e-4:Us.z+=1e-4,Us.normalize(),id.crossVectors(r,Us)),id.normalize(),t1.crossVectors(Us,id),i[0]=id.x,i[4]=t1.x,i[8]=Us.x,i[1]=id.y,i[5]=t1.y,i[9]=Us.y,i[2]=id.z,i[6]=t1.z,i[10]=Us.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],m=r[9],g=r[13],x=r[2],y=r[6],b=r[10],v=r[14],N=r[3],S=r[7],T=r[11],E=r[15],k=i[0],C=i[4],D=i[8],A=i[12],R=i[1],F=i[5],O=i[9],q=i[13],j=i[2],G=i[6],Y=i[10],K=i[14],Z=i[3],te=i[7],ne=i[11],z=i[15];return s[0]=o*k+l*R+c*j+u*Z,s[4]=o*C+l*F+c*G+u*te,s[8]=o*D+l*O+c*Y+u*ne,s[12]=o*A+l*q+c*K+u*z,s[1]=d*k+f*R+m*j+g*Z,s[5]=d*C+f*F+m*G+g*te,s[9]=d*D+f*O+m*Y+g*ne,s[13]=d*A+f*q+m*K+g*z,s[2]=x*k+y*R+b*j+v*Z,s[6]=x*C+y*F+b*G+v*te,s[10]=x*D+y*O+b*Y+v*ne,s[14]=x*A+y*q+b*K+v*z,s[3]=N*k+S*R+T*j+E*Z,s[7]=N*C+S*F+T*G+E*te,s[11]=N*D+S*O+T*Y+E*ne,s[15]=N*A+S*q+T*K+E*z,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],s=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],m=e[10],g=e[14],x=e[3],y=e[7],b=e[11],v=e[15];return x*(+s*c*f-i*u*f-s*l*m+r*u*m+i*l*g-r*c*g)+y*(+n*c*g-n*u*m+s*o*m-i*o*g+i*u*d-s*c*d)+b*(+n*u*f-n*l*g-s*o*f+r*o*g+s*l*d-r*u*d)+v*(-i*l*d-n*c*f+n*l*m+i*o*f-r*o*m+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],m=e[10],g=e[11],x=e[12],y=e[13],b=e[14],v=e[15],N=f*b*u-y*m*u+y*c*g-l*b*g-f*c*v+l*m*v,S=x*m*u-d*b*u-x*c*g+o*b*g+d*c*v-o*m*v,T=d*y*u-x*f*u+x*l*g-o*y*g-d*l*v+o*f*v,E=x*f*c-d*y*c-x*l*m+o*y*m+d*l*b-o*f*b,k=n*N+r*S+i*T+s*E;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/k;return e[0]=N*C,e[1]=(y*m*s-f*b*s-y*i*g+r*b*g+f*i*v-r*m*v)*C,e[2]=(l*b*s-y*c*s+y*i*u-r*b*u-l*i*v+r*c*v)*C,e[3]=(f*c*s-l*m*s-f*i*u+r*m*u+l*i*g-r*c*g)*C,e[4]=S*C,e[5]=(d*b*s-x*m*s+x*i*g-n*b*g-d*i*v+n*m*v)*C,e[6]=(x*c*s-o*b*s-x*i*u+n*b*u+o*i*v-n*c*v)*C,e[7]=(o*m*s-d*c*s+d*i*u-n*m*u-o*i*g+n*c*g)*C,e[8]=T*C,e[9]=(x*f*s-d*y*s-x*r*g+n*y*g+d*r*v-n*f*v)*C,e[10]=(o*y*s-x*l*s+x*r*u-n*y*u-o*r*v+n*l*v)*C,e[11]=(d*l*s-o*f*s-d*r*u+n*f*u+o*r*g-n*l*g)*C,e[12]=E*C,e[13]=(d*y*i-x*f*i+x*r*m-n*y*m-d*r*b+n*f*b)*C,e[14]=(x*l*i-o*y*i-x*r*c+n*y*c+o*r*b-n*l*b)*C,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*m+n*l*m)*C,this}scale(e){const n=this.elements,r=e.x,i=e.y,s=e.z;return n[0]*=r,n[4]*=i,n[8]*=s,n[1]*=r,n[5]*=i,n[9]*=s,n[2]*=r,n[6]*=i,n[10]*=s,n[3]*=r,n[7]*=i,n[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),s=1-r,o=e.x,l=e.y,c=e.z,u=s*o,d=s*l;return this.set(u*o+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*o,0,u*c-i*l,d*c+i*o,s*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,s,o){return this.set(1,r,s,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,s=n._x,o=n._y,l=n._z,c=n._w,u=s+s,d=o+o,f=l+l,m=s*u,g=s*d,x=s*f,y=o*d,b=o*f,v=l*f,N=c*u,S=c*d,T=c*f,E=r.x,k=r.y,C=r.z;return i[0]=(1-(y+v))*E,i[1]=(g+T)*E,i[2]=(x-S)*E,i[3]=0,i[4]=(g-T)*k,i[5]=(1-(m+v))*k,i[6]=(b+N)*k,i[7]=0,i[8]=(x+S)*C,i[9]=(b-N)*C,i[10]=(1-(m+y))*C,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let s=mp.set(i[0],i[1],i[2]).length();const o=mp.set(i[4],i[5],i[6]).length(),l=mp.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Xo.copy(this);const u=1/s,d=1/o,f=1/l;return Xo.elements[0]*=u,Xo.elements[1]*=u,Xo.elements[2]*=u,Xo.elements[4]*=d,Xo.elements[5]*=d,Xo.elements[6]*=d,Xo.elements[8]*=f,Xo.elements[9]*=f,Xo.elements[10]*=f,n.setFromRotationMatrix(Xo),r.x=s,r.y=o,r.z=l,this}makePerspective(e,n,r,i,s,o,l=Dl){const c=this.elements,u=2*s/(n-e),d=2*s/(r-i),f=(n+e)/(n-e),m=(r+i)/(r-i);let g,x;if(l===Dl)g=-(o+s)/(o-s),x=-2*o*s/(o-s);else if(l===H0)g=-o/(o-s),x=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return c[0]=u,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=d,c[9]=m,c[13]=0,c[2]=0,c[6]=0,c[10]=g,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,s,o,l=Dl){const c=this.elements,u=1/(n-e),d=1/(r-i),f=1/(o-s),m=(n+e)*u,g=(r+i)*d;let x,y;if(l===Dl)x=(o+s)*f,y=-2*f;else if(l===H0)x=s*f,y=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-m,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-g,c[2]=0,c[6]=0,c[10]=y,c[14]=-x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const mp=new qe,Xo=new kr,vIe=new qe(0,0,0),_Ie=new qe(1,1,1),id=new qe,t1=new qe,Us=new qe,l7=new kr,c7=new Yf;class Fy{constructor(e=0,n=0,r=0,i=Fy.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,s=i[0],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],m=i[6],g=i[10];switch(n){case"XYZ":this._y=Math.asin(wa(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,g),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(m,u),this._z=0);break;case"YXZ":this._x=Math.asin(-wa(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,g),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(wa(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-f,g),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-wa(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(m,g),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(wa(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(l,g));break;case"XZY":this._z=Math.asin(-wa(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(m,u),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-d,g),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 l7.makeRotationFromQuaternion(e),this.setFromRotationMatrix(l7,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return c7.setFromEuler(this),this.setFromQuaternion(c7,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}}Fy.DEFAULT_ORDER="XYZ";class zJ{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 wIe=0;const u7=new qe,pp=new Yf,Cc=new kr,n1=new qe,yb=new qe,SIe=new qe,NIe=new Yf,d7=new qe(1,0,0),h7=new qe(0,1,0),f7=new qe(0,0,1),MIe={type:"added"},EIe={type:"removed"};class Za extends lm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:wIe++}),this.uuid=ru(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Za.DEFAULT_UP.clone();const e=new qe,n=new Fy,r=new Yf,i=new qe(1,1,1);function s(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(s),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new kr},normalMatrix:{value:new An}}),this.matrix=new kr,this.matrixWorld=new kr,this.matrixAutoUpdate=Za.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Za.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new zJ,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 pp.setFromAxisAngle(e,n),this.quaternion.multiply(pp),this}rotateOnWorldAxis(e,n){return pp.setFromAxisAngle(e,n),this.quaternion.premultiply(pp),this}rotateX(e){return this.rotateOnAxis(d7,e)}rotateY(e){return this.rotateOnAxis(h7,e)}rotateZ(e){return this.rotateOnAxis(f7,e)}translateOnAxis(e,n){return u7.copy(e).applyQuaternion(this.quaternion),this.position.add(u7.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(d7,e)}translateY(e){return this.translateOnAxis(h7,e)}translateZ(e){return this.translateOnAxis(f7,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Cc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?n1.copy(e):n1.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),yb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Cc.lookAt(yb,n1,this.up):Cc.lookAt(n1,yb,this.up),this.quaternion.setFromRotationMatrix(Cc),i&&(Cc.extractRotation(i.matrixWorld),pp.setFromRotationMatrix(Cc),this.quaternion.premultiply(pp.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(MIe)):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(EIe)),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),Cc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Cc.multiply(e.parent.matrixWorld)),e.applyMatrix4(Cc),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(yb,e,SIe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(yb,NIe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++){const s=n[r];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.matrixWorldAutoUpdate===!0&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),n===!0){const i=this.children;for(let s=0,o=i.length;s<o;s++){const l=i[s];l.matrixWorldAutoUpdate===!0&&l.updateWorldMatrix(!1,!0)}}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(l=>({boxInitialized:l.boxInitialized,boxMin:l.box.min.toArray(),boxMax:l.box.max.toArray(),sphereInitialized:l.sphereInitialized,sphereRadius:l.sphere.radius,sphereCenter:l.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function s(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];s(e.shapes,f)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(s(e.materials,this.material[c]));i.material=l}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(s(e.animations,c))}}if(n){const l=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),f=o(e.shapes),m=o(e.skeletons),g=o(e.animations),x=o(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),m.length>0&&(r.skeletons=m),g.length>0&&(r.animations=g),x.length>0&&(r.nodes=x)}return r.object=i,r;function o(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}Za.DEFAULT_UP=new qe(0,1,0);Za.DEFAULT_MATRIX_AUTO_UPDATE=!0;Za.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Yo=new qe,Ac=new qe,bk=new qe,kc=new qe,gp=new qe,xp=new qe,m7=new qe,yk=new qe,vk=new qe,_k=new qe;let r1=!1;class Qo{constructor(e=new qe,n=new qe,r=new qe){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Yo.subVectors(e,n),i.cross(Yo);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,n,r,i,s){Yo.subVectors(i,n),Ac.subVectors(r,n),bk.subVectors(e,n);const o=Yo.dot(Yo),l=Yo.dot(Ac),c=Yo.dot(bk),u=Ac.dot(Ac),d=Ac.dot(bk),f=o*u-l*l;if(f===0)return s.set(-2,-1,-1);const m=1/f,g=(u*c-l*d)*m,x=(o*d-l*c)*m;return s.set(1-g-x,x,g)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,kc),kc.x>=0&&kc.y>=0&&kc.x+kc.y<=1}static getUV(e,n,r,i,s,o,l,c){return r1===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),r1=!0),this.getInterpolation(e,n,r,i,s,o,l,c)}static getInterpolation(e,n,r,i,s,o,l,c){return this.getBarycoord(e,n,r,i,kc),c.setScalar(0),c.addScaledVector(s,kc.x),c.addScaledVector(o,kc.y),c.addScaledVector(l,kc.z),c}static isFrontFacing(e,n,r,i){return Yo.subVectors(r,n),Ac.subVectors(e,n),Yo.cross(Ac).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 Yo.subVectors(this.c,this.b),Ac.subVectors(this.a,this.b),Yo.cross(Ac).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Qo.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Qo.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,s){return r1===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),r1=!0),Qo.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}getInterpolation(e,n,r,i,s){return Qo.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return Qo.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Qo.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,s=this.c;let o,l;gp.subVectors(i,r),xp.subVectors(s,r),yk.subVectors(e,r);const c=gp.dot(yk),u=xp.dot(yk);if(c<=0&&u<=0)return n.copy(r);vk.subVectors(e,i);const d=gp.dot(vk),f=xp.dot(vk);if(d>=0&&f<=d)return n.copy(i);const m=c*f-d*u;if(m<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(gp,o);_k.subVectors(e,s);const g=gp.dot(_k),x=xp.dot(_k);if(x>=0&&g<=x)return n.copy(s);const y=g*u-c*x;if(y<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(xp,l);const b=d*x-g*f;if(b<=0&&f-d>=0&&g-x>=0)return m7.subVectors(s,i),l=(f-d)/(f-d+(g-x)),n.copy(i).addScaledVector(m7,l);const v=1/(b+y+m);return o=y*v,l=m*v,n.copy(r).addScaledVector(gp,o).addScaledVector(xp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const BJ={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ad={h:0,s:0,l:0},i1={h:0,s:0,l:0};function wk(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 Jt=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=_a){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,xr.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=xr.workingColorSpace){return this.r=e,this.g=n,this.b=r,xr.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=xr.workingColorSpace){if(e=BO(e,1),n=wa(n,0,1),r=wa(r,0,1),n===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+n):r+n-r*n,o=2*r-s;this.r=wk(o,s,e+1/3),this.g=wk(o,s,e),this.b=wk(o,s,e-1/3)}return xr.toWorkingColorSpace(this,i),this}setStyle(e,n=_a){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=i[1],l=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,n);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(s,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=_a){const r=BJ[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=ng(e.r),this.g=ng(e.g),this.b=ng(e.b),this}copyLinearToSRGB(e){return this.r=uk(e.r),this.g=uk(e.g),this.b=uk(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=_a){return xr.fromWorkingColorSpace(ja.copy(this),e),Math.round(wa(ja.r*255,0,255))*65536+Math.round(wa(ja.g*255,0,255))*256+Math.round(wa(ja.b*255,0,255))}getHexString(e=_a){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=xr.workingColorSpace){xr.fromWorkingColorSpace(ja.copy(this),n);const r=ja.r,i=ja.g,s=ja.b,o=Math.max(r,i,s),l=Math.min(r,i,s);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const f=o-l;switch(u=d<=.5?f/(o+l):f/(2-o-l),o){case r:c=(i-s)/f+(i<s?6:0);break;case i:c=(s-r)/f+2;break;case s:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=xr.workingColorSpace){return xr.fromWorkingColorSpace(ja.copy(this),n),e.r=ja.r,e.g=ja.g,e.b=ja.b,e}getStyle(e=_a){xr.fromWorkingColorSpace(ja.copy(this),e);const n=ja.r,r=ja.g,i=ja.b;return e!==_a?`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(ad),this.setHSL(ad.h+e,ad.s+n,ad.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(ad),e.getHSL(i1);const r=qb(ad.h,i1.h,n),i=qb(ad.s,i1.s,n),s=qb(ad.l,i1.l,n);return this.setHSL(r,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,s=e.elements;return this.r=s[0]*n+s[3]*r+s[6]*i,this.g=s[1]*n+s[4]*r+s[7]*i,this.b=s[2]*n+s[5]*r+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const ja=new Jt;Jt.NAMES=BJ;let TIe=0;class rx extends lm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:TIe++}),this.uuid=ru(),this.name="",this.type="Material",this.blending=tg,this.side=nh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=KP,this.blendDst=XP,this.blendEquation=ef,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Jt(0,0,0),this.blendAlpha=0,this.depthFunc=CS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=t7,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=cp,this.stencilZFail=cp,this.stencilZPass=cp,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!==tg&&(r.blending=this.blending),this.side!==nh&&(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!==KP&&(r.blendSrc=this.blendSrc),this.blendDst!==XP&&(r.blendDst=this.blendDst),this.blendEquation!==ef&&(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!==CS&&(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!==t7&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==cp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==cp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==cp&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const o=[];for(const l in s){const c=s[l];delete c.metadata,o.push(c)}return o}if(n){const s=i(e.textures),o=i(e.images);s.length>0&&(r.textures=s),o.length>0&&(r.images=o)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=n[s].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class $J extends rx{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Jt(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=FO,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 vi=new qe,a1=new pn;class Ys{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=eR,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Xc,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)a1.fromBufferAttribute(this,n),a1.applyMatrix3(e),this.setXY(n,a1.x,a1.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)vi.fromBufferAttribute(this,n),vi.applyMatrix3(e),this.setXYZ(n,vi.x,vi.y,vi.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)vi.fromBufferAttribute(this,n),vi.applyMatrix4(e),this.setXYZ(n,vi.x,vi.y,vi.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)vi.fromBufferAttribute(this,n),vi.applyNormalMatrix(e),this.setXYZ(n,vi.x,vi.y,vi.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)vi.fromBufferAttribute(this,n),vi.transformDirection(e),this.setXYZ(n,vi.x,vi.y,vi.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=kl(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=gr(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=kl(n,this.array)),n}setX(e,n){return this.normalized&&(n=gr(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=kl(n,this.array)),n}setY(e,n){return this.normalized&&(n=gr(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=kl(n,this.array)),n}setZ(e,n){return this.normalized&&(n=gr(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=kl(n,this.array)),n}setW(e,n){return this.normalized&&(n=gr(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=gr(n,this.array),r=gr(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=gr(n,this.array),r=gr(r,this.array),i=gr(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e*=this.itemSize,this.normalized&&(n=gr(n,this.array),r=gr(r,this.array),i=gr(i,this.array),s=gr(s,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==eR&&(e.usage=this.usage),e}}class HJ extends Ys{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class VJ extends Ys{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class mi extends Ys{constructor(e,n,r){super(new Float32Array(e),n,r)}}let CIe=0;const mo=new kr,Sk=new Za,bp=new qe,zs=new jo,vb=new jo,Xi=new qe;class Ba extends lm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:CIe++}),this.uuid=ru(),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(LJ(e)?VJ:HJ)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new An().getNormalMatrix(e);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return mo.makeRotationFromQuaternion(e),this.applyMatrix4(mo),this}rotateX(e){return mo.makeRotationX(e),this.applyMatrix4(mo),this}rotateY(e){return mo.makeRotationY(e),this.applyMatrix4(mo),this}rotateZ(e){return mo.makeRotationZ(e),this.applyMatrix4(mo),this}translate(e,n,r){return mo.makeTranslation(e,n,r),this.applyMatrix4(mo),this}scale(e,n,r){return mo.makeScale(e,n,r),this.applyMatrix4(mo),this}lookAt(e){return Sk.lookAt(e),Sk.updateMatrix(),this.applyMatrix4(Sk.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(bp).negate(),this.translate(bp.x,bp.y,bp.z),this}setFromPoints(e){const n=[];for(let r=0,i=e.length;r<i;r++){const s=e[r];n.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new mi(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new jo);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 qe(-1/0,-1/0,-1/0),new qe(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const s=n[r];zs.setFromBufferAttribute(s),this.morphTargetsRelative?(Xi.addVectors(this.boundingBox.min,zs.min),this.boundingBox.expandByPoint(Xi),Xi.addVectors(this.boundingBox.max,zs.max),this.boundingBox.expandByPoint(Xi)):(this.boundingBox.expandByPoint(zs.min),this.boundingBox.expandByPoint(zs.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 Il);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 qe,1/0);return}if(e){const r=this.boundingSphere.center;if(zs.setFromBufferAttribute(e),n)for(let s=0,o=n.length;s<o;s++){const l=n[s];vb.setFromBufferAttribute(l),this.morphTargetsRelative?(Xi.addVectors(zs.min,vb.min),zs.expandByPoint(Xi),Xi.addVectors(zs.max,vb.max),zs.expandByPoint(Xi)):(zs.expandByPoint(vb.min),zs.expandByPoint(vb.max))}zs.getCenter(r);let i=0;for(let s=0,o=e.count;s<o;s++)Xi.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Xi));if(n)for(let s=0,o=n.length;s<o;s++){const l=n[s],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)Xi.fromBufferAttribute(l,u),c&&(bp.fromBufferAttribute(e,u),Xi.add(bp)),i=Math.max(i,r.distanceToSquared(Xi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.array,i=n.position.array,s=n.normal.array,o=n.uv.array,l=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ys(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let R=0;R<l;R++)u[R]=new qe,d[R]=new qe;const f=new qe,m=new qe,g=new qe,x=new pn,y=new pn,b=new pn,v=new qe,N=new qe;function S(R,F,O){f.fromArray(i,R*3),m.fromArray(i,F*3),g.fromArray(i,O*3),x.fromArray(o,R*2),y.fromArray(o,F*2),b.fromArray(o,O*2),m.sub(f),g.sub(f),y.sub(x),b.sub(x);const q=1/(y.x*b.y-b.x*y.y);isFinite(q)&&(v.copy(m).multiplyScalar(b.y).addScaledVector(g,-y.y).multiplyScalar(q),N.copy(g).multiplyScalar(y.x).addScaledVector(m,-b.x).multiplyScalar(q),u[R].add(v),u[F].add(v),u[O].add(v),d[R].add(N),d[F].add(N),d[O].add(N))}let T=this.groups;T.length===0&&(T=[{start:0,count:r.length}]);for(let R=0,F=T.length;R<F;++R){const O=T[R],q=O.start,j=O.count;for(let G=q,Y=q+j;G<Y;G+=3)S(r[G+0],r[G+1],r[G+2])}const E=new qe,k=new qe,C=new qe,D=new qe;function A(R){C.fromArray(s,R*3),D.copy(C);const F=u[R];E.copy(F),E.sub(C.multiplyScalar(C.dot(F))).normalize(),k.crossVectors(D,F);const q=k.dot(d[R])<0?-1:1;c[R*4]=E.x,c[R*4+1]=E.y,c[R*4+2]=E.z,c[R*4+3]=q}for(let R=0,F=T.length;R<F;++R){const O=T[R],q=O.start,j=O.count;for(let G=q,Y=q+j;G<Y;G+=3)A(r[G+0]),A(r[G+1]),A(r[G+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 Ys(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,g=r.count;m<g;m++)r.setXYZ(m,0,0,0);const i=new qe,s=new qe,o=new qe,l=new qe,c=new qe,u=new qe,d=new qe,f=new qe;if(e)for(let m=0,g=e.count;m<g;m+=3){const x=e.getX(m+0),y=e.getX(m+1),b=e.getX(m+2);i.fromBufferAttribute(n,x),s.fromBufferAttribute(n,y),o.fromBufferAttribute(n,b),d.subVectors(o,s),f.subVectors(i,s),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,b),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(y,c.x,c.y,c.z),r.setXYZ(b,u.x,u.y,u.z)}else for(let m=0,g=n.count;m<g;m+=3)i.fromBufferAttribute(n,m+0),s.fromBufferAttribute(n,m+1),o.fromBufferAttribute(n,m+2),d.subVectors(o,s),f.subVectors(i,s),d.cross(f),r.setXYZ(m+0,d.x,d.y,d.z),r.setXYZ(m+1,d.x,d.y,d.z),r.setXYZ(m+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Xi.fromBufferAttribute(e,n),Xi.normalize(),e.setXYZ(n,Xi.x,Xi.y,Xi.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,m=new u.constructor(c.length*d);let g=0,x=0;for(let y=0,b=c.length;y<b;y++){l.isInterleavedBufferAttribute?g=c[y]*l.data.stride+l.offset:g=c[y]*d;for(let v=0;v<d;v++)m[x++]=u[g++]}return new Ys(m,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new Ba,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const s=this.morphAttributes;for(const l in s){const c=[],u=s[l];for(let d=0,f=u.length;d<f;d++){const m=u[d],g=e(m,r);c.push(g)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let s=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,m=u.length;f<m;f++){const g=u[f];d.push(g.toJSON(e.data))}d.length>0&&(i[c]=d,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(n));const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const s=e.morphAttributes;for(const u in s){const d=[],f=s[u];for(let m=0,g=f.length;m<g;m++)d.push(f[m].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let u=0,d=o.length;u<d;u++){const f=o[u];this.addGroup(f.start,f.count,f.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const p7=new kr,Hh=new $O,s1=new Il,g7=new qe,yp=new qe,vp=new qe,_p=new qe,Nk=new qe,o1=new qe,l1=new pn,c1=new pn,u1=new pn,x7=new qe,b7=new qe,y7=new qe,d1=new qe,h1=new qe;class il extends Za{constructor(e=new Ba,n=new $J){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const l=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(s&&l){o1.set(0,0,0);for(let c=0,u=s.length;c<u;c++){const d=l[c],f=s[c];d!==0&&(Nk.fromBufferAttribute(f,e),o?o1.addScaledVector(Nk,d):o1.addScaledVector(Nk.sub(n),d))}n.add(o1)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),s1.copy(r.boundingSphere),s1.applyMatrix4(s),Hh.copy(e.ray).recast(e.near),!(s1.containsPoint(Hh.origin)===!1&&(Hh.intersectSphere(s1,g7)===null||Hh.origin.distanceToSquared(g7)>(e.far-e.near)**2))&&(p7.copy(s).invert(),Hh.copy(e.ray).applyMatrix4(p7),!(r.boundingBox!==null&&Hh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Hh)))}_computeIntersections(e,n,r){let i;const s=this.geometry,o=this.material,l=s.index,c=s.attributes.position,u=s.attributes.uv,d=s.attributes.uv1,f=s.attributes.normal,m=s.groups,g=s.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,y=m.length;x<y;x++){const b=m[x],v=o[b.materialIndex],N=Math.max(b.start,g.start),S=Math.min(l.count,Math.min(b.start+b.count,g.start+g.count));for(let T=N,E=S;T<E;T+=3){const k=l.getX(T),C=l.getX(T+1),D=l.getX(T+2);i=f1(this,v,e,r,u,d,f,k,C,D),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,g.start),y=Math.min(l.count,g.start+g.count);for(let b=x,v=y;b<v;b+=3){const N=l.getX(b),S=l.getX(b+1),T=l.getX(b+2);i=f1(this,o,e,r,u,d,f,N,S,T),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,y=m.length;x<y;x++){const b=m[x],v=o[b.materialIndex],N=Math.max(b.start,g.start),S=Math.min(c.count,Math.min(b.start+b.count,g.start+g.count));for(let T=N,E=S;T<E;T+=3){const k=T,C=T+1,D=T+2;i=f1(this,v,e,r,u,d,f,k,C,D),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,g.start),y=Math.min(c.count,g.start+g.count);for(let b=x,v=y;b<v;b+=3){const N=b,S=b+1,T=b+2;i=f1(this,o,e,r,u,d,f,N,S,T),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}}function AIe(t,e,n,r,i,s,o,l){let c;if(e.side===ws?c=r.intersectTriangle(o,s,i,!0,l):c=r.intersectTriangle(i,s,o,e.side===nh,l),c===null)return null;h1.copy(l),h1.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(h1);return u<n.near||u>n.far?null:{distance:u,point:h1.clone(),object:t}}function f1(t,e,n,r,i,s,o,l,c,u){t.getVertexPosition(l,yp),t.getVertexPosition(c,vp),t.getVertexPosition(u,_p);const d=AIe(t,e,n,r,yp,vp,_p,d1);if(d){i&&(l1.fromBufferAttribute(i,l),c1.fromBufferAttribute(i,c),u1.fromBufferAttribute(i,u),d.uv=Qo.getInterpolation(d1,yp,vp,_p,l1,c1,u1,new pn)),s&&(l1.fromBufferAttribute(s,l),c1.fromBufferAttribute(s,c),u1.fromBufferAttribute(s,u),d.uv1=Qo.getInterpolation(d1,yp,vp,_p,l1,c1,u1,new pn),d.uv2=d.uv1),o&&(x7.fromBufferAttribute(o,l),b7.fromBufferAttribute(o,c),y7.fromBufferAttribute(o,u),d.normal=Qo.getInterpolation(d1,yp,vp,_p,x7,b7,y7,new qe),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:l,b:c,c:u,normal:new qe,materialIndex:0};Qo.getNormal(yp,vp,_p,f.normal),d.face=f}return d}class Uy extends Ba{constructor(e=1,n=1,r=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:s,depthSegments:o};const l=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const c=[],u=[],d=[],f=[];let m=0,g=0;x("z","y","x",-1,-1,r,n,e,o,s,0),x("z","y","x",1,-1,r,n,-e,o,s,1),x("x","z","y",1,1,e,r,n,i,o,2),x("x","z","y",1,-1,e,r,-n,i,o,3),x("x","y","z",1,-1,e,n,r,i,s,4),x("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(c),this.setAttribute("position",new mi(u,3)),this.setAttribute("normal",new mi(d,3)),this.setAttribute("uv",new mi(f,2));function x(y,b,v,N,S,T,E,k,C,D,A){const R=T/C,F=E/D,O=T/2,q=E/2,j=k/2,G=C+1,Y=D+1;let K=0,Z=0;const te=new qe;for(let ne=0;ne<Y;ne++){const z=ne*F-q;for(let W=0;W<G;W++){const se=W*R-O;te[y]=se*N,te[b]=z*S,te[v]=j,u.push(te.x,te.y,te.z),te[y]=0,te[b]=0,te[v]=k>0?1:-1,d.push(te.x,te.y,te.z),f.push(W/C),f.push(1-ne/D),K+=1}}for(let ne=0;ne<D;ne++)for(let z=0;z<C;z++){const W=m+z+G*ne,se=m+z+G*(ne+1),ae=m+(z+1)+G*(ne+1),de=m+(z+1)+G*ne;c.push(W,se,de),c.push(se,ae,de),Z+=6}l.addGroup(g,Z,A),g+=Z,m+=K}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Uy(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Tg(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 qa(t){const e={};for(let n=0;n<t.length;n++){const r=Tg(t[n]);for(const i in r)e[i]=r[i]}return e}function kIe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function GJ(t){return t.getRenderTarget()===null?t.outputColorSpace:xr.workingColorSpace}const HO={clone:Tg,merge:qa};var jIe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,PIe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class rh extends rx{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=jIe,this.fragmentShader=PIe,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=Tg(e.uniforms),this.uniformsGroups=kIe(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?n.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?n.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?n.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?n.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?n.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?n.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?n.uniforms[i]={type:"m4",value:o.toArray()}:n.uniforms[i]={value:o}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const r={};for(const i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(n.extensions=r),n}}class qJ extends Za{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new kr,this.projectionMatrix=new kr,this.projectionMatrixInverse=new kr,this.coordinateSystem=Dl}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 $s extends qJ{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=V0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Gb*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return V0*2*Math.atan(Math.tan(Gb*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,n,r,i,s,o){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(Gb*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,s=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;s+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.height/u}const l=this.filmOffset;l!==0&&(s+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,n,n-r,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}const wp=-90,Sp=1;class RIe extends Za{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new $s(wp,Sp,e,n);i.layers=this.layers,this.add(i);const s=new $s(wp,Sp,e,n);s.layers=this.layers,this.add(s);const o=new $s(wp,Sp,e,n);o.layers=this.layers,this.add(o);const l=new $s(wp,Sp,e,n);l.layers=this.layers,this.add(l);const c=new $s(wp,Sp,e,n);c.layers=this.layers,this.add(c);const u=new $s(wp,Sp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,o,l,c]=n;for(const u of n)this.remove(u);if(e===Dl)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===H0)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,o,l,c,u,d]=this.children,f=e.getRenderTarget(),m=e.getActiveCubeFace(),g=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,s),e.setRenderTarget(r,1,i),e.render(n,o),e.setRenderTarget(r,2,i),e.render(n,l),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,m,g),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class WJ extends Ss{constructor(e,n,r,i,s,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:Ng,super(e,n,r,i,s,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class DIe extends Xf{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&&(Wb("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Mf?_a:Eo),this.texture=new WJ(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:No}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new Uy(5,5,5),s=new rh({name:"CubemapFromEquirect",uniforms:Tg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ws,blending:Id});s.uniforms.tEquirect.value=n;const o=new il(i,s),l=n.minFilter;return n.minFilter===B0&&(n.minFilter=No),new RIe(1,10,this).update(e,o),n.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,n,r,i){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(s)}}const Mk=new qe,OIe=new qe,LIe=new An;class md{constructor(e=new qe(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=Mk.subVectors(r,n).cross(OIe.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(Mk),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:n.copy(e.start).addScaledVector(r,s)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||LIe.getNormalMatrix(e),i=this.coplanarPoint(Mk).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Vh=new Il,m1=new qe;class XN{constructor(e=new md,n=new md,r=new md,i=new md,s=new md,o=new md){this.planes=[e,n,r,i,s,o]}set(e,n,r,i,s,o){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(s),l[5].copy(o),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=Dl){const r=this.planes,i=e.elements,s=i[0],o=i[1],l=i[2],c=i[3],u=i[4],d=i[5],f=i[6],m=i[7],g=i[8],x=i[9],y=i[10],b=i[11],v=i[12],N=i[13],S=i[14],T=i[15];if(r[0].setComponents(c-s,m-u,b-g,T-v).normalize(),r[1].setComponents(c+s,m+u,b+g,T+v).normalize(),r[2].setComponents(c+o,m+d,b+x,T+N).normalize(),r[3].setComponents(c-o,m-d,b-x,T-N).normalize(),r[4].setComponents(c-l,m-f,b-y,T-S).normalize(),n===Dl)r[5].setComponents(c+l,m+f,b+y,T+S).normalize();else if(n===H0)r[5].setComponents(l,f,y,S).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Vh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Vh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Vh)}intersectsSprite(e){return Vh.center.set(0,0,0),Vh.radius=.7071067811865476,Vh.applyMatrix4(e.matrixWorld),this.intersectsSphere(Vh)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(n[s].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(m1.x=i.normal.x>0?e.max.x:e.min.x,m1.y=i.normal.y>0?e.max.y:e.min.y,m1.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(m1)<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 KJ(){let t=null,e=!1,n=null,r=null;function i(s,o){n(s,o),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(s){n=s},setContext:function(s){t=s}}}function IIe(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,m=u.usage,g=f.byteLength,x=t.createBuffer();t.bindBuffer(d,x),t.bufferData(d,f,m),u.onUploadCallback();let y;if(f instanceof Float32Array)y=t.FLOAT;else if(f instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)y=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else y=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)y=t.SHORT;else if(f instanceof Uint32Array)y=t.UNSIGNED_INT;else if(f instanceof Int32Array)y=t.INT;else if(f instanceof Int8Array)y=t.BYTE;else if(f instanceof Uint8Array)y=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)y=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:x,type:y,bytesPerElement:f.BYTES_PER_ELEMENT,version:u.version,size:g}}function s(u,d,f){const m=d.array,g=d._updateRange,x=d.updateRanges;if(t.bindBuffer(f,u),g.count===-1&&x.length===0&&t.bufferSubData(f,0,m),x.length!==0){for(let y=0,b=x.length;y<b;y++){const v=x[y];n?t.bufferSubData(f,v.start*m.BYTES_PER_ELEMENT,m,v.start,v.count):t.bufferSubData(f,v.start*m.BYTES_PER_ELEMENT,m.subarray(v.start,v.start+v.count))}d.clearUpdateRanges()}g.count!==-1&&(n?t.bufferSubData(f,g.offset*m.BYTES_PER_ELEMENT,m,g.offset,g.count):t.bufferSubData(f,g.offset*m.BYTES_PER_ELEMENT,m.subarray(g.offset,g.offset+g.count)),g.count=-1),d.onUploadCallback()}function o(u){return u.isInterleavedBufferAttribute&&(u=u.data),r.get(u)}function l(u){u.isInterleavedBufferAttribute&&(u=u.data);const d=r.get(u);d&&(t.deleteBuffer(d.buffer),r.delete(u))}function c(u,d){if(u.isGLBufferAttribute){const m=r.get(u);(!m||m.version<u.version)&&r.set(u,{buffer:u.buffer,type:u.type,bytesPerElement:u.elementSize,version:u.version});return}u.isInterleavedBufferAttribute&&(u=u.data);const f=r.get(u);if(f===void 0)r.set(u,i(u,d));else if(f.version<u.version){if(f.size!==u.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");s(f.buffer,u,d),f.version=u.version}}return{get:o,remove:l,update:c}}class VO extends Ba{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const s=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,m=n/c,g=[],x=[],y=[],b=[];for(let v=0;v<d;v++){const N=v*m-o;for(let S=0;S<u;S++){const T=S*f-s;x.push(T,-N,0),y.push(0,0,1),b.push(S/l),b.push(1-v/c)}}for(let v=0;v<c;v++)for(let N=0;N<l;N++){const S=N+u*v,T=N+u*(v+1),E=N+1+u*(v+1),k=N+1+u*v;g.push(S,T,k),g.push(T,E,k)}this.setIndex(g),this.setAttribute("position",new mi(x,3)),this.setAttribute("normal",new mi(y,3)),this.setAttribute("uv",new mi(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new VO(e.width,e.height,e.widthSegments,e.heightSegments)}}var FIe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,UIe=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,zIe=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,BIe=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,$Ie=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,HIe=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,VIe=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,GIe=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,qIe=`#ifdef USE_BATCHING
- attribute float batchId;
- uniform highp sampler2D batchingTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,WIe=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,KIe=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,XIe=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,YIe=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,QIe=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,ZIe=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,JIe=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif`,e5e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,t5e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,n5e=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,r5e=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,i5e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,a5e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,s5e=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif`,o5e=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- mat3 transposeMat3( const in mat3 m ) {
- mat3 tmp;
- tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
- tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
- tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
- return tmp;
- }
- float luminance( const in vec3 rgb ) {
- const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
- return dot( weights, rgb );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,l5e=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_v0 0.339
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_v1 0.276
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_v4 0.046
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_v5 0.016
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_v6 0.0038
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,c5e=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,u5e=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,d5e=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,h5e=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,f5e=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,m5e="gl_FragColor = linearToOutputTexel( gl_FragColor );",p5e=`
- const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
- vec3( 0.8224621, 0.177538, 0.0 ),
- vec3( 0.0331941, 0.9668058, 0.0 ),
- vec3( 0.0170827, 0.0723974, 0.9105199 )
- );
- const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
- vec3( 1.2249401, - 0.2249404, 0.0 ),
- vec3( - 0.0420569, 1.0420571, 0.0 ),
- vec3( - 0.0196376, - 0.0786361, 1.0982735 )
- );
- vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
- return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
- }
- vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
- return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
- }
- vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }
- vec4 LinearToLinear( in vec4 value ) {
- return value;
- }
- vec4 LinearTosRGB( in vec4 value ) {
- return sRGBTransferOETF( value );
- }`,g5e=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,x5e=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,b5e=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,y5e=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,v5e=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,_5e=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,w5e=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,S5e=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,N5e=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,M5e=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,E5e=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,T5e=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,C5e=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,A5e=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,k5e=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- #if defined ( LEGACY_LIGHTS )
- if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
- return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
- }
- return 1.0;
- #else
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- #endif
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,j5e=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,P5e=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,R5e=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,D5e=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,O5e=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,L5e=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,I5e=`struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
- const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
- vec4 r = roughness * c0 + c1;
- float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
- vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
- return fab;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,F5e=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,U5e=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,z5e=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,B5e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,$5e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,H5e=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,V5e=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #else
- if ( isPerspectiveMatrix( projectionMatrix ) ) {
- gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
- gl_Position.z *= gl_Position.w;
- }
- #endif
- #endif`,G5e=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
-
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,q5e=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,W5e=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,K5e=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,X5e=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,Y5e=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,Q5e=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,Z5e=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
- objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
- objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
- objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
- #endif
- #endif`,J5e=`#ifdef USE_MORPHTARGETS
- uniform float morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #else
- #ifndef USE_MORPHNORMALS
- uniform float morphTargetInfluences[ 8 ];
- #else
- uniform float morphTargetInfluences[ 4 ];
- #endif
- #endif
- #endif`,eFe=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- transformed += morphTarget0 * morphTargetInfluences[ 0 ];
- transformed += morphTarget1 * morphTargetInfluences[ 1 ];
- transformed += morphTarget2 * morphTargetInfluences[ 2 ];
- transformed += morphTarget3 * morphTargetInfluences[ 3 ];
- #ifndef USE_MORPHNORMALS
- transformed += morphTarget4 * morphTargetInfluences[ 4 ];
- transformed += morphTarget5 * morphTargetInfluences[ 5 ];
- transformed += morphTarget6 * morphTargetInfluences[ 6 ];
- transformed += morphTarget7 * morphTargetInfluences[ 7 ];
- #endif
- #endif
- #endif`,tFe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,nFe=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,rFe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,iFe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,aFe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,sFe=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,oFe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,lFe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,cFe=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,uFe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,dFe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,hFe=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
- const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
- const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
- const float ShiftRight8 = 1. / 256.;
- vec4 packDepthToRGBA( const in float v ) {
- vec4 r = vec4( fract( v * PackFactors ), v );
- r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors );
- }
- vec2 packDepthToRG( in highp float v ) {
- return packDepthToRGBA( v ).yx;
- }
- float unpackRGToDepth( const in highp vec2 v ) {
- return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
- }
- vec4 pack2HalfToRGBA( vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,fFe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,mFe=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,pFe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,gFe=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,xFe=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,bFe=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,yFe=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
- return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
- }
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
- }
- float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
- float occlusion = 1.0;
- vec2 distribution = texture2DDistribution( shadow, uv );
- float hard_shadow = step( compare , distribution.x );
- if (hard_shadow != 1.0 ) {
- float distance = compare - distribution.x ;
- float variance = max( 0.00000, distribution.y * distribution.y );
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
- }
- return occlusion;
- }
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- #if defined( SHADOWMAP_TYPE_PCF )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx0 = - texelSize.x * shadowRadius;
- float dy0 = - texelSize.y * shadowRadius;
- float dx1 = + texelSize.x * shadowRadius;
- float dy1 = + texelSize.y * shadowRadius;
- float dx2 = dx0 / 2.0;
- float dy2 = dy0 / 2.0;
- float dx3 = dx1 / 2.0;
- float dy3 = dy1 / 2.0;
- shadow = (
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
- ) * ( 1.0 / 17.0 );
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx = texelSize.x;
- float dy = texelSize.y;
- vec2 uv = shadowCoord.xy;
- vec2 f = fract( uv * shadowMapSize + 0.5 );
- uv -= f * texelSize;
- shadow = (
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
- f.x ),
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
- f.x ),
- f.y )
- ) * ( 1.0 / 9.0 );
- #elif defined( SHADOWMAP_TYPE_VSM )
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
- #else
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
- #endif
- }
- return shadow;
- }
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
- vec3 absV = abs( v );
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
- absV *= scaleToCube;
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
- vec2 planar = v.xy;
- float almostATexel = 1.5 * texelSizeY;
- float almostOne = 1.0 - almostATexel;
- if ( absV.z >= almostOne ) {
- if ( v.z > 0.0 )
- planar.x = 4.0 - v.x;
- } else if ( absV.x >= almostOne ) {
- float signX = sign( v.x );
- planar.x = v.z * signX + 2.0 * signX;
- } else if ( absV.y >= almostOne ) {
- float signY = sign( v.y );
- planar.x = v.x + 2.0 * signY + 2.0;
- planar.y = v.z * signY - 2.0;
- }
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
- }
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- vec3 lightToPosition = shadowCoord.xyz;
- float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- return (
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
- ) * ( 1.0 / 9.0 );
- #else
- return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- #endif`,vFe=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,_Fe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,wFe=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,SFe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,NFe=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,MFe=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,EFe=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,TFe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,CFe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,AFe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,kFe=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 OptimizedCineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,jFe=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,PFe=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,RFe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,DFe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,OFe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,LFe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const IFe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,FFe=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,UFe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,zFe=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,BFe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,$Fe=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,HFe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,VFe=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #endif
- }`,GFe=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,qFe=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,WFe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,KFe=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,XFe=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,YFe=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,QFe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,ZFe=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,JFe=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,eUe=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,tUe=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,nUe=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,rUe=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,iUe=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <packing>
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,aUe=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,sUe=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,oUe=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,lUe=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,cUe=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,uUe=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,dUe=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,hUe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,fUe=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,mUe=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,pUe=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
- vec2 scale;
- scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
- scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,gUe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,wn={alphahash_fragment:FIe,alphahash_pars_fragment:UIe,alphamap_fragment:zIe,alphamap_pars_fragment:BIe,alphatest_fragment:$Ie,alphatest_pars_fragment:HIe,aomap_fragment:VIe,aomap_pars_fragment:GIe,batching_pars_vertex:qIe,batching_vertex:WIe,begin_vertex:KIe,beginnormal_vertex:XIe,bsdfs:YIe,iridescence_fragment:QIe,bumpmap_pars_fragment:ZIe,clipping_planes_fragment:JIe,clipping_planes_pars_fragment:e5e,clipping_planes_pars_vertex:t5e,clipping_planes_vertex:n5e,color_fragment:r5e,color_pars_fragment:i5e,color_pars_vertex:a5e,color_vertex:s5e,common:o5e,cube_uv_reflection_fragment:l5e,defaultnormal_vertex:c5e,displacementmap_pars_vertex:u5e,displacementmap_vertex:d5e,emissivemap_fragment:h5e,emissivemap_pars_fragment:f5e,colorspace_fragment:m5e,colorspace_pars_fragment:p5e,envmap_fragment:g5e,envmap_common_pars_fragment:x5e,envmap_pars_fragment:b5e,envmap_pars_vertex:y5e,envmap_physical_pars_fragment:j5e,envmap_vertex:v5e,fog_vertex:_5e,fog_pars_vertex:w5e,fog_fragment:S5e,fog_pars_fragment:N5e,gradientmap_pars_fragment:M5e,lightmap_fragment:E5e,lightmap_pars_fragment:T5e,lights_lambert_fragment:C5e,lights_lambert_pars_fragment:A5e,lights_pars_begin:k5e,lights_toon_fragment:P5e,lights_toon_pars_fragment:R5e,lights_phong_fragment:D5e,lights_phong_pars_fragment:O5e,lights_physical_fragment:L5e,lights_physical_pars_fragment:I5e,lights_fragment_begin:F5e,lights_fragment_maps:U5e,lights_fragment_end:z5e,logdepthbuf_fragment:B5e,logdepthbuf_pars_fragment:$5e,logdepthbuf_pars_vertex:H5e,logdepthbuf_vertex:V5e,map_fragment:G5e,map_pars_fragment:q5e,map_particle_fragment:W5e,map_particle_pars_fragment:K5e,metalnessmap_fragment:X5e,metalnessmap_pars_fragment:Y5e,morphcolor_vertex:Q5e,morphnormal_vertex:Z5e,morphtarget_pars_vertex:J5e,morphtarget_vertex:eFe,normal_fragment_begin:tFe,normal_fragment_maps:nFe,normal_pars_fragment:rFe,normal_pars_vertex:iFe,normal_vertex:aFe,normalmap_pars_fragment:sFe,clearcoat_normal_fragment_begin:oFe,clearcoat_normal_fragment_maps:lFe,clearcoat_pars_fragment:cFe,iridescence_pars_fragment:uFe,opaque_fragment:dFe,packing:hFe,premultiplied_alpha_fragment:fFe,project_vertex:mFe,dithering_fragment:pFe,dithering_pars_fragment:gFe,roughnessmap_fragment:xFe,roughnessmap_pars_fragment:bFe,shadowmap_pars_fragment:yFe,shadowmap_pars_vertex:vFe,shadowmap_vertex:_Fe,shadowmask_pars_fragment:wFe,skinbase_vertex:SFe,skinning_pars_vertex:NFe,skinning_vertex:MFe,skinnormal_vertex:EFe,specularmap_fragment:TFe,specularmap_pars_fragment:CFe,tonemapping_fragment:AFe,tonemapping_pars_fragment:kFe,transmission_fragment:jFe,transmission_pars_fragment:PFe,uv_pars_fragment:RFe,uv_pars_vertex:DFe,uv_vertex:OFe,worldpos_vertex:LFe,background_vert:IFe,background_frag:FFe,backgroundCube_vert:UFe,backgroundCube_frag:zFe,cube_vert:BFe,cube_frag:$Fe,depth_vert:HFe,depth_frag:VFe,distanceRGBA_vert:GFe,distanceRGBA_frag:qFe,equirect_vert:WFe,equirect_frag:KFe,linedashed_vert:XFe,linedashed_frag:YFe,meshbasic_vert:QFe,meshbasic_frag:ZFe,meshlambert_vert:JFe,meshlambert_frag:eUe,meshmatcap_vert:tUe,meshmatcap_frag:nUe,meshnormal_vert:rUe,meshnormal_frag:iUe,meshphong_vert:aUe,meshphong_frag:sUe,meshphysical_vert:oUe,meshphysical_frag:lUe,meshtoon_vert:cUe,meshtoon_frag:uUe,points_vert:dUe,points_frag:hUe,shadow_vert:fUe,shadow_frag:mUe,sprite_vert:pUe,sprite_frag:gUe},Rt={common:{diffuse:{value:new Jt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new An},alphaMap:{value:null},alphaMapTransform:{value:new An},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new An}},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 An}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new An}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new An},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new An},normalScale:{value:new pn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new An},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new An}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new An}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new An}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Jt(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 Jt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new An},alphaTest:{value:0},uvTransform:{value:new An}},sprite:{diffuse:{value:new Jt(16777215)},opacity:{value:1},center:{value:new pn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new An},alphaMap:{value:null},alphaMapTransform:{value:new An},alphaTest:{value:0}}},gs={basic:{uniforms:qa([Rt.common,Rt.specularmap,Rt.envmap,Rt.aomap,Rt.lightmap,Rt.fog]),vertexShader:wn.meshbasic_vert,fragmentShader:wn.meshbasic_frag},lambert:{uniforms:qa([Rt.common,Rt.specularmap,Rt.envmap,Rt.aomap,Rt.lightmap,Rt.emissivemap,Rt.bumpmap,Rt.normalmap,Rt.displacementmap,Rt.fog,Rt.lights,{emissive:{value:new Jt(0)}}]),vertexShader:wn.meshlambert_vert,fragmentShader:wn.meshlambert_frag},phong:{uniforms:qa([Rt.common,Rt.specularmap,Rt.envmap,Rt.aomap,Rt.lightmap,Rt.emissivemap,Rt.bumpmap,Rt.normalmap,Rt.displacementmap,Rt.fog,Rt.lights,{emissive:{value:new Jt(0)},specular:{value:new Jt(1118481)},shininess:{value:30}}]),vertexShader:wn.meshphong_vert,fragmentShader:wn.meshphong_frag},standard:{uniforms:qa([Rt.common,Rt.envmap,Rt.aomap,Rt.lightmap,Rt.emissivemap,Rt.bumpmap,Rt.normalmap,Rt.displacementmap,Rt.roughnessmap,Rt.metalnessmap,Rt.fog,Rt.lights,{emissive:{value:new Jt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:wn.meshphysical_vert,fragmentShader:wn.meshphysical_frag},toon:{uniforms:qa([Rt.common,Rt.aomap,Rt.lightmap,Rt.emissivemap,Rt.bumpmap,Rt.normalmap,Rt.displacementmap,Rt.gradientmap,Rt.fog,Rt.lights,{emissive:{value:new Jt(0)}}]),vertexShader:wn.meshtoon_vert,fragmentShader:wn.meshtoon_frag},matcap:{uniforms:qa([Rt.common,Rt.bumpmap,Rt.normalmap,Rt.displacementmap,Rt.fog,{matcap:{value:null}}]),vertexShader:wn.meshmatcap_vert,fragmentShader:wn.meshmatcap_frag},points:{uniforms:qa([Rt.points,Rt.fog]),vertexShader:wn.points_vert,fragmentShader:wn.points_frag},dashed:{uniforms:qa([Rt.common,Rt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:wn.linedashed_vert,fragmentShader:wn.linedashed_frag},depth:{uniforms:qa([Rt.common,Rt.displacementmap]),vertexShader:wn.depth_vert,fragmentShader:wn.depth_frag},normal:{uniforms:qa([Rt.common,Rt.bumpmap,Rt.normalmap,Rt.displacementmap,{opacity:{value:1}}]),vertexShader:wn.meshnormal_vert,fragmentShader:wn.meshnormal_frag},sprite:{uniforms:qa([Rt.sprite,Rt.fog]),vertexShader:wn.sprite_vert,fragmentShader:wn.sprite_frag},background:{uniforms:{uvTransform:{value:new An},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:wn.background_vert,fragmentShader:wn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:wn.backgroundCube_vert,fragmentShader:wn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:wn.cube_vert,fragmentShader:wn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:wn.equirect_vert,fragmentShader:wn.equirect_frag},distanceRGBA:{uniforms:qa([Rt.common,Rt.displacementmap,{referencePosition:{value:new qe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:wn.distanceRGBA_vert,fragmentShader:wn.distanceRGBA_frag},shadow:{uniforms:qa([Rt.lights,Rt.fog,{color:{value:new Jt(0)},opacity:{value:1}}]),vertexShader:wn.shadow_vert,fragmentShader:wn.shadow_frag}};gs.physical={uniforms:qa([gs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new An},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new An},clearcoatNormalScale:{value:new pn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new An},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new An},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new An},sheen:{value:0},sheenColor:{value:new Jt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new An},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new An},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new An},transmissionSamplerSize:{value:new pn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new An},attenuationDistance:{value:0},attenuationColor:{value:new Jt(0)},specularColor:{value:new Jt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new An},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new An},anisotropyVector:{value:new pn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new An}}]),vertexShader:wn.meshphysical_vert,fragmentShader:wn.meshphysical_frag};const p1={r:0,b:0,g:0};function xUe(t,e,n,r,i,s,o){const l=new Jt(0);let c=s===!0?0:1,u,d,f=null,m=0,g=null;function x(b,v){let N=!1,S=v.isScene===!0?v.background:null;S&&S.isTexture&&(S=(v.backgroundBlurriness>0?n:e).get(S)),S===null?y(l,c):S&&S.isColor&&(y(S,1),N=!0);const T=t.xr.getEnvironmentBlendMode();T==="additive"?r.buffers.color.setClear(0,0,0,1,o):T==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||N)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),S&&(S.isCubeTexture||S.mapping===WN)?(d===void 0&&(d=new il(new Uy(1,1,1),new rh({name:"BackgroundCubeMaterial",uniforms:Tg(gs.backgroundCube.uniforms),vertexShader:gs.backgroundCube.vertexShader,fragmentShader:gs.backgroundCube.fragmentShader,side:ws,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(E,k,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),d.material.uniforms.envMap.value=S,d.material.uniforms.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,d.material.toneMapped=xr.getTransfer(S.colorSpace)!==Dr,(f!==S||m!==S.version||g!==t.toneMapping)&&(d.material.needsUpdate=!0,f=S,m=S.version,g=t.toneMapping),d.layers.enableAll(),b.unshift(d,d.geometry,d.material,0,0,null)):S&&S.isTexture&&(u===void 0&&(u=new il(new VO(2,2),new rh({name:"BackgroundMaterial",uniforms:Tg(gs.background.uniforms),vertexShader:gs.background.vertexShader,fragmentShader:gs.background.fragmentShader,side:nh,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=S,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.toneMapped=xr.getTransfer(S.colorSpace)!==Dr,S.matrixAutoUpdate===!0&&S.updateMatrix(),u.material.uniforms.uvTransform.value.copy(S.matrix),(f!==S||m!==S.version||g!==t.toneMapping)&&(u.material.needsUpdate=!0,f=S,m=S.version,g=t.toneMapping),u.layers.enableAll(),b.unshift(u,u.geometry,u.material,0,0,null))}function y(b,v){b.getRGB(p1,GJ(t)),r.buffers.color.setClear(p1.r,p1.g,p1.b,v,o)}return{getClearColor:function(){return l},setClearColor:function(b,v=1){l.set(b),c=v,y(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(b){c=b,y(l,c)},render:x}}function bUe(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),s=r.isWebGL2?null:e.get("OES_vertex_array_object"),o=r.isWebGL2||s!==null,l={},c=b(null);let u=c,d=!1;function f(j,G,Y,K,Z){let te=!1;if(o){const ne=y(K,Y,G);u!==ne&&(u=ne,g(u.object)),te=v(j,K,Y,Z),te&&N(j,K,Y,Z)}else{const ne=G.wireframe===!0;(u.geometry!==K.id||u.program!==Y.id||u.wireframe!==ne)&&(u.geometry=K.id,u.program=Y.id,u.wireframe=ne,te=!0)}Z!==null&&n.update(Z,t.ELEMENT_ARRAY_BUFFER),(te||d)&&(d=!1,D(j,G,Y,K),Z!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(Z).buffer))}function m(){return r.isWebGL2?t.createVertexArray():s.createVertexArrayOES()}function g(j){return r.isWebGL2?t.bindVertexArray(j):s.bindVertexArrayOES(j)}function x(j){return r.isWebGL2?t.deleteVertexArray(j):s.deleteVertexArrayOES(j)}function y(j,G,Y){const K=Y.wireframe===!0;let Z=l[j.id];Z===void 0&&(Z={},l[j.id]=Z);let te=Z[G.id];te===void 0&&(te={},Z[G.id]=te);let ne=te[K];return ne===void 0&&(ne=b(m()),te[K]=ne),ne}function b(j){const G=[],Y=[],K=[];for(let Z=0;Z<i;Z++)G[Z]=0,Y[Z]=0,K[Z]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:G,enabledAttributes:Y,attributeDivisors:K,object:j,attributes:{},index:null}}function v(j,G,Y,K){const Z=u.attributes,te=G.attributes;let ne=0;const z=Y.getAttributes();for(const W in z)if(z[W].location>=0){const ae=Z[W];let de=te[W];if(de===void 0&&(W==="instanceMatrix"&&j.instanceMatrix&&(de=j.instanceMatrix),W==="instanceColor"&&j.instanceColor&&(de=j.instanceColor)),ae===void 0||ae.attribute!==de||de&&ae.data!==de.data)return!0;ne++}return u.attributesNum!==ne||u.index!==K}function N(j,G,Y,K){const Z={},te=G.attributes;let ne=0;const z=Y.getAttributes();for(const W in z)if(z[W].location>=0){let ae=te[W];ae===void 0&&(W==="instanceMatrix"&&j.instanceMatrix&&(ae=j.instanceMatrix),W==="instanceColor"&&j.instanceColor&&(ae=j.instanceColor));const de={};de.attribute=ae,ae&&ae.data&&(de.data=ae.data),Z[W]=de,ne++}u.attributes=Z,u.attributesNum=ne,u.index=K}function S(){const j=u.newAttributes;for(let G=0,Y=j.length;G<Y;G++)j[G]=0}function T(j){E(j,0)}function E(j,G){const Y=u.newAttributes,K=u.enabledAttributes,Z=u.attributeDivisors;Y[j]=1,K[j]===0&&(t.enableVertexAttribArray(j),K[j]=1),Z[j]!==G&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](j,G),Z[j]=G)}function k(){const j=u.newAttributes,G=u.enabledAttributes;for(let Y=0,K=G.length;Y<K;Y++)G[Y]!==j[Y]&&(t.disableVertexAttribArray(Y),G[Y]=0)}function C(j,G,Y,K,Z,te,ne){ne===!0?t.vertexAttribIPointer(j,G,Y,Z,te):t.vertexAttribPointer(j,G,Y,K,Z,te)}function D(j,G,Y,K){if(r.isWebGL2===!1&&(j.isInstancedMesh||K.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;S();const Z=K.attributes,te=Y.getAttributes(),ne=G.defaultAttributeValues;for(const z in te){const W=te[z];if(W.location>=0){let se=Z[z];if(se===void 0&&(z==="instanceMatrix"&&j.instanceMatrix&&(se=j.instanceMatrix),z==="instanceColor"&&j.instanceColor&&(se=j.instanceColor)),se!==void 0){const ae=se.normalized,de=se.itemSize,me=n.get(se);if(me===void 0)continue;const xe=me.buffer,be=me.type,fe=me.bytesPerElement,Ce=r.isWebGL2===!0&&(be===t.INT||be===t.UNSIGNED_INT||se.gpuType===MJ);if(se.isInterleavedBufferAttribute){const Ne=se.data,re=Ne.stride,He=se.offset;if(Ne.isInstancedInterleavedBuffer){for(let H=0;H<W.locationSize;H++)E(W.location+H,Ne.meshPerAttribute);j.isInstancedMesh!==!0&&K._maxInstanceCount===void 0&&(K._maxInstanceCount=Ne.meshPerAttribute*Ne.count)}else for(let H=0;H<W.locationSize;H++)T(W.location+H);t.bindBuffer(t.ARRAY_BUFFER,xe);for(let H=0;H<W.locationSize;H++)C(W.location+H,de/W.locationSize,be,ae,re*fe,(He+de/W.locationSize*H)*fe,Ce)}else{if(se.isInstancedBufferAttribute){for(let Ne=0;Ne<W.locationSize;Ne++)E(W.location+Ne,se.meshPerAttribute);j.isInstancedMesh!==!0&&K._maxInstanceCount===void 0&&(K._maxInstanceCount=se.meshPerAttribute*se.count)}else for(let Ne=0;Ne<W.locationSize;Ne++)T(W.location+Ne);t.bindBuffer(t.ARRAY_BUFFER,xe);for(let Ne=0;Ne<W.locationSize;Ne++)C(W.location+Ne,de/W.locationSize,be,ae,de*fe,de/W.locationSize*Ne*fe,Ce)}}else if(ne!==void 0){const ae=ne[z];if(ae!==void 0)switch(ae.length){case 2:t.vertexAttrib2fv(W.location,ae);break;case 3:t.vertexAttrib3fv(W.location,ae);break;case 4:t.vertexAttrib4fv(W.location,ae);break;default:t.vertexAttrib1fv(W.location,ae)}}}}k()}function A(){O();for(const j in l){const G=l[j];for(const Y in G){const K=G[Y];for(const Z in K)x(K[Z].object),delete K[Z];delete G[Y]}delete l[j]}}function R(j){if(l[j.id]===void 0)return;const G=l[j.id];for(const Y in G){const K=G[Y];for(const Z in K)x(K[Z].object),delete K[Z];delete G[Y]}delete l[j.id]}function F(j){for(const G in l){const Y=l[G];if(Y[j.id]===void 0)continue;const K=Y[j.id];for(const Z in K)x(K[Z].object),delete K[Z];delete Y[j.id]}}function O(){q(),d=!0,u!==c&&(u=c,g(u.object))}function q(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:O,resetDefaultState:q,dispose:A,releaseStatesOfGeometry:R,releaseStatesOfProgram:F,initAttributes:S,enableAttribute:T,disableUnusedAttributes:k}}function yUe(t,e,n,r){const i=r.isWebGL2;let s;function o(d){s=d}function l(d,f){t.drawArrays(s,d,f),n.update(f,s,1)}function c(d,f,m){if(m===0)return;let g,x;if(i)g=t,x="drawArraysInstanced";else if(g=e.get("ANGLE_instanced_arrays"),x="drawArraysInstancedANGLE",g===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}g[x](s,d,f,m),n.update(f,s,m)}function u(d,f,m){if(m===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let x=0;x<m;x++)this.render(d[x],f[x]);else{g.multiDrawArraysWEBGL(s,d,0,f,0,m);let x=0;for(let y=0;y<m;y++)x+=f[y];n.update(x,s,1)}}this.setMode=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function vUe(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function s(C){if(C==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&t.constructor.name==="WebGL2RenderingContext";let l=n.precision!==void 0?n.precision:"highp";const c=s(l);c!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",c,"instead."),l=c);const u=o||e.has("WEBGL_draw_buffers"),d=n.logarithmicDepthBuffer===!0,f=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),m=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),g=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),y=t.getParameter(t.MAX_VERTEX_ATTRIBS),b=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),v=t.getParameter(t.MAX_VARYING_VECTORS),N=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),S=m>0,T=o||e.has("OES_texture_float"),E=S&&T,k=o?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:s,precision:l,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:m,maxTextureSize:g,maxCubemapSize:x,maxAttributes:y,maxVertexUniforms:b,maxVaryings:v,maxFragmentUniforms:N,vertexTextures:S,floatFragmentTextures:T,floatVertexTextures:E,maxSamples:k}}function _Ue(t){const e=this;let n=null,r=0,i=!1,s=!1;const o=new md,l=new An,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,m){const g=f.length!==0||m||r!==0||i;return i=m,r=f.length,g},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,m){n=d(f,m,0)},this.setState=function(f,m,g){const x=f.clippingPlanes,y=f.clipIntersection,b=f.clipShadows,v=t.get(f);if(!i||x===null||x.length===0||s&&!b)s?d(null):u();else{const N=s?0:r,S=N*4;let T=v.clippingState||null;c.value=T,T=d(x,m,S,g);for(let E=0;E!==S;++E)T[E]=n[E];v.clippingState=T,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=N}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,m,g,x){const y=f!==null?f.length:0;let b=null;if(y!==0){if(b=c.value,x!==!0||b===null){const v=g+y*4,N=m.matrixWorldInverse;l.getNormalMatrix(N),(b===null||b.length<v)&&(b=new Float32Array(v));for(let S=0,T=g;S!==y;++S,T+=4)o.copy(f[S]).applyMatrix4(N,l),o.normal.toArray(b,T),b[T+3]=o.constant}c.value=b,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,b}}function wUe(t){let e=new WeakMap;function n(o,l){return l===YP?o.mapping=Ng:l===QP&&(o.mapping=Mg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===YP||l===QP)if(e.has(o)){const c=e.get(o).texture;return n(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const u=new DIe(c.height/2);return u.fromEquirectangularTexture(t,o),e.set(o,u),o.addEventListener("dispose",i),n(u.texture,o.mapping)}else return null}}return o}function i(o){const l=o.target;l.removeEventListener("dispose",i);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}class SUe extends qJ{constructor(e=-1,n=1,r=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=r-e,o=r+e,l=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=u*this.view.offsetX,o=s+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(s,o,l,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}const Vp=4,v7=[.125,.215,.35,.446,.526,.582],tf=20,Ek=new SUe,_7=new Jt;let Tk=null,Ck=0,Ak=0;const Qh=(1+Math.sqrt(5))/2,Np=1/Qh,w7=[new qe(1,1,1),new qe(-1,1,1),new qe(1,1,-1),new qe(-1,1,-1),new qe(0,Qh,Np),new qe(0,Qh,-Np),new qe(Np,0,Qh),new qe(-Np,0,Qh),new qe(Qh,Np,0),new qe(-Qh,Np,0)];class S7{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){Tk=this._renderer.getRenderTarget(),Ck=this._renderer.getActiveCubeFace(),Ak=this._renderer.getActiveMipmapLevel(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,r,i,s),n>0&&this._blur(s,0,0,n),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=E7(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=M7(),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(Tk,Ck,Ak),e.scissorTest=!1,g1(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Ng||e.mapping===Mg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Tk=this._renderer.getRenderTarget(),Ck=this._renderer.getActiveCubeFace(),Ak=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:No,minFilter:No,generateMipmaps:!1,type:$0,format:Mo,colorSpace:bu,depthBuffer:!1},i=N7(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=N7(e,n,r);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=NUe(s)),this._blurMaterial=MUe(s,e,n)}return i}_compileMaterial(e){const n=new il(this._lodPlanes[0],e);this._renderer.compile(n,Ek)}_sceneToCubeUV(e,n,r,i){const l=new $s(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,m=d.toneMapping;d.getClearColor(_7),d.toneMapping=Fd,d.autoClear=!1;const g=new $J({name:"PMREM.Background",side:ws,depthWrite:!1,depthTest:!1}),x=new il(new Uy,g);let y=!1;const b=e.background;b?b.isColor&&(g.color.copy(b),e.background=null,y=!0):(g.color.copy(_7),y=!0);for(let v=0;v<6;v++){const N=v%3;N===0?(l.up.set(0,c[v],0),l.lookAt(u[v],0,0)):N===1?(l.up.set(0,0,c[v]),l.lookAt(0,u[v],0)):(l.up.set(0,c[v],0),l.lookAt(0,0,u[v]));const S=this._cubeSize;g1(i,N*S,v>2?S:0,S,S),d.setRenderTarget(i),y&&d.render(x,l),d.render(e,l)}x.geometry.dispose(),x.material.dispose(),d.toneMapping=m,d.autoClear=f,e.background=b}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Ng||e.mapping===Mg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=E7()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=M7());const s=i?this._cubemapMaterial:this._equirectMaterial,o=new il(this._lodPlanes[0],s),l=s.uniforms;l.envMap.value=e;const c=this._cubeSize;g1(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,Ek)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const s=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=w7[(i-1)%w7.length];this._blur(e,i-1,i,s,o)}n.autoClear=r}_blur(e,n,r,i,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",s),this._halfBlur(o,e,r,r,i,"longitudinal",s)}_halfBlur(e,n,r,i,s,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,f=new il(this._lodPlanes[i],u),m=u.uniforms,g=this._sizeLods[r]-1,x=isFinite(s)?Math.PI/(2*g):2*Math.PI/(2*tf-1),y=s/x,b=isFinite(s)?1+Math.floor(d*y):tf;b>tf&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${tf}`);const v=[];let N=0;for(let C=0;C<tf;++C){const D=C/y,A=Math.exp(-D*D/2);v.push(A),C===0?N+=A:C<b&&(N+=2*A)}for(let C=0;C<v.length;C++)v[C]=v[C]/N;m.envMap.value=e.texture,m.samples.value=b,m.weights.value=v,m.latitudinal.value=o==="latitudinal",l&&(m.poleAxis.value=l);const{_lodMax:S}=this;m.dTheta.value=x,m.mipInt.value=S-r;const T=this._sizeLods[i],E=3*T*(i>S-Vp?i-S+Vp:0),k=4*(this._cubeSize-T);g1(n,E,k,3*T,2*T),c.setRenderTarget(n),c.render(f,Ek)}}function NUe(t){const e=[],n=[],r=[];let i=t;const s=t-Vp+1+v7.length;for(let o=0;o<s;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-Vp?c=v7[o-t+Vp-1]:o===0&&(c=0),r.push(c);const u=1/(l-2),d=-u,f=1+u,m=[d,d,f,d,f,f,d,d,f,f,d,f],g=6,x=6,y=3,b=2,v=1,N=new Float32Array(y*x*g),S=new Float32Array(b*x*g),T=new Float32Array(v*x*g);for(let k=0;k<g;k++){const C=k%3*2/3-1,D=k>2?0:-1,A=[C,D,0,C+2/3,D,0,C+2/3,D+1,0,C,D,0,C+2/3,D+1,0,C,D+1,0];N.set(A,y*x*k),S.set(m,b*x*k);const R=[k,k,k,k,k,k];T.set(R,v*x*k)}const E=new Ba;E.setAttribute("position",new Ys(N,y)),E.setAttribute("uv",new Ys(S,b)),E.setAttribute("faceIndex",new Ys(T,v)),e.push(E),i>Vp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function N7(t,e,n){const r=new Xf(t,e,n);return r.texture.mapping=WN,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function g1(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function MUe(t,e,n){const r=new Float32Array(tf),i=new qe(0,1,0);return new rh({name:"SphericalGaussianBlur",defines:{n:tf,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:GO(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:Id,depthTest:!1,depthWrite:!1})}function M7(){return new rh({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:GO(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:Id,depthTest:!1,depthWrite:!1})}function E7(){return new rh({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:GO(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:Id,depthTest:!1,depthWrite:!1})}function GO(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function EUe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===YP||c===QP,d=c===Ng||c===Mg;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let f=e.get(l);return n===null&&(n=new S7(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),e.set(l,f),f.texture}else{if(e.has(l))return e.get(l).texture;{const f=l.image;if(u&&f&&f.height>0||d&&f&&i(f)){n===null&&(n=new S7(t));const m=u?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,m),l.addEventListener("dispose",s),m.texture}else return null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function s(l){const c=l.target;c.removeEventListener("dispose",s);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function TUe(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 CUe(t,e,n,r){const i={},s=new WeakMap;function o(f){const m=f.target;m.index!==null&&e.remove(m.index);for(const x in m.attributes)e.remove(m.attributes[x]);for(const x in m.morphAttributes){const y=m.morphAttributes[x];for(let b=0,v=y.length;b<v;b++)e.remove(y[b])}m.removeEventListener("dispose",o),delete i[m.id];const g=s.get(m);g&&(e.remove(g),s.delete(m)),r.releaseStatesOfGeometry(m),m.isInstancedBufferGeometry===!0&&delete m._maxInstanceCount,n.memory.geometries--}function l(f,m){return i[m.id]===!0||(m.addEventListener("dispose",o),i[m.id]=!0,n.memory.geometries++),m}function c(f){const m=f.attributes;for(const x in m)e.update(m[x],t.ARRAY_BUFFER);const g=f.morphAttributes;for(const x in g){const y=g[x];for(let b=0,v=y.length;b<v;b++)e.update(y[b],t.ARRAY_BUFFER)}}function u(f){const m=[],g=f.index,x=f.attributes.position;let y=0;if(g!==null){const N=g.array;y=g.version;for(let S=0,T=N.length;S<T;S+=3){const E=N[S+0],k=N[S+1],C=N[S+2];m.push(E,k,k,C,C,E)}}else if(x!==void 0){const N=x.array;y=x.version;for(let S=0,T=N.length/3-1;S<T;S+=3){const E=S+0,k=S+1,C=S+2;m.push(E,k,k,C,C,E)}}else return;const b=new(LJ(m)?VJ:HJ)(m,1);b.version=y;const v=s.get(f);v&&e.remove(v),s.set(f,b)}function d(f){const m=s.get(f);if(m){const g=f.index;g!==null&&m.version<g.version&&u(f)}else u(f);return s.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function AUe(t,e,n,r){const i=r.isWebGL2;let s;function o(g){s=g}let l,c;function u(g){l=g.type,c=g.bytesPerElement}function d(g,x){t.drawElements(s,x,l,g*c),n.update(x,s,1)}function f(g,x,y){if(y===0)return;let b,v;if(i)b=t,v="drawElementsInstanced";else if(b=e.get("ANGLE_instanced_arrays"),v="drawElementsInstancedANGLE",b===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}b[v](s,x,l,g*c,y),n.update(x,s,y)}function m(g,x,y){if(y===0)return;const b=e.get("WEBGL_multi_draw");if(b===null)for(let v=0;v<y;v++)this.render(g[v]/c,x[v]);else{b.multiDrawElementsWEBGL(s,x,0,l,g,0,y);let v=0;for(let N=0;N<y;N++)v+=x[N];n.update(v,s,1)}}this.setMode=o,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=m}function kUe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,o,l){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=l*(s/3);break;case t.LINES:n.lines+=l*(s/2);break;case t.LINE_STRIP:n.lines+=l*(s-1);break;case t.LINE_LOOP:n.lines+=l*s;break;case t.POINTS:n.points+=l*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function jUe(t,e){return t[0]-e[0]}function PUe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function RUe(t,e,n){const r={},i=new Float32Array(8),s=new WeakMap,o=new yr,l=[];for(let u=0;u<8;u++)l[u]=[u,0];function c(u,d,f){const m=u.morphTargetInfluences;if(e.isWebGL2===!0){const x=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,y=x!==void 0?x.length:0;let b=s.get(d);if(b===void 0||b.count!==y){let G=function(){q.dispose(),s.delete(d),d.removeEventListener("dispose",G)};var g=G;b!==void 0&&b.texture.dispose();const S=d.morphAttributes.position!==void 0,T=d.morphAttributes.normal!==void 0,E=d.morphAttributes.color!==void 0,k=d.morphAttributes.position||[],C=d.morphAttributes.normal||[],D=d.morphAttributes.color||[];let A=0;S===!0&&(A=1),T===!0&&(A=2),E===!0&&(A=3);let R=d.attributes.position.count*A,F=1;R>e.maxTextureSize&&(F=Math.ceil(R/e.maxTextureSize),R=e.maxTextureSize);const O=new Float32Array(R*F*4*y),q=new UJ(O,R,F,y);q.type=Xc,q.needsUpdate=!0;const j=A*4;for(let Y=0;Y<y;Y++){const K=k[Y],Z=C[Y],te=D[Y],ne=R*F*4*Y;for(let z=0;z<K.count;z++){const W=z*j;S===!0&&(o.fromBufferAttribute(K,z),O[ne+W+0]=o.x,O[ne+W+1]=o.y,O[ne+W+2]=o.z,O[ne+W+3]=0),T===!0&&(o.fromBufferAttribute(Z,z),O[ne+W+4]=o.x,O[ne+W+5]=o.y,O[ne+W+6]=o.z,O[ne+W+7]=0),E===!0&&(o.fromBufferAttribute(te,z),O[ne+W+8]=o.x,O[ne+W+9]=o.y,O[ne+W+10]=o.z,O[ne+W+11]=te.itemSize===4?o.w:1)}}b={count:y,texture:q,size:new pn(R,F)},s.set(d,b),d.addEventListener("dispose",G)}let v=0;for(let S=0;S<m.length;S++)v+=m[S];const N=d.morphTargetsRelative?1:1-v;f.getUniforms().setValue(t,"morphTargetBaseInfluence",N),f.getUniforms().setValue(t,"morphTargetInfluences",m),f.getUniforms().setValue(t,"morphTargetsTexture",b.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",b.size)}else{const x=m===void 0?0:m.length;let y=r[d.id];if(y===void 0||y.length!==x){y=[];for(let T=0;T<x;T++)y[T]=[T,0];r[d.id]=y}for(let T=0;T<x;T++){const E=y[T];E[0]=T,E[1]=m[T]}y.sort(PUe);for(let T=0;T<8;T++)T<x&&y[T][1]?(l[T][0]=y[T][0],l[T][1]=y[T][1]):(l[T][0]=Number.MAX_SAFE_INTEGER,l[T][1]=0);l.sort(jUe);const b=d.morphAttributes.position,v=d.morphAttributes.normal;let N=0;for(let T=0;T<8;T++){const E=l[T],k=E[0],C=E[1];k!==Number.MAX_SAFE_INTEGER&&C?(b&&d.getAttribute("morphTarget"+T)!==b[k]&&d.setAttribute("morphTarget"+T,b[k]),v&&d.getAttribute("morphNormal"+T)!==v[k]&&d.setAttribute("morphNormal"+T,v[k]),i[T]=C,N+=C):(b&&d.hasAttribute("morphTarget"+T)===!0&&d.deleteAttribute("morphTarget"+T),v&&d.hasAttribute("morphNormal"+T)===!0&&d.deleteAttribute("morphNormal"+T),i[T]=0)}const S=d.morphTargetsRelative?1:1-N;f.getUniforms().setValue(t,"morphTargetBaseInfluence",S),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function DUe(t,e,n,r){let i=new WeakMap;function s(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const m=c.skeleton;i.get(m)!==u&&(m.update(),i.set(m,u))}return f}function o(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:s,dispose:o}}class XJ extends Ss{constructor(e,n,r,i,s,o,l,c,u,d){if(d=d!==void 0?d:Nf,d!==Nf&&d!==Eg)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===Nf&&(r=Ed),r===void 0&&d===Eg&&(r=Sf),super(null,i,s,o,l,c,d,r,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=l!==void 0?l:va,this.minFilter=c!==void 0?c:va,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 YJ=new Ss,QJ=new XJ(1,1);QJ.compareFunction=DJ;const ZJ=new UJ,JJ=new bIe,eee=new WJ,T7=[],C7=[],A7=new Float32Array(16),k7=new Float32Array(9),j7=new Float32Array(4);function ix(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=T7[i];if(s===void 0&&(s=new Float32Array(i),T7[i]=s),e!==0){r.toArray(s,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(s,l)}return s}function Fi(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 Ui(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function YN(t,e){let n=C7[e];n===void 0&&(n=new Int32Array(e),C7[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function OUe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function LUe(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(Fi(n,e))return;t.uniform2fv(this.addr,e),Ui(n,e)}}function IUe(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(Fi(n,e))return;t.uniform3fv(this.addr,e),Ui(n,e)}}function FUe(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(Fi(n,e))return;t.uniform4fv(this.addr,e),Ui(n,e)}}function UUe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Fi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Ui(n,e)}else{if(Fi(n,r))return;j7.set(r),t.uniformMatrix2fv(this.addr,!1,j7),Ui(n,r)}}function zUe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Fi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Ui(n,e)}else{if(Fi(n,r))return;k7.set(r),t.uniformMatrix3fv(this.addr,!1,k7),Ui(n,r)}}function BUe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Fi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Ui(n,e)}else{if(Fi(n,r))return;A7.set(r),t.uniformMatrix4fv(this.addr,!1,A7),Ui(n,r)}}function $Ue(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function HUe(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(Fi(n,e))return;t.uniform2iv(this.addr,e),Ui(n,e)}}function VUe(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(Fi(n,e))return;t.uniform3iv(this.addr,e),Ui(n,e)}}function GUe(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(Fi(n,e))return;t.uniform4iv(this.addr,e),Ui(n,e)}}function qUe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function WUe(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(Fi(n,e))return;t.uniform2uiv(this.addr,e),Ui(n,e)}}function KUe(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(Fi(n,e))return;t.uniform3uiv(this.addr,e),Ui(n,e)}}function XUe(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(Fi(n,e))return;t.uniform4uiv(this.addr,e),Ui(n,e)}}function YUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);const s=this.type===t.SAMPLER_2D_SHADOW?QJ:YJ;n.setTexture2D(e||s,i)}function QUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||JJ,i)}function ZUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||eee,i)}function JUe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||ZJ,i)}function eze(t){switch(t){case 5126:return OUe;case 35664:return LUe;case 35665:return IUe;case 35666:return FUe;case 35674:return UUe;case 35675:return zUe;case 35676:return BUe;case 5124:case 35670:return $Ue;case 35667:case 35671:return HUe;case 35668:case 35672:return VUe;case 35669:case 35673:return GUe;case 5125:return qUe;case 36294:return WUe;case 36295:return KUe;case 36296:return XUe;case 35678:case 36198:case 36298:case 36306:case 35682:return YUe;case 35679:case 36299:case 36307:return QUe;case 35680:case 36300:case 36308:case 36293:return ZUe;case 36289:case 36303:case 36311:case 36292:return JUe}}function tze(t,e){t.uniform1fv(this.addr,e)}function nze(t,e){const n=ix(e,this.size,2);t.uniform2fv(this.addr,n)}function rze(t,e){const n=ix(e,this.size,3);t.uniform3fv(this.addr,n)}function ize(t,e){const n=ix(e,this.size,4);t.uniform4fv(this.addr,n)}function aze(t,e){const n=ix(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function sze(t,e){const n=ix(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function oze(t,e){const n=ix(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function lze(t,e){t.uniform1iv(this.addr,e)}function cze(t,e){t.uniform2iv(this.addr,e)}function uze(t,e){t.uniform3iv(this.addr,e)}function dze(t,e){t.uniform4iv(this.addr,e)}function hze(t,e){t.uniform1uiv(this.addr,e)}function fze(t,e){t.uniform2uiv(this.addr,e)}function mze(t,e){t.uniform3uiv(this.addr,e)}function pze(t,e){t.uniform4uiv(this.addr,e)}function gze(t,e,n){const r=this.cache,i=e.length,s=YN(n,i);Fi(r,s)||(t.uniform1iv(this.addr,s),Ui(r,s));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||YJ,s[o])}function xze(t,e,n){const r=this.cache,i=e.length,s=YN(n,i);Fi(r,s)||(t.uniform1iv(this.addr,s),Ui(r,s));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||JJ,s[o])}function bze(t,e,n){const r=this.cache,i=e.length,s=YN(n,i);Fi(r,s)||(t.uniform1iv(this.addr,s),Ui(r,s));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||eee,s[o])}function yze(t,e,n){const r=this.cache,i=e.length,s=YN(n,i);Fi(r,s)||(t.uniform1iv(this.addr,s),Ui(r,s));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||ZJ,s[o])}function vze(t){switch(t){case 5126:return tze;case 35664:return nze;case 35665:return rze;case 35666:return ize;case 35674:return aze;case 35675:return sze;case 35676:return oze;case 5124:case 35670:return lze;case 35667:case 35671:return cze;case 35668:case 35672:return uze;case 35669:case 35673:return dze;case 5125:return hze;case 36294:return fze;case 36295:return mze;case 36296:return pze;case 35678:case 36198:case 36298:case 36306:case 35682:return gze;case 35679:case 36299:case 36307:return xze;case 35680:case 36300:case 36308:case 36293:return bze;case 36289:case 36303:case 36311:case 36292:return yze}}class _ze{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=eze(n.type)}}class wze{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=vze(n.type)}}class Sze{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let s=0,o=i.length;s!==o;++s){const l=i[s];l.setValue(e,n[l.id],r)}}}const kk=/(\w+)(\])?(\[|\.)?/g;function P7(t,e){t.seq.push(e),t.map[e.id]=e}function Nze(t,e,n){const r=t.name,i=r.length;for(kk.lastIndex=0;;){const s=kk.exec(r),o=kk.lastIndex;let l=s[1];const c=s[2]==="]",u=s[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){P7(n,u===void 0?new _ze(l,t,e):new wze(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new Sze(l),P7(n,f)),n=f}}}class sw{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const s=e.getActiveUniform(n,i),o=e.getUniformLocation(n,s.name);Nze(s,o,this)}}setValue(e,n,r,i){const s=this.map[n];s!==void 0&&s.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let s=0,o=n.length;s!==o;++s){const l=n[s],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,s=e.length;i!==s;++i){const o=e[i];o.id in n&&r.push(o)}return r}}function R7(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const Mze=37297;let Eze=0;function Tze(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let o=i;o<s;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
- `)}function Cze(t){const e=xr.getPrimaries(xr.workingColorSpace),n=xr.getPrimaries(t);let r;switch(e===n?r="":e===jS&&n===kS?r="LinearDisplayP3ToLinearSRGB":e===kS&&n===jS&&(r="LinearSRGBToLinearDisplayP3"),t){case bu:case KN:return[r,"LinearTransferOETF"];case _a:case zO:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function D7(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const o=parseInt(s[1]);return n.toUpperCase()+`
- `+i+`
- `+Tze(t.getShaderSource(e),o)}else return i}function Aze(t,e){const n=Cze(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function kze(t,e){let n;switch(e){case ALe:n="Linear";break;case kLe:n="Reinhard";break;case jLe:n="OptimizedCineon";break;case PLe:n="ACESFilmic";break;case RLe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function jze(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(Rb).join(`
- `)}function Pze(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function Rze(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const s=t.getActiveAttrib(e,i),o=s.name;let l=1;s.type===t.FLOAT_MAT2&&(l=2),s.type===t.FLOAT_MAT3&&(l=3),s.type===t.FLOAT_MAT4&&(l=4),n[o]={type:s.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function Rb(t){return t!==""}function O7(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 L7(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Dze=/^[ \t]*#include +<([\w\d./]+)>/gm;function rR(t){return t.replace(Dze,Lze)}const Oze=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function Lze(t,e){let n=wn[e];if(n===void 0){const r=Oze.get(e);if(r!==void 0)n=wn[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 rR(n)}const Ize=/#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 I7(t){return t.replace(Ize,Fze)}function Fze(t,e,n,r){let i="";for(let s=parseInt(e);s<parseInt(n);s++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function F7(t){let e="precision "+t.precision+` float;
- precision `+t.precision+" int;";return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function Uze(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===SJ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===rLe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Lc&&(e="SHADOWMAP_TYPE_VSM"),e}function zze(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Ng:case Mg:e="ENVMAP_TYPE_CUBE";break;case WN:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Bze(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Mg:e="ENVMAP_MODE_REFRACTION";break}return e}function $ze(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case FO:e="ENVMAP_BLENDING_MULTIPLY";break;case TLe:e="ENVMAP_BLENDING_MIX";break;case CLe:e="ENVMAP_BLENDING_ADD";break}return e}function Hze(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 Vze(t,e,n,r){const i=t.getContext(),s=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=Uze(n),u=zze(n),d=Bze(n),f=$ze(n),m=Hze(n),g=n.isWebGL2?"":jze(n),x=Pze(s),y=i.createProgram();let b,v,N=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Rb).join(`
- `),b.length>0&&(b+=`
- `),v=[g,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Rb).join(`
- `),v.length>0&&(v+=`
- `)):(b=[F7(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(Rb).join(`
- `),v=[g,F7(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Fd?"#define TONE_MAPPING":"",n.toneMapping!==Fd?wn.tonemapping_pars_fragment:"",n.toneMapping!==Fd?kze("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",wn.colorspace_pars_fragment,Aze("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Rb).join(`
- `)),o=rR(o),o=O7(o,n),o=L7(o,n),l=rR(l),l=O7(l,n),l=L7(l,n),o=I7(o),l=I7(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(N=`#version 300 es
- `,b=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+b,v=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===n7?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===n7?"":"#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(`
- `)+`
- `+v);const S=N+b+o,T=N+v+l,E=R7(i,i.VERTEX_SHADER,S),k=R7(i,i.FRAGMENT_SHADER,T);i.attachShader(y,E),i.attachShader(y,k),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function C(F){if(t.debug.checkShaderErrors){const O=i.getProgramInfoLog(y).trim(),q=i.getShaderInfoLog(E).trim(),j=i.getShaderInfoLog(k).trim();let G=!0,Y=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(G=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,E,k);else{const K=D7(i,E,"vertex"),Z=D7(i,k,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
- Program Info Log: `+O+`
- `+K+`
- `+Z)}else O!==""?console.warn("THREE.WebGLProgram: Program Info Log:",O):(q===""||j==="")&&(Y=!1);Y&&(F.diagnostics={runnable:G,programLog:O,vertexShader:{log:q,prefix:b},fragmentShader:{log:j,prefix:v}})}i.deleteShader(E),i.deleteShader(k),D=new sw(i,y),A=Rze(i,y)}let D;this.getUniforms=function(){return D===void 0&&C(this),D};let A;this.getAttributes=function(){return A===void 0&&C(this),A};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(y,Mze)),R},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Eze++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=E,this.fragmentShader=k,this}let Gze=0;class qze{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),s=this._getShaderStage(r),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new Wze(e),n.set(e,r)),r}}class Wze{constructor(e){this.id=Gze++,this.code=e,this.usedTimes=0}}function Kze(t,e,n,r,i,s,o){const l=new zJ,c=new qze,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,m=i.vertexTextures;let g=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(A){return A===0?"uv":`uv${A}`}function b(A,R,F,O,q){const j=O.fog,G=q.geometry,Y=A.isMeshStandardMaterial?O.environment:null,K=(A.isMeshStandardMaterial?n:e).get(A.envMap||Y),Z=K&&K.mapping===WN?K.image.height:null,te=x[A.type];A.precision!==null&&(g=i.getMaxPrecision(A.precision),g!==A.precision&&console.warn("THREE.WebGLProgram.getParameters:",A.precision,"not supported, using",g,"instead."));const ne=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,z=ne!==void 0?ne.length:0;let W=0;G.morphAttributes.position!==void 0&&(W=1),G.morphAttributes.normal!==void 0&&(W=2),G.morphAttributes.color!==void 0&&(W=3);let se,ae,de,me;if(te){const ln=gs[te];se=ln.vertexShader,ae=ln.fragmentShader}else se=A.vertexShader,ae=A.fragmentShader,c.update(A),de=c.getVertexShaderID(A),me=c.getFragmentShaderID(A);const xe=t.getRenderTarget(),be=q.isInstancedMesh===!0,fe=q.isBatchedMesh===!0,Ce=!!A.map,Ne=!!A.matcap,re=!!K,He=!!A.aoMap,H=!!A.lightMap,B=!!A.bumpMap,X=!!A.normalMap,U=!!A.displacementMap,Q=!!A.emissiveMap,le=!!A.metalnessMap,Pe=!!A.roughnessMap,Oe=A.anisotropy>0,je=A.clearcoat>0,$=A.iridescence>0,I=A.sheen>0,V=A.transmission>0,ie=Oe&&!!A.anisotropyMap,Se=je&&!!A.clearcoatMap,ye=je&&!!A.clearcoatNormalMap,$e=je&&!!A.clearcoatRoughnessMap,Ue=$&&!!A.iridescenceMap,Ge=$&&!!A.iridescenceThicknessMap,We=I&&!!A.sheenColorMap,Ye=I&&!!A.sheenRoughnessMap,oe=!!A.specularMap,ve=!!A.specularColorMap,Le=!!A.specularIntensityMap,Ke=V&&!!A.transmissionMap,lt=V&&!!A.thicknessMap,_e=!!A.gradientMap,ce=!!A.alphaMap,ee=A.alphaTest>0,ke=!!A.alphaHash,De=!!A.extensions,Ae=!!G.attributes.uv1,Je=!!G.attributes.uv2,gt=!!G.attributes.uv3;let At=Fd;return A.toneMapped&&(xe===null||xe.isXRRenderTarget===!0)&&(At=t.toneMapping),{isWebGL2:d,shaderID:te,shaderType:A.type,shaderName:A.name,vertexShader:se,fragmentShader:ae,defines:A.defines,customVertexShaderID:de,customFragmentShaderID:me,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:g,batching:fe,instancing:be,instancingColor:be&&q.instanceColor!==null,supportsVertexTextures:m,outputColorSpace:xe===null?t.outputColorSpace:xe.isXRRenderTarget===!0?xe.texture.colorSpace:bu,map:Ce,matcap:Ne,envMap:re,envMapMode:re&&K.mapping,envMapCubeUVHeight:Z,aoMap:He,lightMap:H,bumpMap:B,normalMap:X,displacementMap:m&&U,emissiveMap:Q,normalMapObjectSpace:X&&A.normalMapType===GLe,normalMapTangentSpace:X&&A.normalMapType===RJ,metalnessMap:le,roughnessMap:Pe,anisotropy:Oe,anisotropyMap:ie,clearcoat:je,clearcoatMap:Se,clearcoatNormalMap:ye,clearcoatRoughnessMap:$e,iridescence:$,iridescenceMap:Ue,iridescenceThicknessMap:Ge,sheen:I,sheenColorMap:We,sheenRoughnessMap:Ye,specularMap:oe,specularColorMap:ve,specularIntensityMap:Le,transmission:V,transmissionMap:Ke,thicknessMap:lt,gradientMap:_e,opaque:A.transparent===!1&&A.blending===tg,alphaMap:ce,alphaTest:ee,alphaHash:ke,combine:A.combine,mapUv:Ce&&y(A.map.channel),aoMapUv:He&&y(A.aoMap.channel),lightMapUv:H&&y(A.lightMap.channel),bumpMapUv:B&&y(A.bumpMap.channel),normalMapUv:X&&y(A.normalMap.channel),displacementMapUv:U&&y(A.displacementMap.channel),emissiveMapUv:Q&&y(A.emissiveMap.channel),metalnessMapUv:le&&y(A.metalnessMap.channel),roughnessMapUv:Pe&&y(A.roughnessMap.channel),anisotropyMapUv:ie&&y(A.anisotropyMap.channel),clearcoatMapUv:Se&&y(A.clearcoatMap.channel),clearcoatNormalMapUv:ye&&y(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:$e&&y(A.clearcoatRoughnessMap.channel),iridescenceMapUv:Ue&&y(A.iridescenceMap.channel),iridescenceThicknessMapUv:Ge&&y(A.iridescenceThicknessMap.channel),sheenColorMapUv:We&&y(A.sheenColorMap.channel),sheenRoughnessMapUv:Ye&&y(A.sheenRoughnessMap.channel),specularMapUv:oe&&y(A.specularMap.channel),specularColorMapUv:ve&&y(A.specularColorMap.channel),specularIntensityMapUv:Le&&y(A.specularIntensityMap.channel),transmissionMapUv:Ke&&y(A.transmissionMap.channel),thicknessMapUv:lt&&y(A.thicknessMap.channel),alphaMapUv:ce&&y(A.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(X||Oe),vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,vertexUv1s:Ae,vertexUv2s:Je,vertexUv3s:gt,pointsUvs:q.isPoints===!0&&!!G.attributes.uv&&(Ce||ce),fog:!!j,useFog:A.fog===!0,fogExp2:j&&j.isFogExp2,flatShading:A.flatShading===!0,sizeAttenuation:A.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:q.isSkinnedMesh===!0,morphTargets:G.morphAttributes.position!==void 0,morphNormals:G.morphAttributes.normal!==void 0,morphColors:G.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:W,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numSpotLightMaps:R.spotLightMap.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numSpotLightShadowsWithMaps:R.numSpotLightShadowsWithMaps,numLightProbes:R.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:A.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:At,useLegacyLights:t._useLegacyLights,decodeVideoTexture:Ce&&A.map.isVideoTexture===!0&&xr.getTransfer(A.map.colorSpace)===Dr,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===Hc,flipSided:A.side===ws,useDepthPacking:A.depthPacking>=0,depthPacking:A.depthPacking||0,index0AttributeName:A.index0AttributeName,extensionDerivatives:De&&A.extensions.derivatives===!0,extensionFragDepth:De&&A.extensions.fragDepth===!0,extensionDrawBuffers:De&&A.extensions.drawBuffers===!0,extensionShaderTextureLOD:De&&A.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:d||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||r.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:A.customProgramCacheKey()}}function v(A){const R=[];if(A.shaderID?R.push(A.shaderID):(R.push(A.customVertexShaderID),R.push(A.customFragmentShaderID)),A.defines!==void 0)for(const F in A.defines)R.push(F),R.push(A.defines[F]);return A.isRawShaderMaterial===!1&&(N(R,A),S(R,A),R.push(t.outputColorSpace)),R.push(A.customProgramCacheKey),R.join()}function N(A,R){A.push(R.precision),A.push(R.outputColorSpace),A.push(R.envMapMode),A.push(R.envMapCubeUVHeight),A.push(R.mapUv),A.push(R.alphaMapUv),A.push(R.lightMapUv),A.push(R.aoMapUv),A.push(R.bumpMapUv),A.push(R.normalMapUv),A.push(R.displacementMapUv),A.push(R.emissiveMapUv),A.push(R.metalnessMapUv),A.push(R.roughnessMapUv),A.push(R.anisotropyMapUv),A.push(R.clearcoatMapUv),A.push(R.clearcoatNormalMapUv),A.push(R.clearcoatRoughnessMapUv),A.push(R.iridescenceMapUv),A.push(R.iridescenceThicknessMapUv),A.push(R.sheenColorMapUv),A.push(R.sheenRoughnessMapUv),A.push(R.specularMapUv),A.push(R.specularColorMapUv),A.push(R.specularIntensityMapUv),A.push(R.transmissionMapUv),A.push(R.thicknessMapUv),A.push(R.combine),A.push(R.fogExp2),A.push(R.sizeAttenuation),A.push(R.morphTargetsCount),A.push(R.morphAttributeCount),A.push(R.numDirLights),A.push(R.numPointLights),A.push(R.numSpotLights),A.push(R.numSpotLightMaps),A.push(R.numHemiLights),A.push(R.numRectAreaLights),A.push(R.numDirLightShadows),A.push(R.numPointLightShadows),A.push(R.numSpotLightShadows),A.push(R.numSpotLightShadowsWithMaps),A.push(R.numLightProbes),A.push(R.shadowMapType),A.push(R.toneMapping),A.push(R.numClippingPlanes),A.push(R.numClipIntersection),A.push(R.depthPacking)}function S(A,R){l.disableAll(),R.isWebGL2&&l.enable(0),R.supportsVertexTextures&&l.enable(1),R.instancing&&l.enable(2),R.instancingColor&&l.enable(3),R.matcap&&l.enable(4),R.envMap&&l.enable(5),R.normalMapObjectSpace&&l.enable(6),R.normalMapTangentSpace&&l.enable(7),R.clearcoat&&l.enable(8),R.iridescence&&l.enable(9),R.alphaTest&&l.enable(10),R.vertexColors&&l.enable(11),R.vertexAlphas&&l.enable(12),R.vertexUv1s&&l.enable(13),R.vertexUv2s&&l.enable(14),R.vertexUv3s&&l.enable(15),R.vertexTangents&&l.enable(16),R.anisotropy&&l.enable(17),R.alphaHash&&l.enable(18),R.batching&&l.enable(19),A.push(l.mask),l.disableAll(),R.fog&&l.enable(0),R.useFog&&l.enable(1),R.flatShading&&l.enable(2),R.logarithmicDepthBuffer&&l.enable(3),R.skinning&&l.enable(4),R.morphTargets&&l.enable(5),R.morphNormals&&l.enable(6),R.morphColors&&l.enable(7),R.premultipliedAlpha&&l.enable(8),R.shadowMapEnabled&&l.enable(9),R.useLegacyLights&&l.enable(10),R.doubleSided&&l.enable(11),R.flipSided&&l.enable(12),R.useDepthPacking&&l.enable(13),R.dithering&&l.enable(14),R.transmission&&l.enable(15),R.sheen&&l.enable(16),R.opaque&&l.enable(17),R.pointsUvs&&l.enable(18),R.decodeVideoTexture&&l.enable(19),A.push(l.mask)}function T(A){const R=x[A.type];let F;if(R){const O=gs[R];F=HO.clone(O.uniforms)}else F=A.uniforms;return F}function E(A,R){let F;for(let O=0,q=u.length;O<q;O++){const j=u[O];if(j.cacheKey===R){F=j,++F.usedTimes;break}}return F===void 0&&(F=new Vze(t,R,A,s),u.push(F)),F}function k(A){if(--A.usedTimes===0){const R=u.indexOf(A);u[R]=u[u.length-1],u.pop(),A.destroy()}}function C(A){c.remove(A)}function D(){c.dispose()}return{getParameters:b,getProgramCacheKey:v,getUniforms:T,acquireProgram:E,releaseProgram:k,releaseShaderCache:C,programs:u,dispose:D}}function Xze(){let t=new WeakMap;function e(s){let o=t.get(s);return o===void 0&&(o={},t.set(s,o)),o}function n(s){t.delete(s)}function r(s,o,l){t.get(s)[o]=l}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function Yze(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 U7(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 z7(){const t=[];let e=0;const n=[],r=[],i=[];function s(){e=0,n.length=0,r.length=0,i.length=0}function o(f,m,g,x,y,b){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:m,material:g,groupOrder:x,renderOrder:f.renderOrder,z:y,group:b},t[e]=v):(v.id=f.id,v.object=f,v.geometry=m,v.material=g,v.groupOrder=x,v.renderOrder=f.renderOrder,v.z=y,v.group=b),e++,v}function l(f,m,g,x,y,b){const v=o(f,m,g,x,y,b);g.transmission>0?r.push(v):g.transparent===!0?i.push(v):n.push(v)}function c(f,m,g,x,y,b){const v=o(f,m,g,x,y,b);g.transmission>0?r.unshift(v):g.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,m){n.length>1&&n.sort(f||Yze),r.length>1&&r.sort(m||U7),i.length>1&&i.sort(m||U7)}function d(){for(let f=e,m=t.length;f<m;f++){const g=t[f];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:n,transmissive:r,transparent:i,init:s,push:l,unshift:c,finish:d,sort:u}}function Qze(){let t=new WeakMap;function e(r,i){const s=t.get(r);let o;return s===void 0?(o=new z7,t.set(r,[o])):i>=s.length?(o=new z7,s.push(o)):o=s[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function Zze(){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 qe,color:new Jt};break;case"SpotLight":n={position:new qe,direction:new qe,color:new Jt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new qe,color:new Jt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new qe,skyColor:new Jt,groundColor:new Jt};break;case"RectAreaLight":n={color:new Jt,position:new qe,halfWidth:new qe,halfHeight:new qe};break}return t[e.id]=n,n}}}function Jze(){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 pn};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new pn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new pn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let eBe=0;function tBe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function nBe(t,e){const n=new Zze,r=Jze(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let d=0;d<9;d++)i.probe.push(new qe);const s=new qe,o=new kr,l=new kr;function c(d,f){let m=0,g=0,x=0;for(let O=0;O<9;O++)i.probe[O].set(0,0,0);let y=0,b=0,v=0,N=0,S=0,T=0,E=0,k=0,C=0,D=0,A=0;d.sort(tBe);const R=f===!0?Math.PI:1;for(let O=0,q=d.length;O<q;O++){const j=d[O],G=j.color,Y=j.intensity,K=j.distance,Z=j.shadow&&j.shadow.map?j.shadow.map.texture:null;if(j.isAmbientLight)m+=G.r*Y*R,g+=G.g*Y*R,x+=G.b*Y*R;else if(j.isLightProbe){for(let te=0;te<9;te++)i.probe[te].addScaledVector(j.sh.coefficients[te],Y);A++}else if(j.isDirectionalLight){const te=n.get(j);if(te.color.copy(j.color).multiplyScalar(j.intensity*R),j.castShadow){const ne=j.shadow,z=r.get(j);z.shadowBias=ne.bias,z.shadowNormalBias=ne.normalBias,z.shadowRadius=ne.radius,z.shadowMapSize=ne.mapSize,i.directionalShadow[y]=z,i.directionalShadowMap[y]=Z,i.directionalShadowMatrix[y]=j.shadow.matrix,T++}i.directional[y]=te,y++}else if(j.isSpotLight){const te=n.get(j);te.position.setFromMatrixPosition(j.matrixWorld),te.color.copy(G).multiplyScalar(Y*R),te.distance=K,te.coneCos=Math.cos(j.angle),te.penumbraCos=Math.cos(j.angle*(1-j.penumbra)),te.decay=j.decay,i.spot[v]=te;const ne=j.shadow;if(j.map&&(i.spotLightMap[C]=j.map,C++,ne.updateMatrices(j),j.castShadow&&D++),i.spotLightMatrix[v]=ne.matrix,j.castShadow){const z=r.get(j);z.shadowBias=ne.bias,z.shadowNormalBias=ne.normalBias,z.shadowRadius=ne.radius,z.shadowMapSize=ne.mapSize,i.spotShadow[v]=z,i.spotShadowMap[v]=Z,k++}v++}else if(j.isRectAreaLight){const te=n.get(j);te.color.copy(G).multiplyScalar(Y),te.halfWidth.set(j.width*.5,0,0),te.halfHeight.set(0,j.height*.5,0),i.rectArea[N]=te,N++}else if(j.isPointLight){const te=n.get(j);if(te.color.copy(j.color).multiplyScalar(j.intensity*R),te.distance=j.distance,te.decay=j.decay,j.castShadow){const ne=j.shadow,z=r.get(j);z.shadowBias=ne.bias,z.shadowNormalBias=ne.normalBias,z.shadowRadius=ne.radius,z.shadowMapSize=ne.mapSize,z.shadowCameraNear=ne.camera.near,z.shadowCameraFar=ne.camera.far,i.pointShadow[b]=z,i.pointShadowMap[b]=Z,i.pointShadowMatrix[b]=j.shadow.matrix,E++}i.point[b]=te,b++}else if(j.isHemisphereLight){const te=n.get(j);te.skyColor.copy(j.color).multiplyScalar(Y*R),te.groundColor.copy(j.groundColor).multiplyScalar(Y*R),i.hemi[S]=te,S++}}N>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Rt.LTC_FLOAT_1,i.rectAreaLTC2=Rt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Rt.LTC_HALF_1,i.rectAreaLTC2=Rt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=m,i.ambient[1]=g,i.ambient[2]=x;const F=i.hash;(F.directionalLength!==y||F.pointLength!==b||F.spotLength!==v||F.rectAreaLength!==N||F.hemiLength!==S||F.numDirectionalShadows!==T||F.numPointShadows!==E||F.numSpotShadows!==k||F.numSpotMaps!==C||F.numLightProbes!==A)&&(i.directional.length=y,i.spot.length=v,i.rectArea.length=N,i.point.length=b,i.hemi.length=S,i.directionalShadow.length=T,i.directionalShadowMap.length=T,i.pointShadow.length=E,i.pointShadowMap.length=E,i.spotShadow.length=k,i.spotShadowMap.length=k,i.directionalShadowMatrix.length=T,i.pointShadowMatrix.length=E,i.spotLightMatrix.length=k+C-D,i.spotLightMap.length=C,i.numSpotLightShadowsWithMaps=D,i.numLightProbes=A,F.directionalLength=y,F.pointLength=b,F.spotLength=v,F.rectAreaLength=N,F.hemiLength=S,F.numDirectionalShadows=T,F.numPointShadows=E,F.numSpotShadows=k,F.numSpotMaps=C,F.numLightProbes=A,i.version=eBe++)}function u(d,f){let m=0,g=0,x=0,y=0,b=0;const v=f.matrixWorldInverse;for(let N=0,S=d.length;N<S;N++){const T=d[N];if(T.isDirectionalLight){const E=i.directional[m];E.direction.setFromMatrixPosition(T.matrixWorld),s.setFromMatrixPosition(T.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(v),m++}else if(T.isSpotLight){const E=i.spot[x];E.position.setFromMatrixPosition(T.matrixWorld),E.position.applyMatrix4(v),E.direction.setFromMatrixPosition(T.matrixWorld),s.setFromMatrixPosition(T.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(v),x++}else if(T.isRectAreaLight){const E=i.rectArea[y];E.position.setFromMatrixPosition(T.matrixWorld),E.position.applyMatrix4(v),l.identity(),o.copy(T.matrixWorld),o.premultiply(v),l.extractRotation(o),E.halfWidth.set(T.width*.5,0,0),E.halfHeight.set(0,T.height*.5,0),E.halfWidth.applyMatrix4(l),E.halfHeight.applyMatrix4(l),y++}else if(T.isPointLight){const E=i.point[g];E.position.setFromMatrixPosition(T.matrixWorld),E.position.applyMatrix4(v),g++}else if(T.isHemisphereLight){const E=i.hemi[b];E.direction.setFromMatrixPosition(T.matrixWorld),E.direction.transformDirection(v),b++}}}return{setup:c,setupView:u,state:i}}function B7(t,e){const n=new nBe(t,e),r=[],i=[];function s(){r.length=0,i.length=0}function o(f){r.push(f)}function l(f){i.push(f)}function c(f){n.setup(r,f)}function u(f){n.setupView(r,f)}return{init:s,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:c,setupLightsView:u,pushLight:o,pushShadow:l}}function rBe(t,e){let n=new WeakMap;function r(s,o=0){const l=n.get(s);let c;return l===void 0?(c=new B7(t,e),n.set(s,[c])):o>=l.length?(c=new B7(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class iBe extends rx{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=HLe,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 aBe extends rx{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 sBe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,oBe=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function lBe(t,e,n){let r=new XN;const i=new pn,s=new pn,o=new yr,l=new iBe({depthPacking:VLe}),c=new aBe,u={},d=n.maxTextureSize,f={[nh]:ws,[ws]:nh,[Hc]:Hc},m=new rh({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new pn},radius:{value:4}},vertexShader:sBe,fragmentShader:oBe}),g=m.clone();g.defines.HORIZONTAL_PASS=1;const x=new Ba;x.setAttribute("position",new Ys(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new il(x,m),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=SJ;let v=this.type;this.render=function(E,k,C){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||E.length===0)return;const D=t.getRenderTarget(),A=t.getActiveCubeFace(),R=t.getActiveMipmapLevel(),F=t.state;F.setBlending(Id),F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const O=v!==Lc&&this.type===Lc,q=v===Lc&&this.type!==Lc;for(let j=0,G=E.length;j<G;j++){const Y=E[j],K=Y.shadow;if(K===void 0){console.warn("THREE.WebGLShadowMap:",Y,"has no shadow.");continue}if(K.autoUpdate===!1&&K.needsUpdate===!1)continue;i.copy(K.mapSize);const Z=K.getFrameExtents();if(i.multiply(Z),s.copy(K.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/Z.x),i.x=s.x*Z.x,K.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/Z.y),i.y=s.y*Z.y,K.mapSize.y=s.y)),K.map===null||O===!0||q===!0){const ne=this.type!==Lc?{minFilter:va,magFilter:va}:{};K.map!==null&&K.map.dispose(),K.map=new Xf(i.x,i.y,ne),K.map.texture.name=Y.name+".shadowMap",K.camera.updateProjectionMatrix()}t.setRenderTarget(K.map),t.clear();const te=K.getViewportCount();for(let ne=0;ne<te;ne++){const z=K.getViewport(ne);o.set(s.x*z.x,s.y*z.y,s.x*z.z,s.y*z.w),F.viewport(o),K.updateMatrices(Y,ne),r=K.getFrustum(),T(k,C,K.camera,Y,this.type)}K.isPointLightShadow!==!0&&this.type===Lc&&N(K,C),K.needsUpdate=!1}v=this.type,b.needsUpdate=!1,t.setRenderTarget(D,A,R)};function N(E,k){const C=e.update(y);m.defines.VSM_SAMPLES!==E.blurSamples&&(m.defines.VSM_SAMPLES=E.blurSamples,g.defines.VSM_SAMPLES=E.blurSamples,m.needsUpdate=!0,g.needsUpdate=!0),E.mapPass===null&&(E.mapPass=new Xf(i.x,i.y)),m.uniforms.shadow_pass.value=E.map.texture,m.uniforms.resolution.value=E.mapSize,m.uniforms.radius.value=E.radius,t.setRenderTarget(E.mapPass),t.clear(),t.renderBufferDirect(k,null,C,m,y,null),g.uniforms.shadow_pass.value=E.mapPass.texture,g.uniforms.resolution.value=E.mapSize,g.uniforms.radius.value=E.radius,t.setRenderTarget(E.map),t.clear(),t.renderBufferDirect(k,null,C,g,y,null)}function S(E,k,C,D){let A=null;const R=C.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(R!==void 0)A=R;else if(A=C.isPointLight===!0?c:l,t.localClippingEnabled&&k.clipShadows===!0&&Array.isArray(k.clippingPlanes)&&k.clippingPlanes.length!==0||k.displacementMap&&k.displacementScale!==0||k.alphaMap&&k.alphaTest>0||k.map&&k.alphaTest>0){const F=A.uuid,O=k.uuid;let q=u[F];q===void 0&&(q={},u[F]=q);let j=q[O];j===void 0&&(j=A.clone(),q[O]=j),A=j}if(A.visible=k.visible,A.wireframe=k.wireframe,D===Lc?A.side=k.shadowSide!==null?k.shadowSide:k.side:A.side=k.shadowSide!==null?k.shadowSide:f[k.side],A.alphaMap=k.alphaMap,A.alphaTest=k.alphaTest,A.map=k.map,A.clipShadows=k.clipShadows,A.clippingPlanes=k.clippingPlanes,A.clipIntersection=k.clipIntersection,A.displacementMap=k.displacementMap,A.displacementScale=k.displacementScale,A.displacementBias=k.displacementBias,A.wireframeLinewidth=k.wireframeLinewidth,A.linewidth=k.linewidth,C.isPointLight===!0&&A.isMeshDistanceMaterial===!0){const F=t.properties.get(A);F.light=C}return A}function T(E,k,C,D,A){if(E.visible===!1)return;if(E.layers.test(k.layers)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&A===Lc)&&(!E.frustumCulled||r.intersectsObject(E))){E.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,E.matrixWorld);const O=e.update(E),q=E.material;if(Array.isArray(q)){const j=O.groups;for(let G=0,Y=j.length;G<Y;G++){const K=j[G],Z=q[K.materialIndex];if(Z&&Z.visible){const te=S(E,Z,D,A);E.onBeforeShadow(t,E,k,C,O,te,K),t.renderBufferDirect(C,null,O,te,E,K),E.onAfterShadow(t,E,k,C,O,te,K)}}}else if(q.visible){const j=S(E,q,D,A);E.onBeforeShadow(t,E,k,C,O,j,null),t.renderBufferDirect(C,null,O,j,E,null),E.onAfterShadow(t,E,k,C,O,j,null)}}const F=E.children;for(let O=0,q=F.length;O<q;O++)T(F[O],k,C,D,A)}}function cBe(t,e,n){const r=n.isWebGL2;function i(){let ee=!1;const ke=new yr;let De=null;const Ae=new yr(0,0,0,0);return{setMask:function(Je){De!==Je&&!ee&&(t.colorMask(Je,Je,Je,Je),De=Je)},setLocked:function(Je){ee=Je},setClear:function(Je,gt,At,jt,ln){ln===!0&&(Je*=jt,gt*=jt,At*=jt),ke.set(Je,gt,At,jt),Ae.equals(ke)===!1&&(t.clearColor(Je,gt,At,jt),Ae.copy(ke))},reset:function(){ee=!1,De=null,Ae.set(-1,0,0,0)}}}function s(){let ee=!1,ke=null,De=null,Ae=null;return{setTest:function(Je){Je?fe(t.DEPTH_TEST):Ce(t.DEPTH_TEST)},setMask:function(Je){ke!==Je&&!ee&&(t.depthMask(Je),ke=Je)},setFunc:function(Je){if(De!==Je){switch(Je){case vLe:t.depthFunc(t.NEVER);break;case _Le:t.depthFunc(t.ALWAYS);break;case wLe:t.depthFunc(t.LESS);break;case CS:t.depthFunc(t.LEQUAL);break;case SLe:t.depthFunc(t.EQUAL);break;case NLe:t.depthFunc(t.GEQUAL);break;case MLe:t.depthFunc(t.GREATER);break;case ELe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}De=Je}},setLocked:function(Je){ee=Je},setClear:function(Je){Ae!==Je&&(t.clearDepth(Je),Ae=Je)},reset:function(){ee=!1,ke=null,De=null,Ae=null}}}function o(){let ee=!1,ke=null,De=null,Ae=null,Je=null,gt=null,At=null,jt=null,ln=null;return{setTest:function(Lt){ee||(Lt?fe(t.STENCIL_TEST):Ce(t.STENCIL_TEST))},setMask:function(Lt){ke!==Lt&&!ee&&(t.stencilMask(Lt),ke=Lt)},setFunc:function(Lt,Cn,en){(De!==Lt||Ae!==Cn||Je!==en)&&(t.stencilFunc(Lt,Cn,en),De=Lt,Ae=Cn,Je=en)},setOp:function(Lt,Cn,en){(gt!==Lt||At!==Cn||jt!==en)&&(t.stencilOp(Lt,Cn,en),gt=Lt,At=Cn,jt=en)},setLocked:function(Lt){ee=Lt},setClear:function(Lt){ln!==Lt&&(t.clearStencil(Lt),ln=Lt)},reset:function(){ee=!1,ke=null,De=null,Ae=null,Je=null,gt=null,At=null,jt=null,ln=null}}}const l=new i,c=new s,u=new o,d=new WeakMap,f=new WeakMap;let m={},g={},x=new WeakMap,y=[],b=null,v=!1,N=null,S=null,T=null,E=null,k=null,C=null,D=null,A=new Jt(0,0,0),R=0,F=!1,O=null,q=null,j=null,G=null,Y=null;const K=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Z=!1,te=0;const ne=t.getParameter(t.VERSION);ne.indexOf("WebGL")!==-1?(te=parseFloat(/^WebGL (\d)/.exec(ne)[1]),Z=te>=1):ne.indexOf("OpenGL ES")!==-1&&(te=parseFloat(/^OpenGL ES (\d)/.exec(ne)[1]),Z=te>=2);let z=null,W={};const se=t.getParameter(t.SCISSOR_BOX),ae=t.getParameter(t.VIEWPORT),de=new yr().fromArray(se),me=new yr().fromArray(ae);function xe(ee,ke,De,Ae){const Je=new Uint8Array(4),gt=t.createTexture();t.bindTexture(ee,gt),t.texParameteri(ee,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ee,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let At=0;At<De;At++)r&&(ee===t.TEXTURE_3D||ee===t.TEXTURE_2D_ARRAY)?t.texImage3D(ke,0,t.RGBA,1,1,Ae,0,t.RGBA,t.UNSIGNED_BYTE,Je):t.texImage2D(ke+At,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Je);return gt}const be={};be[t.TEXTURE_2D]=xe(t.TEXTURE_2D,t.TEXTURE_2D,1),be[t.TEXTURE_CUBE_MAP]=xe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(be[t.TEXTURE_2D_ARRAY]=xe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),be[t.TEXTURE_3D]=xe(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),fe(t.DEPTH_TEST),c.setFunc(CS),Q(!1),le(SV),fe(t.CULL_FACE),X(Id);function fe(ee){m[ee]!==!0&&(t.enable(ee),m[ee]=!0)}function Ce(ee){m[ee]!==!1&&(t.disable(ee),m[ee]=!1)}function Ne(ee,ke){return g[ee]!==ke?(t.bindFramebuffer(ee,ke),g[ee]=ke,r&&(ee===t.DRAW_FRAMEBUFFER&&(g[t.FRAMEBUFFER]=ke),ee===t.FRAMEBUFFER&&(g[t.DRAW_FRAMEBUFFER]=ke)),!0):!1}function re(ee,ke){let De=y,Ae=!1;if(ee)if(De=x.get(ke),De===void 0&&(De=[],x.set(ke,De)),ee.isWebGLMultipleRenderTargets){const Je=ee.texture;if(De.length!==Je.length||De[0]!==t.COLOR_ATTACHMENT0){for(let gt=0,At=Je.length;gt<At;gt++)De[gt]=t.COLOR_ATTACHMENT0+gt;De.length=Je.length,Ae=!0}}else De[0]!==t.COLOR_ATTACHMENT0&&(De[0]=t.COLOR_ATTACHMENT0,Ae=!0);else De[0]!==t.BACK&&(De[0]=t.BACK,Ae=!0);Ae&&(n.isWebGL2?t.drawBuffers(De):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(De))}function He(ee){return b!==ee?(t.useProgram(ee),b=ee,!0):!1}const H={[ef]:t.FUNC_ADD,[aLe]:t.FUNC_SUBTRACT,[sLe]:t.FUNC_REVERSE_SUBTRACT};if(r)H[TV]=t.MIN,H[CV]=t.MAX;else{const ee=e.get("EXT_blend_minmax");ee!==null&&(H[TV]=ee.MIN_EXT,H[CV]=ee.MAX_EXT)}const B={[oLe]:t.ZERO,[lLe]:t.ONE,[cLe]:t.SRC_COLOR,[KP]:t.SRC_ALPHA,[pLe]:t.SRC_ALPHA_SATURATE,[fLe]:t.DST_COLOR,[dLe]:t.DST_ALPHA,[uLe]:t.ONE_MINUS_SRC_COLOR,[XP]:t.ONE_MINUS_SRC_ALPHA,[mLe]:t.ONE_MINUS_DST_COLOR,[hLe]:t.ONE_MINUS_DST_ALPHA,[gLe]:t.CONSTANT_COLOR,[xLe]:t.ONE_MINUS_CONSTANT_COLOR,[bLe]:t.CONSTANT_ALPHA,[yLe]:t.ONE_MINUS_CONSTANT_ALPHA};function X(ee,ke,De,Ae,Je,gt,At,jt,ln,Lt){if(ee===Id){v===!0&&(Ce(t.BLEND),v=!1);return}if(v===!1&&(fe(t.BLEND),v=!0),ee!==iLe){if(ee!==N||Lt!==F){if((S!==ef||k!==ef)&&(t.blendEquation(t.FUNC_ADD),S=ef,k=ef),Lt)switch(ee){case tg:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case NV:t.blendFunc(t.ONE,t.ONE);break;case MV:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case EV:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",ee);break}else switch(ee){case tg:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case NV:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case MV:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case EV:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",ee);break}T=null,E=null,C=null,D=null,A.set(0,0,0),R=0,N=ee,F=Lt}return}Je=Je||ke,gt=gt||De,At=At||Ae,(ke!==S||Je!==k)&&(t.blendEquationSeparate(H[ke],H[Je]),S=ke,k=Je),(De!==T||Ae!==E||gt!==C||At!==D)&&(t.blendFuncSeparate(B[De],B[Ae],B[gt],B[At]),T=De,E=Ae,C=gt,D=At),(jt.equals(A)===!1||ln!==R)&&(t.blendColor(jt.r,jt.g,jt.b,ln),A.copy(jt),R=ln),N=ee,F=!1}function U(ee,ke){ee.side===Hc?Ce(t.CULL_FACE):fe(t.CULL_FACE);let De=ee.side===ws;ke&&(De=!De),Q(De),ee.blending===tg&&ee.transparent===!1?X(Id):X(ee.blending,ee.blendEquation,ee.blendSrc,ee.blendDst,ee.blendEquationAlpha,ee.blendSrcAlpha,ee.blendDstAlpha,ee.blendColor,ee.blendAlpha,ee.premultipliedAlpha),c.setFunc(ee.depthFunc),c.setTest(ee.depthTest),c.setMask(ee.depthWrite),l.setMask(ee.colorWrite);const Ae=ee.stencilWrite;u.setTest(Ae),Ae&&(u.setMask(ee.stencilWriteMask),u.setFunc(ee.stencilFunc,ee.stencilRef,ee.stencilFuncMask),u.setOp(ee.stencilFail,ee.stencilZFail,ee.stencilZPass)),Oe(ee.polygonOffset,ee.polygonOffsetFactor,ee.polygonOffsetUnits),ee.alphaToCoverage===!0?fe(t.SAMPLE_ALPHA_TO_COVERAGE):Ce(t.SAMPLE_ALPHA_TO_COVERAGE)}function Q(ee){O!==ee&&(ee?t.frontFace(t.CW):t.frontFace(t.CCW),O=ee)}function le(ee){ee!==tLe?(fe(t.CULL_FACE),ee!==q&&(ee===SV?t.cullFace(t.BACK):ee===nLe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ce(t.CULL_FACE),q=ee}function Pe(ee){ee!==j&&(Z&&t.lineWidth(ee),j=ee)}function Oe(ee,ke,De){ee?(fe(t.POLYGON_OFFSET_FILL),(G!==ke||Y!==De)&&(t.polygonOffset(ke,De),G=ke,Y=De)):Ce(t.POLYGON_OFFSET_FILL)}function je(ee){ee?fe(t.SCISSOR_TEST):Ce(t.SCISSOR_TEST)}function $(ee){ee===void 0&&(ee=t.TEXTURE0+K-1),z!==ee&&(t.activeTexture(ee),z=ee)}function I(ee,ke,De){De===void 0&&(z===null?De=t.TEXTURE0+K-1:De=z);let Ae=W[De];Ae===void 0&&(Ae={type:void 0,texture:void 0},W[De]=Ae),(Ae.type!==ee||Ae.texture!==ke)&&(z!==De&&(t.activeTexture(De),z=De),t.bindTexture(ee,ke||be[ee]),Ae.type=ee,Ae.texture=ke)}function V(){const ee=W[z];ee!==void 0&&ee.type!==void 0&&(t.bindTexture(ee.type,null),ee.type=void 0,ee.texture=void 0)}function ie(){try{t.compressedTexImage2D.apply(t,arguments)}catch(ee){console.error("THREE.WebGLState:",ee)}}function Se(){try{t.compressedTexImage3D.apply(t,arguments)}catch(ee){console.error("THREE.WebGLState:",ee)}}function ye(){try{t.texSubImage2D.apply(t,arguments)}catch(ee){console.error("THREE.WebGLState:",ee)}}function $e(){try{t.texSubImage3D.apply(t,arguments)}catch(ee){console.error("THREE.WebGLState:",ee)}}function Ue(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(ee){console.error("THREE.WebGLState:",ee)}}function Ge(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(ee){console.error("THREE.WebGLState:",ee)}}function We(){try{t.texStorage2D.apply(t,arguments)}catch(ee){console.error("THREE.WebGLState:",ee)}}function Ye(){try{t.texStorage3D.apply(t,arguments)}catch(ee){console.error("THREE.WebGLState:",ee)}}function oe(){try{t.texImage2D.apply(t,arguments)}catch(ee){console.error("THREE.WebGLState:",ee)}}function ve(){try{t.texImage3D.apply(t,arguments)}catch(ee){console.error("THREE.WebGLState:",ee)}}function Le(ee){de.equals(ee)===!1&&(t.scissor(ee.x,ee.y,ee.z,ee.w),de.copy(ee))}function Ke(ee){me.equals(ee)===!1&&(t.viewport(ee.x,ee.y,ee.z,ee.w),me.copy(ee))}function lt(ee,ke){let De=f.get(ke);De===void 0&&(De=new WeakMap,f.set(ke,De));let Ae=De.get(ee);Ae===void 0&&(Ae=t.getUniformBlockIndex(ke,ee.name),De.set(ee,Ae))}function _e(ee,ke){const Ae=f.get(ke).get(ee);d.get(ke)!==Ae&&(t.uniformBlockBinding(ke,Ae,ee.__bindingPointIndex),d.set(ke,Ae))}function ce(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),r===!0&&(t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),m={},z=null,W={},g={},x=new WeakMap,y=[],b=null,v=!1,N=null,S=null,T=null,E=null,k=null,C=null,D=null,A=new Jt(0,0,0),R=0,F=!1,O=null,q=null,j=null,G=null,Y=null,de.set(0,0,t.canvas.width,t.canvas.height),me.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),u.reset()}return{buffers:{color:l,depth:c,stencil:u},enable:fe,disable:Ce,bindFramebuffer:Ne,drawBuffers:re,useProgram:He,setBlending:X,setMaterial:U,setFlipSided:Q,setCullFace:le,setLineWidth:Pe,setPolygonOffset:Oe,setScissorTest:je,activeTexture:$,bindTexture:I,unbindTexture:V,compressedTexImage2D:ie,compressedTexImage3D:Se,texImage2D:oe,texImage3D:ve,updateUBOMapping:lt,uniformBlockBinding:_e,texStorage2D:We,texStorage3D:Ye,texSubImage2D:ye,texSubImage3D:$e,compressedTexSubImage2D:Ue,compressedTexSubImage3D:Ge,scissor:Le,viewport:Ke,reset:ce}}function uBe(t,e,n,r,i,s,o){const l=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=i.maxSamples,m=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,g=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),x=new WeakMap;let y;const b=new WeakMap;let v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function N($,I){return v?new OffscreenCanvas($,I):RS("canvas")}function S($,I,V,ie){let Se=1;if(($.width>ie||$.height>ie)&&(Se=ie/Math.max($.width,$.height)),Se<1||I===!0)if(typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&$ instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&$ instanceof ImageBitmap){const ye=I?PS:Math.floor,$e=ye(Se*$.width),Ue=ye(Se*$.height);y===void 0&&(y=N($e,Ue));const Ge=V?N($e,Ue):y;return Ge.width=$e,Ge.height=Ue,Ge.getContext("2d").drawImage($,0,0,$e,Ue),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+$e+"x"+Ue+")."),Ge}else return"data"in $&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),$;return $}function T($){return nR($.width)&&nR($.height)}function E($){return l?!1:$.wrapS!==tl||$.wrapT!==tl||$.minFilter!==va&&$.minFilter!==No}function k($,I){return $.generateMipmaps&&I&&$.minFilter!==va&&$.minFilter!==No}function C($){t.generateMipmap($)}function D($,I,V,ie,Se=!1){if(l===!1)return I;if($!==null){if(t[$]!==void 0)return t[$];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+$+"'")}let ye=I;if(I===t.RED&&(V===t.FLOAT&&(ye=t.R32F),V===t.HALF_FLOAT&&(ye=t.R16F),V===t.UNSIGNED_BYTE&&(ye=t.R8)),I===t.RED_INTEGER&&(V===t.UNSIGNED_BYTE&&(ye=t.R8UI),V===t.UNSIGNED_SHORT&&(ye=t.R16UI),V===t.UNSIGNED_INT&&(ye=t.R32UI),V===t.BYTE&&(ye=t.R8I),V===t.SHORT&&(ye=t.R16I),V===t.INT&&(ye=t.R32I)),I===t.RG&&(V===t.FLOAT&&(ye=t.RG32F),V===t.HALF_FLOAT&&(ye=t.RG16F),V===t.UNSIGNED_BYTE&&(ye=t.RG8)),I===t.RGBA){const $e=Se?AS:xr.getTransfer(ie);V===t.FLOAT&&(ye=t.RGBA32F),V===t.HALF_FLOAT&&(ye=t.RGBA16F),V===t.UNSIGNED_BYTE&&(ye=$e===Dr?t.SRGB8_ALPHA8:t.RGBA8),V===t.UNSIGNED_SHORT_4_4_4_4&&(ye=t.RGBA4),V===t.UNSIGNED_SHORT_5_5_5_1&&(ye=t.RGB5_A1)}return(ye===t.R16F||ye===t.R32F||ye===t.RG16F||ye===t.RG32F||ye===t.RGBA16F||ye===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ye}function A($,I,V){return k($,V)===!0||$.isFramebufferTexture&&$.minFilter!==va&&$.minFilter!==No?Math.log2(Math.max(I.width,I.height))+1:$.mipmaps!==void 0&&$.mipmaps.length>0?$.mipmaps.length:$.isCompressedTexture&&Array.isArray($.image)?I.mipmaps.length:1}function R($){return $===va||$===AV||$===rk?t.NEAREST:t.LINEAR}function F($){const I=$.target;I.removeEventListener("dispose",F),q(I),I.isVideoTexture&&x.delete(I)}function O($){const I=$.target;I.removeEventListener("dispose",O),G(I)}function q($){const I=r.get($);if(I.__webglInit===void 0)return;const V=$.source,ie=b.get(V);if(ie){const Se=ie[I.__cacheKey];Se.usedTimes--,Se.usedTimes===0&&j($),Object.keys(ie).length===0&&b.delete(V)}r.remove($)}function j($){const I=r.get($);t.deleteTexture(I.__webglTexture);const V=$.source,ie=b.get(V);delete ie[I.__cacheKey],o.memory.textures--}function G($){const I=$.texture,V=r.get($),ie=r.get(I);if(ie.__webglTexture!==void 0&&(t.deleteTexture(ie.__webglTexture),o.memory.textures--),$.depthTexture&&$.depthTexture.dispose(),$.isWebGLCubeRenderTarget)for(let Se=0;Se<6;Se++){if(Array.isArray(V.__webglFramebuffer[Se]))for(let ye=0;ye<V.__webglFramebuffer[Se].length;ye++)t.deleteFramebuffer(V.__webglFramebuffer[Se][ye]);else t.deleteFramebuffer(V.__webglFramebuffer[Se]);V.__webglDepthbuffer&&t.deleteRenderbuffer(V.__webglDepthbuffer[Se])}else{if(Array.isArray(V.__webglFramebuffer))for(let Se=0;Se<V.__webglFramebuffer.length;Se++)t.deleteFramebuffer(V.__webglFramebuffer[Se]);else t.deleteFramebuffer(V.__webglFramebuffer);if(V.__webglDepthbuffer&&t.deleteRenderbuffer(V.__webglDepthbuffer),V.__webglMultisampledFramebuffer&&t.deleteFramebuffer(V.__webglMultisampledFramebuffer),V.__webglColorRenderbuffer)for(let Se=0;Se<V.__webglColorRenderbuffer.length;Se++)V.__webglColorRenderbuffer[Se]&&t.deleteRenderbuffer(V.__webglColorRenderbuffer[Se]);V.__webglDepthRenderbuffer&&t.deleteRenderbuffer(V.__webglDepthRenderbuffer)}if($.isWebGLMultipleRenderTargets)for(let Se=0,ye=I.length;Se<ye;Se++){const $e=r.get(I[Se]);$e.__webglTexture&&(t.deleteTexture($e.__webglTexture),o.memory.textures--),r.remove(I[Se])}r.remove(I),r.remove($)}let Y=0;function K(){Y=0}function Z(){const $=Y;return $>=c&&console.warn("THREE.WebGLTextures: Trying to use "+$+" texture units while this GPU supports only "+c),Y+=1,$}function te($){const I=[];return I.push($.wrapS),I.push($.wrapT),I.push($.wrapR||0),I.push($.magFilter),I.push($.minFilter),I.push($.anisotropy),I.push($.internalFormat),I.push($.format),I.push($.type),I.push($.generateMipmaps),I.push($.premultiplyAlpha),I.push($.flipY),I.push($.unpackAlignment),I.push($.colorSpace),I.join()}function ne($,I){const V=r.get($);if($.isVideoTexture&&Oe($),$.isRenderTargetTexture===!1&&$.version>0&&V.__version!==$.version){const ie=$.image;if(ie===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ie.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{fe(V,$,I);return}}n.bindTexture(t.TEXTURE_2D,V.__webglTexture,t.TEXTURE0+I)}function z($,I){const V=r.get($);if($.version>0&&V.__version!==$.version){fe(V,$,I);return}n.bindTexture(t.TEXTURE_2D_ARRAY,V.__webglTexture,t.TEXTURE0+I)}function W($,I){const V=r.get($);if($.version>0&&V.__version!==$.version){fe(V,$,I);return}n.bindTexture(t.TEXTURE_3D,V.__webglTexture,t.TEXTURE0+I)}function se($,I){const V=r.get($);if($.version>0&&V.__version!==$.version){Ce(V,$,I);return}n.bindTexture(t.TEXTURE_CUBE_MAP,V.__webglTexture,t.TEXTURE0+I)}const ae={[ZP]:t.REPEAT,[tl]:t.CLAMP_TO_EDGE,[JP]:t.MIRRORED_REPEAT},de={[va]:t.NEAREST,[AV]:t.NEAREST_MIPMAP_NEAREST,[rk]:t.NEAREST_MIPMAP_LINEAR,[No]:t.LINEAR,[DLe]:t.LINEAR_MIPMAP_NEAREST,[B0]:t.LINEAR_MIPMAP_LINEAR},me={[qLe]:t.NEVER,[ZLe]:t.ALWAYS,[WLe]:t.LESS,[DJ]:t.LEQUAL,[KLe]:t.EQUAL,[QLe]:t.GEQUAL,[XLe]:t.GREATER,[YLe]:t.NOTEQUAL};function xe($,I,V){if(V?(t.texParameteri($,t.TEXTURE_WRAP_S,ae[I.wrapS]),t.texParameteri($,t.TEXTURE_WRAP_T,ae[I.wrapT]),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,ae[I.wrapR]),t.texParameteri($,t.TEXTURE_MAG_FILTER,de[I.magFilter]),t.texParameteri($,t.TEXTURE_MIN_FILTER,de[I.minFilter])):(t.texParameteri($,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri($,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(I.wrapS!==tl||I.wrapT!==tl)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri($,t.TEXTURE_MAG_FILTER,R(I.magFilter)),t.texParameteri($,t.TEXTURE_MIN_FILTER,R(I.minFilter)),I.minFilter!==va&&I.minFilter!==No&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),I.compareFunction&&(t.texParameteri($,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri($,t.TEXTURE_COMPARE_FUNC,me[I.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ie=e.get("EXT_texture_filter_anisotropic");if(I.magFilter===va||I.minFilter!==rk&&I.minFilter!==B0||I.type===Xc&&e.has("OES_texture_float_linear")===!1||l===!1&&I.type===$0&&e.has("OES_texture_half_float_linear")===!1)return;(I.anisotropy>1||r.get(I).__currentAnisotropy)&&(t.texParameterf($,ie.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,i.getMaxAnisotropy())),r.get(I).__currentAnisotropy=I.anisotropy)}}function be($,I){let V=!1;$.__webglInit===void 0&&($.__webglInit=!0,I.addEventListener("dispose",F));const ie=I.source;let Se=b.get(ie);Se===void 0&&(Se={},b.set(ie,Se));const ye=te(I);if(ye!==$.__cacheKey){Se[ye]===void 0&&(Se[ye]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,V=!0),Se[ye].usedTimes++;const $e=Se[$.__cacheKey];$e!==void 0&&(Se[$.__cacheKey].usedTimes--,$e.usedTimes===0&&j(I)),$.__cacheKey=ye,$.__webglTexture=Se[ye].texture}return V}function fe($,I,V){let ie=t.TEXTURE_2D;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(ie=t.TEXTURE_2D_ARRAY),I.isData3DTexture&&(ie=t.TEXTURE_3D);const Se=be($,I),ye=I.source;n.bindTexture(ie,$.__webglTexture,t.TEXTURE0+V);const $e=r.get(ye);if(ye.version!==$e.__version||Se===!0){n.activeTexture(t.TEXTURE0+V);const Ue=xr.getPrimaries(xr.workingColorSpace),Ge=I.colorSpace===Eo?null:xr.getPrimaries(I.colorSpace),We=I.colorSpace===Eo||Ue===Ge?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,I.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,I.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,We);const Ye=E(I)&&T(I.image)===!1;let oe=S(I.image,Ye,!1,d);oe=je(I,oe);const ve=T(oe)||l,Le=s.convert(I.format,I.colorSpace);let Ke=s.convert(I.type),lt=D(I.internalFormat,Le,Ke,I.colorSpace,I.isVideoTexture);xe(ie,I,ve);let _e;const ce=I.mipmaps,ee=l&&I.isVideoTexture!==!0&<!==jJ,ke=$e.__version===void 0||Se===!0,De=A(I,oe,ve);if(I.isDepthTexture)lt=t.DEPTH_COMPONENT,l?I.type===Xc?lt=t.DEPTH_COMPONENT32F:I.type===Ed?lt=t.DEPTH_COMPONENT24:I.type===Sf?lt=t.DEPTH24_STENCIL8:lt=t.DEPTH_COMPONENT16:I.type===Xc&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),I.format===Nf&<===t.DEPTH_COMPONENT&&I.type!==UO&&I.type!==Ed&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),I.type=Ed,Ke=s.convert(I.type)),I.format===Eg&<===t.DEPTH_COMPONENT&&(lt=t.DEPTH_STENCIL,I.type!==Sf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),I.type=Sf,Ke=s.convert(I.type))),ke&&(ee?n.texStorage2D(t.TEXTURE_2D,1,lt,oe.width,oe.height):n.texImage2D(t.TEXTURE_2D,0,lt,oe.width,oe.height,0,Le,Ke,null));else if(I.isDataTexture)if(ce.length>0&&ve){ee&&ke&&n.texStorage2D(t.TEXTURE_2D,De,lt,ce[0].width,ce[0].height);for(let Ae=0,Je=ce.length;Ae<Je;Ae++)_e=ce[Ae],ee?n.texSubImage2D(t.TEXTURE_2D,Ae,0,0,_e.width,_e.height,Le,Ke,_e.data):n.texImage2D(t.TEXTURE_2D,Ae,lt,_e.width,_e.height,0,Le,Ke,_e.data);I.generateMipmaps=!1}else ee?(ke&&n.texStorage2D(t.TEXTURE_2D,De,lt,oe.width,oe.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,oe.width,oe.height,Le,Ke,oe.data)):n.texImage2D(t.TEXTURE_2D,0,lt,oe.width,oe.height,0,Le,Ke,oe.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){ee&&ke&&n.texStorage3D(t.TEXTURE_2D_ARRAY,De,lt,ce[0].width,ce[0].height,oe.depth);for(let Ae=0,Je=ce.length;Ae<Je;Ae++)_e=ce[Ae],I.format!==Mo?Le!==null?ee?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ae,0,0,0,_e.width,_e.height,oe.depth,Le,_e.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Ae,lt,_e.width,_e.height,oe.depth,0,_e.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ee?n.texSubImage3D(t.TEXTURE_2D_ARRAY,Ae,0,0,0,_e.width,_e.height,oe.depth,Le,Ke,_e.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Ae,lt,_e.width,_e.height,oe.depth,0,Le,Ke,_e.data)}else{ee&&ke&&n.texStorage2D(t.TEXTURE_2D,De,lt,ce[0].width,ce[0].height);for(let Ae=0,Je=ce.length;Ae<Je;Ae++)_e=ce[Ae],I.format!==Mo?Le!==null?ee?n.compressedTexSubImage2D(t.TEXTURE_2D,Ae,0,0,_e.width,_e.height,Le,_e.data):n.compressedTexImage2D(t.TEXTURE_2D,Ae,lt,_e.width,_e.height,0,_e.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ee?n.texSubImage2D(t.TEXTURE_2D,Ae,0,0,_e.width,_e.height,Le,Ke,_e.data):n.texImage2D(t.TEXTURE_2D,Ae,lt,_e.width,_e.height,0,Le,Ke,_e.data)}else if(I.isDataArrayTexture)ee?(ke&&n.texStorage3D(t.TEXTURE_2D_ARRAY,De,lt,oe.width,oe.height,oe.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,oe.width,oe.height,oe.depth,Le,Ke,oe.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,lt,oe.width,oe.height,oe.depth,0,Le,Ke,oe.data);else if(I.isData3DTexture)ee?(ke&&n.texStorage3D(t.TEXTURE_3D,De,lt,oe.width,oe.height,oe.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,oe.width,oe.height,oe.depth,Le,Ke,oe.data)):n.texImage3D(t.TEXTURE_3D,0,lt,oe.width,oe.height,oe.depth,0,Le,Ke,oe.data);else if(I.isFramebufferTexture){if(ke)if(ee)n.texStorage2D(t.TEXTURE_2D,De,lt,oe.width,oe.height);else{let Ae=oe.width,Je=oe.height;for(let gt=0;gt<De;gt++)n.texImage2D(t.TEXTURE_2D,gt,lt,Ae,Je,0,Le,Ke,null),Ae>>=1,Je>>=1}}else if(ce.length>0&&ve){ee&&ke&&n.texStorage2D(t.TEXTURE_2D,De,lt,ce[0].width,ce[0].height);for(let Ae=0,Je=ce.length;Ae<Je;Ae++)_e=ce[Ae],ee?n.texSubImage2D(t.TEXTURE_2D,Ae,0,0,Le,Ke,_e):n.texImage2D(t.TEXTURE_2D,Ae,lt,Le,Ke,_e);I.generateMipmaps=!1}else ee?(ke&&n.texStorage2D(t.TEXTURE_2D,De,lt,oe.width,oe.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,Le,Ke,oe)):n.texImage2D(t.TEXTURE_2D,0,lt,Le,Ke,oe);k(I,ve)&&C(ie),$e.__version=ye.version,I.onUpdate&&I.onUpdate(I)}$.__version=I.version}function Ce($,I,V){if(I.image.length!==6)return;const ie=be($,I),Se=I.source;n.bindTexture(t.TEXTURE_CUBE_MAP,$.__webglTexture,t.TEXTURE0+V);const ye=r.get(Se);if(Se.version!==ye.__version||ie===!0){n.activeTexture(t.TEXTURE0+V);const $e=xr.getPrimaries(xr.workingColorSpace),Ue=I.colorSpace===Eo?null:xr.getPrimaries(I.colorSpace),Ge=I.colorSpace===Eo||$e===Ue?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,I.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,I.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ge);const We=I.isCompressedTexture||I.image[0].isCompressedTexture,Ye=I.image[0]&&I.image[0].isDataTexture,oe=[];for(let Ae=0;Ae<6;Ae++)!We&&!Ye?oe[Ae]=S(I.image[Ae],!1,!0,u):oe[Ae]=Ye?I.image[Ae].image:I.image[Ae],oe[Ae]=je(I,oe[Ae]);const ve=oe[0],Le=T(ve)||l,Ke=s.convert(I.format,I.colorSpace),lt=s.convert(I.type),_e=D(I.internalFormat,Ke,lt,I.colorSpace),ce=l&&I.isVideoTexture!==!0,ee=ye.__version===void 0||ie===!0;let ke=A(I,ve,Le);xe(t.TEXTURE_CUBE_MAP,I,Le);let De;if(We){ce&&ee&&n.texStorage2D(t.TEXTURE_CUBE_MAP,ke,_e,ve.width,ve.height);for(let Ae=0;Ae<6;Ae++){De=oe[Ae].mipmaps;for(let Je=0;Je<De.length;Je++){const gt=De[Je];I.format!==Mo?Ke!==null?ce?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je,0,0,gt.width,gt.height,Ke,gt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je,_e,gt.width,gt.height,0,gt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ce?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je,0,0,gt.width,gt.height,Ke,lt,gt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je,_e,gt.width,gt.height,0,Ke,lt,gt.data)}}}else{De=I.mipmaps,ce&&ee&&(De.length>0&&ke++,n.texStorage2D(t.TEXTURE_CUBE_MAP,ke,_e,oe[0].width,oe[0].height));for(let Ae=0;Ae<6;Ae++)if(Ye){ce?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,0,0,oe[Ae].width,oe[Ae].height,Ke,lt,oe[Ae].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,_e,oe[Ae].width,oe[Ae].height,0,Ke,lt,oe[Ae].data);for(let Je=0;Je<De.length;Je++){const At=De[Je].image[Ae].image;ce?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je+1,0,0,At.width,At.height,Ke,lt,At.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je+1,_e,At.width,At.height,0,Ke,lt,At.data)}}else{ce?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,0,0,Ke,lt,oe[Ae]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,_e,Ke,lt,oe[Ae]);for(let Je=0;Je<De.length;Je++){const gt=De[Je];ce?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je+1,0,0,Ke,lt,gt.image[Ae]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Je+1,_e,Ke,lt,gt.image[Ae])}}}k(I,Le)&&C(t.TEXTURE_CUBE_MAP),ye.__version=Se.version,I.onUpdate&&I.onUpdate(I)}$.__version=I.version}function Ne($,I,V,ie,Se,ye){const $e=s.convert(V.format,V.colorSpace),Ue=s.convert(V.type),Ge=D(V.internalFormat,$e,Ue,V.colorSpace);if(!r.get(I).__hasExternalTextures){const Ye=Math.max(1,I.width>>ye),oe=Math.max(1,I.height>>ye);Se===t.TEXTURE_3D||Se===t.TEXTURE_2D_ARRAY?n.texImage3D(Se,ye,Ge,Ye,oe,I.depth,0,$e,Ue,null):n.texImage2D(Se,ye,Ge,Ye,oe,0,$e,Ue,null)}n.bindFramebuffer(t.FRAMEBUFFER,$),Pe(I)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ie,Se,r.get(V).__webglTexture,0,le(I)):(Se===t.TEXTURE_2D||Se>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Se<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ie,Se,r.get(V).__webglTexture,ye),n.bindFramebuffer(t.FRAMEBUFFER,null)}function re($,I,V){if(t.bindRenderbuffer(t.RENDERBUFFER,$),I.depthBuffer&&!I.stencilBuffer){let ie=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(V||Pe(I)){const Se=I.depthTexture;Se&&Se.isDepthTexture&&(Se.type===Xc?ie=t.DEPTH_COMPONENT32F:Se.type===Ed&&(ie=t.DEPTH_COMPONENT24));const ye=le(I);Pe(I)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ye,ie,I.width,I.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ye,ie,I.width,I.height)}else t.renderbufferStorage(t.RENDERBUFFER,ie,I.width,I.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,$)}else if(I.depthBuffer&&I.stencilBuffer){const ie=le(I);V&&Pe(I)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ie,t.DEPTH24_STENCIL8,I.width,I.height):Pe(I)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ie,t.DEPTH24_STENCIL8,I.width,I.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,I.width,I.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,$)}else{const ie=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let Se=0;Se<ie.length;Se++){const ye=ie[Se],$e=s.convert(ye.format,ye.colorSpace),Ue=s.convert(ye.type),Ge=D(ye.internalFormat,$e,Ue,ye.colorSpace),We=le(I);V&&Pe(I)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,We,Ge,I.width,I.height):Pe(I)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,We,Ge,I.width,I.height):t.renderbufferStorage(t.RENDERBUFFER,Ge,I.width,I.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function He($,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,$),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(I.depthTexture).__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),ne(I.depthTexture,0);const ie=r.get(I.depthTexture).__webglTexture,Se=le(I);if(I.depthTexture.format===Nf)Pe(I)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ie,0,Se):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ie,0);else if(I.depthTexture.format===Eg)Pe(I)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ie,0,Se):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ie,0);else throw new Error("Unknown depthTexture format")}function H($){const I=r.get($),V=$.isWebGLCubeRenderTarget===!0;if($.depthTexture&&!I.__autoAllocateDepthBuffer){if(V)throw new Error("target.depthTexture not supported in Cube render targets");He(I.__webglFramebuffer,$)}else if(V){I.__webglDepthbuffer=[];for(let ie=0;ie<6;ie++)n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer[ie]),I.__webglDepthbuffer[ie]=t.createRenderbuffer(),re(I.__webglDepthbuffer[ie],$,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer),I.__webglDepthbuffer=t.createRenderbuffer(),re(I.__webglDepthbuffer,$,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function B($,I,V){const ie=r.get($);I!==void 0&&Ne(ie.__webglFramebuffer,$,$.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),V!==void 0&&H($)}function X($){const I=$.texture,V=r.get($),ie=r.get(I);$.addEventListener("dispose",O),$.isWebGLMultipleRenderTargets!==!0&&(ie.__webglTexture===void 0&&(ie.__webglTexture=t.createTexture()),ie.__version=I.version,o.memory.textures++);const Se=$.isWebGLCubeRenderTarget===!0,ye=$.isWebGLMultipleRenderTargets===!0,$e=T($)||l;if(Se){V.__webglFramebuffer=[];for(let Ue=0;Ue<6;Ue++)if(l&&I.mipmaps&&I.mipmaps.length>0){V.__webglFramebuffer[Ue]=[];for(let Ge=0;Ge<I.mipmaps.length;Ge++)V.__webglFramebuffer[Ue][Ge]=t.createFramebuffer()}else V.__webglFramebuffer[Ue]=t.createFramebuffer()}else{if(l&&I.mipmaps&&I.mipmaps.length>0){V.__webglFramebuffer=[];for(let Ue=0;Ue<I.mipmaps.length;Ue++)V.__webglFramebuffer[Ue]=t.createFramebuffer()}else V.__webglFramebuffer=t.createFramebuffer();if(ye)if(i.drawBuffers){const Ue=$.texture;for(let Ge=0,We=Ue.length;Ge<We;Ge++){const Ye=r.get(Ue[Ge]);Ye.__webglTexture===void 0&&(Ye.__webglTexture=t.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(l&&$.samples>0&&Pe($)===!1){const Ue=ye?I:[I];V.__webglMultisampledFramebuffer=t.createFramebuffer(),V.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,V.__webglMultisampledFramebuffer);for(let Ge=0;Ge<Ue.length;Ge++){const We=Ue[Ge];V.__webglColorRenderbuffer[Ge]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,V.__webglColorRenderbuffer[Ge]);const Ye=s.convert(We.format,We.colorSpace),oe=s.convert(We.type),ve=D(We.internalFormat,Ye,oe,We.colorSpace,$.isXRRenderTarget===!0),Le=le($);t.renderbufferStorageMultisample(t.RENDERBUFFER,Le,ve,$.width,$.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ge,t.RENDERBUFFER,V.__webglColorRenderbuffer[Ge])}t.bindRenderbuffer(t.RENDERBUFFER,null),$.depthBuffer&&(V.__webglDepthRenderbuffer=t.createRenderbuffer(),re(V.__webglDepthRenderbuffer,$,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(Se){n.bindTexture(t.TEXTURE_CUBE_MAP,ie.__webglTexture),xe(t.TEXTURE_CUBE_MAP,I,$e);for(let Ue=0;Ue<6;Ue++)if(l&&I.mipmaps&&I.mipmaps.length>0)for(let Ge=0;Ge<I.mipmaps.length;Ge++)Ne(V.__webglFramebuffer[Ue][Ge],$,I,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ue,Ge);else Ne(V.__webglFramebuffer[Ue],$,I,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ue,0);k(I,$e)&&C(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ye){const Ue=$.texture;for(let Ge=0,We=Ue.length;Ge<We;Ge++){const Ye=Ue[Ge],oe=r.get(Ye);n.bindTexture(t.TEXTURE_2D,oe.__webglTexture),xe(t.TEXTURE_2D,Ye,$e),Ne(V.__webglFramebuffer,$,Ye,t.COLOR_ATTACHMENT0+Ge,t.TEXTURE_2D,0),k(Ye,$e)&&C(t.TEXTURE_2D)}n.unbindTexture()}else{let Ue=t.TEXTURE_2D;if(($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(l?Ue=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Ue,ie.__webglTexture),xe(Ue,I,$e),l&&I.mipmaps&&I.mipmaps.length>0)for(let Ge=0;Ge<I.mipmaps.length;Ge++)Ne(V.__webglFramebuffer[Ge],$,I,t.COLOR_ATTACHMENT0,Ue,Ge);else Ne(V.__webglFramebuffer,$,I,t.COLOR_ATTACHMENT0,Ue,0);k(I,$e)&&C(Ue),n.unbindTexture()}$.depthBuffer&&H($)}function U($){const I=T($)||l,V=$.isWebGLMultipleRenderTargets===!0?$.texture:[$.texture];for(let ie=0,Se=V.length;ie<Se;ie++){const ye=V[ie];if(k(ye,I)){const $e=$.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Ue=r.get(ye).__webglTexture;n.bindTexture($e,Ue),C($e),n.unbindTexture()}}}function Q($){if(l&&$.samples>0&&Pe($)===!1){const I=$.isWebGLMultipleRenderTargets?$.texture:[$.texture],V=$.width,ie=$.height;let Se=t.COLOR_BUFFER_BIT;const ye=[],$e=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ue=r.get($),Ge=$.isWebGLMultipleRenderTargets===!0;if(Ge)for(let We=0;We<I.length;We++)n.bindFramebuffer(t.FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+We,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ue.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+We,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ue.__webglFramebuffer);for(let We=0;We<I.length;We++){ye.push(t.COLOR_ATTACHMENT0+We),$.depthBuffer&&ye.push($e);const Ye=Ue.__ignoreDepthValues!==void 0?Ue.__ignoreDepthValues:!1;if(Ye===!1&&($.depthBuffer&&(Se|=t.DEPTH_BUFFER_BIT),$.stencilBuffer&&(Se|=t.STENCIL_BUFFER_BIT)),Ge&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ue.__webglColorRenderbuffer[We]),Ye===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[$e]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[$e])),Ge){const oe=r.get(I[We]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,oe,0)}t.blitFramebuffer(0,0,V,ie,0,0,V,ie,Se,t.NEAREST),g&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ye)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ge)for(let We=0;We<I.length;We++){n.bindFramebuffer(t.FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+We,t.RENDERBUFFER,Ue.__webglColorRenderbuffer[We]);const Ye=r.get(I[We]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ue.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+We,t.TEXTURE_2D,Ye,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ue.__webglMultisampledFramebuffer)}}function le($){return Math.min(f,$.samples)}function Pe($){const I=r.get($);return l&&$.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function Oe($){const I=o.render.frame;x.get($)!==I&&(x.set($,I),$.update())}function je($,I){const V=$.colorSpace,ie=$.format,Se=$.type;return $.isCompressedTexture===!0||$.isVideoTexture===!0||$.format===tR||V!==bu&&V!==Eo&&(xr.getTransfer(V)===Dr?l===!1?e.has("EXT_sRGB")===!0&&ie===Mo?($.format=tR,$.minFilter=No,$.generateMipmaps=!1):I=IJ.sRGBToLinear(I):(ie!==Mo||Se!==Ud)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",V)),I}this.allocateTextureUnit=Z,this.resetTextureUnits=K,this.setTexture2D=ne,this.setTexture2DArray=z,this.setTexture3D=W,this.setTextureCube=se,this.rebindTextures=B,this.setupRenderTarget=X,this.updateRenderTargetMipmap=U,this.updateMultisampleRenderTarget=Q,this.setupDepthRenderbuffer=H,this.setupFrameBufferTexture=Ne,this.useMultisampledRTT=Pe}function dBe(t,e,n){const r=n.isWebGL2;function i(s,o=Eo){let l;const c=xr.getTransfer(o);if(s===Ud)return t.UNSIGNED_BYTE;if(s===EJ)return t.UNSIGNED_SHORT_4_4_4_4;if(s===TJ)return t.UNSIGNED_SHORT_5_5_5_1;if(s===OLe)return t.BYTE;if(s===LLe)return t.SHORT;if(s===UO)return t.UNSIGNED_SHORT;if(s===MJ)return t.INT;if(s===Ed)return t.UNSIGNED_INT;if(s===Xc)return t.FLOAT;if(s===$0)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(s===ILe)return t.ALPHA;if(s===Mo)return t.RGBA;if(s===FLe)return t.LUMINANCE;if(s===ULe)return t.LUMINANCE_ALPHA;if(s===Nf)return t.DEPTH_COMPONENT;if(s===Eg)return t.DEPTH_STENCIL;if(s===tR)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(s===zLe)return t.RED;if(s===CJ)return t.RED_INTEGER;if(s===BLe)return t.RG;if(s===AJ)return t.RG_INTEGER;if(s===kJ)return t.RGBA_INTEGER;if(s===ik||s===ak||s===sk||s===ok)if(c===Dr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(s===ik)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===ak)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===sk)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===ok)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(s===ik)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===ak)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===sk)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===ok)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===kV||s===jV||s===PV||s===RV)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(s===kV)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===jV)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===PV)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===RV)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===jJ)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===DV||s===OV)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(s===DV)return c===Dr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(s===OV)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===LV||s===IV||s===FV||s===UV||s===zV||s===BV||s===$V||s===HV||s===VV||s===GV||s===qV||s===WV||s===KV||s===XV)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(s===LV)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===IV)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===FV)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===UV)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===zV)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===BV)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===$V)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===HV)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===VV)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===GV)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===qV)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===WV)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===KV)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===XV)return c===Dr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===lk||s===YV||s===QV)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(s===lk)return c===Dr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===YV)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===QV)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===$Le||s===ZV||s===JV||s===e7)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(s===lk)return l.COMPRESSED_RED_RGTC1_EXT;if(s===ZV)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===JV)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===e7)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Sf?r?t.UNSIGNED_INT_24_8:(l=e.get("WEBGL_depth_texture"),l!==null?l.UNSIGNED_INT_24_8_WEBGL:null):t[s]!==void 0?t[s]:null}return{convert:i}}class hBe extends $s{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Db extends Za{constructor(){super(),this.isGroup=!0,this.type="Group"}}const fBe={type:"move"};class jk{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Db,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 Db,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new qe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new qe),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Db,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new qe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new qe),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,s=null,o=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(const y of e.hand.values()){const b=n.getJointPose(y,r),v=this._getHandJoint(u,y);b!==null&&(v.matrix.fromArray(b.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=b.radius),v.visible=b!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],m=d.position.distanceTo(f.position),g=.02,x=.005;u.inputState.pinching&&m>g+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=g-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(fBe)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new Db;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class mBe extends lm{constructor(e,n){super();const r=this;let i=null,s=1,o=null,l="local-floor",c=1,u=null,d=null,f=null,m=null,g=null,x=null;const y=n.getContextAttributes();let b=null,v=null;const N=[],S=[],T=new pn;let E=null;const k=new $s;k.layers.enable(1),k.viewport=new yr;const C=new $s;C.layers.enable(2),C.viewport=new yr;const D=[k,C],A=new hBe;A.layers.enable(1),A.layers.enable(2);let R=null,F=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(se){let ae=N[se];return ae===void 0&&(ae=new jk,N[se]=ae),ae.getTargetRaySpace()},this.getControllerGrip=function(se){let ae=N[se];return ae===void 0&&(ae=new jk,N[se]=ae),ae.getGripSpace()},this.getHand=function(se){let ae=N[se];return ae===void 0&&(ae=new jk,N[se]=ae),ae.getHandSpace()};function O(se){const ae=S.indexOf(se.inputSource);if(ae===-1)return;const de=N[ae];de!==void 0&&(de.update(se.inputSource,se.frame,u||o),de.dispatchEvent({type:se.type,data:se.inputSource}))}function q(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",j);for(let se=0;se<N.length;se++){const ae=S[se];ae!==null&&(S[se]=null,N[se].disconnect(ae))}R=null,F=null,e.setRenderTarget(b),g=null,m=null,f=null,i=null,v=null,W.stop(),r.isPresenting=!1,e.setPixelRatio(E),e.setSize(T.width,T.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(se){s=se,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(se){l=se,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(se){u=se},this.getBaseLayer=function(){return m!==null?m:g},this.getBinding=function(){return f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(se){if(i=se,i!==null){if(b=e.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",q),i.addEventListener("inputsourceschange",j),y.xrCompatible!==!0&&await n.makeXRCompatible(),E=e.getPixelRatio(),e.getSize(T),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ae={antialias:i.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};g=new XRWebGLLayer(i,n,ae),i.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),v=new Xf(g.framebufferWidth,g.framebufferHeight,{format:Mo,type:Ud,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let ae=null,de=null,me=null;y.depth&&(me=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ae=y.stencil?Eg:Nf,de=y.stencil?Sf:Ed);const xe={colorFormat:n.RGBA8,depthFormat:me,scaleFactor:s};f=new XRWebGLBinding(i,n),m=f.createProjectionLayer(xe),i.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),v=new Xf(m.textureWidth,m.textureHeight,{format:Mo,type:Ud,depthTexture:new XJ(m.textureWidth,m.textureHeight,de,void 0,void 0,void 0,void 0,void 0,void 0,ae),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});const be=e.properties.get(v);be.__ignoreDepthValues=m.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),W.setContext(i),W.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function j(se){for(let ae=0;ae<se.removed.length;ae++){const de=se.removed[ae],me=S.indexOf(de);me>=0&&(S[me]=null,N[me].disconnect(de))}for(let ae=0;ae<se.added.length;ae++){const de=se.added[ae];let me=S.indexOf(de);if(me===-1){for(let be=0;be<N.length;be++)if(be>=S.length){S.push(de),me=be;break}else if(S[be]===null){S[be]=de,me=be;break}if(me===-1)break}const xe=N[me];xe&&xe.connect(de)}}const G=new qe,Y=new qe;function K(se,ae,de){G.setFromMatrixPosition(ae.matrixWorld),Y.setFromMatrixPosition(de.matrixWorld);const me=G.distanceTo(Y),xe=ae.projectionMatrix.elements,be=de.projectionMatrix.elements,fe=xe[14]/(xe[10]-1),Ce=xe[14]/(xe[10]+1),Ne=(xe[9]+1)/xe[5],re=(xe[9]-1)/xe[5],He=(xe[8]-1)/xe[0],H=(be[8]+1)/be[0],B=fe*He,X=fe*H,U=me/(-He+H),Q=U*-He;ae.matrixWorld.decompose(se.position,se.quaternion,se.scale),se.translateX(Q),se.translateZ(U),se.matrixWorld.compose(se.position,se.quaternion,se.scale),se.matrixWorldInverse.copy(se.matrixWorld).invert();const le=fe+U,Pe=Ce+U,Oe=B-Q,je=X+(me-Q),$=Ne*Ce/Pe*le,I=re*Ce/Pe*le;se.projectionMatrix.makePerspective(Oe,je,$,I,le,Pe),se.projectionMatrixInverse.copy(se.projectionMatrix).invert()}function Z(se,ae){ae===null?se.matrixWorld.copy(se.matrix):se.matrixWorld.multiplyMatrices(ae.matrixWorld,se.matrix),se.matrixWorldInverse.copy(se.matrixWorld).invert()}this.updateCamera=function(se){if(i===null)return;A.near=C.near=k.near=se.near,A.far=C.far=k.far=se.far,(R!==A.near||F!==A.far)&&(i.updateRenderState({depthNear:A.near,depthFar:A.far}),R=A.near,F=A.far);const ae=se.parent,de=A.cameras;Z(A,ae);for(let me=0;me<de.length;me++)Z(de[me],ae);de.length===2?K(A,k,C):A.projectionMatrix.copy(k.projectionMatrix),te(se,A,ae)};function te(se,ae,de){de===null?se.matrix.copy(ae.matrixWorld):(se.matrix.copy(de.matrixWorld),se.matrix.invert(),se.matrix.multiply(ae.matrixWorld)),se.matrix.decompose(se.position,se.quaternion,se.scale),se.updateMatrixWorld(!0),se.projectionMatrix.copy(ae.projectionMatrix),se.projectionMatrixInverse.copy(ae.projectionMatrixInverse),se.isPerspectiveCamera&&(se.fov=V0*2*Math.atan(1/se.projectionMatrix.elements[5]),se.zoom=1)}this.getCamera=function(){return A},this.getFoveation=function(){if(!(m===null&&g===null))return c},this.setFoveation=function(se){c=se,m!==null&&(m.fixedFoveation=se),g!==null&&g.fixedFoveation!==void 0&&(g.fixedFoveation=se)};let ne=null;function z(se,ae){if(d=ae.getViewerPose(u||o),x=ae,d!==null){const de=d.views;g!==null&&(e.setRenderTargetFramebuffer(v,g.framebuffer),e.setRenderTarget(v));let me=!1;de.length!==A.cameras.length&&(A.cameras.length=0,me=!0);for(let xe=0;xe<de.length;xe++){const be=de[xe];let fe=null;if(g!==null)fe=g.getViewport(be);else{const Ne=f.getViewSubImage(m,be);fe=Ne.viewport,xe===0&&(e.setRenderTargetTextures(v,Ne.colorTexture,m.ignoreDepthValues?void 0:Ne.depthStencilTexture),e.setRenderTarget(v))}let Ce=D[xe];Ce===void 0&&(Ce=new $s,Ce.layers.enable(xe),Ce.viewport=new yr,D[xe]=Ce),Ce.matrix.fromArray(be.transform.matrix),Ce.matrix.decompose(Ce.position,Ce.quaternion,Ce.scale),Ce.projectionMatrix.fromArray(be.projectionMatrix),Ce.projectionMatrixInverse.copy(Ce.projectionMatrix).invert(),Ce.viewport.set(fe.x,fe.y,fe.width,fe.height),xe===0&&(A.matrix.copy(Ce.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),me===!0&&A.cameras.push(Ce)}}for(let de=0;de<N.length;de++){const me=S[de],xe=N[de];me!==null&&xe!==void 0&&xe.update(me,ae,u||o)}ne&&ne(se,ae),ae.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ae}),x=null}const W=new KJ;W.setAnimationLoop(z),this.setAnimationLoop=function(se){ne=se},this.dispose=function(){}}}function pBe(t,e){function n(b,v){b.matrixAutoUpdate===!0&&b.updateMatrix(),v.value.copy(b.matrix)}function r(b,v){v.color.getRGB(b.fogColor.value,GJ(t)),v.isFog?(b.fogNear.value=v.near,b.fogFar.value=v.far):v.isFogExp2&&(b.fogDensity.value=v.density)}function i(b,v,N,S,T){v.isMeshBasicMaterial||v.isMeshLambertMaterial?s(b,v):v.isMeshToonMaterial?(s(b,v),f(b,v)):v.isMeshPhongMaterial?(s(b,v),d(b,v)):v.isMeshStandardMaterial?(s(b,v),m(b,v),v.isMeshPhysicalMaterial&&g(b,v,T)):v.isMeshMatcapMaterial?(s(b,v),x(b,v)):v.isMeshDepthMaterial?s(b,v):v.isMeshDistanceMaterial?(s(b,v),y(b,v)):v.isMeshNormalMaterial?s(b,v):v.isLineBasicMaterial?(o(b,v),v.isLineDashedMaterial&&l(b,v)):v.isPointsMaterial?c(b,v,N,S):v.isSpriteMaterial?u(b,v):v.isShadowMaterial?(b.color.value.copy(v.color),b.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function s(b,v){b.opacity.value=v.opacity,v.color&&b.diffuse.value.copy(v.color),v.emissive&&b.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(b.map.value=v.map,n(v.map,b.mapTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.bumpMap&&(b.bumpMap.value=v.bumpMap,n(v.bumpMap,b.bumpMapTransform),b.bumpScale.value=v.bumpScale,v.side===ws&&(b.bumpScale.value*=-1)),v.normalMap&&(b.normalMap.value=v.normalMap,n(v.normalMap,b.normalMapTransform),b.normalScale.value.copy(v.normalScale),v.side===ws&&b.normalScale.value.negate()),v.displacementMap&&(b.displacementMap.value=v.displacementMap,n(v.displacementMap,b.displacementMapTransform),b.displacementScale.value=v.displacementScale,b.displacementBias.value=v.displacementBias),v.emissiveMap&&(b.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,b.emissiveMapTransform)),v.specularMap&&(b.specularMap.value=v.specularMap,n(v.specularMap,b.specularMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest);const N=e.get(v).envMap;if(N&&(b.envMap.value=N,b.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,b.reflectivity.value=v.reflectivity,b.ior.value=v.ior,b.refractionRatio.value=v.refractionRatio),v.lightMap){b.lightMap.value=v.lightMap;const S=t._useLegacyLights===!0?Math.PI:1;b.lightMapIntensity.value=v.lightMapIntensity*S,n(v.lightMap,b.lightMapTransform)}v.aoMap&&(b.aoMap.value=v.aoMap,b.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,b.aoMapTransform))}function o(b,v){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,v.map&&(b.map.value=v.map,n(v.map,b.mapTransform))}function l(b,v){b.dashSize.value=v.dashSize,b.totalSize.value=v.dashSize+v.gapSize,b.scale.value=v.scale}function c(b,v,N,S){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.size.value=v.size*N,b.scale.value=S*.5,v.map&&(b.map.value=v.map,n(v.map,b.uvTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest)}function u(b,v){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.rotation.value=v.rotation,v.map&&(b.map.value=v.map,n(v.map,b.mapTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest)}function d(b,v){b.specular.value.copy(v.specular),b.shininess.value=Math.max(v.shininess,1e-4)}function f(b,v){v.gradientMap&&(b.gradientMap.value=v.gradientMap)}function m(b,v){b.metalness.value=v.metalness,v.metalnessMap&&(b.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,b.metalnessMapTransform)),b.roughness.value=v.roughness,v.roughnessMap&&(b.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,b.roughnessMapTransform)),e.get(v).envMap&&(b.envMapIntensity.value=v.envMapIntensity)}function g(b,v,N){b.ior.value=v.ior,v.sheen>0&&(b.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),b.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(b.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,b.sheenColorMapTransform)),v.sheenRoughnessMap&&(b.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,b.sheenRoughnessMapTransform))),v.clearcoat>0&&(b.clearcoat.value=v.clearcoat,b.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(b.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,b.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(b.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,b.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(b.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,b.clearcoatNormalMapTransform),b.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===ws&&b.clearcoatNormalScale.value.negate())),v.iridescence>0&&(b.iridescence.value=v.iridescence,b.iridescenceIOR.value=v.iridescenceIOR,b.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],b.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(b.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,b.iridescenceMapTransform)),v.iridescenceThicknessMap&&(b.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,b.iridescenceThicknessMapTransform))),v.transmission>0&&(b.transmission.value=v.transmission,b.transmissionSamplerMap.value=N.texture,b.transmissionSamplerSize.value.set(N.width,N.height),v.transmissionMap&&(b.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,b.transmissionMapTransform)),b.thickness.value=v.thickness,v.thicknessMap&&(b.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,b.thicknessMapTransform)),b.attenuationDistance.value=v.attenuationDistance,b.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(b.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(b.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,b.anisotropyMapTransform))),b.specularIntensity.value=v.specularIntensity,b.specularColor.value.copy(v.specularColor),v.specularColorMap&&(b.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,b.specularColorMapTransform)),v.specularIntensityMap&&(b.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,b.specularIntensityMapTransform))}function x(b,v){v.matcap&&(b.matcap.value=v.matcap)}function y(b,v){const N=e.get(v).light;b.referencePosition.value.setFromMatrixPosition(N.matrixWorld),b.nearDistance.value=N.shadow.camera.near,b.farDistance.value=N.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function gBe(t,e,n,r){let i={},s={},o=[];const l=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(N,S){const T=S.program;r.uniformBlockBinding(N,T)}function u(N,S){let T=i[N.id];T===void 0&&(x(N),T=d(N),i[N.id]=T,N.addEventListener("dispose",b));const E=S.program;r.updateUBOMapping(N,E);const k=e.render.frame;s[N.id]!==k&&(m(N),s[N.id]=k)}function d(N){const S=f();N.__bindingPointIndex=S;const T=t.createBuffer(),E=N.__size,k=N.usage;return t.bindBuffer(t.UNIFORM_BUFFER,T),t.bufferData(t.UNIFORM_BUFFER,E,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,S,T),T}function f(){for(let N=0;N<l;N++)if(o.indexOf(N)===-1)return o.push(N),N;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(N){const S=i[N.id],T=N.uniforms,E=N.__cache;t.bindBuffer(t.UNIFORM_BUFFER,S);for(let k=0,C=T.length;k<C;k++){const D=T[k];if(g(D,k,E)===!0){const A=D.__offset,R=Array.isArray(D.value)?D.value:[D.value];let F=0;for(let O=0;O<R.length;O++){const q=R[O],j=y(q);typeof q=="number"?(D.__data[0]=q,t.bufferSubData(t.UNIFORM_BUFFER,A+F,D.__data)):q.isMatrix3?(D.__data[0]=q.elements[0],D.__data[1]=q.elements[1],D.__data[2]=q.elements[2],D.__data[3]=q.elements[0],D.__data[4]=q.elements[3],D.__data[5]=q.elements[4],D.__data[6]=q.elements[5],D.__data[7]=q.elements[0],D.__data[8]=q.elements[6],D.__data[9]=q.elements[7],D.__data[10]=q.elements[8],D.__data[11]=q.elements[0]):(q.toArray(D.__data,F),F+=j.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,A,D.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function g(N,S,T){const E=N.value;if(T[S]===void 0){if(typeof E=="number")T[S]=E;else{const k=Array.isArray(E)?E:[E],C=[];for(let D=0;D<k.length;D++)C.push(k[D].clone());T[S]=C}return!0}else if(typeof E=="number"){if(T[S]!==E)return T[S]=E,!0}else{const k=Array.isArray(T[S])?T[S]:[T[S]],C=Array.isArray(E)?E:[E];for(let D=0;D<k.length;D++){const A=k[D];if(A.equals(C[D])===!1)return A.copy(C[D]),!0}}return!1}function x(N){const S=N.uniforms;let T=0;const E=16;let k=0;for(let C=0,D=S.length;C<D;C++){const A=S[C],R={boundary:0,storage:0},F=Array.isArray(A.value)?A.value:[A.value];for(let O=0,q=F.length;O<q;O++){const j=F[O],G=y(j);R.boundary+=G.boundary,R.storage+=G.storage}if(A.__data=new Float32Array(R.storage/Float32Array.BYTES_PER_ELEMENT),A.__offset=T,C>0){k=T%E;const O=E-k;k!==0&&O-R.boundary<0&&(T+=E-k,A.__offset=T)}T+=R.storage}return k=T%E,k>0&&(T+=E-k),N.__size=T,N.__cache={},this}function y(N){const S={boundary:0,storage:0};return typeof N=="number"?(S.boundary=4,S.storage=4):N.isVector2?(S.boundary=8,S.storage=8):N.isVector3||N.isColor?(S.boundary=16,S.storage=12):N.isVector4?(S.boundary=16,S.storage=16):N.isMatrix3?(S.boundary=48,S.storage=48):N.isMatrix4?(S.boundary=64,S.storage=64):N.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",N),S}function b(N){const S=N.target;S.removeEventListener("dispose",b);const T=o.indexOf(S.__bindingPointIndex);o.splice(T,1),t.deleteBuffer(i[S.id]),delete i[S.id],delete s[S.id]}function v(){for(const N in i)t.deleteBuffer(i[N]);o=[],i={},s={}}return{bind:c,update:u,dispose:v}}class iR{constructor(e={}){const{canvas:n=fIe(),context:r=null,depth:i=!0,stencil:s=!0,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let m;r!==null?m=r.getContextAttributes().alpha:m=o;const g=new Uint32Array(4),x=new Int32Array(4);let y=null,b=null;const v=[],N=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=_a,this._useLegacyLights=!1,this.toneMapping=Fd,this.toneMappingExposure=1;const S=this;let T=!1,E=0,k=0,C=null,D=-1,A=null;const R=new yr,F=new yr;let O=null;const q=new Jt(0);let j=0,G=n.width,Y=n.height,K=1,Z=null,te=null;const ne=new yr(0,0,G,Y),z=new yr(0,0,G,Y);let W=!1;const se=new XN;let ae=!1,de=!1,me=null;const xe=new kr,be=new pn,fe=new qe,Ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ne(){return C===null?K:1}let re=r;function He(Ee,Xe){for(let it=0;it<Ee.length;it++){const st=Ee[it],et=n.getContext(st,Xe);if(et!==null)return et}return null}try{const Ee={alpha:!0,depth:i,stencil:s,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${qN}`),n.addEventListener("webglcontextlost",ce,!1),n.addEventListener("webglcontextrestored",ee,!1),n.addEventListener("webglcontextcreationerror",ke,!1),re===null){const Xe=["webgl2","webgl","experimental-webgl"];if(S.isWebGL1Renderer===!0&&Xe.shift(),re=He(Xe,Ee),re===null)throw He(Xe)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&re instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),re.getShaderPrecisionFormat===void 0&&(re.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Ee){throw console.error("THREE.WebGLRenderer: "+Ee.message),Ee}let H,B,X,U,Q,le,Pe,Oe,je,$,I,V,ie,Se,ye,$e,Ue,Ge,We,Ye,oe,ve,Le,Ke;function lt(){H=new TUe(re),B=new vUe(re,H,e),H.init(B),ve=new dBe(re,H,B),X=new cBe(re,H,B),U=new kUe(re),Q=new Xze,le=new uBe(re,H,X,Q,B,ve,U),Pe=new wUe(S),Oe=new EUe(S),je=new IIe(re,B),Le=new bUe(re,H,je,B),$=new CUe(re,je,U,Le),I=new DUe(re,$,je,U),We=new RUe(re,B,le),$e=new _Ue(Q),V=new Kze(S,Pe,Oe,H,B,Le,$e),ie=new pBe(S,Q),Se=new Qze,ye=new rBe(H,B),Ge=new xUe(S,Pe,Oe,X,I,m,c),Ue=new lBe(S,I,B),Ke=new gBe(re,U,B,X),Ye=new yUe(re,H,U,B),oe=new AUe(re,H,U,B),U.programs=V.programs,S.capabilities=B,S.extensions=H,S.properties=Q,S.renderLists=Se,S.shadowMap=Ue,S.state=X,S.info=U}lt();const _e=new mBe(S,re);this.xr=_e,this.getContext=function(){return re},this.getContextAttributes=function(){return re.getContextAttributes()},this.forceContextLoss=function(){const Ee=H.get("WEBGL_lose_context");Ee&&Ee.loseContext()},this.forceContextRestore=function(){const Ee=H.get("WEBGL_lose_context");Ee&&Ee.restoreContext()},this.getPixelRatio=function(){return K},this.setPixelRatio=function(Ee){Ee!==void 0&&(K=Ee,this.setSize(G,Y,!1))},this.getSize=function(Ee){return Ee.set(G,Y)},this.setSize=function(Ee,Xe,it=!0){if(_e.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}G=Ee,Y=Xe,n.width=Math.floor(Ee*K),n.height=Math.floor(Xe*K),it===!0&&(n.style.width=Ee+"px",n.style.height=Xe+"px"),this.setViewport(0,0,Ee,Xe)},this.getDrawingBufferSize=function(Ee){return Ee.set(G*K,Y*K).floor()},this.setDrawingBufferSize=function(Ee,Xe,it){G=Ee,Y=Xe,K=it,n.width=Math.floor(Ee*it),n.height=Math.floor(Xe*it),this.setViewport(0,0,Ee,Xe)},this.getCurrentViewport=function(Ee){return Ee.copy(R)},this.getViewport=function(Ee){return Ee.copy(ne)},this.setViewport=function(Ee,Xe,it,st){Ee.isVector4?ne.set(Ee.x,Ee.y,Ee.z,Ee.w):ne.set(Ee,Xe,it,st),X.viewport(R.copy(ne).multiplyScalar(K).floor())},this.getScissor=function(Ee){return Ee.copy(z)},this.setScissor=function(Ee,Xe,it,st){Ee.isVector4?z.set(Ee.x,Ee.y,Ee.z,Ee.w):z.set(Ee,Xe,it,st),X.scissor(F.copy(z).multiplyScalar(K).floor())},this.getScissorTest=function(){return W},this.setScissorTest=function(Ee){X.setScissorTest(W=Ee)},this.setOpaqueSort=function(Ee){Z=Ee},this.setTransparentSort=function(Ee){te=Ee},this.getClearColor=function(Ee){return Ee.copy(Ge.getClearColor())},this.setClearColor=function(){Ge.setClearColor.apply(Ge,arguments)},this.getClearAlpha=function(){return Ge.getClearAlpha()},this.setClearAlpha=function(){Ge.setClearAlpha.apply(Ge,arguments)},this.clear=function(Ee=!0,Xe=!0,it=!0){let st=0;if(Ee){let et=!1;if(C!==null){const Ct=C.texture.format;et=Ct===kJ||Ct===AJ||Ct===CJ}if(et){const Ct=C.texture.type,ue=Ct===Ud||Ct===Ed||Ct===UO||Ct===Sf||Ct===EJ||Ct===TJ,ge=Ge.getClearColor(),Fe=Ge.getClearAlpha(),Ie=ge.r,Me=ge.g,mt=ge.b;ue?(g[0]=Ie,g[1]=Me,g[2]=mt,g[3]=Fe,re.clearBufferuiv(re.COLOR,0,g)):(x[0]=Ie,x[1]=Me,x[2]=mt,x[3]=Fe,re.clearBufferiv(re.COLOR,0,x))}else st|=re.COLOR_BUFFER_BIT}Xe&&(st|=re.DEPTH_BUFFER_BIT),it&&(st|=re.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),re.clear(st)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",ce,!1),n.removeEventListener("webglcontextrestored",ee,!1),n.removeEventListener("webglcontextcreationerror",ke,!1),Se.dispose(),ye.dispose(),Q.dispose(),Pe.dispose(),Oe.dispose(),I.dispose(),Le.dispose(),Ke.dispose(),V.dispose(),_e.dispose(),_e.removeEventListener("sessionstart",ln),_e.removeEventListener("sessionend",Lt),me&&(me.dispose(),me=null),Cn.stop()};function ce(Ee){Ee.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),T=!0}function ee(){console.log("THREE.WebGLRenderer: Context Restored."),T=!1;const Ee=U.autoReset,Xe=Ue.enabled,it=Ue.autoUpdate,st=Ue.needsUpdate,et=Ue.type;lt(),U.autoReset=Ee,Ue.enabled=Xe,Ue.autoUpdate=it,Ue.needsUpdate=st,Ue.type=et}function ke(Ee){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",Ee.statusMessage)}function De(Ee){const Xe=Ee.target;Xe.removeEventListener("dispose",De),Ae(Xe)}function Ae(Ee){Je(Ee),Q.remove(Ee)}function Je(Ee){const Xe=Q.get(Ee).programs;Xe!==void 0&&(Xe.forEach(function(it){V.releaseProgram(it)}),Ee.isShaderMaterial&&V.releaseShaderCache(Ee))}this.renderBufferDirect=function(Ee,Xe,it,st,et,Ct){Xe===null&&(Xe=Ce);const ue=et.isMesh&&et.matrixWorld.determinant()<0,ge=zn(Ee,Xe,it,st,et);X.setMaterial(st,ue);let Fe=it.index,Ie=1;if(st.wireframe===!0){if(Fe=$.getWireframeAttribute(it),Fe===void 0)return;Ie=2}const Me=it.drawRange,mt=it.attributes.position;let wt=Me.start*Ie,kt=(Me.start+Me.count)*Ie;Ct!==null&&(wt=Math.max(wt,Ct.start*Ie),kt=Math.min(kt,(Ct.start+Ct.count)*Ie)),Fe!==null?(wt=Math.max(wt,0),kt=Math.min(kt,Fe.count)):mt!=null&&(wt=Math.max(wt,0),kt=Math.min(kt,mt.count));const pt=kt-wt;if(pt<0||pt===1/0)return;Le.setup(et,st,ge,it,Fe);let zt,Pt=Ye;if(Fe!==null&&(zt=je.get(Fe),Pt=oe,Pt.setIndex(zt)),et.isMesh)st.wireframe===!0?(X.setLineWidth(st.wireframeLinewidth*Ne()),Pt.setMode(re.LINES)):Pt.setMode(re.TRIANGLES);else if(et.isLine){let Mt=st.linewidth;Mt===void 0&&(Mt=1),X.setLineWidth(Mt*Ne()),et.isLineSegments?Pt.setMode(re.LINES):et.isLineLoop?Pt.setMode(re.LINE_LOOP):Pt.setMode(re.LINE_STRIP)}else et.isPoints?Pt.setMode(re.POINTS):et.isSprite&&Pt.setMode(re.TRIANGLES);if(et.isBatchedMesh)Pt.renderMultiDraw(et._multiDrawStarts,et._multiDrawCounts,et._multiDrawCount);else if(et.isInstancedMesh)Pt.renderInstances(wt,pt,et.count);else if(it.isInstancedBufferGeometry){const Mt=it._maxInstanceCount!==void 0?it._maxInstanceCount:1/0,nn=Math.min(it.instanceCount,Mt);Pt.renderInstances(wt,pt,nn)}else Pt.render(wt,pt)};function gt(Ee,Xe,it){Ee.transparent===!0&&Ee.side===Hc&&Ee.forceSinglePass===!1?(Ee.side=ws,Ee.needsUpdate=!0,jr(Ee,Xe,it),Ee.side=nh,Ee.needsUpdate=!0,jr(Ee,Xe,it),Ee.side=Hc):jr(Ee,Xe,it)}this.compile=function(Ee,Xe,it=null){it===null&&(it=Ee),b=ye.get(it),b.init(),N.push(b),it.traverseVisible(function(et){et.isLight&&et.layers.test(Xe.layers)&&(b.pushLight(et),et.castShadow&&b.pushShadow(et))}),Ee!==it&&Ee.traverseVisible(function(et){et.isLight&&et.layers.test(Xe.layers)&&(b.pushLight(et),et.castShadow&&b.pushShadow(et))}),b.setupLights(S._useLegacyLights);const st=new Set;return Ee.traverse(function(et){const Ct=et.material;if(Ct)if(Array.isArray(Ct))for(let ue=0;ue<Ct.length;ue++){const ge=Ct[ue];gt(ge,it,et),st.add(ge)}else gt(Ct,it,et),st.add(Ct)}),N.pop(),b=null,st},this.compileAsync=function(Ee,Xe,it=null){const st=this.compile(Ee,Xe,it);return new Promise(et=>{function Ct(){if(st.forEach(function(ue){Q.get(ue).currentProgram.isReady()&&st.delete(ue)}),st.size===0){et(Ee);return}setTimeout(Ct,10)}H.get("KHR_parallel_shader_compile")!==null?Ct():setTimeout(Ct,10)})};let At=null;function jt(Ee){At&&At(Ee)}function ln(){Cn.stop()}function Lt(){Cn.start()}const Cn=new KJ;Cn.setAnimationLoop(jt),typeof self<"u"&&Cn.setContext(self),this.setAnimationLoop=function(Ee){At=Ee,_e.setAnimationLoop(Ee),Ee===null?Cn.stop():Cn.start()},_e.addEventListener("sessionstart",ln),_e.addEventListener("sessionend",Lt),this.render=function(Ee,Xe){if(Xe!==void 0&&Xe.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;Ee.matrixWorldAutoUpdate===!0&&Ee.updateMatrixWorld(),Xe.parent===null&&Xe.matrixWorldAutoUpdate===!0&&Xe.updateMatrixWorld(),_e.enabled===!0&&_e.isPresenting===!0&&(_e.cameraAutoUpdate===!0&&_e.updateCamera(Xe),Xe=_e.getCamera()),Ee.isScene===!0&&Ee.onBeforeRender(S,Ee,Xe,C),b=ye.get(Ee,N.length),b.init(),N.push(b),xe.multiplyMatrices(Xe.projectionMatrix,Xe.matrixWorldInverse),se.setFromProjectionMatrix(xe),de=this.localClippingEnabled,ae=$e.init(this.clippingPlanes,de),y=Se.get(Ee,v.length),y.init(),v.push(y),en(Ee,Xe,0,S.sortObjects),y.finish(),S.sortObjects===!0&&y.sort(Z,te),this.info.render.frame++,ae===!0&&$e.beginShadows();const it=b.state.shadowsArray;if(Ue.render(it,Ee,Xe),ae===!0&&$e.endShadows(),this.info.autoReset===!0&&this.info.reset(),Ge.render(y,Ee),b.setupLights(S._useLegacyLights),Xe.isArrayCamera){const st=Xe.cameras;for(let et=0,Ct=st.length;et<Ct;et++){const ue=st[et];er(y,Ee,ue,ue.viewport)}}else er(y,Ee,Xe);C!==null&&(le.updateMultisampleRenderTarget(C),le.updateRenderTargetMipmap(C)),Ee.isScene===!0&&Ee.onAfterRender(S,Ee,Xe),Le.resetDefaultState(),D=-1,A=null,N.pop(),N.length>0?b=N[N.length-1]:b=null,v.pop(),v.length>0?y=v[v.length-1]:y=null};function en(Ee,Xe,it,st){if(Ee.visible===!1)return;if(Ee.layers.test(Xe.layers)){if(Ee.isGroup)it=Ee.renderOrder;else if(Ee.isLOD)Ee.autoUpdate===!0&&Ee.update(Xe);else if(Ee.isLight)b.pushLight(Ee),Ee.castShadow&&b.pushShadow(Ee);else if(Ee.isSprite){if(!Ee.frustumCulled||se.intersectsSprite(Ee)){st&&fe.setFromMatrixPosition(Ee.matrixWorld).applyMatrix4(xe);const ue=I.update(Ee),ge=Ee.material;ge.visible&&y.push(Ee,ue,ge,it,fe.z,null)}}else if((Ee.isMesh||Ee.isLine||Ee.isPoints)&&(!Ee.frustumCulled||se.intersectsObject(Ee))){const ue=I.update(Ee),ge=Ee.material;if(st&&(Ee.boundingSphere!==void 0?(Ee.boundingSphere===null&&Ee.computeBoundingSphere(),fe.copy(Ee.boundingSphere.center)):(ue.boundingSphere===null&&ue.computeBoundingSphere(),fe.copy(ue.boundingSphere.center)),fe.applyMatrix4(Ee.matrixWorld).applyMatrix4(xe)),Array.isArray(ge)){const Fe=ue.groups;for(let Ie=0,Me=Fe.length;Ie<Me;Ie++){const mt=Fe[Ie],wt=ge[mt.materialIndex];wt&&wt.visible&&y.push(Ee,ue,wt,it,fe.z,mt)}}else ge.visible&&y.push(Ee,ue,ge,it,fe.z,null)}}const Ct=Ee.children;for(let ue=0,ge=Ct.length;ue<ge;ue++)en(Ct[ue],Xe,it,st)}function er(Ee,Xe,it,st){const et=Ee.opaque,Ct=Ee.transmissive,ue=Ee.transparent;b.setupLightsView(it),ae===!0&&$e.setGlobalState(S.clippingPlanes,it),Ct.length>0&&ur(et,Ct,Xe,it),st&&X.viewport(R.copy(st)),et.length>0&&Un(et,Xe,it),Ct.length>0&&Un(Ct,Xe,it),ue.length>0&&Un(ue,Xe,it),X.buffers.depth.setTest(!0),X.buffers.depth.setMask(!0),X.buffers.color.setMask(!0),X.setPolygonOffset(!1)}function ur(Ee,Xe,it,st){if((it.isScene===!0?it.overrideMaterial:null)!==null)return;const Ct=B.isWebGL2;me===null&&(me=new Xf(1,1,{generateMipmaps:!0,type:H.has("EXT_color_buffer_half_float")?$0:Ud,minFilter:B0,samples:Ct?4:0})),S.getDrawingBufferSize(be),Ct?me.setSize(be.x,be.y):me.setSize(PS(be.x),PS(be.y));const ue=S.getRenderTarget();S.setRenderTarget(me),S.getClearColor(q),j=S.getClearAlpha(),j<1&&S.setClearColor(16777215,.5),S.clear();const ge=S.toneMapping;S.toneMapping=Fd,Un(Ee,it,st),le.updateMultisampleRenderTarget(me),le.updateRenderTargetMipmap(me);let Fe=!1;for(let Ie=0,Me=Xe.length;Ie<Me;Ie++){const mt=Xe[Ie],wt=mt.object,kt=mt.geometry,pt=mt.material,zt=mt.group;if(pt.side===Hc&&wt.layers.test(st.layers)){const Pt=pt.side;pt.side=ws,pt.needsUpdate=!0,wr(wt,it,st,kt,pt,zt),pt.side=Pt,pt.needsUpdate=!0,Fe=!0}}Fe===!0&&(le.updateMultisampleRenderTarget(me),le.updateRenderTargetMipmap(me)),S.setRenderTarget(ue),S.setClearColor(q,j),S.toneMapping=ge}function Un(Ee,Xe,it){const st=Xe.isScene===!0?Xe.overrideMaterial:null;for(let et=0,Ct=Ee.length;et<Ct;et++){const ue=Ee[et],ge=ue.object,Fe=ue.geometry,Ie=st===null?ue.material:st,Me=ue.group;ge.layers.test(it.layers)&&wr(ge,Xe,it,Fe,Ie,Me)}}function wr(Ee,Xe,it,st,et,Ct){Ee.onBeforeRender(S,Xe,it,st,et,Ct),Ee.modelViewMatrix.multiplyMatrices(it.matrixWorldInverse,Ee.matrixWorld),Ee.normalMatrix.getNormalMatrix(Ee.modelViewMatrix),et.onBeforeRender(S,Xe,it,st,Ee,Ct),et.transparent===!0&&et.side===Hc&&et.forceSinglePass===!1?(et.side=ws,et.needsUpdate=!0,S.renderBufferDirect(it,Xe,st,et,Ee,Ct),et.side=nh,et.needsUpdate=!0,S.renderBufferDirect(it,Xe,st,et,Ee,Ct),et.side=Hc):S.renderBufferDirect(it,Xe,st,et,Ee,Ct),Ee.onAfterRender(S,Xe,it,st,et,Ct)}function jr(Ee,Xe,it){Xe.isScene!==!0&&(Xe=Ce);const st=Q.get(Ee),et=b.state.lights,Ct=b.state.shadowsArray,ue=et.state.version,ge=V.getParameters(Ee,et.state,Ct,Xe,it),Fe=V.getProgramCacheKey(ge);let Ie=st.programs;st.environment=Ee.isMeshStandardMaterial?Xe.environment:null,st.fog=Xe.fog,st.envMap=(Ee.isMeshStandardMaterial?Oe:Pe).get(Ee.envMap||st.environment),Ie===void 0&&(Ee.addEventListener("dispose",De),Ie=new Map,st.programs=Ie);let Me=Ie.get(Fe);if(Me!==void 0){if(st.currentProgram===Me&&st.lightsStateVersion===ue)return Xt(Ee,ge),Me}else ge.uniforms=V.getUniforms(Ee),Ee.onBuild(it,ge,S),Ee.onBeforeCompile(ge,S),Me=V.acquireProgram(ge,Fe),Ie.set(Fe,Me),st.uniforms=ge.uniforms;const mt=st.uniforms;return(!Ee.isShaderMaterial&&!Ee.isRawShaderMaterial||Ee.clipping===!0)&&(mt.clippingPlanes=$e.uniform),Xt(Ee,ge),st.needsLights=Zr(Ee),st.lightsStateVersion=ue,st.needsLights&&(mt.ambientLightColor.value=et.state.ambient,mt.lightProbe.value=et.state.probe,mt.directionalLights.value=et.state.directional,mt.directionalLightShadows.value=et.state.directionalShadow,mt.spotLights.value=et.state.spot,mt.spotLightShadows.value=et.state.spotShadow,mt.rectAreaLights.value=et.state.rectArea,mt.ltc_1.value=et.state.rectAreaLTC1,mt.ltc_2.value=et.state.rectAreaLTC2,mt.pointLights.value=et.state.point,mt.pointLightShadows.value=et.state.pointShadow,mt.hemisphereLights.value=et.state.hemi,mt.directionalShadowMap.value=et.state.directionalShadowMap,mt.directionalShadowMatrix.value=et.state.directionalShadowMatrix,mt.spotShadowMap.value=et.state.spotShadowMap,mt.spotLightMatrix.value=et.state.spotLightMatrix,mt.spotLightMap.value=et.state.spotLightMap,mt.pointShadowMap.value=et.state.pointShadowMap,mt.pointShadowMatrix.value=et.state.pointShadowMatrix),st.currentProgram=Me,st.uniformsList=null,Me}function Zn(Ee){if(Ee.uniformsList===null){const Xe=Ee.currentProgram.getUniforms();Ee.uniformsList=sw.seqWithValue(Xe.seq,Ee.uniforms)}return Ee.uniformsList}function Xt(Ee,Xe){const it=Q.get(Ee);it.outputColorSpace=Xe.outputColorSpace,it.batching=Xe.batching,it.instancing=Xe.instancing,it.instancingColor=Xe.instancingColor,it.skinning=Xe.skinning,it.morphTargets=Xe.morphTargets,it.morphNormals=Xe.morphNormals,it.morphColors=Xe.morphColors,it.morphTargetsCount=Xe.morphTargetsCount,it.numClippingPlanes=Xe.numClippingPlanes,it.numIntersection=Xe.numClipIntersection,it.vertexAlphas=Xe.vertexAlphas,it.vertexTangents=Xe.vertexTangents,it.toneMapping=Xe.toneMapping}function zn(Ee,Xe,it,st,et){Xe.isScene!==!0&&(Xe=Ce),le.resetTextureUnits();const Ct=Xe.fog,ue=st.isMeshStandardMaterial?Xe.environment:null,ge=C===null?S.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:bu,Fe=(st.isMeshStandardMaterial?Oe:Pe).get(st.envMap||ue),Ie=st.vertexColors===!0&&!!it.attributes.color&&it.attributes.color.itemSize===4,Me=!!it.attributes.tangent&&(!!st.normalMap||st.anisotropy>0),mt=!!it.morphAttributes.position,wt=!!it.morphAttributes.normal,kt=!!it.morphAttributes.color;let pt=Fd;st.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(pt=S.toneMapping);const zt=it.morphAttributes.position||it.morphAttributes.normal||it.morphAttributes.color,Pt=zt!==void 0?zt.length:0,Mt=Q.get(st),nn=b.state.lights;if(ae===!0&&(de===!0||Ee!==A)){const Wt=Ee===A&&st.id===D;$e.setState(st,Ee,Wt)}let Bt=!1;st.version===Mt.__version?(Mt.needsLights&&Mt.lightsStateVersion!==nn.state.version||Mt.outputColorSpace!==ge||et.isBatchedMesh&&Mt.batching===!1||!et.isBatchedMesh&&Mt.batching===!0||et.isInstancedMesh&&Mt.instancing===!1||!et.isInstancedMesh&&Mt.instancing===!0||et.isSkinnedMesh&&Mt.skinning===!1||!et.isSkinnedMesh&&Mt.skinning===!0||et.isInstancedMesh&&Mt.instancingColor===!0&&et.instanceColor===null||et.isInstancedMesh&&Mt.instancingColor===!1&&et.instanceColor!==null||Mt.envMap!==Fe||st.fog===!0&&Mt.fog!==Ct||Mt.numClippingPlanes!==void 0&&(Mt.numClippingPlanes!==$e.numPlanes||Mt.numIntersection!==$e.numIntersection)||Mt.vertexAlphas!==Ie||Mt.vertexTangents!==Me||Mt.morphTargets!==mt||Mt.morphNormals!==wt||Mt.morphColors!==kt||Mt.toneMapping!==pt||B.isWebGL2===!0&&Mt.morphTargetsCount!==Pt)&&(Bt=!0):(Bt=!0,Mt.__version=st.version);let tn=Mt.currentProgram;Bt===!0&&(tn=jr(st,Xe,et));let cn=!1,we=!1,bt=!1;const $t=tn.getUniforms(),Be=Mt.uniforms;if(X.useProgram(tn.program)&&(cn=!0,we=!0,bt=!0),st.id!==D&&(D=st.id,we=!0),cn||A!==Ee){$t.setValue(re,"projectionMatrix",Ee.projectionMatrix),$t.setValue(re,"viewMatrix",Ee.matrixWorldInverse);const Wt=$t.map.cameraPosition;Wt!==void 0&&Wt.setValue(re,fe.setFromMatrixPosition(Ee.matrixWorld)),B.logarithmicDepthBuffer&&$t.setValue(re,"logDepthBufFC",2/(Math.log(Ee.far+1)/Math.LN2)),(st.isMeshPhongMaterial||st.isMeshToonMaterial||st.isMeshLambertMaterial||st.isMeshBasicMaterial||st.isMeshStandardMaterial||st.isShaderMaterial)&&$t.setValue(re,"isOrthographic",Ee.isOrthographicCamera===!0),A!==Ee&&(A=Ee,we=!0,bt=!0)}if(et.isSkinnedMesh){$t.setOptional(re,et,"bindMatrix"),$t.setOptional(re,et,"bindMatrixInverse");const Wt=et.skeleton;Wt&&(B.floatVertexTextures?(Wt.boneTexture===null&&Wt.computeBoneTexture(),$t.setValue(re,"boneTexture",Wt.boneTexture,le)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}et.isBatchedMesh&&($t.setOptional(re,et,"batchingTexture"),$t.setValue(re,"batchingTexture",et._matricesTexture,le));const Et=it.morphAttributes;if((Et.position!==void 0||Et.normal!==void 0||Et.color!==void 0&&B.isWebGL2===!0)&&We.update(et,it,tn),(we||Mt.receiveShadow!==et.receiveShadow)&&(Mt.receiveShadow=et.receiveShadow,$t.setValue(re,"receiveShadow",et.receiveShadow)),st.isMeshGouraudMaterial&&st.envMap!==null&&(Be.envMap.value=Fe,Be.flipEnvMap.value=Fe.isCubeTexture&&Fe.isRenderTargetTexture===!1?-1:1),we&&($t.setValue(re,"toneMappingExposure",S.toneMappingExposure),Mt.needsLights&&Wn(Be,bt),Ct&&st.fog===!0&&ie.refreshFogUniforms(Be,Ct),ie.refreshMaterialUniforms(Be,st,K,Y,me),sw.upload(re,Zn(Mt),Be,le)),st.isShaderMaterial&&st.uniformsNeedUpdate===!0&&(sw.upload(re,Zn(Mt),Be,le),st.uniformsNeedUpdate=!1),st.isSpriteMaterial&&$t.setValue(re,"center",et.center),$t.setValue(re,"modelViewMatrix",et.modelViewMatrix),$t.setValue(re,"normalMatrix",et.normalMatrix),$t.setValue(re,"modelMatrix",et.matrixWorld),st.isShaderMaterial||st.isRawShaderMaterial){const Wt=st.uniformsGroups;for(let dt=0,Kt=Wt.length;dt<Kt;dt++)if(B.isWebGL2){const sn=Wt[dt];Ke.update(sn,tn),Ke.bind(sn,tn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return tn}function Wn(Ee,Xe){Ee.ambientLightColor.needsUpdate=Xe,Ee.lightProbe.needsUpdate=Xe,Ee.directionalLights.needsUpdate=Xe,Ee.directionalLightShadows.needsUpdate=Xe,Ee.pointLights.needsUpdate=Xe,Ee.pointLightShadows.needsUpdate=Xe,Ee.spotLights.needsUpdate=Xe,Ee.spotLightShadows.needsUpdate=Xe,Ee.rectAreaLights.needsUpdate=Xe,Ee.hemisphereLights.needsUpdate=Xe}function Zr(Ee){return Ee.isMeshLambertMaterial||Ee.isMeshToonMaterial||Ee.isMeshPhongMaterial||Ee.isMeshStandardMaterial||Ee.isShadowMaterial||Ee.isShaderMaterial&&Ee.lights===!0}this.getActiveCubeFace=function(){return E},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(Ee,Xe,it){Q.get(Ee.texture).__webglTexture=Xe,Q.get(Ee.depthTexture).__webglTexture=it;const st=Q.get(Ee);st.__hasExternalTextures=!0,st.__hasExternalTextures&&(st.__autoAllocateDepthBuffer=it===void 0,st.__autoAllocateDepthBuffer||H.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),st.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(Ee,Xe){const it=Q.get(Ee);it.__webglFramebuffer=Xe,it.__useDefaultFramebuffer=Xe===void 0},this.setRenderTarget=function(Ee,Xe=0,it=0){C=Ee,E=Xe,k=it;let st=!0,et=null,Ct=!1,ue=!1;if(Ee){const Fe=Q.get(Ee);Fe.__useDefaultFramebuffer!==void 0?(X.bindFramebuffer(re.FRAMEBUFFER,null),st=!1):Fe.__webglFramebuffer===void 0?le.setupRenderTarget(Ee):Fe.__hasExternalTextures&&le.rebindTextures(Ee,Q.get(Ee.texture).__webglTexture,Q.get(Ee.depthTexture).__webglTexture);const Ie=Ee.texture;(Ie.isData3DTexture||Ie.isDataArrayTexture||Ie.isCompressedArrayTexture)&&(ue=!0);const Me=Q.get(Ee).__webglFramebuffer;Ee.isWebGLCubeRenderTarget?(Array.isArray(Me[Xe])?et=Me[Xe][it]:et=Me[Xe],Ct=!0):B.isWebGL2&&Ee.samples>0&&le.useMultisampledRTT(Ee)===!1?et=Q.get(Ee).__webglMultisampledFramebuffer:Array.isArray(Me)?et=Me[it]:et=Me,R.copy(Ee.viewport),F.copy(Ee.scissor),O=Ee.scissorTest}else R.copy(ne).multiplyScalar(K).floor(),F.copy(z).multiplyScalar(K).floor(),O=W;if(X.bindFramebuffer(re.FRAMEBUFFER,et)&&B.drawBuffers&&st&&X.drawBuffers(Ee,et),X.viewport(R),X.scissor(F),X.setScissorTest(O),Ct){const Fe=Q.get(Ee.texture);re.framebufferTexture2D(re.FRAMEBUFFER,re.COLOR_ATTACHMENT0,re.TEXTURE_CUBE_MAP_POSITIVE_X+Xe,Fe.__webglTexture,it)}else if(ue){const Fe=Q.get(Ee.texture),Ie=Xe||0;re.framebufferTextureLayer(re.FRAMEBUFFER,re.COLOR_ATTACHMENT0,Fe.__webglTexture,it||0,Ie)}D=-1},this.readRenderTargetPixels=function(Ee,Xe,it,st,et,Ct,ue){if(!(Ee&&Ee.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ge=Q.get(Ee).__webglFramebuffer;if(Ee.isWebGLCubeRenderTarget&&ue!==void 0&&(ge=ge[ue]),ge){X.bindFramebuffer(re.FRAMEBUFFER,ge);try{const Fe=Ee.texture,Ie=Fe.format,Me=Fe.type;if(Ie!==Mo&&ve.convert(Ie)!==re.getParameter(re.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const mt=Me===$0&&(H.has("EXT_color_buffer_half_float")||B.isWebGL2&&H.has("EXT_color_buffer_float"));if(Me!==Ud&&ve.convert(Me)!==re.getParameter(re.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Me===Xc&&(B.isWebGL2||H.has("OES_texture_float")||H.has("WEBGL_color_buffer_float")))&&!mt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Xe>=0&&Xe<=Ee.width-st&&it>=0&&it<=Ee.height-et&&re.readPixels(Xe,it,st,et,ve.convert(Ie),ve.convert(Me),Ct)}finally{const Fe=C!==null?Q.get(C).__webglFramebuffer:null;X.bindFramebuffer(re.FRAMEBUFFER,Fe)}}},this.copyFramebufferToTexture=function(Ee,Xe,it=0){const st=Math.pow(2,-it),et=Math.floor(Xe.image.width*st),Ct=Math.floor(Xe.image.height*st);le.setTexture2D(Xe,0),re.copyTexSubImage2D(re.TEXTURE_2D,it,0,0,Ee.x,Ee.y,et,Ct),X.unbindTexture()},this.copyTextureToTexture=function(Ee,Xe,it,st=0){const et=Xe.image.width,Ct=Xe.image.height,ue=ve.convert(it.format),ge=ve.convert(it.type);le.setTexture2D(it,0),re.pixelStorei(re.UNPACK_FLIP_Y_WEBGL,it.flipY),re.pixelStorei(re.UNPACK_PREMULTIPLY_ALPHA_WEBGL,it.premultiplyAlpha),re.pixelStorei(re.UNPACK_ALIGNMENT,it.unpackAlignment),Xe.isDataTexture?re.texSubImage2D(re.TEXTURE_2D,st,Ee.x,Ee.y,et,Ct,ue,ge,Xe.image.data):Xe.isCompressedTexture?re.compressedTexSubImage2D(re.TEXTURE_2D,st,Ee.x,Ee.y,Xe.mipmaps[0].width,Xe.mipmaps[0].height,ue,Xe.mipmaps[0].data):re.texSubImage2D(re.TEXTURE_2D,st,Ee.x,Ee.y,ue,ge,Xe.image),st===0&&it.generateMipmaps&&re.generateMipmap(re.TEXTURE_2D),X.unbindTexture()},this.copyTextureToTexture3D=function(Ee,Xe,it,st,et=0){if(S.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Ct=Ee.max.x-Ee.min.x+1,ue=Ee.max.y-Ee.min.y+1,ge=Ee.max.z-Ee.min.z+1,Fe=ve.convert(st.format),Ie=ve.convert(st.type);let Me;if(st.isData3DTexture)le.setTexture3D(st,0),Me=re.TEXTURE_3D;else if(st.isDataArrayTexture)le.setTexture2DArray(st,0),Me=re.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}re.pixelStorei(re.UNPACK_FLIP_Y_WEBGL,st.flipY),re.pixelStorei(re.UNPACK_PREMULTIPLY_ALPHA_WEBGL,st.premultiplyAlpha),re.pixelStorei(re.UNPACK_ALIGNMENT,st.unpackAlignment);const mt=re.getParameter(re.UNPACK_ROW_LENGTH),wt=re.getParameter(re.UNPACK_IMAGE_HEIGHT),kt=re.getParameter(re.UNPACK_SKIP_PIXELS),pt=re.getParameter(re.UNPACK_SKIP_ROWS),zt=re.getParameter(re.UNPACK_SKIP_IMAGES),Pt=it.isCompressedTexture?it.mipmaps[0]:it.image;re.pixelStorei(re.UNPACK_ROW_LENGTH,Pt.width),re.pixelStorei(re.UNPACK_IMAGE_HEIGHT,Pt.height),re.pixelStorei(re.UNPACK_SKIP_PIXELS,Ee.min.x),re.pixelStorei(re.UNPACK_SKIP_ROWS,Ee.min.y),re.pixelStorei(re.UNPACK_SKIP_IMAGES,Ee.min.z),it.isDataTexture||it.isData3DTexture?re.texSubImage3D(Me,et,Xe.x,Xe.y,Xe.z,Ct,ue,ge,Fe,Ie,Pt.data):it.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),re.compressedTexSubImage3D(Me,et,Xe.x,Xe.y,Xe.z,Ct,ue,ge,Fe,Pt.data)):re.texSubImage3D(Me,et,Xe.x,Xe.y,Xe.z,Ct,ue,ge,Fe,Ie,Pt),re.pixelStorei(re.UNPACK_ROW_LENGTH,mt),re.pixelStorei(re.UNPACK_IMAGE_HEIGHT,wt),re.pixelStorei(re.UNPACK_SKIP_PIXELS,kt),re.pixelStorei(re.UNPACK_SKIP_ROWS,pt),re.pixelStorei(re.UNPACK_SKIP_IMAGES,zt),et===0&&st.generateMipmaps&&re.generateMipmap(Me),X.unbindTexture()},this.initTexture=function(Ee){Ee.isCubeTexture?le.setTextureCube(Ee,0):Ee.isData3DTexture?le.setTexture3D(Ee,0):Ee.isDataArrayTexture||Ee.isCompressedArrayTexture?le.setTexture2DArray(Ee,0):le.setTexture2D(Ee,0),X.unbindTexture()},this.resetState=function(){E=0,k=0,C=null,X.reset(),Le.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Dl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===zO?"display-p3":"srgb",n.unpackColorSpace=xr.workingColorSpace===KN?"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===_a?Mf:PJ}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Mf?_a:bu}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 xBe extends iR{}xBe.prototype.isWebGL1Renderer=!0;class qO{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new Jt(e),this.near=n,this.far=r}clone(){return new qO(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class bBe extends Za{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 yBe{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=eR,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=ru()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,n,r){e*=this.stride,r*=n.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=n.array[r+i];return this}set(e,n=0){return this.array.set(e,n),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ru()),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=ru()),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 Va=new qe;class Td{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++)Va.fromBufferAttribute(this,n),Va.applyMatrix4(e),this.setXYZ(n,Va.x,Va.y,Va.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Va.fromBufferAttribute(this,n),Va.applyNormalMatrix(e),this.setXYZ(n,Va.x,Va.y,Va.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Va.fromBufferAttribute(this,n),Va.transformDirection(e),this.setXYZ(n,Va.x,Va.y,Va.z);return this}setX(e,n){return this.normalized&&(n=gr(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=gr(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=gr(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=gr(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=kl(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=kl(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=kl(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=kl(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=gr(n,this.array),r=gr(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=gr(n,this.array),r=gr(r,this.array),i=gr(i,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(n=gr(n,this.array),r=gr(r,this.array),i=gr(i,this.array),s=gr(s,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)n.push(this.data.array[i+s])}return new Ys(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 Td(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)n.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:n,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class vBe extends Ss{constructor(e=null,n=1,r=1,i,s,o,l,c,u=va,d=va,f,m){super(null,o,l,c,u,d,i,s,f,m),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function _Be(t,e){return t.z-e.z}function wBe(t,e){return e.z-t.z}class SBe{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,n){const r=this.pool,i=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1});const s=r[this.index];i.push(s),this.index++,s.start=e.start,s.count=e.count,s.z=n}reset(){this.list.length=0,this.index=0}}const Mp="batchId",sd=new kr,$7=new kr,NBe=new kr,H7=new kr,Pk=new XN,x1=new jo,Gh=new Il,_b=new qe,Rk=new SBe,Pa=new il,b1=[];function MBe(t,e,n=0){const r=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const i=t.count;for(let s=0;s<i;s++)for(let o=0;o<r;o++)e.setComponent(s+n,o,t.getComponent(s,o))}else e.array.set(t.array,n*r);e.needsUpdate=!0}class EBe extends il{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new Ba,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 vBe(n,e,e,Mo,Xc);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,s=this._maxIndexCount;if(this._geometryInitialized===!1){for(const l in e.attributes){const c=e.getAttribute(l),{array:u,itemSize:d,normalized:f}=c,m=new u.constructor(r*d),g=new c.constructor(m,d,f);g.setUsage(c.usage),n.setAttribute(l,g)}if(e.getIndex()!==null){const l=r>65536?new Uint32Array(s):new Uint16Array(s);n.setIndex(new Ys(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(Mp,new Ys(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Mp))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Mp}"`);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===Mp)continue;if(!e.hasAttribute(r))throw new Error(`BatchedMesh: Added geometry missing "${r}". All geometries must have consistent attributes.`);const i=e.getAttribute(r),s=n.getAttribute(r);if(i.itemSize!==s.itemSize||i.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new jo);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,sd),this.getBoundingBoxAt(i,x1).applyMatrix4(sd),n.union(x1))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Il);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,sd),this.getBoundingSphereAt(i,Gh).applyMatrix4(sd),n.union(Gh))}addGeometry(e,n=-1,r=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const o=this._reservedRanges,l=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(s=o[o.length-1]),n===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=n,s===null?i.vertexStart=0:i.vertexStart=s.vertexStart+s.vertexCount;const u=e.getIndex(),d=u!==null;if(d&&(r===-1?i.indexCount=u.count:i.indexCount=r,s===null?i.indexStart=0:i.indexStart=s.indexStart+s.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const f=this._visibility,m=this._active,g=this._matricesTexture,x=this._matricesTexture.image.data;f.push(!0),m.push(!0);const y=this._geometryCount;this._geometryCount++,NBe.toArray(x,y*16),g.needsUpdate=!0,o.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new jo,sphereInitialized:!1,sphere:new Il});const b=this.geometry.getAttribute(Mp);for(let v=0;v<i.vertexCount;v++)b.setX(i.vertexStart+v,y);return b.needsUpdate=!0,this.setGeometryAt(y,e),y}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,s=r.getIndex(),o=n.getIndex(),l=this._reservedRanges[e];if(i&&o.count>l.indexCount||n.attributes.position.count>l.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const c=l.vertexStart,u=l.vertexCount;for(const g in r.attributes){if(g===Mp)continue;const x=n.getAttribute(g),y=r.getAttribute(g);MBe(x,y,c);const b=x.itemSize;for(let v=x.count,N=u;v<N;v++){const S=c+v;for(let T=0;T<b;T++)y.setComponent(S,T,0)}y.needsUpdate=!0}if(i){const g=l.indexStart;for(let x=0;x<o.count;x++)s.setX(g+x,c+o.getX(x));for(let x=o.count,y=l.indexCount;x<y;x++)s.setX(g+x,c);s.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const f=this._drawRanges[e],m=n.getAttribute("position");return f.count=i?o.count:m.count,this._visibilityChanged=!0,e}deleteGeometry(e){const n=this._active;return e>=n.length||n[e]===!1?this:(n[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],s=i.box,o=this.geometry;if(i.boxInitialized===!1){s.makeEmpty();const l=o.index,c=o.attributes.position,u=this._drawRanges[e];for(let d=u.start,f=u.start+u.count;d<f;d++){let m=d;l&&(m=l.getX(m)),s.expandByPoint(_b.fromBufferAttribute(c,m))}i.boxInitialized=!0}return n.copy(s),n}getBoundingSphereAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],s=i.sphere,o=this.geometry;if(i.sphereInitialized===!1){s.makeEmpty(),this.getBoundingBoxAt(e,x1),x1.getCenter(s.center);const l=o.index,c=o.attributes.position,u=this._drawRanges[e];let d=0;for(let f=u.start,m=u.start+u.count;f<m;f++){let g=f;l&&(g=l.getX(g)),_b.fromBufferAttribute(c,g),d=Math.max(d,s.center.distanceToSquared(_b))}s.radius=Math.sqrt(d),i.sphereInitialized=!0}return n.copy(s),n}setMatrixAt(e,n){const r=this._active,i=this._matricesTexture,s=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||r[e]===!1?this:(n.toArray(s,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,n){const r=this._active,i=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||r[e]===!1?null:n.fromArray(i,e*16)}setVisibleAt(e,n){const r=this._visibility,i=this._active,s=this._geometryCount;return e>=s||i[e]===!1||r[e]===n?this:(r[e]=n,this._visibilityChanged=!0,this)}getVisibleAt(e){const n=this._visibility,r=this._active,i=this._geometryCount;return e>=i||r[e]===!1?!1:n[e]}raycast(e,n){const r=this._visibility,i=this._active,s=this._drawRanges,o=this._geometryCount,l=this.matrixWorld,c=this.geometry;Pa.material=this.material,Pa.geometry.index=c.index,Pa.geometry.attributes=c.attributes,Pa.geometry.boundingBox===null&&(Pa.geometry.boundingBox=new jo),Pa.geometry.boundingSphere===null&&(Pa.geometry.boundingSphere=new Il);for(let u=0;u<o;u++){if(!r[u]||!i[u])continue;const d=s[u];Pa.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,Pa.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,Pa.geometry.boundingBox),this.getBoundingSphereAt(u,Pa.geometry.boundingSphere),Pa.raycast(e,b1);for(let f=0,m=b1.length;f<m;f++){const g=b1[f];g.object=this,g.batchId=u,n.push(g)}b1.length=0}Pa.material=null,Pa.geometry.index=null,Pa.geometry.attributes={},Pa.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(n=>({...n})),this._reservedRanges=e._reservedRanges.map(n=>({...n})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(n=>({boxInitialized:n.boxInitialized,box:n.box.clone(),sphereInitialized:n.sphereInitialized,sphere:n.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,n,r,i,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=i.getIndex(),l=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,m=this.perObjectFrustumCulled;m&&(H7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),Pk.setFromProjectionMatrix(H7,e.isWebGPURenderer?H0:Dl));let g=0;if(this.sortObjects){$7.copy(this.matrixWorld).invert(),_b.setFromMatrixPosition(r.matrixWorld).applyMatrix4($7);for(let b=0,v=c.length;b<v;b++)if(c[b]){this.getMatrixAt(b,sd),this.getBoundingSphereAt(b,Gh).applyMatrix4(sd);let N=!1;if(m&&(N=!Pk.intersectsSphere(Gh)),!N){const S=_b.distanceTo(Gh.center);Rk.push(f[b],S)}}const x=Rk.list,y=this.customSort;y===null?x.sort(s.transparent?wBe:_Be):y.call(this,x,r);for(let b=0,v=x.length;b<v;b++){const N=x[b];u[g]=N.start*l,d[g]=N.count,g++}Rk.reset()}else for(let x=0,y=c.length;x<y;x++)if(c[x]){let b=!1;if(m&&(this.getMatrixAt(x,sd),this.getBoundingSphereAt(x,Gh).applyMatrix4(sd),b=!Pk.intersectsSphere(Gh)),!b){const v=f[x];u[g]=v.start*l,d[g]=v.count,g++}}this._multiDrawCount=g,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,s,o){this.onBeforeRender(e,null,i,s,o)}}class zy extends rx{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Jt(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 V7=new qe,G7=new qe,q7=new kr,Dk=new $O,y1=new Il;class TBe extends Za{constructor(e=new Ba,n=new zy){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,s=n.count;i<s;i++)V7.fromBufferAttribute(n,i-1),G7.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=V7.distanceTo(G7);e.setAttribute("lineDistance",new mi(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),y1.copy(r.boundingSphere),y1.applyMatrix4(i),y1.radius+=s,e.ray.intersectsSphere(y1)===!1)return;q7.copy(i).invert(),Dk.copy(e.ray).applyMatrix4(q7);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new qe,d=new qe,f=new qe,m=new qe,g=this.isLineSegments?2:1,x=r.index,b=r.attributes.position;if(x!==null){const v=Math.max(0,o.start),N=Math.min(x.count,o.start+o.count);for(let S=v,T=N-1;S<T;S+=g){const E=x.getX(S),k=x.getX(S+1);if(u.fromBufferAttribute(b,E),d.fromBufferAttribute(b,k),Dk.distanceSqToSegment(u,d,m,f)>c)continue;m.applyMatrix4(this.matrixWorld);const D=e.ray.origin.distanceTo(m);D<e.near||D>e.far||n.push({distance:D,point:f.clone().applyMatrix4(this.matrixWorld),index:S,face:null,faceIndex:null,object:this})}}else{const v=Math.max(0,o.start),N=Math.min(b.count,o.start+o.count);for(let S=v,T=N-1;S<T;S+=g){if(u.fromBufferAttribute(b,S),d.fromBufferAttribute(b,S+1),Dk.distanceSqToSegment(u,d,m,f)>c)continue;m.applyMatrix4(this.matrixWorld);const k=e.ray.origin.distanceTo(m);k<e.near||k>e.far||n.push({distance:k,point:f.clone().applyMatrix4(this.matrixWorld),index:S,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const l=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}}const W7=new qe,K7=new qe;class QN extends TBe{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,s=n.count;i<s;i+=2)W7.fromBufferAttribute(n,i),K7.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+W7.distanceTo(K7);e.setAttribute("lineDistance",new mi(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class CBe extends Ba{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new qe,s=new qe;if(e.index!==null){const o=e.attributes.position,l=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:l.count,materialIndex:0}]);for(let u=0,d=c.length;u<d;++u){const f=c[u],m=f.start,g=f.count;for(let x=m,y=m+g;x<y;x+=3)for(let b=0;b<3;b++){const v=l.getX(x+b),N=l.getX(x+(b+1)%3);i.fromBufferAttribute(o,v),s.fromBufferAttribute(o,N),X7(i,s,r)===!0&&(n.push(i.x,i.y,i.z),n.push(s.x,s.y,s.z))}}}else{const o=e.attributes.position;for(let l=0,c=o.count/3;l<c;l++)for(let u=0;u<3;u++){const d=3*l+u,f=3*l+(u+1)%3;i.fromBufferAttribute(o,d),s.fromBufferAttribute(o,f),X7(i,s,r)===!0&&(n.push(i.x,i.y,i.z),n.push(s.x,s.y,s.z))}}this.setAttribute("position",new mi(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function X7(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 ABe extends rx{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Jt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Jt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=RJ,this.normalScale=new pn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=FO,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 kBe extends zy{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 tee extends Za{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Jt(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 Ok=new kr,Y7=new qe,Q7=new qe;class jBe{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new pn(512,512),this.map=null,this.mapPass=null,this.matrix=new kr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new XN,this._frameExtents=new pn(1,1),this._viewportCount=1,this._viewports=[new yr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;Y7.setFromMatrixPosition(e.matrixWorld),n.position.copy(Y7),Q7.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(Q7),n.updateMatrixWorld(),Ok.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ok),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(Ok)}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 Z7=new kr,wb=new qe,Lk=new qe;class PBe extends jBe{constructor(){super(new $s(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new pn(4,2),this._viewportCount=6,this._viewports=[new yr(2,1,1,1),new yr(0,1,1,1),new yr(3,1,1,1),new yr(1,1,1,1),new yr(3,0,1,1),new yr(1,0,1,1)],this._cubeDirections=[new qe(1,0,0),new qe(-1,0,0),new qe(0,0,1),new qe(0,0,-1),new qe(0,1,0),new qe(0,-1,0)],this._cubeUps=[new qe(0,1,0),new qe(0,1,0),new qe(0,1,0),new qe(0,1,0),new qe(0,0,1),new qe(0,0,-1)]}updateMatrices(e,n=0){const r=this.camera,i=this.matrix,s=e.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),wb.setFromMatrixPosition(e.matrixWorld),r.position.copy(wb),Lk.copy(r.position),Lk.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(Lk),r.updateMatrixWorld(),i.makeTranslation(-wb.x,-wb.y,-wb.z),Z7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Z7)}}class RBe extends tee{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 PBe}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,n){return super.copy(e,n),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class DBe extends tee{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class OBe extends Ba{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 aR extends yBe{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 J7{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(wa(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const e9=new qe,v1=new qe;class LBe{constructor(e=new qe,n=new qe){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){e9.subVectors(e,this.start),v1.subVectors(this.end,this.start);const r=v1.dot(v1);let s=v1.dot(e9)/r;return n&&(s=wa(s,0,1)),s}closestPointToPoint(e,n,r){const i=this.closestPointToPointParameter(e,n);return this.delta(r).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}class IBe extends QN{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 Ba;i.setAttribute("position",new mi(n,3)),i.setAttribute("color",new mi(r,3));const s=new zy({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,n,r){const i=new Jt,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(n),i.toArray(s,6),i.toArray(s,9),i.set(r),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:qN}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=qN);class Fl{constructor(e,n,r,i,s="div"){this.parent=e,this.object=n,this.property=r,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(s),this.domElement.classList.add("controller"),this.domElement.classList.add(i),this.$name=document.createElement("div"),this.$name.classList.add("name"),Fl.nextNameID=Fl.nextNameID||0,this.$name.id=`lil-gui-name-${++Fl.nextNameID}`,this.$widget=document.createElement("div"),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.domElement.addEventListener("keydown",o=>o.stopPropagation()),this.domElement.addEventListener("keyup",o=>o.stopPropagation()),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(r)}name(e){return this._name=e,this.$name.textContent=e,this}onChange(e){return this._onChange=e,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(e=!0){return this.disable(!e)}disable(e=!0){return e===this._disabled?this:(this._disabled=e,this.domElement.classList.toggle("disabled",e),this.$disable.toggleAttribute("disabled",e),this)}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(e){const n=this.parent.add(this.object,this.property,e);return n.name(this._name),this.destroy(),n}min(e){return this}max(e){return this}step(e){return this}decimals(e){return this}listen(e=!0){return this._listening=e,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const e=this.save();e!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=e}getValue(){return this.object[this.property]}setValue(e){return this.getValue()!==e&&(this.object[this.property]=e,this._callOnChange(),this.updateDisplay()),this}updateDisplay(){return this}load(e){return this.setValue(e),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}}class FBe extends Fl{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 sR(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 UBe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:sR,toHexString:sR},G0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},zBe={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=G0.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 G0.toHexString(i)}},BBe={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=G0.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 G0.toHexString(i)}},$Be=[UBe,G0,zBe,BBe];function HBe(t){return $Be.find(e=>e.match(t))}class VBe extends Fl{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=HBe(this.initialValue),this._rgbScale=i,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const s=sR(this.$text.value);s&&this._setValueFromHexString(s)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){const n=this._format.fromHexString(e);this.setValue(n)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class Ik extends Fl{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 GBe extends Fl{constructor(e,n,r,i,s,o){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(s);const l=o!==void 0;this.step(l?o:this._getImplicitStep(),l),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,n=!0){return this._step=e,this._stepExplicit=n,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let n=(e-this._min)/(this._max-this._min);n=Math.max(0,Math.min(n,1)),this.$fill.style.width=n*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const n=()=>{let N=parseFloat(this.$input.value);isNaN(N)||(this._stepExplicit&&(N=this._snap(N)),this.setValue(this._clamp(N)))},r=N=>{const S=parseFloat(this.$input.value);isNaN(S)||(this._snapClampSetValue(S+N),this.$input.value=this.getValue())},i=N=>{N.key==="Enter"&&this.$input.blur(),N.code==="ArrowUp"&&(N.preventDefault(),r(this._step*this._arrowKeyMultiplier(N))),N.code==="ArrowDown"&&(N.preventDefault(),r(this._step*this._arrowKeyMultiplier(N)*-1))},s=N=>{this._inputFocused&&(N.preventDefault(),r(this._step*this._normalizeMouseWheel(N)))};let o=!1,l,c,u,d,f;const m=5,g=N=>{l=N.clientX,c=u=N.clientY,o=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",x),window.addEventListener("mouseup",y)},x=N=>{if(o){const S=N.clientX-l,T=N.clientY-c;Math.abs(T)>m?(N.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(S)>m&&y()}if(!o){const S=N.clientY-u;f-=S*this._step*this._arrowKeyMultiplier(N),d+f>this._max?f=this._max-d:d+f<this._min&&(f=this._min-d),this._snapClampSetValue(d+f)}u=N.clientY},y=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",y)},b=()=>{this._inputFocused=!0},v=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",s,{passive:!1}),this.$input.addEventListener("mousedown",g),this.$input.addEventListener("focus",b),this.$input.addEventListener("blur",v)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=(v,N,S,T,E)=>(v-N)/(S-N)*(E-T)+T,n=v=>{const N=this.$slider.getBoundingClientRect();let S=e(v,N.left,N.right,this._min,this._max);this._snapClampSetValue(S)},r=v=>{this._setDraggingStyle(!0),n(v.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",s)},i=v=>{n(v.clientX)},s=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",s)};let o=!1,l,c;const u=v=>{v.preventDefault(),this._setDraggingStyle(!0),n(v.touches[0].clientX),o=!1},d=v=>{v.touches.length>1||(this._hasScrollBar?(l=v.touches[0].clientX,c=v.touches[0].clientY,o=!0):u(v),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",m))},f=v=>{if(o){const N=v.touches[0].clientX-l,S=v.touches[0].clientY-c;Math.abs(N)>Math.abs(S)?u(v):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",m))}else v.preventDefault(),n(v.touches[0].clientX)},m=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",m)},g=this._callOnFinishChange.bind(this),x=400;let y;const b=v=>{if(Math.abs(v.deltaX)<Math.abs(v.deltaY)&&this._hasScrollBar)return;v.preventDefault();const S=this._normalizeMouseWheel(v)*this._step;this._snapClampSetValue(this.getValue()+S),this.$input.value=this.getValue(),clearTimeout(y),y=setTimeout(g,x)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",b,{passive:!1})}_setDraggingStyle(e,n="horizontal"){this.$slider&&this.$slider.classList.toggle("active",e),document.body.classList.toggle("lil-gui-dragging",e),document.body.classList.toggle(`lil-gui-${n}`,e)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(e){let{deltaX:n,deltaY:r}=e;return Math.floor(e.deltaY)!==e.deltaY&&e.wheelDelta&&(n=0,r=-e.wheelDelta/120,r*=this._stepExplicit?1:10),n+-r}_arrowKeyMultiplier(e){let n=this._stepExplicit?1:10;return e.shiftKey?n*=10:e.altKey&&(n/=10),n}_snap(e){const n=Math.round(e/this._step)*this._step;return parseFloat(n.toPrecision(15))}_clamp(e){return e<this._min&&(e=this._min),e>this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){const e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class qBe extends Fl{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 WBe extends Fl{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 KBe=`.lil-gui {
- font-family: var(--font-family);
- font-size: var(--font-size);
- line-height: 1;
- font-weight: normal;
- font-style: normal;
- text-align: left;
- color: var(--text-color);
- user-select: none;
- -webkit-user-select: none;
- touch-action: manipulation;
- --background-color: #1f1f1f;
- --text-color: #ebebeb;
- --title-background-color: #111111;
- --title-text-color: #ebebeb;
- --widget-color: #424242;
- --hover-color: #4f4f4f;
- --focus-color: #595959;
- --number-color: #2cc9ff;
- --string-color: #a2db3c;
- --font-size: 11px;
- --input-font-size: 11px;
- --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
- --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
- --padding: 4px;
- --spacing: 4px;
- --widget-height: 20px;
- --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
- --name-width: 45%;
- --slider-knob-width: 2px;
- --slider-input-width: 27%;
- --color-input-width: 27%;
- --slider-input-min-width: 45px;
- --color-input-min-width: 45px;
- --folder-indent: 7px;
- --widget-padding: 0 0 0 3px;
- --widget-border-radius: 2px;
- --checkbox-size: calc(0.75 * var(--widget-height));
- --scrollbar-width: 5px;
- }
- .lil-gui, .lil-gui * {
- box-sizing: border-box;
- margin: 0;
- padding: 0;
- }
- .lil-gui.root {
- width: var(--width, 245px);
- display: flex;
- flex-direction: column;
- background: var(--background-color);
- }
- .lil-gui.root > .title {
- background: var(--title-background-color);
- color: var(--title-text-color);
- }
- .lil-gui.root > .children {
- overflow-x: hidden;
- overflow-y: auto;
- }
- .lil-gui.root > .children::-webkit-scrollbar {
- width: var(--scrollbar-width);
- height: var(--scrollbar-width);
- background: var(--background-color);
- }
- .lil-gui.root > .children::-webkit-scrollbar-thumb {
- border-radius: var(--scrollbar-width);
- background: var(--focus-color);
- }
- @media (pointer: coarse) {
- .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- }
- .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- .lil-gui.autoPlace {
- max-height: 100%;
- position: fixed;
- top: 0;
- right: 15px;
- z-index: 1001;
- }
- .lil-gui .controller {
- display: flex;
- align-items: center;
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- }
- .lil-gui .controller.disabled {
- opacity: 0.5;
- }
- .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
- pointer-events: none !important;
- }
- .lil-gui .controller > .name {
- min-width: var(--name-width);
- flex-shrink: 0;
- white-space: pre;
- padding-right: var(--spacing);
- line-height: var(--widget-height);
- }
- .lil-gui .controller .widget {
- position: relative;
- display: flex;
- align-items: center;
- width: 100%;
- min-height: var(--widget-height);
- }
- .lil-gui .controller.string input {
- color: var(--string-color);
- }
- .lil-gui .controller.boolean {
- cursor: pointer;
- }
- .lil-gui .controller.color .display {
- width: 100%;
- height: var(--widget-height);
- border-radius: var(--widget-border-radius);
- position: relative;
- }
- @media (hover: hover) {
- .lil-gui .controller.color .display:hover:before {
- content: " ";
- display: block;
- position: absolute;
- border-radius: var(--widget-border-radius);
- border: 1px solid #fff9;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- }
- }
- .lil-gui .controller.color input[type=color] {
- opacity: 0;
- width: 100%;
- height: 100%;
- cursor: pointer;
- }
- .lil-gui .controller.color input[type=text] {
- margin-left: var(--spacing);
- font-family: var(--font-family-mono);
- min-width: var(--color-input-min-width);
- width: var(--color-input-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.option select {
- opacity: 0;
- position: absolute;
- width: 100%;
- max-width: 100%;
- }
- .lil-gui .controller.option .display {
- position: relative;
- pointer-events: none;
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- line-height: var(--widget-height);
- max-width: 100%;
- overflow: hidden;
- word-break: break-all;
- padding-left: 0.55em;
- padding-right: 1.75em;
- background: var(--widget-color);
- }
- @media (hover: hover) {
- .lil-gui .controller.option .display.focus {
- background: var(--focus-color);
- }
- }
- .lil-gui .controller.option .display.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.option .display:after {
- font-family: "lil-gui";
- content: "↕";
- position: absolute;
- top: 0;
- right: 0;
- bottom: 0;
- padding-right: 0.375em;
- }
- .lil-gui .controller.option .widget,
- .lil-gui .controller.option select {
- cursor: pointer;
- }
- @media (hover: hover) {
- .lil-gui .controller.option .widget:hover .display {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number input {
- color: var(--number-color);
- }
- .lil-gui .controller.number.hasSlider input {
- margin-left: var(--spacing);
- width: var(--slider-input-width);
- min-width: var(--slider-input-min-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.number .slider {
- width: 100%;
- height: var(--widget-height);
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- padding-right: var(--slider-knob-width);
- overflow: hidden;
- cursor: ew-resize;
- touch-action: pan-y;
- }
- @media (hover: hover) {
- .lil-gui .controller.number .slider:hover {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number .slider.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.number .slider.active .fill {
- opacity: 0.95;
- }
- .lil-gui .controller.number .fill {
- height: 100%;
- border-right: var(--slider-knob-width) solid var(--number-color);
- box-sizing: content-box;
- }
- .lil-gui-dragging .lil-gui {
- --hover-color: var(--widget-color);
- }
- .lil-gui-dragging * {
- cursor: ew-resize !important;
- }
- .lil-gui-dragging.lil-gui-vertical * {
- cursor: ns-resize !important;
- }
- .lil-gui .title {
- height: var(--title-height);
- line-height: calc(var(--title-height) - 4px);
- font-weight: 600;
- padding: 0 var(--padding);
- -webkit-tap-highlight-color: transparent;
- cursor: pointer;
- outline: none;
- text-decoration-skip: objects;
- }
- .lil-gui .title:before {
- font-family: "lil-gui";
- content: "▾";
- padding-right: 2px;
- display: inline-block;
- }
- .lil-gui .title:active {
- background: var(--title-background-color);
- opacity: 0.75;
- }
- @media (hover: hover) {
- body:not(.lil-gui-dragging) .lil-gui .title:hover {
- background: var(--title-background-color);
- opacity: 0.85;
- }
- .lil-gui .title:focus {
- text-decoration: underline var(--focus-color);
- }
- }
- .lil-gui.root > .title:focus {
- text-decoration: none !important;
- }
- .lil-gui.closed > .title:before {
- content: "▸";
- }
- .lil-gui.closed > .children {
- transform: translateY(-7px);
- opacity: 0;
- }
- .lil-gui.closed:not(.transition) > .children {
- display: none;
- }
- .lil-gui.transition > .children {
- transition-duration: 300ms;
- transition-property: height, opacity, transform;
- transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
- overflow: hidden;
- pointer-events: none;
- }
- .lil-gui .children:empty:before {
- content: "Empty";
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- display: block;
- height: var(--widget-height);
- font-style: italic;
- line-height: var(--widget-height);
- opacity: 0.5;
- }
- .lil-gui.root > .children > .lil-gui > .title {
- border: 0 solid var(--widget-color);
- border-width: 1px 0;
- transition: border-color 300ms;
- }
- .lil-gui.root > .children > .lil-gui.closed > .title {
- border-bottom-color: transparent;
- }
- .lil-gui + .controller {
- border-top: 1px solid var(--widget-color);
- margin-top: 0;
- padding-top: var(--spacing);
- }
- .lil-gui .lil-gui .lil-gui > .title {
- border: none;
- }
- .lil-gui .lil-gui .lil-gui > .children {
- border: none;
- margin-left: var(--folder-indent);
- border-left: 2px solid var(--widget-color);
- }
- .lil-gui .lil-gui .controller {
- border: none;
- }
- .lil-gui label, .lil-gui input, .lil-gui button {
- -webkit-tap-highlight-color: transparent;
- }
- .lil-gui input {
- border: 0;
- outline: none;
- font-family: var(--font-family);
- font-size: var(--input-font-size);
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- background: var(--widget-color);
- color: var(--text-color);
- width: 100%;
- }
- @media (hover: hover) {
- .lil-gui input:hover {
- background: var(--hover-color);
- }
- .lil-gui input:active {
- background: var(--focus-color);
- }
- }
- .lil-gui input:disabled {
- opacity: 1;
- }
- .lil-gui input[type=text],
- .lil-gui input[type=number] {
- padding: var(--widget-padding);
- -moz-appearance: textfield;
- }
- .lil-gui input[type=text]:focus,
- .lil-gui input[type=number]:focus {
- background: var(--focus-color);
- }
- .lil-gui input[type=checkbox] {
- appearance: none;
- width: var(--checkbox-size);
- height: var(--checkbox-size);
- border-radius: var(--widget-border-radius);
- text-align: center;
- cursor: pointer;
- }
- .lil-gui input[type=checkbox]:checked:before {
- font-family: "lil-gui";
- content: "✓";
- font-size: var(--checkbox-size);
- line-height: var(--checkbox-size);
- }
- @media (hover: hover) {
- .lil-gui input[type=checkbox]:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button {
- outline: none;
- cursor: pointer;
- font-family: var(--font-family);
- font-size: var(--font-size);
- color: var(--text-color);
- width: 100%;
- height: var(--widget-height);
- text-transform: none;
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- border: none;
- }
- @media (hover: hover) {
- .lil-gui button:hover {
- background: var(--hover-color);
- }
- .lil-gui button:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button:active {
- background: var(--focus-color);
- }
- @font-face {
- font-family: "lil-gui";
- src: url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff");
- }`;function XBe(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 t9=!1;class DS{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:s="Controls",closeFolders:o=!1,injectStyles:l=!0,touchStyles:c=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",u=>{(u.code==="Enter"||u.code==="Space")&&(u.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(s),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),c&&this.domElement.classList.add("allow-touch-styles"),!t9&&l&&(XBe(KBe),t9=!0),r?r.appendChild(this.domElement):n&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),i&&this.domElement.style.setProperty("--width",i+"px"),this._closeFolders=o}add(e,n,r,i,s){if(Object(r)===r)return new qBe(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new GBe(this,e,n,r,i,s);case"boolean":return new FBe(this,e,n);case"string":return new WBe(this,e,n);case"function":return new Ik(this,e,n)}console.error(`gui.add failed
- property:`,n,`
- object:`,e,`
- value:`,o)}addColor(e,n,r=1){return new VBe(this,e,n,r)}addFolder(e){const n=new DS({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof Ik||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 Ik)){if(r._name in n.controllers)throw new Error(`Cannot save GUI with duplicate property "${r._name}"`);n.controllers[r._name]=r.save()}}),e&&this.folders.forEach(r=>{if(r._title in n.folders)throw new Error(`Cannot save GUI with duplicate folder "${r._title}"`);n.folders[r._title]=r.save()}),n}open(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}_setClosed(e){this._closed!==e&&(this._closed=e,this._callOnOpenClose(this))}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const n=this.$children.clientHeight;this.$children.style.height=n+"px",this.domElement.classList.add("transition");const r=s=>{s.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",r))};this.$children.addEventListener("transitionend",r);const i=e?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!e),requestAnimationFrame(()=>{this.$children.style.height=i+"px"})}),this}title(e){return this._title=e,this.$title.textContent=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(r=>r.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onOpenClose(e){return this._onOpenClose=e,this}_callOnOpenClose(e){this.parent&&this.parent._callOnOpenClose(e),this._onOpenClose!==void 0&&this._onOpenClose.call(this,e)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(n=>{e=e.concat(n.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(n=>{e=e.concat(n.foldersRecursive())}),e}}function Fk(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(u){try{c(r.next(u))}catch(d){s(d)}}function l(u){try{c(r.throw(u))}catch(d){s(d)}}function c(u){var d;u.done?i(u.value):(d=u.value,d instanceof n?d:new n((function(f){f(d)}))).then(o,l)}c((r=r.apply(t,[])).next())}))}class WO{constructor(e,n,r,i){this.size=e,this.width=n,this.height=r,this.charLength=i,this.chars=""}static parse(e){const n=e.split(" "),r=n[0],i=r.split("x");return new WO(r,+i[0],+i[1],+n[1])}get src(){return"data:image/jpeg;base64,"+this.chars}get isValid(){return this.chars.length==this.charLength&&/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(this.chars)}}class KO{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class n9 extends KO{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class od extends KO{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class r9{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class OS{constructor(e){this.lines=[],this.preamble=new r9(-1,[],0),this.layers=[],this.curZ=0,this.maxZ=0,this.metadata={thumbnails:{}},this.tolerance=0,this.tolerance=e??this.tolerance}parseGCode(e){const n=Array.isArray(e)?e:e.split(`
- `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((s=>s.comment))).thumbnails;for(const[s,o]of Object.entries(i))this.metadata.thumbnails[s]=o;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((n=>this.parseCommand(n)))}parseCommand(e,n=!0){var r;const i=e.trim().split(";"),s=i[0],o=n&&i[1]||void 0,l=s.split(/([a-zA-Z])/g).slice(1).map((d=>d.trim())),c=l.length?`${(r=l[0])===null||r===void 0?void 0:r.toLowerCase()}${l[1]}`:"",u=this.parseParams(l.slice(2));switch(c){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new n9(e,c,u,o);case"t0":return new od(e,c,o,0);case"t1":return new od(e,c,o,1);case"t2":return new od(e,c,o,2);case"t3":return new od(e,c,o,3);case"t4":return new od(e,c,o,4);case"t5":return new od(e,c,o,5);case"t6":return new od(e,c,o,6);case"t7":return new od(e,c,o,7);default:return new KO(e,c,u,o)}}parseMove(e){return e.reduce(((n,r)=>{const i=r.charAt(0).toLowerCase();return i!="x"&&i!="y"&&i!="z"&&i!="e"&&i!="r"&&i!="f"&&i!="i"&&i!="j"||(n[i]=parseFloat(r.slice(1))),n}),{})}isAlpha(e){const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90}parseParams(e){return e.reduce(((n,r,i,s)=>{if(i%2==0)return n;let o=s[i-1];return o=o.toLowerCase(),this.isAlpha(o)&&(n[o]=parseFloat(r)),n}),{})}groupIntoLayers(e){var n;for(let r=0;r<e.length;r++){const i=e[r];if(i instanceof n9){const s=i.params;if(s.z&&(this.curZ=s.z),((n=s.e)!==null&&n!==void 0?n:0)>0&&(s.x!=null||s.y!=null)&&Math.abs(this.curZ-(this.maxZ||-1/0))>this.tolerance){const o=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new r9(this.layers.length,[],r,o))}}this.maxLayer.commands.push(i)}return this.layers}get maxLayer(){var e;return(e=this.layers[this.layers.length-1])!==null&&e!==void 0?e:this.preamble}parseMetadata(e){const n={};let r;for(const i of e){const s=i.comment;if(!s)continue;const o=s.indexOf("thumbnail begin"),l=s.indexOf("thumbnail end");o>-1?r=WO.parse(s.slice(o+15).trim()):r&&(l==-1?r.chars+=s.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}OS.prototype.parseGcode=OS.prototype.parseGCode;const i9={type:"change"},Uk={type:"start"},a9={type:"end"},_1=new $O,s9=new md,YBe=Math.cos(70*OJ.DEG2RAD);class QBe extends lm{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new qe,this.cursor=new qe,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:op.ROTATE,MIDDLE:op.DOLLY,RIGHT:op.PAN},this.touches={ONE:lp.ROTATE,TWO:lp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return l.phi},this.getAzimuthalAngle=function(){return l.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(B){B.addEventListener("keydown",Ne),this._domElementKeyEvents=B},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Ne),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(i9),r.update(),s=i.NONE},this.update=(function(){const B=new qe,X=new Yf().setFromUnitVectors(e.up,new qe(0,1,0)),U=X.clone().invert(),Q=new qe,le=new Yf,Pe=new qe,Oe=2*Math.PI;return function(je=null){const $=r.object.position;B.copy($).sub(r.target),B.applyQuaternion(X),l.setFromVector3(B),r.autoRotate&&s===i.NONE&&R((function(Se){return Se!==null?2*Math.PI/60*r.autoRotateSpeed*Se:2*Math.PI/60/60*r.autoRotateSpeed})(je)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let I=r.minAzimuthAngle,V=r.maxAzimuthAngle;isFinite(I)&&isFinite(V)&&(I<-Math.PI?I+=Oe:I>Math.PI&&(I-=Oe),V<-Math.PI?V+=Oe:V>Math.PI&&(V-=Oe),l.theta=I<=V?Math.max(I,Math.min(V,l.theta)):l.theta>(I+V)/2?Math.max(I,l.theta):Math.min(V,l.theta)),l.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,l.phi)),l.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(d,r.dampingFactor):r.target.add(d),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&k||r.object.isOrthographicCamera?l.radius=Z(l.radius):l.radius=Z(l.radius*u),B.setFromSpherical(l),B.applyQuaternion(U),$.copy(r.target).add(B),r.object.lookAt(r.target),r.enableDamping===!0?(c.theta*=1-r.dampingFactor,c.phi*=1-r.dampingFactor,d.multiplyScalar(1-r.dampingFactor)):(c.set(0,0,0),d.set(0,0,0));let ie=!1;if(r.zoomToCursor&&k){let Se=null;if(r.object.isPerspectiveCamera){const ye=B.length();Se=Z(ye*u);const $e=ye-Se;r.object.position.addScaledVector(T,$e),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ye=new qe(E.x,E.y,0);ye.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ie=!0;const $e=new qe(E.x,E.y,0);$e.unproject(r.object),r.object.position.sub($e).add(ye),r.object.updateMatrixWorld(),Se=B.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;Se!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(Se).add(r.object.position):(_1.origin.copy(r.object.position),_1.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(_1.direction))<YBe?e.lookAt(r.target):(s9.setFromNormalAndCoplanarPoint(r.object.up,r.target),_1.intersectPlane(s9,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ie=!0);return u=1,k=!1,!!(ie||Q.distanceToSquared(r.object.position)>o||8*(1-le.dot(r.object.quaternion))>o||Pe.distanceToSquared(r.target)>0)&&(r.dispatchEvent(i9),Q.copy(r.object.position),le.copy(r.object.quaternion),Pe.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",re),r.domElement.removeEventListener("pointerdown",xe),r.domElement.removeEventListener("pointercancel",fe),r.domElement.removeEventListener("wheel",Ce),r.domElement.removeEventListener("pointermove",be),r.domElement.removeEventListener("pointerup",fe),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",Ne),r._domElementKeyEvents=null)};const r=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=i.NONE;const o=1e-6,l=new J7,c=new J7;let u=1;const d=new qe,f=new pn,m=new pn,g=new pn,x=new pn,y=new pn,b=new pn,v=new pn,N=new pn,S=new pn,T=new qe,E=new pn;let k=!1;const C=[],D={};function A(){return Math.pow(.95,r.zoomSpeed)}function R(B){c.theta-=B}function F(B){c.phi-=B}const O=(function(){const B=new qe;return function(X,U){B.setFromMatrixColumn(U,0),B.multiplyScalar(-X),d.add(B)}})(),q=(function(){const B=new qe;return function(X,U){r.screenSpacePanning===!0?B.setFromMatrixColumn(U,1):(B.setFromMatrixColumn(U,0),B.crossVectors(r.object.up,B)),B.multiplyScalar(X),d.add(B)}})(),j=(function(){const B=new qe;return function(X,U){const Q=r.domElement;if(r.object.isPerspectiveCamera){const le=r.object.position;B.copy(le).sub(r.target);let Pe=B.length();Pe*=Math.tan(r.object.fov/2*Math.PI/180),O(2*X*Pe/Q.clientHeight,r.object.matrix),q(2*U*Pe/Q.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(O(X*(r.object.right-r.object.left)/r.object.zoom/Q.clientWidth,r.object.matrix),q(U*(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 G(B){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=B:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function Y(B){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=B:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function K(B){if(!r.zoomToCursor)return;k=!0;const X=r.domElement.getBoundingClientRect(),U=B.clientX-X.left,Q=B.clientY-X.top,le=X.width,Pe=X.height;E.x=U/le*2-1,E.y=-Q/Pe*2+1,T.set(E.x,E.y,1).unproject(r.object).sub(r.object.position).normalize()}function Z(B){return Math.max(r.minDistance,Math.min(r.maxDistance,B))}function te(B){f.set(B.clientX,B.clientY)}function ne(B){x.set(B.clientX,B.clientY)}function z(){if(C.length===1)f.set(C[0].pageX,C[0].pageY);else{const B=.5*(C[0].pageX+C[1].pageX),X=.5*(C[0].pageY+C[1].pageY);f.set(B,X)}}function W(){if(C.length===1)x.set(C[0].pageX,C[0].pageY);else{const B=.5*(C[0].pageX+C[1].pageX),X=.5*(C[0].pageY+C[1].pageY);x.set(B,X)}}function se(){const B=C[0].pageX-C[1].pageX,X=C[0].pageY-C[1].pageY,U=Math.sqrt(B*B+X*X);v.set(0,U)}function ae(B){if(C.length==1)m.set(B.pageX,B.pageY);else{const U=H(B),Q=.5*(B.pageX+U.x),le=.5*(B.pageY+U.y);m.set(Q,le)}g.subVectors(m,f).multiplyScalar(r.rotateSpeed);const X=r.domElement;R(2*Math.PI*g.x/X.clientHeight),F(2*Math.PI*g.y/X.clientHeight),f.copy(m)}function de(B){if(C.length===1)y.set(B.pageX,B.pageY);else{const X=H(B),U=.5*(B.pageX+X.x),Q=.5*(B.pageY+X.y);y.set(U,Q)}b.subVectors(y,x).multiplyScalar(r.panSpeed),j(b.x,b.y),x.copy(y)}function me(B){const X=H(B),U=B.pageX-X.x,Q=B.pageY-X.y,le=Math.sqrt(U*U+Q*Q);N.set(0,le),S.set(0,Math.pow(N.y/v.y,r.zoomSpeed)),G(S.y),v.copy(N)}function xe(B){r.enabled!==!1&&(C.length===0&&(r.domElement.setPointerCapture(B.pointerId),r.domElement.addEventListener("pointermove",be),r.domElement.addEventListener("pointerup",fe)),(function(X){C.push(X)})(B),B.pointerType==="touch"?(function(X){switch(He(X),C.length){case 1:switch(r.touches.ONE){case lp.ROTATE:if(r.enableRotate===!1)return;z(),s=i.TOUCH_ROTATE;break;case lp.PAN:if(r.enablePan===!1)return;W(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(r.touches.TWO){case lp.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&se(),r.enablePan&&W(),s=i.TOUCH_DOLLY_PAN;break;case lp.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&se(),r.enableRotate&&z(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(Uk)})(B):(function(X){let U;switch(X.button){case 0:U=r.mouseButtons.LEFT;break;case 1:U=r.mouseButtons.MIDDLE;break;case 2:U=r.mouseButtons.RIGHT;break;default:U=-1}switch(U){case op.DOLLY:if(r.enableZoom===!1)return;(function(Q){K(Q),v.set(Q.clientX,Q.clientY)})(X),s=i.DOLLY;break;case op.ROTATE:if(X.ctrlKey||X.metaKey||X.shiftKey){if(r.enablePan===!1)return;ne(X),s=i.PAN}else{if(r.enableRotate===!1)return;te(X),s=i.ROTATE}break;case op.PAN:if(X.ctrlKey||X.metaKey||X.shiftKey){if(r.enableRotate===!1)return;te(X),s=i.ROTATE}else{if(r.enablePan===!1)return;ne(X),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(Uk)})(B))}function be(B){r.enabled!==!1&&(B.pointerType==="touch"?(function(X){switch(He(X),s){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;ae(X),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;de(X),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(U){r.enableZoom&&me(U),r.enablePan&&de(U)})(X),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(U){r.enableZoom&&me(U),r.enableRotate&&ae(U)})(X),r.update();break;default:s=i.NONE}})(B):(function(X){switch(s){case i.ROTATE:if(r.enableRotate===!1)return;(function(U){m.set(U.clientX,U.clientY),g.subVectors(m,f).multiplyScalar(r.rotateSpeed);const Q=r.domElement;R(2*Math.PI*g.x/Q.clientHeight),F(2*Math.PI*g.y/Q.clientHeight),f.copy(m),r.update()})(X);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(U){N.set(U.clientX,U.clientY),S.subVectors(N,v),S.y>0?G(A()):S.y<0&&Y(A()),v.copy(N),r.update()})(X);break;case i.PAN:if(r.enablePan===!1)return;(function(U){y.set(U.clientX,U.clientY),b.subVectors(y,x).multiplyScalar(r.panSpeed),j(b.x,b.y),x.copy(y),r.update()})(X)}})(B))}function fe(B){(function(X){delete D[X.pointerId];for(let U=0;U<C.length;U++)if(C[U].pointerId==X.pointerId)return void C.splice(U,1)})(B),C.length===0&&(r.domElement.releasePointerCapture(B.pointerId),r.domElement.removeEventListener("pointermove",be),r.domElement.removeEventListener("pointerup",fe)),r.dispatchEvent(a9),s=i.NONE}function Ce(B){r.enabled!==!1&&r.enableZoom!==!1&&s===i.NONE&&(B.preventDefault(),r.dispatchEvent(Uk),(function(X){K(X),X.deltaY<0?Y(A()):X.deltaY>0&&G(A()),r.update()})(B),r.dispatchEvent(a9))}function Ne(B){r.enabled!==!1&&r.enablePan!==!1&&(function(X){let U=!1;switch(X.code){case r.keys.UP:X.ctrlKey||X.metaKey||X.shiftKey?F(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,r.keyPanSpeed),U=!0;break;case r.keys.BOTTOM:X.ctrlKey||X.metaKey||X.shiftKey?F(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,-r.keyPanSpeed),U=!0;break;case r.keys.LEFT:X.ctrlKey||X.metaKey||X.shiftKey?R(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(r.keyPanSpeed,0),U=!0;break;case r.keys.RIGHT:X.ctrlKey||X.metaKey||X.shiftKey?R(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(-r.keyPanSpeed,0),U=!0}U&&(X.preventDefault(),r.update())})(B)}function re(B){r.enabled!==!1&&B.preventDefault()}function He(B){let X=D[B.pointerId];X===void 0&&(X=new pn,D[B.pointerId]=X),X.set(B.pageX,B.pageY)}function H(B){const X=B.pointerId===C[0].pointerId?C[1]:C[0];return D[X.pointerId]}r.domElement.addEventListener("contextmenu",re),r.domElement.addEventListener("pointerdown",xe),r.domElement.addEventListener("pointercancel",fe),r.domElement.addEventListener("wheel",Ce,{passive:!1}),this.update()}}Rt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new pn(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},gs.line={uniforms:HO.merge([Rt.common,Rt.fog,Rt.line]),vertexShader:`
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- uniform float linewidth;
- uniform vec2 resolution;
- attribute vec3 instanceStart;
- attribute vec3 instanceEnd;
- attribute vec3 instanceColorStart;
- attribute vec3 instanceColorEnd;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #ifdef USE_DASH
- uniform float dashScale;
- attribute float instanceDistanceStart;
- attribute float instanceDistanceEnd;
- varying float vLineDistance;
- #endif
- void trimSegment( const in vec4 start, inout vec4 end ) {
- // trim end segment so it terminates between the camera plane and the near plane
- // conservative estimate of the near plane
- float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
- float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
- float nearEstimate = - 0.5 * b / a;
- float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
- end.xyz = mix( start.xyz, end.xyz, alpha );
- }
- void main() {
- #ifdef USE_COLOR
- vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
- #endif
- #ifdef USE_DASH
- vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
- vUv = uv;
- #endif
- float aspect = resolution.x / resolution.y;
- // camera space
- vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
- vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
- #ifdef WORLD_UNITS
- worldStart = start.xyz;
- worldEnd = end.xyz;
- #else
- vUv = uv;
- #endif
- // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
- // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
- // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
- // perhaps there is a more elegant solution -- WestLangley
- bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
- if ( perspective ) {
- if ( start.z < 0.0 && end.z >= 0.0 ) {
- trimSegment( start, end );
- } else if ( end.z < 0.0 && start.z >= 0.0 ) {
- trimSegment( end, start );
- }
- }
- // clip space
- vec4 clipStart = projectionMatrix * start;
- vec4 clipEnd = projectionMatrix * end;
- // ndc space
- vec3 ndcStart = clipStart.xyz / clipStart.w;
- vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
- // direction
- vec2 dir = ndcEnd.xy - ndcStart.xy;
- // account for clip-space aspect ratio
- dir.x *= aspect;
- dir = normalize( dir );
- #ifdef WORLD_UNITS
- // get the offset direction as perpendicular to the view vector
- vec3 worldDir = normalize( end.xyz - start.xyz );
- vec3 offset;
- if ( position.y < 0.5 ) {
- offset = normalize( cross( start.xyz, worldDir ) );
- } else {
- offset = normalize( cross( end.xyz, worldDir ) );
- }
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
- // don't extend the line if we're rendering dashes because we
- // won't be rendering the endcaps
- #ifndef USE_DASH
- // extend the line bounds to encompass endcaps
- start.xyz += - worldDir * linewidth * 0.5;
- end.xyz += worldDir * linewidth * 0.5;
- // shift the position of the quad so it hugs the forward edge of the line
- offset.xy -= dir * forwardOffset;
- offset.z += 0.5;
- #endif
- // endcaps
- if ( position.y > 1.0 || position.y < 0.0 ) {
- offset.xy += dir * 2.0 * forwardOffset;
- }
- // adjust for linewidth
- offset *= linewidth * 0.5;
- // set the world position
- worldPos = ( position.y < 0.5 ) ? start : end;
- worldPos.xyz += offset;
- // project the worldpos
- vec4 clip = projectionMatrix * worldPos;
- // shift the depth of the projected points so the line
- // segments overlap neatly
- vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
- clip.z = clipPose.z * clip.w;
- #else
- vec2 offset = vec2( dir.y, - dir.x );
- // undo aspect ratio adjustment
- dir.x /= aspect;
- offset.x /= aspect;
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- // endcaps
- if ( position.y < 0.0 ) {
- offset += - dir;
- } else if ( position.y > 1.0 ) {
- offset += dir;
- }
- // adjust for linewidth
- offset *= linewidth;
- // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
- offset /= resolution.y;
- // select end
- vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
- // back to clip space
- offset *= clip.w;
- clip.xy += offset;
- #endif
- gl_Position = clip;
- vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }
- `,fragmentShader:`
- uniform vec3 diffuse;
- uniform float opacity;
- uniform float linewidth;
- #ifdef USE_DASH
- uniform float dashOffset;
- uniform float dashSize;
- uniform float gapSize;
- #endif
- varying float vLineDistance;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #include <common>
- #include <color_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
- float mua;
- float mub;
- vec3 p13 = p1 - p3;
- vec3 p43 = p4 - p3;
- vec3 p21 = p2 - p1;
- float d1343 = dot( p13, p43 );
- float d4321 = dot( p43, p21 );
- float d1321 = dot( p13, p21 );
- float d4343 = dot( p43, p43 );
- float d2121 = dot( p21, p21 );
- float denom = d2121 * d4343 - d4321 * d4321;
- float numer = d1343 * d4321 - d1321 * d4343;
- mua = numer / denom;
- mua = clamp( mua, 0.0, 1.0 );
- mub = ( d1343 + d4321 * ( mua ) ) / d4343;
- mub = clamp( mub, 0.0, 1.0 );
- return vec2( mua, mub );
- }
- void main() {
- #include <clipping_planes_fragment>
- #ifdef USE_DASH
- if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
- if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
- #endif
- float alpha = opacity;
- #ifdef WORLD_UNITS
- // Find the closest points on the view ray and the line segment
- vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
- vec3 lineDir = worldEnd - worldStart;
- vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
- vec3 p1 = worldStart + lineDir * params.x;
- vec3 p2 = rayEnd * params.y;
- vec3 delta = p1 - p2;
- float len = length( delta );
- float norm = len / linewidth;
- #ifndef USE_DASH
- #ifdef USE_ALPHA_TO_COVERAGE
- float dnorm = fwidth( norm );
- alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
- #else
- if ( norm > 0.5 ) {
- discard;
- }
- #endif
- #endif
- #else
- #ifdef USE_ALPHA_TO_COVERAGE
- // artifacts appear on some hardware if a derivative is taken within a conditional
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- float dlen = fwidth( len2 );
- if ( abs( vUv.y ) > 1.0 ) {
- alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
- }
- #else
- if ( abs( vUv.y ) > 1.0 ) {
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- if ( len2 > 1.0 ) discard;
- }
- #endif
- #endif
- vec4 diffuseColor = vec4( diffuse, alpha );
- #include <logdepthbuf_fragment>
- #include <color_fragment>
- gl_FragColor = vec4( diffuseColor.rgb, alpha );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }
- `};class nee extends rh{constructor(e){super({type:"LineMaterial",uniforms:HO.clone(gs.line.uniforms),vertexShader:gs.line.vertexShader,fragmentShader:gs.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 o9=new jo,w1=new qe;class ree extends OBe{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 mi([-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 mi([-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 aR(n,6,1);return this.setAttribute("instanceStart",new Td(r,3,0)),this.setAttribute("instanceEnd",new Td(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 aR(n,6,1);return this.setAttribute("instanceColorStart",new Td(r,3,0)),this.setAttribute("instanceColorEnd",new Td(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 CBe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new jo);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),o9.setFromBufferAttribute(n),this.boundingBox.union(o9))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Il),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){const r=this.boundingSphere.center;this.boundingBox.getCenter(r);let i=0;for(let s=0,o=e.count;s<o;s++)w1.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(w1)),w1.fromBufferAttribute(n,s),i=Math.max(i,r.distanceToSquared(w1));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 l9=new qe,c9=new qe,pa=new yr,ga=new yr,_l=new yr,zk=new qe,Bk=new kr,xa=new LBe,u9=new qe,S1=new jo,N1=new Il,wl=new yr;let Sl,nf;function d9(t,e,n){return wl.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),wl.multiplyScalar(1/wl.w),wl.x=nf/n.width,wl.y=nf/n.height,wl.applyMatrix4(t.projectionMatrixInverse),wl.multiplyScalar(1/wl.w),Math.abs(Math.max(wl.x,wl.y))}class ZBe extends il{constructor(e=new ree,n=new nee({color:16777215*Math.random()})){super(e,n),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,n=e.attributes.instanceStart,r=e.attributes.instanceEnd,i=new Float32Array(2*n.count);for(let o=0,l=0,c=n.count;o<c;o++,l+=2)l9.fromBufferAttribute(n,o),c9.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+l9.distanceTo(c9);const s=new aR(i,2,1);return e.setAttribute("instanceDistanceStart",new Td(s,1,0)),e.setAttribute("instanceDistanceEnd",new Td(s,1,1)),this}raycast(e,n){const r=this.material.worldUnits,i=e.camera;i!==null||r||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const s=e.params.Line2!==void 0&&e.params.Line2.threshold||0;Sl=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let u,d;nf=c.linewidth+s,l.boundingSphere===null&&l.computeBoundingSphere(),N1.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*nf:u=d9(i,Math.max(i.near,N1.distanceToPoint(Sl.origin)),c.resolution),N1.radius+=u,Sl.intersectsSphere(N1)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),S1.copy(l.boundingBox).applyMatrix4(o),r?d=.5*nf:d=d9(i,Math.max(i.near,S1.distanceToPoint(Sl.origin)),c.resolution),S1.expandByScalar(d),Sl.intersectsBox(S1)!==!1&&(r?(function(f,m){const g=f.matrixWorld,x=f.geometry,y=x.attributes.instanceStart,b=x.attributes.instanceEnd;for(let v=0,N=Math.min(x.instanceCount,y.count);v<N;v++){xa.start.fromBufferAttribute(y,v),xa.end.fromBufferAttribute(b,v),xa.applyMatrix4(g);const S=new qe,T=new qe;Sl.distanceSqToSegment(xa.start,xa.end,T,S),T.distanceTo(S)<.5*nf&&m.push({point:T,pointOnLine:S,distance:Sl.origin.distanceTo(T),object:f,face:null,faceIndex:v,uv:null,uv1:null})}})(this,n):(function(f,m,g){const x=m.projectionMatrix,y=f.material.resolution,b=f.matrixWorld,v=f.geometry,N=v.attributes.instanceStart,S=v.attributes.instanceEnd,T=Math.min(v.instanceCount,N.count),E=-m.near;Sl.at(1,_l),_l.w=1,_l.applyMatrix4(m.matrixWorldInverse),_l.applyMatrix4(x),_l.multiplyScalar(1/_l.w),_l.x*=y.x/2,_l.y*=y.y/2,_l.z=0,zk.copy(_l),Bk.multiplyMatrices(m.matrixWorldInverse,b);for(let k=0,C=T;k<C;k++){if(pa.fromBufferAttribute(N,k),ga.fromBufferAttribute(S,k),pa.w=1,ga.w=1,pa.applyMatrix4(Bk),ga.applyMatrix4(Bk),pa.z>E&&ga.z>E)continue;if(pa.z>E){const O=pa.z-ga.z,q=(pa.z-E)/O;pa.lerp(ga,q)}else if(ga.z>E){const O=ga.z-pa.z,q=(ga.z-E)/O;ga.lerp(pa,q)}pa.applyMatrix4(x),ga.applyMatrix4(x),pa.multiplyScalar(1/pa.w),ga.multiplyScalar(1/ga.w),pa.x*=y.x/2,pa.y*=y.y/2,ga.x*=y.x/2,ga.y*=y.y/2,xa.start.copy(pa),xa.start.z=0,xa.end.copy(ga),xa.end.z=0;const D=xa.closestPointToPointParameter(zk,!0);xa.at(D,u9);const A=OJ.lerp(pa.z,ga.z,D),R=A>=-1&&A<=1,F=zk.distanceTo(u9)<.5*nf;if(R&&F){xa.start.fromBufferAttribute(N,k),xa.end.fromBufferAttribute(S,k),xa.start.applyMatrix4(b),xa.end.applyMatrix4(b);const O=new qe,q=new qe;Sl.distanceSqToSegment(xa.start,xa.end,q,O),g.push({point:q,pointOnLine:O,distance:Sl.origin.distanceTo(q),object:f,face:null,faceIndex:k,uv:null,uv1:null})}}})(this,i,n)))}}class JBe extends QN{constructor(e,n,r,i,s=4473924,o=8947848){s=new Jt(s),o=new Jt(o);const l=Math.round(e/n);r=Math.round(r/i)*i/2;const c=[],u=[];let d=0;for(let m=-1*(e=l*n/2);m<=e;m+=n){c.push(m,0,-1*r,m,0,r);const g=m===0?s:o;g.toArray(u,d),d+=3,g.toArray(u,d),d+=3,g.toArray(u,d),d+=3,g.toArray(u,d),d+=3}for(let m=-1*r;m<=r;m+=i){c.push(-1*e,0,m,e,0,m);const g=m===0?s:o;g.toArray(u,d),d+=3,g.toArray(u,d),d+=3,g.toArray(u,d),d+=3,g.toArray(u,d),d+=3}const f=new Ba;f.setAttribute("position",new mi(c,3)),f.setAttribute("color",new mi(u,3)),super(f,new zy({vertexColors:!0,toneMapped:!1}))}}function e8e(t,e,n,r){const i=(function(o,l,c){o*=.5,l*=.5,c*=.5;const u=new Ba,d=[];return d.push(-o,-l,-c,-o,l,-c,-o,l,-c,o,l,-c,o,l,-c,o,-l,-c,o,-l,-c,-o,-l,-c,-o,-l,c,-o,l,c,-o,l,c,o,l,c,o,l,c,o,-l,c,o,-l,c,-o,-l,c,-o,-l,-c,-o,-l,c,-o,l,-c,-o,l,c,o,l,-c,o,l,c,o,-l,-c,o,-l,c),u.setAttribute("position",new mi(d,3)),u})(t,e,n),s=new QN(i,new kBe({color:new Jt(r),dashSize:3,gapSize:1}));return s.computeLineDistances(),s}var Kb=function(){var t=0,e=document.createElement("div");function n(d){return e.appendChild(d.dom),d}function r(d){for(var f=0;f<e.children.length;f++)e.children[f].style.display=f===d?"block":"none";t=d}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(d){d.preventDefault(),r(++t%e.children.length)}),!1);var i=(performance||Date).now(),s=i,o=0,l=n(new Kb.Panel("FPS","#0ff","#002")),c=n(new Kb.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new Kb.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:e,addPanel:n,showPanel:r,begin:function(){i=(performance||Date).now()},end:function(){o++;var d=(performance||Date).now();if(c.update(d-i,200),d>=s+1e3&&(l.update(1e3*o/(d-s),100),s=d,o=0,u)){var f=performance.memory;u.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:e,setMode:r}};Kb.Panel=function(t,e,n){var r=1/0,i=0,s=Math.round,o=s(window.devicePixelRatio||1),l=80*o,c=48*o,u=3*o,d=2*o,f=3*o,m=15*o,g=74*o,x=30*o,y=document.createElement("canvas");y.width=l,y.height=c,y.style.cssText="width:80px;height:48px";var b=y.getContext("2d");return b.font="bold "+9*o+"px Helvetica,Arial,sans-serif",b.textBaseline="top",b.fillStyle=n,b.fillRect(0,0,l,c),b.fillStyle=e,b.fillText(t,u,d),b.fillRect(f,m,g,x),b.fillStyle=n,b.globalAlpha=.9,b.fillRect(f,m,g,x),{dom:y,update:function(v,N){r=Math.min(r,v),i=Math.max(i,v),b.fillStyle=n,b.globalAlpha=1,b.fillRect(0,0,l,m),b.fillStyle=e,b.fillText(s(v)+" "+t+" ("+s(r)+"-"+s(i)+")",u,d),b.drawImage(y,f+o,m,g-o,x,f,m,g-o,x),b.fillRect(f+g-o,m,o,x),b.fillStyle=n,b.globalAlpha=.9,b.fillRect(f+g-o,m,o,s((1-v/N)*x))}}};var t8e=Kb;class h9{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new DS,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 DS,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 n8e extends Ba{constructor(e=[new qe],n=.6,r=.2,i=8){super(),this.type="ExtrusionGeometry",this.parameters={points:e,lineWidth:n,lineHeight:r,radialSegments:i,closed:!1};const s=new qe,o=new qe,l=new pn,c=[],u=[],d=[],f=[];function m(g){const[x,y,b]=(function(v){const N=e[v],S=new qe,T=new qe,E=new qe,k=new qe;S.copy(N).sub(e[v-1]||N).normalize().add((e[v+1]||N).clone().sub(N).normalize()).normalize();let C=Number.MAX_VALUE;const D=Math.abs(S.x),A=Math.abs(S.y),R=Math.abs(S.z);return D<=C&&(C=D,T.set(1,0,0)),A<=C&&(C=A,T.set(0,1,0)),R<=C&&T.set(0,0,1),k.crossVectors(S,T).normalize(),T.crossVectors(S,k),E.crossVectors(S,T),[N,T,E]})(g);for(let v=0;v<=i;v++){const N=v/i*Math.PI*2,S=Math.sin(N),T=-Math.cos(N);o.x=T*y.x+S*b.x,o.y=T*y.y+S*b.y,o.z=T*y.z+S*b.z,o.normalize(),u.push(o.x,o.y,o.z),s.x=x.x+n*o.x*.5,s.y=x.y+n*o.y*.5,s.z=x.z+r*o.z*.5,c.push(s.x,s.y,s.z)}}(function(){for(let g=0;g<e.length;g++)m(g);m(closed===!1?e.length-1:0),(function(){for(let g=0;g<e.length;g++)for(let x=0;x<=i;x++)l.x=g/e.length,l.y=x/i,d.push(l.x,l.y)})(),(function(){for(let g=1;g<e.length;g++)for(let x=1;x<=i;x++){const y=(i+1)*(g-1)+(x-1),b=(i+1)*g+(x-1),v=(i+1)*g+x,N=(i+1)*(g-1)+x;f.push(y,b,N),f.push(b,v,N)}})()})(),this.setIndex(f),this.setAttribute("position",new mi(c,3)),this.setAttribute("normal",new mi(u,3)),this.setAttribute("uv",new mi(d,2))}}class Xb{static get initial(){const e=new Xb;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const $k={h:0,s:0,l:0};class rg{constructor(e){var n,r,i,s,o,l,c,u,d;if(this.minLayerThreshold=.05,this.renderExtrusion=!0,this.renderTravel=!1,this.renderTubes=!1,this.extrusionWidth=.6,this.singleLayerMode=!1,this.initialCameraPosition=[-100,400,450],this.debug=!1,this.inches=!1,this.nonTravelmoves=[],this.disableGradient=!1,this.state=Xb.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=rg.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new Jt(14737632),this._travelColor=new Jt(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 OS(this.minLayerThreshold),this.scene=new bBe,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new Jt(e.backgroundColor)),this.targetId=e.targetId,this.endLayer=e.endLayer,this.startLayer=e.startLayer,this.lineWidth=e.lineWidth,this.lineHeight=e.lineHeight,this.buildVolume=e.buildVolume,this.initialCameraPosition=(r=e.initialCameraPosition)!==null&&r!==void 0?r:this.initialCameraPosition,this.debug=(i=e.debug)!==null&&i!==void 0?i:this.debug,this.renderExtrusion=(s=e.renderExtrusion)!==null&&s!==void 0?s:this.renderExtrusion,this.renderTravel=(o=e.renderTravel)!==null&&o!==void 0?o:this.renderTravel,this.nonTravelmoves=(l=e.nonTravelMoves)!==null&&l!==void 0?l:this.nonTravelmoves,this.renderTubes=(c=e.renderTubes)!==null&&c!==void 0?c:this.renderTubes,this.extrusionWidth=(u=e.extrusionWidth)!==null&&u!==void 0?u:this.extrusionWidth,this.devMode=(d=e.devMode)!==null&&d!==void 0?d:this.devMode,this.stats=this.devMode?new t8e:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new Jt(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new Jt(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new Jt(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[g,x]of Object.entries(e.toolColors))this._toolColors[parseInt(g)]=new Jt(x)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+qN),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 iR({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const g=document.getElementById(this.targetId);if(!g)throw new Error("Unable to find element "+this.targetId);this.renderer=new iR({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,g.appendChild(this.canvas)}this.camera=new $s(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const f=this.camera.far,m=.8*f;this.scene.fog=new qO(this._backgroundColor,m,f),this.resize(),this.controls=new QBe(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 Jt(r)}else this._extrusionColor=new Jt(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?rg.defaultExtrusionColor:this._extrusionColor instanceof Jt?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:rg.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new Jt(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new Jt(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new Jt(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new Jt(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 IBe(Math.max(this.buildVolume.x/2,this.buildVolume.y/2)+20);this.scene.add(e)}if(this.buildVolume&&this.drawBuildVolume(),this.renderTubes){console.warn("Volumetric rendering is experimental. It may not work as expected or change in the future.");const e=new DBe(13421772,.3*Math.PI),n=new RBe(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 Db;return n.name=e,n.quaternion.setFromEuler(new Fy(-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=Xb.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 Fk(this,void 0,void 0,(function*(){return this.initScene(),this.renderLayerIndex=0,this.renderFrameLoop(e>0?e:1)}))}renderFrameLoop(e){return new Promise((n=>{const r=()=>{this.renderLayerIndex>this.layers.length-1?n():(this.renderFrame(e),requestAnimationFrame(r))};r()}))}renderFrame(e){this.group=this.createGroup("layer"+this.renderLayerIndex);for(let n=0;n<e&&this.renderLayerIndex+n<this.layers.length;n++)this.renderLayer(this.renderLayerIndex),this.renderLayerIndex++;this.batchGeometries(),this.scene.add(this.group)}renderLayer(e){var n,r,i,s,o,l,c,u;if(e>this.maxLayerIndex)return;const d=this.layers[e],f={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const m of d.commands)if(m.gcode!="g20"){if(m.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const g=m;this.state.t=g.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(m.gcode)>-1){const g=m,x={x:(n=g.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=g.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=g.params.z)!==null&&i!==void 0?i:this.state.z,r:(s=g.params.r)!==null&&s!==void 0?s:this.state.r,e:(o=g.params.e)!==null&&o!==void 0?o:this.state.e,i:(l=g.params.i)!==null&&l!==void 0?l:this.state.i,j:(c=g.params.j)!==null&&c!==void 0?c:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const y=((u=g.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(m.gcode)>-1;(x.x!=this.state.x||x.y!=this.state.y||x.z!=this.state.z)&&(y&&this.renderExtrusion||!y&&this.renderTravel)&&(m.gcode=="g2"||m.gcode=="g3"||m.gcode=="g02"||m.gcode=="g03"?this.addArcSegment(f,this.state,x,y,m.gcode=="g2"||m.gcode=="g02"):this.addLineSegment(f,this.state,x,y))}this.state.x=x.x,this.state.y=x.y,this.state.z=x.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(f,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let s=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const o=.1+.7*n/this.layers.length;s.getHSL($k),s=new Jt().setHSL($k.h,$k.s,o)}if(n==this.layers.length-1){const o=(r=this._topLayerColor)!==null&&r!==void 0?r:s,l=(i=this._lastSegmentColor)!==null&&i!==void 0?i:o,c=e.extrusion.splice(-3),u=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,o.getHex(),e.height),this.addTubeLine([...u,...c],l.getHex(),e.height)):(this.addLine(e.extrusion,o.getHex()),this.addLine([...u,...c],l.getHex()))}else this.renderTubes?this.addTubeLine(e.extrusion,s.getHex(),e.height):this.addLine(e.extrusion,s.getHex())}this.renderTravel&&this.addLine(e.travel,this._travelColor.getHex())}setInches(){this.beyondFirstMove?console.warn("Switching units after movement is already made is discouraged and is not supported."):this.inches=!0}drawBuildVolume(){if(!this.buildVolume)return;this.scene.add(new JBe(this.buildVolume.x,10,this.buildVolume.y,10));const e=e8e(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 OS(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=Xb.initial,(e=this.devGui)===null||e===void 0||e.reset(),this._geometries={}}resize(){const[e,n]=[this.canvas.offsetWidth,this.canvas.offsetHeight];this.camera.aspect=e/n,this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,n,!1)}addLineSegment(e,n,r,i){(i?e.extrusion:e.travel).push(n.x,n.y,n.z,r.x,r.y,r.z)}addArcSegment(e,n,r,i,s){const o=i?e.extrusion:e.travel,l=n.x,c=n.y,u=n.z,d=r.x,f=r.y,m=r.z;let g=r.r,x=r.i,y=r.j;if(g){const G=d-l,Y=f-c,K=Math.sqrt(Math.pow(G/2,2)+Math.pow(Y/2,2));g=Math.max(g,K);const Z=Math.pow(G,2)+Math.pow(Y,2),te=Math.pow(g,2)-Z/4;let ne=Math.sqrt(te/Z);(s&&g<0||!s&&g>0)&&(ne=-ne),x=G/2+Y*ne,y=Y/2-G*ne}const b=l==d&&c==f,v=l+x,N=c+y,S=Math.sqrt(x*x+y*y),T=Math.atan2(-y,-x),E=Math.atan2(f-N,d-v);let k;b?k=2*Math.PI:(k=s?T-E:E-T,k<0&&(k+=2*Math.PI));let C=S*k/1.8;this.inches&&(C*=25),C<1&&(C=1);let D=k/C;D*=s?-1:1;const A=[];A.push({x:l,y:c,z:u});const R=(u-m)/C;let F=l,O=c,q=u,j=T;for(let G=0;G<C-1;G++)j+=D,F=v+S*Math.cos(j),O=N+S*Math.sin(j),q+=R,A.push({x:F,y:O,z:q});A.push({x:r.x,y:r.y,z:r.z});for(let G=0;G<A.length-1;G++)o.push(A[G].x,A[G].y,A[G].z,A[G+1].x,A[G+1].y,A[G+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new Ba;i.setAttribute("position",new mi(e,3)),this.disposables.push(i);const s=new zy({color:n});this.disposables.push(s);const o=new QN(i,s);(r=this.group)===null||r===void 0||r.add(o)}addTubeLine(e,n,r=.2){let i=[];const s=[];for(let o=0;o<e.length;o+=6){const l=e.slice(o,o+9),c=new qe(l[0],l[1],l[2]),u=new qe(l[3],l[4],l[5]),d=new qe(l[6],l[7],l[8]);i.push(c),u.equals(d)||(i.push(u),s.push(i),i=[])}s.forEach((o=>{var l;const c=new n8e(o,this.extrusionWidth,this.lineHeight||r,4);(l=this._geometries)[n]||(l[n]=[]),this._geometries[n].push(c)}))}addThickLine(e,n){var r;if(!e.length||!this.lineWidth)return;const i=new ree;this.disposables.push(i);const s=new nee({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(s),i.setPositions(e);const o=new ZBe(i,s);(r=this.group)===null||r===void 0||r.add(o)}dispose(){this.disposables.forEach((e=>e.dispose())),this.disposables=[],this.controls.dispose(),this.renderer.dispose(),this.cancelAnimation()}cancelAnimation(){this.animationFrameId!==void 0&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0}_enableDropHandler(){console.warn("Drag and drop is deprecated as a library feature. See the demo how to implement your own."),this.canvas.addEventListener("dragover",(e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),this.canvas.classList.add("dragging")})),this.canvas.addEventListener("dragleave",(e=>{e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove("dragging")})),this.canvas.addEventListener("drop",(e=>Fk(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 ABe({color:e,wireframe:this._wireframe});this.disposables.push(i);const s=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new EBe(r.length,s,void 0,i);return this.disposables.push(o),(n=this.group)===null||n===void 0||n.add(o),o}_readFromStream(e){var n,r;return Fk(this,void 0,void 0,(function*(){const i=e.getReader();let s,o="",l=0;do{console.debug("reading from stream"),s=yield i.read(),l+=(r=(n=s.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const u=(c=s.value,new TextDecoder("utf-8").decode(c)),d=u.lastIndexOf(`
- `),f=u.slice(0,d);this.parser.parseGCode(o+f),o=u.slice(d)}while(!s.done);var c;console.debug("read from stream",l)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new h9(this):typeof this.devMode=="object"&&(this.devGui=new h9(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())}}rg.defaultExtrusionColor=new Jt("hotpink");function r8e({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=w.useRef(null),s=w.useRef(null),o=w.useRef(null),l=w.useRef(!1),[c,u]=w.useState(!0),[d,f]=w.useState(null),[m,g]=w.useState(!1),[x,y]=w.useState(0),[b,v]=w.useState(0),N=w.useMemo(()=>JSON.stringify(n),[n]);w.useEffect(()=>{if(!i.current||l.current)return;l.current=!0;const E=i.current,k=E.parentElement?.getBoundingClientRect();k&&(E.width=k.width,E.height=k.height);const C=n&&n.length>1,D=n?.[0]||"#00ae42",A=new rg({canvas:E,buildVolume:e,backgroundColor:1710618,extrusionColor:C?n:D,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});s.current=A,fetch(t).then(async F=>{if(!F.ok)throw F.status===404&&(await F.json().catch(()=>({}))).detail?.includes("sliced")?(g(!0),new Error("not_sliced")):new Error("Failed to load G-code");return F.text()}).then(F=>{const O=new Set,q=/^(\s*)T(\d+)(\s*;.*)?$/gim;let j;for(;(j=q.exec(F))!==null;){const ne=parseInt(j[2],10);ne<=15&&O.add(ne)}const G=new Map,Y=Array.from(O).sort((ne,z)=>ne-z);Y.forEach((ne,z)=>{G.set(ne,z%8)});const K=[];Y.forEach((ne,z)=>{const W=n?.[ne]||"#00ae42";K[z%8]=W});const Z=F.split(`
- `).map(ne=>{const z=ne.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(z){const W=parseInt(z[2],10);if(W>15)return`; FILTERED: ${ne.trim()}`;const se=G.get(W)??0;return`${z[1]}T${se}${z[3]||""}`}return ne}).join(`
- `);K.length>0&&(A.extrusionColor=K),A.processGCode(Z);const te=A.layers?.length||0;v(te),y(te),A.render(),u(!1)}).catch(F=>{F.message!=="not_sliced"&&f(F.message),u(!1)});const R=()=>{if(E.parentElement&&s.current){const F=E.parentElement.getBoundingClientRect();E.width=F.width,E.height=F.height,s.current.resize()}};return window.addEventListener("resize",R),()=>{window.removeEventListener("resize",R),o.current&&cancelAnimationFrame(o.current),s.current&&(s.current.dispose(),s.current=null),l.current=!1}},[t,N]);const S=w.useCallback(E=>{if(!s.current)return;const k=Math.max(1,Math.min(E,b));y(k),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{s.current&&(s.current.endLayer=k,s.current.render())})},[b]),T=E=>{S(parseInt(E.target.value,10))};return a.jsxs("div",{className:`relative flex flex-col h-full ${r}`,children:[a.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsx("canvas",{ref:i,className:"w-full h-full"}),c&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsxs("div",{className:"text-center",children:[a.jsx(ut,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),a.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),m&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsxs("div",{className:"text-center max-w-sm px-4",children:[a.jsx(Eue,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),a.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),a.jsx("p",{className:"text-bambu-gray text-sm",children:"This file hasn't been sliced yet. G-code preview is only available after slicing in Bambu Studio or Orca Slicer."})]})}),d&&!m&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsx("div",{className:"text-center text-red-400",children:a.jsx("p",{className:"text-sm",children:d})})})]}),!c&&!d&&!m&&b>0&&a.jsx("div",{className:"mt-4 px-2",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ul,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("button",{onClick:()=>S(x-1),disabled:x<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:a.jsx(Vd,{className:"w-4 h-4"})}),a.jsx("input",{type:"range",min:1,max:b,value:x,onChange:T,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),a.jsx("button",{onClick:()=>S(x+1),disabled:x>=b,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:a.jsx(Ms,{className:"w-4 h-4"})}),a.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[x," / ",b]})]})})]})}function iee({archiveId:t,title:e,onClose:n}){const[r,i]=w.useState(null),[s,o]=w.useState(null),[l,c]=w.useState(!0);w.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),w.useEffect(()=>{he.getArchiveCapabilities(t).then(d=>{o(d),d.has_model?i("3d"):d.has_gcode&&i("gcode"),c(!1)}).catch(()=>{o({has_model:!0,has_gcode:!1,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),i("3d"),c(!1)})},[t]);const u=()=>{const d=e||"model",f=`${window.location.origin}${he.getArchiveForSlicer(t,d)}`;$c(f)};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col",onClick:d=>d.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Te,{variant:"secondary",size:"sm",onClick:u,children:[a.jsx($r,{className:"w-4 h-4"}),"Open in Slicer"]}),a.jsx(Te,{variant:"ghost",size:"sm",onClick:n,children:a.jsx(Ot,{className:"w-5 h-5"})})]})]}),s&&a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[a.jsxs("button",{onClick:()=>s.has_model&&i("3d"),disabled:!s.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":s.has_model?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(Hs,{className:"w-4 h-4"}),"3D Model",!s.has_model&&a.jsx("span",{className:"text-xs",children:"(not available)"})]}),a.jsxs("button",{onClick:()=>s.has_gcode&&i("gcode"),disabled:!s.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":s.has_gcode?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(eue,{className:"w-4 h-4"}),"G-code Preview",!s.has_gcode&&a.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),a.jsx("div",{className:"flex-1 overflow-hidden p-4",children:l?a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:a.jsx(ut,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&s?a.jsx(eLe,{url:s.has_source?he.getSource3mfDownloadUrl(t):he.getArchiveDownload(t),buildVolume:s.build_volume,filamentColors:s.filament_colors,className:"w-full h-full"}):r==="gcode"&&s?a.jsx(r8e,{gcodeUrl:he.getArchiveGcode(t),filamentColors:s.filament_colors,className:"w-full h-full"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}const f9={"000000":"Black","001489":"Blue","002e96":"Blue","0047bb":"Blue","00482b":"Pine Green","004ea8":"Blue","0056b8":"Cobalt Blue","0069b1":"Lake Blue","0072ce":"Blue","0078bf":"Marine Blue","0085ad":"Light Blue","0086d6":"Cyan","008bda":"Blue","009639":"Green","009bd8":"Cyan","009fa1":"Teal","00a6a0":"Green","00ae42":"Bambu Green","00b1b7":"Turquoise","00bb31":"Green","018814":"Candy Green","042f56":"Dark Blue","0a2989":"Blue","0a2ca5":"Blue","0c2340":"Navy Blue","0c3b95":"Blue",101820:"Black","147bd1":"Blue","164b35":"Green","16b08e":"Malachite Green","1d7c6a":"Oxide Green Metallic","1f79e5":"Lake Blue","2140b4":"Blue","25282a":"Black","2842ad":"Royal Blue","2d2b28":"Onyx Black Sparkle",324585:"Indigo Blue",353533:"Gray","39541a":"Forest Green","39699e":"Cobalt Blue Metallic","3b665e":"Green","3f5443":"Alpine Green Sparkle","3f8e43":"Mistletoe Green",424379:"Nebulae","43403d":"Iron Gray Metallic",482960:"Indigo Purple","483d8b":"Royal Purple Sparkle","489fdf":"Azure","4c241c":"Rosewood","4ce4a0":"Green","4d3324":"Dark Chocolate","4d5054":"Lava Gray","4dafda":"Cyan","4f3f24":"Black Walnut",515151:"Dark Gray","515a6c":"Gray",545454:"Dark Gray",565656:"Titan Gray","56b7e6":"Sky Blue",583061:"Violet Purple","5898dd":"Blue",594177:"Purple","5b492f":"Brown","5b6579":"Blue Gray","5c9748":"Matcha Green","5e43b7":"Purple","5e4b3c":"Copper","5f6367":"Titan Gray","61b0ff":"Translucent Light Blue","61bf36":"Green","61c680":"Grass Green","6667ab":"Lavender Blue","684a43":"Brown",686865:"Black","68724d":"Dark Green",688197:"Blue Gray","69398e":"Iris Purple","6e88bc":"Jeans Blue","6ee53c":"Lime Green","6f5034":"Cocoa Brown","7248bd":"Lavender","748c45":"Translucent Olive",757575:"Nardo Gray","75aed8":"Blue","77edd7":"Translucent Teal","789d4a":"Olive","792b36":"Crimson Red Sparkle","7ac0e9":"Glow Blue","7ae1bf":"Mint","7cd82b":"Lime Green","7d6556":"Dark Brown","8344b0":"Purple","847d48":"Bronze","854ce4":"Purple","8671cb":"Purple",875718:"Peanut Brown","87909a":"Silver","898d8d":"Gray","8a949e":"Gray","8e8e8e":"Translucent Gray","8e9089":"Gray","90ff1a":"Neon Green",918669:"Classic Birch",939393:"Gray",950051:"Plum","951e23":"Burgundy Red",959698:"Silver","96d8af":"Light Jade","96dcb9":"Mint","995f11":"Clay Brown","999d9d":"Gray","9b9ea0":"Ash Gray","9d2235":"Maroon Red","9d432c":"Brown","9e007e":"Purple","9ea2a2":"Gray","9f332a":"Brick Red",a1ffac:"Glow Green",a3d8e1:"Ice Blue",a6a9aa:"Silver",a8a8aa:"Gray",a8c6ee:"Baby Blue",aa6443:"Copper Brown Metallic",ad4e38:"Red Granite",adb1b2:"Gray",ae835b:"Caramel",ae96d4:"Lilac Purple",af1685:"Purple",afb1ae:"Gray",b15533:"Terracotta",b28b33:"Gold",b39b84:"Iridium Gold Metallic",b50011:"Red",b8acd6:"Lavender",b8cde9:"Ice Blue",ba9594:"Rose Gold",bb3d43:"Dark Red",bc0900:"Red",becf00:"Bright Green",c0df16:"Green",c12e1f:"Red",c2e189:"Apple Green",c3e2d6:"Light Cyan",c5ed48:"Lime",c6001a:"Red",c6c6c6:"Gray",c8102e:"Red",c8c8c8:"Silver",c98935:"Ochre Yellow",c9a381:"Translucent Brown",cbc6b8:"Bone White",cdceca:"Gray",cea629:"Classic Gold Sparkle",d02727:"Candy Red",d1d3d5:"Light Gray",d32941:"Red",d3b7a7:"Latte Brown",d6001c:"Red",d6abff:"Translucent Purple",d6cca3:"White Oak",dc3a27:"Orange",dd3c22:"Vermilion Red",de4343:"Scarlet Red",dfd1a7:"Beige",e02928:"Red",e4bd68:"Gold",e5b03d:"Gold",e83100:"Red",e8afcf:"Sakura Pink",e8dbb7:"Desert Tan",eaeae4:"White",eaeceb:"Silver",ec008c:"Magenta",ed0000:"Red",eeb1c1:"Pink",efe255:"Yellow",f0f1a8:"Clear",f17b8f:"Glow Pink",f3cfb2:"Champagne",f3e600:"Yellow",f48438:"Orange",f4a925:"Gold",f4d53f:"Yellow",f4ee2a:"Yellow",f5547c:"Hot Pink",f55a74:"Pink",f5b6cd:"Cherry Pink",f5dbab:"Mellow Yellow",f5f1dd:"White",f68b1b:"Neon Orange",f74e02:"Orange",f75403:"Orange",f7ada6:"Pink",f7d959:"Lemon Yellow",f7e6de:"Beige",f7f3f0:"White Marble",f8ff80:"Glow Yellow",f99963:"Mandarin Orange",f9c1bd:"Translucent Pink",f9dfb9:"Cream",f9ef41:"Yellow",f9f7f2:"Nature",f9f7f4:"White",fce300:"Yellow",fce900:"Yellow",fec600:"Sunflower Yellow",fedb00:"Yellow",ff4800:"Orange",ff671f:"Orange",ff6a13:"Orange",ff7f41:"Orange",ff9016:"Pumpkin Orange",ff911a:"Translucent Orange",ff9d5b:"Glow Orange",ffb549:"Sunflower Yellow",ffc72c:"Tangerine Yellow",ffce00:"Yellow",ffd00b:"Yellow",ffe133:"Yellow",fffaf2:"White",ffffff:"White"};function i8e(t){if(!t||t.length<6)return"Unknown";const e=t.replace("#",""),n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16),s=Math.max(n,r,i)/255,o=Math.min(n,r,i)/255,l=(s+o)/2;let c=0,u=0;if(s!==o){const d=s-o;u=l>.5?d/(2-s-o):d/(s+o);const f=n/255,m=r/255,g=i/255;s===f?c=((m-g)/d+(m<g?6:0))/6:s===m?c=((g-f)/d+2)/6:c=((f-m)/d+4)/6}return c=c*360,l<.15?"Black":l>.85?"White":u<.15?l<.4?"Dark Gray":l>.6?"Light Gray":"Gray":c<15||c>=345?"Red":c<45?"Orange":c<70?"Yellow":c<150?"Green":c<200?"Cyan":c<260?"Blue":c<290?"Purple":c<345?"Pink":"Unknown"}function Cg(t){const e=t.replace("#","").toLowerCase().substring(0,6);return f9[e]?f9[e]:i8e(t)}function LS(t){return t?`#${t.replace("#","").substring(0,6)}`:"#808080"}function ia(t){return t?t.replace("#","").toLowerCase().substring(0,6):""}function ih(t,e,n=40){const r=ia(t),i=ia(e);if(!r||!i||r.length<6||i.length<6)return!1;const s=parseInt(r.substring(0,2),16),o=parseInt(r.substring(2,4),16),l=parseInt(r.substring(4,6),16),c=parseInt(i.substring(0,2),16),u=parseInt(i.substring(2,4),16),d=parseInt(i.substring(4,6),16);return Math.abs(s-c)<=n&&Math.abs(o-u)<=n&&Math.abs(l-d)<=n}function aee(t,e,n,r){const i=String.fromCharCode(65+(t>=128?t-128:t));return n?`HT-${i}`:`AMS-${i} Slot ${e+1}`}function see(t,e,n){return t*4+e}function a8e(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 s8e(){const t=new Date;return t.setMinutes(t.getMinutes()+1),t.toISOString().slice(0,16)}function m9(t){if(!t)return!1;const e=Date.now()+4320*60*60*1e3;return new Date(t).getTime()>e}function XO(t){const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const s=LS(i.tray_color);e.push({type:i.tray_type,color:s,colorName:Cg(s),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:aee(n.id,i.id,r),globalTrayId:see(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=LS(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:Cg(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e}function p9(t,e){if(!t?.filaments||t.filaments.length===0)return;const n=XO(e);if(n.length===0)return;const r=new Set,i=t.filaments.map(l=>{const c=n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()&&ia(m.color)===ia(l.color)),u=!c&&n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()&&ih(m.color,l.color)),d=!c&&!u&&n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()),f=c||u||d||void 0;return f&&r.add(f.globalTrayId),{slot_id:l.slot_id,globalTrayId:f?.globalTrayId??-1}}),s=Math.max(...i.map(l=>l.slot_id||0));if(s<=0)return;const o=new Array(s).fill(-1);return i.forEach(l=>{l.slot_id&&l.slot_id>0&&(o[l.slot_id-1]=l.globalTrayId)}),o}function o8e(t){return w.useMemo(()=>{const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const s=LS(i.tray_color);e.push({type:i.tray_type,color:s,colorName:Cg(s),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:aee(n.id,i.id,r),globalTrayId:see(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=LS(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:Cg(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e},[t])}function oee(t,e,n){const r=o8e(e),i=w.useMemo(()=>{if(!t?.filaments||t.filaments.length===0)return[];const c=new Set(Object.values(n));return t.filaments.map(u=>{const d=u.slot_id||0;if(d>0&&n[d]!==void 0){const S=n[d],T=r.find(E=>E.globalTrayId===S);if(T){const E=T.type?.toUpperCase()===u.type?.toUpperCase(),k=ia(T.color)===ia(u.color)||ih(T.color,u.color);let C;return E&&k?C="match":E?C="type_only":C="mismatch",{...u,loaded:T,hasFilament:!0,typeMatch:E,colorMatch:k,status:C,isManual:!0}}}const f=r.find(S=>!c.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase()&&ia(S.color)===ia(u.color)),m=!f&&r.find(S=>!c.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase()&&ih(S.color,u.color)),g=!f&&!m&&r.find(S=>!c.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase()),x=f||m||g||void 0;x&&c.add(x.globalTrayId);const y=!!x,b=y,v=!!f||!!m;let N;return f||m?N="match":g?N="type_only":N="mismatch",{...u,loaded:x,hasFilament:y,typeMatch:b,colorMatch:v,status:N,isManual:!1}})},[t,r,n]),s=w.useMemo(()=>{if(i.length===0)return;const c=Math.max(...i.map(d=>d.slot_id||0));if(c<=0)return;const u=new Array(c).fill(-1);return i.forEach(d=>{d.slot_id&&d.slot_id>0&&(u[d.slot_id-1]=d.loaded?.globalTrayId??-1)}),u},[i]),o=i.some(c=>c.status==="mismatch"),l=i.some(c=>c.status==="type_only");return{loadedFilaments:r,filamentComparison:i,amsMapping:s,hasTypeMismatch:o,hasColorMismatch:l}}function l8e(t,e,n){if(!t||t.length===0)return{exactMatches:0,typeOnlyMatches:0,missingTypes:0,totalSlots:0,status:"full"};let r=0,i=0,s=0;const o=new Set(Object.values(n));for(const u of t){const d=u.slot_id||0;if(d>0&&n[d]!==void 0){const y=n[d],b=e.find(v=>v.globalTrayId===y);if(b){const v=b.type?.toUpperCase()===u.type?.toUpperCase(),N=ia(b.color)===ia(u.color)||ih(b.color,u.color);v&&N?r++:v?i++:s++;continue}}const f=e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()&&ia(y.color)===ia(u.color)),m=f?void 0:e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()&&ih(y.color,u.color)),g=f||m?void 0:e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()),x=f??m??g;x&&o.add(x.globalTrayId),f||m?r++:g?i++:s++}const l=t.length;let c="full";return s>0?c="missing":i>0&&(c="partial"),{exactMatches:r,typeOnlyMatches:i,missingTypes:s,totalSlots:l,status:c}}function c8e(t,e,n){if(!t?.filaments||t.filaments.length===0)return;const r=XO(e);if(r.length===0)return;const i=new Set(Object.values(n)),s=[];for(const c of t.filaments){const u=c.slot_id||0;if(u>0&&n[u]!==void 0){s.push({slot_id:u,globalTrayId:n[u]});continue}const d=r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()&&ia(x.color)===ia(c.color)),f=d?void 0:r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()&&ih(x.color,c.color)),m=d||f?void 0:r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()),g=d??f??m;g&&i.add(g.globalTrayId),s.push({slot_id:u,globalTrayId:g?.globalTrayId??-1})}const o=Math.max(...s.map(c=>c.slot_id||0));if(o<=0)return;const l=new Array(o).fill(-1);return s.forEach(c=>{c.slot_id&&c.slot_id>0&&(l[c.slot_id-1]=c.globalTrayId)}),l}const g9={useDefault:!0,manualMappings:{},autoConfigured:!1};function u8e(t,e,n,r,i,s){const o=eW({queries:t.map(x=>({queryKey:["printer-status",x],queryFn:()=>he.getPrinterStatus(x),enabled:t.length>0,staleTime:5e3}))}),l=w.useMemo(()=>t.map((x,y)=>{const b=o[y],v=b?.data,S=e?.find(R=>R.id===x)?.name||`Printer ${x}`,T=XO(v),E=i[x]||g9,k=p9(n,v),C=E.useDefault?r:E.manualMappings,D=c8e(n,v,C),A=l8e(n?.filaments,T,C);return{printerId:x,printerName:S,status:v,isLoading:b?.isLoading??!1,loadedFilaments:T,autoMapping:k,finalMapping:D,matchStatus:A.status,exactMatches:A.exactMatches,typeOnlyMatches:A.typeOnlyMatches,missingTypes:A.missingTypes,totalSlots:A.totalSlots,config:E}}),[t,o,e,n,i,r]),c=o.some(x=>x.isLoading),u=(x,y)=>{s(b=>({...b,[x]:{...b[x]||g9,...y}}))},d=x=>{const y=l.find(N=>N.printerId===x);if(!y||!y.status||!n?.filaments)return;const b=p9(n,y.status);if(!b)return;const v={};b.forEach((N,S)=>{N!==-1&&(v[S+1]=N)}),u(x,{useDefault:!1,manualMappings:v,autoConfigured:!0})},f=()=>{for(const x of t)d(x)},m=x=>l.find(b=>b.printerId===x)?.finalMapping,g=l.every(x=>x.matchStatus!=="missing");return{printerResults:l,isLoading:c,perPrinterConfigs:i,updatePrinterConfig:u,autoConfigureAll:f,autoConfigurePrinter:d,getFinalMapping:m,allPrintersReady:g}}function d8e({printerResult:t,filamentReqs:e,onUpdateConfig:n}){const r=an(),[i,s]=w.useState(!1),o=(u,d)=>{if(u<=0)return;const f={...t.config.manualMappings};d===""?delete f[u]:f[u]=parseInt(d,10),n({useDefault:!1,manualMappings:f,autoConfigured:!1})},l=async()=>{s(!0);try{await he.refreshPrinterStatus(t.printerId),await new Promise(u=>setTimeout(u,500)),await r.refetchQueries({queryKey:["printer-status",t.printerId]})}finally{s(!1)}},c=e.map(u=>{const d=u.slot_id||0,f=t.config.manualMappings[d];let m,g=!1;if(f!==void 0)m=t.loadedFilaments.find(y=>y.globalTrayId===f),g=!0;else{const y=new Set(Object.values(t.config.manualMappings)),b=t.loadedFilaments.find(S=>!y.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase()&&ia(S.color)===ia(u.color)),v=b?void 0:t.loadedFilaments.find(S=>!y.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase()&&ih(S.color,u.color)),N=b||v?void 0:t.loadedFilaments.find(S=>!y.has(S.globalTrayId)&&S.type?.toUpperCase()===u.type?.toUpperCase());m=b??v??N}let x="mismatch";if(m){const y=m.type?.toUpperCase()===u.type?.toUpperCase(),b=ia(m.color)===ia(u.color)||ih(m.color,u.color);y&&b?x="match":y&&(x="type_only")}return{req:u,loaded:m,status:x,isManual:g}});return a.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom slot mapping"}),a.jsxs("button",{type:"button",onClick:l,className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",disabled:i,children:[a.jsx(vr,{className:`w-3 h-3 ${i?"animate-spin":""}`}),a.jsx("span",{children:"Re-read"})]})]}),c.map(({req:u,loaded:d,status:f,isManual:m},g)=>a.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[a.jsx("span",{title:`Required: ${u.type} - ${Cg(u.color)}`,children:a.jsx(Vj,{className:"w-3 h-3",fill:u.color,stroke:u.color})}),a.jsxs("span",{className:"text-white truncate",children:[u.type," ",a.jsxs("span",{className:"text-bambu-gray",children:["(",u.used_grams,"g)"]})]}),a.jsx("span",{className:"text-bambu-gray",children:"→"}),a.jsxs("select",{value:d?.globalTrayId??"",onChange:x=>o(u.slot_id||0,x.target.value),className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${f==="match"?"border-bambu-green/50 text-bambu-green":f==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${m?"ring-1 ring-blue-400/50":""}`,title:m?"Manually selected":"Auto-matched",children:[a.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),t.loadedFilaments.map(x=>a.jsxs("option",{value:x.globalTrayId,className:"bg-bambu-dark text-white",children:[x.label,": ",x.type," (",x.colorName,")"]},x.globalTrayId))]}),f==="match"?a.jsx(Ua,{className:"w-3 h-3 text-bambu-green"}):f==="type_only"?a.jsx("span",{title:"Same type, different color",children:a.jsx(xn,{className:"w-3 h-3 text-yellow-400"})}):a.jsx("span",{title:"Filament type not loaded",children:a.jsx(xn,{className:"w-3 h-3 text-orange-400"})})]},g))]})}function h8e({printers:t,selectedPrinterIds:e,onMultiSelect:n,isLoading:r=!1,allowMultiple:i=!1,showInactive:s=!1,printerMappingResults:o,filamentReqs:l,onAutoConfigurePrinter:c,onUpdatePrinterConfig:u,assignmentMode:d="printer",onAssignmentModeChange:f,targetModel:m,onTargetModelChange:g,slicedForModel:x}){const[y,b]=w.useState(!1),v=s?t:t.filter(j=>j.is_active),N=w.useMemo(()=>{if(d!=="printer"||!x||y)return v;const j=v.filter(G=>G.model===x);return j.length>0?j:v},[v,d,x,y]),S=v.length-N.length,T=w.useMemo(()=>{const j=v.map(G=>G.model).filter(G=>!!G);return[...new Set(j)].sort()},[v]),E=f&&g&&T.length>0,k=i&&e.length>1&&o&&l?.filaments&&l.filaments.length>0&&c&&u;if(r)return a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(ut,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(N.length===0)return a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm mb-4",children:[a.jsx(Ei,{className:"w-4 h-4"}),"No ",s?"":"active ","printers available"]});const C=j=>{i?e.includes(j)?n(e.filter(G=>G!==j)):n([...e,j]):n([j])},D=()=>{n(N.map(j=>j.id))},A=()=>{n([])},R=(j,G,Y)=>{Y.stopPropagation(),!(!c||!u)&&(G?c(j):u(j,{useDefault:!0,manualMappings:{},autoConfigured:!1}))},F=j=>e.includes(j),O=e.length,q=j=>o?.find(G=>G.printerId===j);return a.jsxs("div",{className:"space-y-2 mb-6",children:[E&&a.jsxs("div",{className:"flex gap-2 mb-4",children:[a.jsxs("button",{type:"button",onClick:()=>{f("printer"),g(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${d==="printer"?"border-bambu-green bg-bambu-green/10 text-white":"border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray hover:border-bambu-gray"}`,children:[a.jsx(Ar,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:"Specific Printer"})]}),a.jsxs("button",{type:"button",onClick:()=>{f("model"),n([]);const j=x&&T.includes(x)?x:T[0];g(j)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${d==="model"?"border-bambu-green bg-bambu-green/10 text-white":"border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray hover:border-bambu-gray"}`,children:[a.jsx(Nd,{className:"w-4 h-4"}),a.jsxs("span",{className:"text-sm",children:["Any ",x||"Model"]})]})]}),d==="model"&&E&&m&&a.jsxs("p",{className:"text-xs text-bambu-gray mb-4",children:["Scheduler will assign to first available idle ",m," printer"]}),d==="printer"&&i&&N.length>1&&a.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray mb-2",children:[a.jsx("span",{children:O===0?"Select printers":`${O} printer${O!==1?"s":""} selected`}),a.jsxs("div",{className:"flex gap-2",children:[O<N.length&&a.jsx("button",{type:"button",onClick:D,className:"text-bambu-green hover:text-bambu-green/80 transition-colors",children:"Select all"}),O>0&&a.jsx("button",{type:"button",onClick:A,className:"text-bambu-gray hover:text-white transition-colors",children:"Clear"})]})]}),d==="printer"&&N.map(j=>{const G=F(j.id),Y=q(j.id),K=Y&&!Y.config.useDefault;return a.jsxs("div",{children:[a.jsxs("button",{type:"button",onClick:()=>C(j.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${G?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"} ${j.is_active?"":"opacity-60"}`,children:[a.jsx("div",{className:`p-2 rounded-lg ${G?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:a.jsx(Ar,{className:`w-5 h-5 ${G?"text-bambu-green":"text-bambu-gray"}`})}),a.jsxs("div",{className:"text-left flex-1",children:[a.jsxs("p",{className:"text-white font-medium",children:[j.name,!j.is_active&&a.jsx("span",{className:"text-bambu-gray text-xs ml-2",children:"(inactive)"})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[j.model||"Unknown model"," • ",j.ip_address]})]}),i&&a.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${G?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:G&&a.jsx(Ua,{className:"w-3 h-3 text-white"})})]}),G&&k&&Y&&a.jsxs("div",{className:"ml-4 mt-2 mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",onClick:Z=>Z.stopPropagation(),children:[a.jsx("input",{type:"checkbox",checked:K,onChange:Z=>R(j.id,Z.target.checked,Z),className:"w-3.5 h-3.5 rounded border-bambu-gray/30 bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),a.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom mapping"})]}),a.jsxs("span",{className:`text-xs ml-2 ${Y.matchStatus==="full"?"text-bambu-green":Y.matchStatus==="partial"?"text-yellow-400":"text-orange-400"}`,children:["(",Y.exactMatches,"/",Y.totalSlots," matched)"]}),Y.isLoading&&a.jsx(vr,{className:"w-3 h-3 text-bambu-gray animate-spin"}),K&&a.jsxs("button",{type:"button",onClick:Z=>{Z.stopPropagation(),c(j.id)},className:"ml-auto flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",children:[a.jsx(ufe,{className:"w-3 h-3"}),"Auto"]})]}),K&&a.jsx(d8e,{printerResult:Y,filamentReqs:l.filaments,onUpdateConfig:Z=>u(j.id,Z)})]})]},j.id)}),d==="printer"&&S>0&&!y&&a.jsxs("button",{type:"button",onClick:()=>b(!0),className:"text-xs text-bambu-gray hover:text-white transition-colors mt-2 flex items-center gap-1",children:[a.jsx(xn,{className:"w-3 h-3 text-yellow-400"}),S," other printer",S>1?"s":""," hidden (different model) —",a.jsx("span",{className:"underline",children:"show all"})]}),d==="printer"&&y&&x&&a.jsx("button",{type:"button",onClick:()=>b(!1),className:"text-xs text-bambu-gray hover:text-white transition-colors mt-2",children:a.jsxs("span",{className:"underline",children:["Show only ",x," printers"]})}),d==="printer"&&O===0&&a.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[a.jsx(Ei,{className:"w-3 h-3"}),"Select at least one printer"]}),d==="model"&&!m&&a.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[a.jsx(Ei,{className:"w-3 h-3"}),"Select a target printer model"]})]})}function f8e({plates:t,isMultiPlate:e,selectedPlate:n,onSelect:r}){return!e||t.length<=1?null:a.jsxs("div",{className:"mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(ul,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:"Select Plate to Print"}),!n&&a.jsxs("span",{className:"text-xs text-orange-400 flex items-center gap-1",children:[a.jsx(xn,{className:"w-3 h-3"}),"Selection required"]})]}),a.jsx("div",{className:"grid grid-cols-2 gap-2",children:t.map(i=>a.jsxs("button",{type:"button",onClick:()=>r(i.index),className:`flex items-center gap-2 p-2 rounded-lg border transition-colors text-left ${n===i.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[i.has_thumbnail&&i.thumbnail_url!=null?a.jsx("img",{src:i.thumbnail_url,alt:`Plate ${i.index}`,className:"w-10 h-10 rounded object-cover bg-bambu-dark-tertiary"}):a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:a.jsx(ul,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white font-medium truncate",children:i.name||`Plate ${i.index}`}),a.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[i.objects.length>0?i.objects.slice(0,3).join(", ")+(i.objects.length>3?"...":""):`${i.filaments.length} filament${i.filaments.length!==1?"s":""}`,i.print_time_seconds!=null?` • ${a8e(i.print_time_seconds)}`:""]})]}),n===i.index&&a.jsx(Ua,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},i.index))})]})}function m8e({printerId:t,filamentReqs:e,manualMappings:n,onManualMappingChange:r,defaultExpanded:i=!1}){const s=an(),[o,l]=w.useState(!1),[c,u]=w.useState(i),{data:d}=ct({queryKey:["printer-status",t],queryFn:()=>he.getPrinterStatus(t),enabled:!!t}),{loadedFilaments:f,filamentComparison:m,hasTypeMismatch:g,hasColorMismatch:x}=oee(e,d,n);if(!(e?.filaments&&e.filaments.length>0)||!d)return null;const b=g?"#f97316":x?"#facc15":"#00ae42",v=(S,T)=>{if(S>0)if(T===""){const E={...n};delete E[S],r(E)}else r({...n,[S]:parseInt(T,10)})},N=async()=>{l(!0);try{await he.refreshPrinterStatus(t),await new Promise(S=>setTimeout(S,500)),await s.refetchQueries({queryKey:["printer-status",t]})}finally{l(!1)}};return a.jsxs("div",{className:"mb-4",children:[a.jsxs("button",{type:"button",onClick:()=>u(!c),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[a.jsx(Vj,{className:"w-4 h-4",fill:b,stroke:"none"}),a.jsx("span",{children:"Filament Mapping"}),g?a.jsx("span",{className:"text-xs text-orange-400",children:"(Type not found)"}):x?a.jsx("span",{className:"text-xs text-yellow-400",children:"(Color mismatch)"}):a.jsx("span",{className:"text-xs text-bambu-green",children:"(Ready)"}),c?a.jsx(ou,{className:"w-4 h-4 ml-auto"}):a.jsx(Br,{className:"w-4 h-4 ml-auto"})]}),c&&a.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Click to change slot assignment"}),a.jsxs("button",{type:"button",onClick:N,className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",disabled:o,children:[a.jsx(vr,{className:`w-3 h-3 ${o?"animate-spin":""}`}),a.jsx("span",{children:"Re-read"})]})]}),m.map((S,T)=>a.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[a.jsx("span",{title:`Required: ${S.type} - ${Cg(S.color)}`,children:a.jsx(Vj,{className:"w-3 h-3",fill:S.color,stroke:S.color})}),a.jsxs("span",{className:"text-white truncate",children:[S.type," ",a.jsxs("span",{className:"text-bambu-gray",children:["(",S.used_grams,"g)"]})]}),a.jsx("span",{className:"text-bambu-gray",children:"→"}),a.jsxs("select",{value:S.loaded?.globalTrayId??"",onChange:E=>v(S.slot_id||0,E.target.value),className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${S.status==="match"?"border-bambu-green/50 text-bambu-green":S.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${S.isManual?"ring-1 ring-blue-400/50":""}`,title:S.isManual?"Manually selected":"Auto-matched",children:[a.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),f.map(E=>a.jsxs("option",{value:E.globalTrayId,className:"bg-bambu-dark text-white",children:[E.label,": ",E.type," (",E.colorName,")"]},E.globalTrayId))]}),S.status==="match"?a.jsx(Ua,{className:"w-3 h-3 text-bambu-green"}):S.status==="type_only"?a.jsx("span",{title:"Same type, different color",children:a.jsx(xn,{className:"w-3 h-3 text-yellow-400"})}):a.jsx("span",{title:"Filament type not loaded",children:a.jsx(xn,{className:"w-3 h-3 text-orange-400"})})]},T)),g&&a.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]})]})}const p8e=[{key:"bed_levelling",label:"Bed Levelling",desc:"Auto-level bed before print"},{key:"flow_cali",label:"Flow Calibration",desc:"Calibrate extrusion flow"},{key:"vibration_cali",label:"Vibration Calibration",desc:"Reduce ringing artifacts"},{key:"layer_inspect",label:"First Layer Inspection",desc:"AI inspection of first layer"},{key:"timelapse",label:"Timelapse",desc:"Record timelapse video"}];function g8e({options:t,onChange:e,defaultExpanded:n=!1}){const[r,i]=w.useState(n),s=o=>{e({...t,[o]:!t[o]})};return a.jsxs("div",{className:"mb-4",children:[a.jsxs("button",{type:"button",onClick:()=>i(!r),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[a.jsx(ly,{className:"w-4 h-4"}),a.jsx("span",{children:"Print Options"}),r?a.jsx(ou,{className:"w-4 h-4 ml-auto"}):a.jsx(Br,{className:"w-4 h-4 ml-auto"})]}),r&&a.jsx("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:p8e.map(({key:o,label:l,desc:c})=>a.jsxs("label",{className:"flex items-center justify-between cursor-pointer group",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-white",children:l}),a.jsx("p",{className:"text-xs text-bambu-gray",children:c})]}),a.jsx("div",{className:`relative w-10 h-5 rounded-full transition-colors ${t[o]?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,onClick:()=>s(o),children:a.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white transition-transform ${t[o]?"translate-x-5":"translate-x-0.5"}`})})]},o))})]})}function x8e({options:t,onChange:e}){const n=r=>{e({...t,scheduleType:r})};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${t.scheduleType==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>n("asap"),children:[a.jsx(qn,{className:"w-4 h-4"}),"ASAP"]}),a.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${t.scheduleType==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>n("scheduled"),children:[a.jsx(si,{className:"w-4 h-4"}),"Scheduled"]}),a.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${t.scheduleType==="manual"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>n("manual"),children:[a.jsx(lW,{className:"w-4 h-4"}),"Queue Only"]})]})]}),t.scheduleType==="scheduled"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),a.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:t.scheduledTime,onChange:r=>e({...t,scheduledTime:r.target.value}),min:s8e(),required:!0})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"requirePrevious",checked:t.requirePreviousSuccess,onChange:r=>e({...t,requirePreviousSuccess:r.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:t.autoOffAfter,onChange:r=>e({...t,autoOffAfter:r.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[a.jsx(yu,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:t.scheduleType==="asap"?"Print will start as soon as the printer is idle.":t.scheduleType==="scheduled"?"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available.":"Print will be staged but won't start automatically. Use the Start button to release it to the queue."})]})}const Ep={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},b8e={scheduleType:"asap",scheduledTime:"",requirePreviousSuccess:!1,autoOffAfter:!1};function ah({mode:t,archiveId:e,libraryFileId:n,archiveName:r,queueItem:i,onClose:s,onSuccess:o}){const l=an(),{showToast:c}=Gn(),u=!!n&&!e,[d,f]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[m,g]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[x,y]=w.useState(()=>t==="edit-queue-item"&&i?{bed_levelling:i.bed_levelling??Ep.bed_levelling,flow_cali:i.flow_cali??Ep.flow_cali,vibration_cali:i.vibration_cali??Ep.vibration_cali,layer_inspect:i.layer_inspect??Ep.layer_inspect,timelapse:i.timelapse??Ep.timelapse}:Ep),[b,v]=w.useState(()=>{if(t==="edit-queue-item"&&i){let $e="asap";i.manual_start?$e="manual":i.scheduled_time&&!m9(i.scheduled_time)&&($e="scheduled");let Ue="";return i.scheduled_time&&!m9(i.scheduled_time)&&(Ue=new Date(i.scheduled_time).toISOString().slice(0,16)),{scheduleType:$e,scheduledTime:Ue,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after}}return b8e}),[N,S]=w.useState(()=>{if(t==="edit-queue-item"&&i?.ams_mapping&&Array.isArray(i.ams_mapping)){const $e={};return i.ams_mapping.forEach((Ue,Ge)=>{Ue!==-1&&($e[Ge+1]=Ue)}),$e}return{}}),[T,E]=w.useState({}),[k,C]=w.useState(()=>t==="edit-queue-item"&&i?.target_model?"model":"printer"),[D,A]=w.useState(()=>t==="edit-queue-item"&&i?.target_model?i.target_model:null),[R]=w.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[F]=w.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[O,q]=w.useState(!1),[j,G]=w.useState({current:0,total:0}),[Y,K]=w.useState(new Set),Z=d.length,te=d.length>0?d[0]:null,{data:ne}=ct({queryKey:["settings"],queryFn:he.getSettings}),{data:z,isLoading:W}=ct({queryKey:["printers"],queryFn:he.getPrinters}),{data:se}=ct({queryKey:["archive",e],queryFn:()=>he.getArchive(e),enabled:!!e&&!u}),ae=se?.sliced_for_model||null,{data:de,isError:me}=ct({queryKey:["archive-plates",e],queryFn:()=>he.getArchivePlates(e),enabled:!!e&&!u,retry:!1}),{data:xe}=ct({queryKey:["library-file-plates",n],queryFn:()=>he.getLibraryFilePlates(n),enabled:u&&!!n}),be=u?xe:de,{data:fe,isError:Ce}=ct({queryKey:["archive-filaments",e,m],queryFn:()=>he.getArchiveFilamentRequirements(e,m??void 0),enabled:!!e&&!u&&(m!==null||!be?.is_multi_plate),retry:!1}),{data:Ne}=ct({queryKey:["library-file-filaments",n,m],queryFn:()=>he.getLibraryFileFilamentRequirements(n,m??void 0),enabled:u&&!!n&&(m!==null||!be?.is_multi_plate)}),re=!u&&(me||Ce),He=u?Ne:fe,{data:H}=ct({queryKey:["printer-status",te],queryFn:()=>he.getPrinterStatus(te),enabled:!!te}),{amsMapping:B}=oee(He,H,N),X=u8e(d,z,He,N,T,E);w.useEffect(()=>{be?.plates?.length===1&&!m&&g(be.plates[0].index)},[be,m]),w.useEffect(()=>{if(t==="edit-queue-item")return;const $e=z?.filter(Ue=>Ue.is_active)||[];$e.length===1&&d.length===0&&f([$e[0].id])},[t,z,d.length]),w.useEffect(()=>{t==="edit-queue-item"?(JSON.stringify(d.sort())!==JSON.stringify(R.sort())||m!==F)&&(S({}),E({}),K(new Set)):(S({}),E({}),K(new Set))},[t,d,m,R,F]),w.useEffect(()=>{if(!ne?.per_printer_mapping_expanded||d.length<=1)return;const $e=d.filter(Ue=>{if(Y.has(Ue))return!1;const Ge=X.printerResults.find(We=>We.printerId===Ue);return Ge&&Ge.status&&!Ge.isLoading});$e.length>0&&(K(Ue=>{const Ge=new Set(Ue);return $e.forEach(We=>Ge.add(We)),Ge}),$e.forEach(Ue=>{X.autoConfigurePrinter(Ue)}))},[ne?.per_printer_mapping_expanded,d,Y,X]),w.useEffect(()=>{const $e=Ue=>{Ue.key==="Escape"&&!O&&s()};return window.addEventListener("keydown",$e),()=>window.removeEventListener("keydown",$e)},[s,O]);const U=be?.is_multi_plate??!1,Q=be?.plates??[],le=ht({mutationFn:$e=>he.addToQueue($e)}),Pe=ht({mutationFn:$e=>he.updateQueueItem(i.id,$e),onSuccess:()=>{l.invalidateQueries({queryKey:["queue"]}),c("Queue item updated"),o?.(),s()},onError:$e=>{c($e.message||"Failed to update queue item","error")}}),Oe=async $e=>{if($e?.preventDefault(),k==="printer"&&d.length===0){c("Please select at least one printer","error");return}if(k==="model"&&!D){c("Please select a target printer model","error");return}q(!0);const Ue=k==="model"?1:d.length;G({current:0,total:Ue});const Ge={success:0,failed:0,errors:[]},We=oe=>{if(d.length>1){const ve=T[oe];if(ve&&!ve.useDefault)return X.getFinalMapping(oe)}return B},Ye=oe=>({printer_id:k==="printer"?oe:null,target_model:k==="model"?D:null,archive_id:u?void 0:e,library_file_id:u?n:void 0,require_previous_success:b.requirePreviousSuccess,auto_off_after:b.autoOffAfter,manual_start:b.scheduleType==="manual",ams_mapping:oe?We(oe):void 0,plate_id:m,scheduled_time:b.scheduleType==="scheduled"&&b.scheduledTime?new Date(b.scheduledTime).toISOString():void 0,...x});if(k==="model"){G({current:1,total:1});try{if(t==="reprint"){c("Model-based assignment only works with queue mode","error"),q(!1);return}else if(t==="edit-queue-item"){const oe={printer_id:null,target_model:D,require_previous_success:b.requirePreviousSuccess,auto_off_after:b.autoOffAfter,manual_start:b.scheduleType==="manual",ams_mapping:void 0,plate_id:m,scheduled_time:b.scheduleType==="scheduled"&&b.scheduledTime?new Date(b.scheduledTime).toISOString():null,...x};await Pe.mutateAsync(oe)}else await le.mutateAsync(Ye(null));Ge.success++}catch(oe){Ge.failed++,Ge.errors.push(oe.message)}}else for(let oe=0;oe<d.length;oe++){const ve=d[oe];G({current:oe+1,total:d.length});try{if(t==="reprint"){const Le=We(ve);u?await he.printLibraryFile(n,ve,{ams_mapping:Le,...x}):await he.reprintArchive(e,ve,{plate_id:m??void 0,ams_mapping:Le,...x})}else if(t==="edit-queue-item"&&oe===0){const Le=We(ve),Ke={printer_id:ve,target_model:null,require_previous_success:b.requirePreviousSuccess,auto_off_after:b.autoOffAfter,manual_start:b.scheduleType==="manual",ams_mapping:Le,plate_id:m,scheduled_time:b.scheduleType==="scheduled"&&b.scheduledTime?new Date(b.scheduledTime).toISOString():null,...x};await Pe.mutateAsync(Ke)}else await le.mutateAsync(Ye(ve));Ge.success++}catch(Le){Ge.failed++;const Ke=z?.find(lt=>lt.id===ve)?.name||`Printer ${ve}`;Ge.errors.push(`${Ke}: ${Le.message}`)}}if(q(!1),Ge.failed===0){if(k==="model")c(t==="edit-queue-item"?"Queue item updated":`Queued for any ${D}`);else{const oe=t==="reprint"?"sent to":t==="edit-queue-item"?"updated/queued for":"queued for";Ge.success===1?c(t==="edit-queue-item"?"Queue item updated":`Print ${oe} printer`):c(`Print ${oe} ${Ge.success} printers`)}l.invalidateQueries({queryKey:["queue"]}),o?.(),s()}else Ge.success===0?c(`Failed: ${Ge.errors[0]}`,"error"):(c(`${Ge.success} succeeded, ${Ge.failed} failed`,"error"),l.invalidateQueries({queryKey:["queue"]}))},je=O||Pe.isPending,$=w.useMemo(()=>!(je||k==="printer"&&d.length===0||k==="model"&&!D||k==="model"&&t==="reprint"||!u&&U&&!m),[d.length,k,D,t,U,m,je,u]),V=(()=>{const $e=d.length;return t==="reprint"?{title:u?"Print":"Re-print",icon:Ar,submitText:$e>1?`Print to ${$e} Printers`:"Print",submitIcon:Ar,loadingText:j.total>1?`Sending ${j.current}/${j.total}...`:"Sending..."}:t==="add-to-queue"?{title:"Schedule Print",icon:si,submitText:$e>1?`Queue to ${$e} Printers`:"Add to Queue",submitIcon:si,loadingText:j.total>1?`Adding ${j.current}/${j.total}...`:"Adding..."}:{title:"Edit Queue Item",icon:Oi,submitText:"Save",submitIcon:Oi,loadingText:j.total>1?`Saving ${j.current}/${j.total}...`:"Saving..."}})(),ie=V.icon,Se=V.submitIcon,ye=te&&(u||(U?m!==null:!0));return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:O?void 0:s,children:a.jsx(_t,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:$e=>$e.stopPropagation(),children:a.jsxs(St,{className:t==="reprint"?"":"p-0",children:[a.jsxs("div",{className:`flex items-center justify-between ${t==="reprint"?"mb-4":"p-4 border-b border-bambu-dark-tertiary"}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ie,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:V.title})]}),a.jsx(Te,{variant:"ghost",size:"sm",onClick:s,disabled:O,children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:Oe,className:t==="reprint"?"":"p-4 space-y-4",children:[a.jsx("p",{className:`text-sm text-bambu-gray ${t==="reprint"?"mb-4":""}`,children:t==="reprint"?a.jsxs(a.Fragment,{children:["Send ",a.jsx("span",{className:"text-white",children:r})," to printer(s)"]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"block text-bambu-gray mb-1",children:"Print Job"}),a.jsx("span",{className:"text-white font-medium truncate block",children:r})]})}),a.jsx(f8e,{plates:Q,isMultiPlate:U,selectedPlate:m,onSelect:g}),a.jsx(h8e,{printers:z||[],selectedPrinterIds:d,onMultiSelect:f,isLoading:W,allowMultiple:!0,showInactive:t==="edit-queue-item",printerMappingResults:X.printerResults,filamentReqs:He,onAutoConfigurePrinter:X.autoConfigurePrinter,onUpdatePrinterConfig:X.updatePrinterConfig,assignmentMode:t==="reprint"?"printer":k,onAssignmentModeChange:t!=="reprint"?C:void 0,targetModel:D,onTargetModelChange:t!=="reprint"?A:void 0,slicedForModel:ae}),ae&&k==="printer"&&d.length===1&&(()=>{const $e=z?.find(Ue=>Ue.id===d[0]);return $e&&$e.model&&ae!==$e.model?a.jsxs("div",{className:"p-3 mb-2 bg-yellow-500/10 border border-yellow-500/30 rounded-lg flex items-center gap-2",children:[a.jsx(xn,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),a.jsxs("span",{className:"text-sm text-yellow-400",children:["File was sliced for ",ae,", but printing on ",$e.model]})]}):null})(),re&&a.jsxs("div",{className:"flex items-start gap-2 p-3 mb-2 bg-orange-500/10 border border-orange-500/30 rounded-lg text-sm",children:[a.jsx(Ei,{className:"w-4 h-4 text-orange-400 mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-orange-400",children:"Archive data unavailable. The source file may have been deleted. Filament mapping is disabled."})]}),ye&&!re&&d.length===1&&a.jsx(m8e,{printerId:te,filamentReqs:He,manualMappings:N,onManualMappingChange:S,defaultExpanded:ne?.per_printer_mapping_expanded??!1}),(t==="reprint"||Z>0||k==="model"&&D)&&a.jsx(g8e,{options:x,onChange:y}),t!=="reprint"&&a.jsx(x8e,{options:b,onChange:v}),Pe.isError&&a.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:Pe.error?.message||"Failed to complete operation"}),a.jsxs("div",{className:`flex gap-3 ${t==="reprint"?"":"pt-2"}`,children:[a.jsx(Te,{type:"button",variant:"secondary",onClick:s,className:"flex-1",disabled:O,children:"Cancel"}),a.jsx(Te,{type:"submit",disabled:!$,className:"flex-1",children:je?a.jsxs(a.Fragment,{children:[a.jsx(ut,{className:"w-4 h-4 animate-spin"}),V.loadingText]}):a.jsxs(a.Fragment,{children:[a.jsx(Se,{className:"w-4 h-4"}),V.submitText]})})]})]})]})})})}function y8e({onClose:t,initialFiles:e}){const n=an(),{showToast:r}=Gn(),i=w.useRef(null),[s,o]=w.useState(()=>e?.filter(T=>T.name.endsWith(".3mf")).map(T=>({file:T,status:"pending"}))||[]),[l,c]=w.useState(!1),[u,d]=w.useState(null);w.useEffect(()=>{const T=E=>{E.key==="Escape"&&t()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t]);const f=ht({mutationFn:T=>he.uploadArchivesBulk(T),onSuccess:T=>{d(T),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),o(E=>E.map(k=>{const C=T.results.find(A=>A.filename===k.file.name),D=T.errors.find(A=>A.filename===k.file.name);return C?{...k,status:"success",archiveId:C.id}:D?{...k,status:"error",error:D.error}:k})),T.failed===0?r(`${T.uploaded} file${T.uploaded!==1?"s":""} uploaded`):T.uploaded===0?r(`Failed to upload ${T.failed} file${T.failed!==1?"s":""}`,"error"):r(`${T.uploaded} uploaded, ${T.failed} failed`,"warning")},onError:()=>{o(T=>T.map(E=>({...E,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),m=w.useCallback(T=>{T.preventDefault(),c(!0)},[]),g=w.useCallback(T=>{T.preventDefault(),c(!1)},[]),x=w.useCallback(T=>{T.preventDefault(),c(!1);const E=Array.from(T.dataTransfer.files).filter(k=>k.name.endsWith(".3mf"));E.length>0&&o(k=>[...k,...E.map(C=>({file:C,status:"pending"}))])},[]),y=w.useCallback(T=>{const E=Array.from(T.target.files||[]).filter(k=>k.name.endsWith(".3mf"));E.length>0&&o(k=>[...k,...E.map(C=>({file:C,status:"pending"}))]),i.current&&(i.current.value="")},[]),b=w.useCallback(T=>{o(E=>E.filter((k,C)=>C!==T))},[]),v=()=>{if(s.length===0)return;const T=s.filter(E=>E.status==="pending");T.length!==0&&(o(E=>E.map(k=>k.status==="pending"?{...k,status:"uploading"}:k)),f.mutate(T.map(E=>E.file)))},N=s.filter(T=>T.status==="pending").length,S=f.isPending;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:a.jsxs(St,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"p-4",children:a.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${l?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:m,onDragLeave:g,onDrop:x,children:[a.jsx(fi,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),a.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),a.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),a.jsx(Te,{variant:"secondary",onClick:()=>i.current?.click(),disabled:S,children:"Browse Files"}),a.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:y})]})}),a.jsx("div",{className:"px-4 pb-4",children:a.jsx("p",{className:"text-xs text-bambu-gray",children:"The printer model will be automatically extracted from the 3MF file metadata."})}),s.length>0&&a.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:a.jsx("div",{className:"space-y-2",children:s.map((T,E)=>a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx(F2,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"flex-1 text-white text-sm truncate",children:T.file.name}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[(T.file.size/(1024*1024)).toFixed(1)," MB"]}),T.status==="pending"&&a.jsx("button",{onClick:()=>b(E),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:S,children:a.jsx(Ot,{className:"w-4 h-4"})}),T.status==="uploading"&&a.jsx(ut,{className:"w-4 h-4 text-bambu-green animate-spin"}),T.status==="success"&&a.jsx(Fn,{className:"w-4 h-4 text-bambu-green"}),T.status==="error"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-red-400",children:T.error}),a.jsx(Ei,{className:"w-4 h-4 text-red-400"})]})]},`${T.file.name}-${E}`))})}),u&&a.jsx("div",{className:"px-4 pb-4",children:a.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:[a.jsx("span",{className:"text-bambu-green",children:u.uploaded})," uploaded",u.failed>0&&a.jsxs(a.Fragment,{children:[", ",a.jsx("span",{className:"text-red-400",children:u.failed})," failed"]})]})})}),a.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Te,{variant:"secondary",onClick:t,className:"flex-1",children:u?"Close":"Cancel"}),!u&&a.jsx(Te,{onClick:v,disabled:N===0||S,className:"flex-1",children:S?a.jsxs(a.Fragment,{children:[a.jsx(ut,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):a.jsxs(a.Fragment,{children:[a.jsx(fi,{className:"w-4 h-4"}),"Upload ",N>0&&`(${N})`]})})]})]})})})}const v8e=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"],_8e=[{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"aborted",label:"Cancelled"},{value:"printing",label:"Printing"}];function lee({archive:t,onClose:e,existingTags:n=[]}){w.useEffect(()=>{const be=fe=>{fe.key==="Escape"&&e()};return window.addEventListener("keydown",be),()=>window.removeEventListener("keydown",be)},[e]);const r=an(),[i,s]=w.useState(t.print_name||""),[o,l]=w.useState(t.printer_id),[c,u]=w.useState(t.project_id??null),[d,f]=w.useState(t.notes||""),[m,g]=w.useState(t.tags||""),[x,y]=w.useState(t.failure_reason||""),[b,v]=w.useState(t.status),[N,S]=w.useState(t.quantity??1),[T,E]=w.useState(t.photos||[]),[k,C]=w.useState(t.external_url||""),[D,A]=w.useState(!1),[R,F]=w.useState(!1),O=w.useRef(null),q=w.useRef(null),j=w.useRef(null),{data:G}=ct({queryKey:["printers"],queryFn:he.getPrinters}),{data:Y}=ct({queryKey:["projects"],queryFn:()=>he.getProjects()}),{data:K}=ct({queryKey:["tags"],queryFn:he.getTags,enabled:n.length===0}),Z=n.length>0?n:K?.map(be=>be.name)||[],te=m.split(",").map(be=>be.trim()).filter(Boolean),ne=m.includes(",")?m.substring(m.lastIndexOf(",")+1).trim().toLowerCase():m.trim().toLowerCase(),z=Z.filter(be=>!te.includes(be)&&(ne===""||be.toLowerCase().includes(ne))),W=be=>{let fe;if(ne&&!Z.includes(ne)?fe=m.includes(",")?m.substring(0,m.lastIndexOf(",")).split(",").map(Ce=>Ce.trim()).filter(Boolean):[]:fe=te,!fe.includes(be)){const Ce=[...fe,be].join(", ");g(Ce)}j.current!==null&&clearTimeout(j.current),O.current?.focus()},se=be=>{const fe=te.filter(Ce=>Ce!==be).join(", ");g(fe)},ae=ht({mutationFn:be=>he.updateArchive(t.id,be),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),de=async be=>{const fe=be.target.files?.[0];if(fe){A(!0);try{const Ce=await he.uploadArchivePhoto(t.id,fe);E(Ce.photos),r.invalidateQueries({queryKey:["archives"]})}catch(Ce){console.error("Failed to upload photo:",Ce)}finally{A(!1),q.current&&(q.current.value="")}}},me=async be=>{try{const fe=await he.deleteArchivePhoto(t.id,be);E(fe.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(fe){console.error("Failed to delete photo:",fe)}},xe=be=>{be.preventDefault();const fe={print_name:i||void 0,printer_id:o,project_id:c,notes:d||void 0,tags:m||void 0,quantity:N,external_url:k||null};b!==t.status&&(fe.status=b),b==="failed"||b==="aborted"?fe.failure_reason=x||void 0:(t.status==="failed"||t.status==="aborted")&&(fe.failure_reason=null),ae.mutate(fe)};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:be=>be.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:xe,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),a.jsx("input",{type:"text",value:i,onChange:be=>s(be.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"Print name"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),a.jsxs("select",{value:o??"",onChange:be=>l(be.target.value?Number(be.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"No printer"}),G?.map(be=>a.jsx("option",{value:be.id,children:be.name},be.id))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(Ma,{className:"w-4 h-4 inline mr-1"}),"Project"]}),a.jsxs("select",{value:c??"",onChange:be=>u(be.target.value?Number(be.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"No project"}),Y?.map(be=>a.jsx("option",{value:be.id,children:be.name},be.id))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(Jue,{className:"w-4 h-4 inline mr-1"}),"Items Printed"]}),a.jsx("input",{type:"number",min:1,value:N,onChange:be=>S(Math.max(1,parseInt(be.target.value)||1)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"1"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of items produced in this print job"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),a.jsx("textarea",{value:d,onChange:be=>f(be.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..."})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx($g,{className:"w-4 h-4 inline mr-1"}),"External Link"]}),a.jsx("input",{type:"url",value:k,onChange:be=>C(be.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"https://printables.com/model/..."}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Link to Printables, Thingiverse, or other source"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),te.length>0&&a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:te.map(be=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[a.jsx(qd,{className:"w-3 h-3"}),be,a.jsx("button",{type:"button",onClick:()=>se(be),className:"ml-0.5 text-bambu-gray hover:text-white",children:a.jsx(Ot,{className:"w-3 h-3"})})]},be))}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{ref:O,type:"text",value:m,onChange:be=>g(be.target.value),onFocus:()=>{j.current!==null&&clearTimeout(j.current),F(!0)},onBlur:()=>{j.current=window.setTimeout(()=>F(!1),200)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:te.length>0?"Add more tags...":"Add tags..."}),R&&z.length>0&&a.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10 max-h-40 overflow-y-auto",children:[a.jsxs("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:[ne?`Matching "${ne}"`:"Existing tags"," (click to add)"]}),a.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:z.map(be=>a.jsx("button",{type:"button",onClick:()=>W(be),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:be},be))})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Status"}),a.jsx("select",{value:b,onChange:be=>{v(be.target.value),be.target.value==="completed"&&y("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:_8e.map(be=>a.jsx("option",{value:be.value,children:be.label},be.value))})]}),(b==="failed"||b==="aborted")&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),a.jsxs("select",{value:x,onChange:be=>y(be.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"Select reason..."}),v8e.map(be=>a.jsx("option",{value:be,children:be},be))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(Df,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),a.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[T.map(be=>a.jsxs("div",{className:"relative group",children:[a.jsx("img",{src:he.getArchivePhotoUrl(t.id,be),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),a.jsx("button",{type:"button",onClick:()=>me(be),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx(on,{className:"w-3 h-3 text-white"})})]},be)),a.jsxs("label",{className:"w-20 h-20 flex items-center justify-center border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green transition-colors",children:[a.jsx("input",{ref:q,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:de,className:"hidden",disabled:D}),D?a.jsx(ut,{className:"w-6 h-6 text-bambu-gray animate-spin"}):a.jsx(rr,{className:"w-6 h-6 text-bambu-gray"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Te,{type:"submit",disabled:ae.isPending,className:"flex-1",children:[a.jsx(bs,{className:"w-4 h-4"}),ae.isPending?"Saving...":"Save"]})]})]})]})})}function cee({x:t,y:e,items:n,onClose:r}){const i=w.useRef(null),[s,o]=w.useState(null),l=w.useRef(null),[c,u]=w.useState({x:t,y:e,visible:!1}),[d,f]=w.useState(!1),[m,g]=w.useState({});w.useEffect(()=>{const b=S=>{i.current&&!i.current.contains(S.target)&&r()},v=S=>{S.key==="Escape"&&r()},N=()=>{r()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",v),document.addEventListener("scroll",N,!0),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",v),document.removeEventListener("scroll",N,!0),l.current&&clearTimeout(l.current)}},[r]),w.useLayoutEffect(()=>{if(i.current){i.current.style.visibility="hidden",i.current.style.display="block";const b=i.current.getBoundingClientRect(),v=window.innerWidth,N=window.innerHeight,S=8;let T=t,E=e;t+b.width>v-S&&(T=Math.max(S,v-b.width-S)),T<S&&(T=S),e+b.height>N-S&&(E=Math.max(S,N-b.height-S)),E<S&&(E=S);const k=180,C=v-T-b.width,D=T;f(C<k&&D>k),u({x:T,y:E,visible:!0})}},[t,e]);const x=(b,v)=>{l.current&&(clearTimeout(l.current),l.current=null);const N=v.getBoundingClientRect(),S=window.innerHeight,T=300,C=S-N.top-8<T&&N.top>T;g(D=>({...D,[b]:C?"bottom":"top"})),o(b)},y=()=>{l.current=window.setTimeout(()=>{o(null)},150)};return a.jsx("div",{ref:i,className:"fixed z-50 min-w-[180px] max-w-[280px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1",style:{left:c.x,top:c.y,visibility:c.visible?"visible":"hidden"},children:n.map((b,v)=>{if(b.divider)return a.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},v);const N=b.submenu&&b.submenu.length>0;return a.jsxs("div",{className:"relative",onMouseEnter:S=>N&&x(v,S.currentTarget),onMouseLeave:()=>N&&y(),children:[a.jsxs("button",{onMouseEnter:S=>N&&x(v,S.currentTarget.parentElement),onClick:()=>{N?o(s===v?null:v):b.disabled||(b.onClick(),r())},disabled:b.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${b.disabled?"text-bambu-gray cursor-not-allowed":b.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${N&&s===v?"bg-bambu-dark-tertiary":""}`,children:[b.icon&&a.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:b.icon}),a.jsx("span",{className:"flex-1",children:b.label}),N&&a.jsx(Ms,{className:"w-4 h-4 text-bambu-gray"})]}),N&&s===v&&a.jsx("div",{className:`absolute min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden max-h-[300px] overflow-y-auto z-[60] ${d?"right-full mr-1":"left-full ml-1"} ${m[v]==="bottom"?"bottom-0":"top-0"}`,onMouseEnter:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>y(),children:b.submenu.map((S,T)=>a.jsxs("button",{onClick:()=>{S.disabled||(S.onClick(),r())},disabled:S.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${S.disabled?"text-bambu-gray cursor-not-allowed":S.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[S.icon&&a.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:S.icon}),S.label]},T))})]},v)})})}function w8e({selectedIds:t,existingTags:e,onClose:n}){const r=an(),{showToast:i}=Gn(),[s,o]=w.useState(""),[l,c]=w.useState(new Set),[u,d]=w.useState("add");w.useEffect(()=>{const y=b=>{b.key==="Escape"&&n()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[n]);const f=ht({mutationFn:async()=>{const y=Array.from(l);let b=0;for(const v of t)try{const N=await he.getArchive(v),S=N.tags?N.tags.split(",").map(E=>E.trim()).filter(Boolean):[];let T;u==="add"?T=[...new Set([...S,...y])]:T=S.filter(E=>!l.has(E)),await he.updateArchive(v,{tags:T.join(", ")}),b++}catch(N){throw console.error(`Failed to update archive ${v}:`,N),new Error(`Failed on archive ${v}: ${N instanceof Error?N.message:"Unknown error"}`)}return{count:b,mode:u,tags:y}},onSuccess:({count:y,mode:b,tags:v})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${b==="add"?"Added":"Removed"} ${v.length} tag${v.length!==1?"s":""} ${b==="add"?"to":"from"} ${y} archive${y!==1?"s":""}`),n()},onError:y=>{i(y.message||"Failed to update tags","error")}}),m=y=>{c(b=>{const v=new Set(b);return v.has(y)?v.delete(y):v.add(y),v})},g=()=>{s.trim()&&!l.has(s.trim())&&(c(y=>new Set([...y,s.trim()])),o(""))},x=y=>{y.key==="Enter"&&(y.preventDefault(),g())};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-md",children:a.jsxs(St,{className:"p-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qd,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:u==="add"?"Add Tags":"Remove Tags"})]}),a.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("p",{className:"text-sm text-bambu-gray",children:[u==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Te,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),a.jsx(Te,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",placeholder:"Enter new tag...",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:s,onChange:y=>o(y.target.value),onKeyDown:x}),a.jsx(Te,{size:"sm",variant:"secondary",onClick:g,disabled:!s.trim(),children:a.jsx(rr,{className:"w-4 h-4"})})]}),e.length>0&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(y=>a.jsx("button",{onClick:()=>m(y),className:`px-2 py-1 rounded text-sm transition-colors ${l.has(y)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:y},y))})]}),l.size>0&&a.jsxs("div",{children:[a.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),a.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(l).map(y=>a.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${u==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[y,a.jsx("button",{onClick:()=>m(y),className:"hover:opacity-70",children:a.jsx(Ot,{className:"w-3 h-3"})})]},y))})]})]}),a.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Te,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),a.jsx(Te,{onClick:()=>f.mutate(),disabled:l.size===0||f.isPending,className:"flex-1",children:f.isPending?a.jsxs(a.Fragment,{children:[a.jsx(ut,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(qd,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function S8e({selectedIds:t,onClose:e}){const n=an(),{showToast:r}=Gn(),{data:i,isLoading:s}=ct({queryKey:["projects"],queryFn:()=>he.getProjects()});w.useEffect(()=>{const d=f=>{f.key==="Escape"&&e()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[e]);const o=()=>{n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["projects"]}),n.invalidateQueries({queryKey:["project"]}),n.invalidateQueries({queryKey:["project-archives"]})},l=ht({mutationFn:async d=>(await he.addArchivesToProject(d,t),d),onSuccess:d=>{const f=i?.find(m=>m.id===d);o(),r(`Added ${t.length} archive${t.length!==1?"s":""} to "${f?.name}"`),e()},onError:()=>{r("Failed to assign project","error")}}),c=ht({mutationFn:async()=>{for(const d of t)await he.updateArchive(d,{project_id:null});return t.length},onSuccess:d=>{o(),r(`Removed ${d} archive${d!==1?"s":""} from project`),e()},onError:()=>{r("Failed to remove from project","error")}}),u=l.isPending||c.isPending;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-md max-h-[80vh] flex flex-col",children:a.jsxs(St,{className:"p-0 flex flex-col min-h-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ma,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:"Assign to Project"})]}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",disabled:u,children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-3 overflow-y-auto min-h-0",children:[a.jsxs("p",{className:"text-sm text-bambu-gray",children:["Assign ",t.length," selected archive",t.length!==1?"s":""," to a project"]}),s?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(ut,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):a.jsxs("div",{className:"space-y-2",children:[a.jsxs("button",{onClick:()=>c.mutate(),disabled:u,className:"w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50",children:[a.jsx("div",{className:"w-8 h-8 rounded-full bg-red-500/20 flex items-center justify-center shrink-0",children:a.jsx(aa,{className:"w-4 h-4 text-red-400"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-white font-medium",children:"Remove from project"}),a.jsx("p",{className:"text-sm text-bambu-gray truncate",children:"Clear project assignment"})]}),c.isPending&&a.jsx(ut,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]}),i&&i.length>0&&a.jsxs("div",{className:"flex items-center gap-2 py-2",children:[a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"}),a.jsx("span",{className:"text-xs text-bambu-gray",children:"or assign to"}),a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"})]}),i?.map(d=>a.jsxs("button",{onClick:()=>l.mutate(d.id),disabled:u,className:"w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50",children:[a.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0",style:{backgroundColor:d.color?`${d.color}20`:"rgb(var(--bambu-green) / 0.2)"},children:a.jsx(Ma,{className:"w-4 h-4",style:{color:d.color||"rgb(var(--bambu-green))"}})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-white font-medium truncate",children:d.name}),a.jsxs("p",{className:"text-sm text-bambu-gray truncate",children:[d.archive_count," archive",d.archive_count!==1?"s":"",d.status&&` • ${d.status}`]})]}),l.isPending&&l.variables===d.id&&a.jsx(ut,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]},d.id)),(!i||i.length===0)&&a.jsx("p",{className:"text-center text-bambu-gray py-4",children:"No projects yet. Create one from the Projects page."})]})]}),a.jsx("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary shrink-0",children:a.jsx(Te,{variant:"secondary",onClick:e,className:"flex-1",disabled:u,children:"Cancel"})})]})})})}function N8e(t,e){return new Date(t,e+1,0).getDate()}function M8e(t,e){return new Date(t,e,1).getDay()}const E8e=["January","February","March","April","May","June","July","August","September","October","November","December"],T8e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function C8e({archives:t,onArchiveClick:e,highlightedArchiveId:n}){const r=new Date,[i,s]=w.useState(r.getMonth()),[o,l]=w.useState(r.getFullYear()),[c,u]=w.useState(null),[d,f]=w.useState(null),m=w.useMemo(()=>{const E=new Map;return t.forEach(k=>{const C=wi(k.completed_at||k.created_at)||new Date,D=`${C.getFullYear()}-${String(C.getMonth()+1).padStart(2,"0")}-${String(C.getDate()).padStart(2,"0")}`,A=E.get(D)||[];A.push(k),E.set(D,A)}),E},[t]),g=N8e(o,i),x=M8e(o,i),y=()=>{i===0?(s(11),l(o-1)):s(i-1)},b=()=>{i===11?(s(0),l(o+1)):s(i+1)},v=()=>{s(r.getMonth()),l(r.getFullYear())},N=[];for(let E=0;E<x;E++)N.push(null);for(let E=1;E<=g;E++)N.push(E);const S=c?m.get(c)||[]:[],T=E=>{E!==c&&f(null),u(E)};return a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("button",{onClick:y,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Vd,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white",children:[E8e[i]," ",o]}),a.jsx("button",{onClick:v,className:"px-2 py-1 text-xs bg-bambu-dark-tertiary hover:bg-bambu-green/20 text-bambu-gray hover:text-white rounded transition-colors",children:"Today"})]}),a.jsx("button",{onClick:b,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Ms,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:T8e.map(E=>a.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:E},E))}),a.jsx("div",{className:"grid grid-cols-7 gap-1",children:N.map((E,k)=>{if(E===null)return a.jsx("div",{className:"aspect-square"},`empty-${k}`);const C=`${o}-${String(i+1).padStart(2,"0")}-${String(E).padStart(2,"0")}`,D=m.get(C)||[],A=D.length>0,R=E===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),F=C===c,O=D.filter(j=>j.status==="completed").length,q=D.filter(j=>j.status==="failed").length;return a.jsxs("button",{onClick:()=>T(F?null:C),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${F?"bg-bambu-green text-white":R?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":A?"bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white":"hover:bg-bambu-dark-tertiary/50 text-bambu-gray"}`,children:[a.jsx("span",{className:`text-sm font-medium ${R&&!F?"text-bambu-green":""}`,children:E}),A&&a.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[a.jsx("div",{className:`w-2 h-2 rounded-full ${q>0&&O===0?"bg-red-400":q>0?"bg-yellow-400":"bg-green-400"}`}),a.jsx("span",{className:"text-xs font-medium",children:D.length})]})]},E)})}),a.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(E=>{const k=new Date(E.completed_at||E.created_at);return k.getMonth()===i&&k.getFullYear()===o}).length}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(E=>{const k=new Date(E.completed_at||E.created_at);return k.getMonth()===i&&k.getFullYear()===o&&E.status==="completed"}).length}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(E=>{const k=new Date(E.completed_at||E.created_at);return k.getMonth()===i&&k.getFullYear()===o&&E.status==="failed"}).length}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),a.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:c?a.jsxs(a.Fragment,{children:[a.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:new Date(c+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),S.length>0?a.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:S.map(E=>{const k=E.id===d||E.id===n;return a.jsxs("button",{onClick:()=>{f(E.id),e?.(E)},className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${k?"":"hover:bg-bambu-dark-tertiary"}`,style:k?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,children:[E.thumbnail_path?a.jsx("img",{src:he.getArchiveThumbnail(E.id),alt:"",className:"w-12 h-12 rounded object-cover"}):a.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:a.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:E.print_name||E.filename}),a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:E.status==="failed"?"text-red-400":"text-green-400",children:E.status==="failed"?"Failed":"Completed"}),E.filament_color&&a.jsx("div",{className:"flex gap-0.5",children:E.filament_color.split(",").map((C,D)=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:C}},D))})]})]})]},E.id)})}):a.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):a.jsx("div",{className:"text-center py-8",children:a.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function uee({archiveId:t,archiveName:e,onClose:n}){const r=he.getArchiveQRCodeUrl(t,300);w.useEffect(()=>{const s=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]);const i=()=>{const s=document.createElement("a");s.href=r,s.download=`${e}_qrcode.png`,s.click()};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:s=>s.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),a.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-6 flex flex-col items-center",children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),a.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:a.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),a.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),a.jsxs(Te,{onClick:i,className:"w-full",children:[a.jsx(Gr,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function dee({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[s,o]=w.useState(0),[l,c]=w.useState(!1);if(w.useEffect(()=>{const g=x=>{x.key==="Escape"&&r(),x.key==="ArrowLeft"&&o(y=>Math.max(0,y-1)),x.key==="ArrowRight"&&o(y=>Math.min(n.length-1,y+1))};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[r,n.length]),w.useEffect(()=>{s>=n.length&&o(Math.max(0,n.length-1))},[n.length,s]),n.length===0)return r(),null;const u=n[s],d=he.getArchivePhotoUrl(t,u),f=()=>{const g=document.createElement("a");g.href=d,g.download=`${e}_photo_${s+1}.jpg`,g.click()},m=()=>{i&&c(!0)};return a.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[a.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:g=>g.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",s+1," of ",n.length]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Te,{variant:"secondary",size:"sm",onClick:f,children:[a.jsx(Gr,{className:"w-4 h-4"}),"Download"]}),i&&a.jsx(Te,{variant:"secondary",size:"sm",onClick:m,className:"text-red-400 hover:text-red-300",children:a.jsx(on,{className:"w-4 h-4"})}),a.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ot,{className:"w-6 h-6"})})]})]}),a.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[s>0&&a.jsx("button",{onClick:()=>o(g=>g-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:a.jsx(Vd,{className:"w-8 h-8 text-white"})}),a.jsx("img",{src:d,alt:`Photo ${s+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),s<n.length-1&&a.jsx("button",{onClick:()=>o(g=>g+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:a.jsx(Ms,{className:"w-8 h-8 text-white"})})]}),n.length>1&&a.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((g,x)=>a.jsx("button",{onClick:()=>o(x),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${x===s?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:a.jsx("img",{src:he.getArchivePhotoUrl(t,g),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},g))})]}),l&&a.jsx(Hn,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function ya(t){this.content=t}ya.prototype={constructor:ya,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),s=r.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new ya(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new ya(n)},addToStart:function(t,e){return new ya([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new ya(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(s==-1?i.length:s,0,e,n),new ya(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=ya.from(t),t.size?new ya(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=ya.from(t),t.size?new ya(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=ya.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}};ya.from=function(t){if(t instanceof ya)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new ya(e)};function hee(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)n++;return n}if(i.content.size||s.content.size){let o=hee(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function fee(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let o=t.child(--i),l=e.child(--s),c=o.nodeSize;if(o==l){n-=c,r-=c;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let u=0,d=Math.min(o.text.length,l.text.length);for(;u<d&&o.text[o.text.length-u-1]==l.text[l.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let u=fee(o.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class Nt{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,s){for(let o=0,l=0;l<n;o++){let c=this.content[o],u=l+c.nodeSize;if(u>e&&r(c,i+l,s||null,o)!==!1&&c.content.size){let d=l+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,n-d),r,i+d)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",o=!0;return this.nodesBetween(e,n,(l,c)=>{let u=l.isText?l.text.slice(Math.max(e,c)-c,n-c):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=u},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new Nt(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let s=0,o=0;o<n;s++){let l=this.content[s],c=o+l.nodeSize;c>e&&((o<e||c>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),i+=l.nodeSize),o=c}return new Nt(r,i)}cutByIndex(e,n){return e==n?Nt.empty:e==0&&n==this.content.length?this:new Nt(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new Nt(i,s)}addToStart(e){return new Nt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Nt(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 hee(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return fee(this,e,n,r)}findIndex(e){if(e==0)return M1(0,e);if(e==this.size)return M1(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),s=r+i.nodeSize;if(s>=e)return s==e?M1(n+1,s):M1(n,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return Nt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Nt(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Nt.empty;let n,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(n||(n=e.slice(0,i)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new Nt(n||e,r)}static from(e){if(!e)return Nt.empty;if(e instanceof Nt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Nt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Nt.empty=new Nt([],0);const Hk={index:0,offset:0};function M1(t,e){return Hk.index=t,Hk.offset=e,Hk}function IS(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(!IS(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!IS(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Nr=class oR{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&IS(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 oR.none;if(e instanceof oR)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Nr.none=[];class FS extends Error{}class Ft{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=pee(this.content,e+this.openStart,n);return r&&new Ft(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Ft(mee(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 Ft.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 Ft(Nt.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new Ft(e,r,i)}}Ft.empty=new Ft(Nt.empty,0,0);function mee(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(i==e||s.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(mee(s.content,e-i-1,n-i-1)))}function pee(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),o=t.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=pee(o.content,e-s-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function A8e(t,e,n){if(n.openStart>t.depth)throw new FS("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new FS("Inconsistent open depths");return gee(t,e,n,0)}function gee(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=gee(t,e,n,r+1);return s.copy(s.content.replaceChild(i,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,l=o.content;return Tf(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=k8e(n,t);return Tf(s,bee(t,o,l,e,r))}else return Tf(s,US(t,e,r))}function xee(t,e){if(!e.type.compatibleContent(t.type))throw new FS("Cannot join "+e.type.name+" onto "+t.type.name)}function lR(t,e,n){let r=t.node(n);return xee(r,e.node(n)),r}function Ef(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 Yb(t,e,n,r){let i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(Ef(t.nodeAfter,r),s++));for(let l=s;l<o;l++)Ef(i.child(l),r);e&&e.depth==n&&e.textOffset&&Ef(e.nodeBefore,r)}function Tf(t,e){return t.type.checkContent(e),t.copy(e)}function bee(t,e,n,r,i){let s=t.depth>i&&lR(t,e,i+1),o=r.depth>i&&lR(n,r,i+1),l=[];return Yb(null,t,i,l),s&&o&&e.index(i)==n.index(i)?(xee(s,o),Ef(Tf(s,bee(t,e,n,r,i+1)),l)):(s&&Ef(Tf(s,US(t,e,i+1)),l),Yb(e,n,i,l),o&&Ef(Tf(o,US(n,r,i+1)),l)),Yb(r,null,i,l),new Nt(l)}function US(t,e,n){let r=[];if(Yb(null,t,n,r),t.depth>n){let i=lR(t,e,n+1);Ef(Tf(i,US(t,e,n+1)),r)}return Yb(e,null,n,r),new Nt(r)}function k8e(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(Nt.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class q0{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Nr.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new zS(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,s=n;for(let o=e;;){let{index:l,offset:c}=o.content.findIndex(s),u=s-c;if(r.push(o,l,i+c),!u||(o=o.child(l),o.isText))break;s=u-1,i+=c+1}return new q0(n,r,s)}static resolveCached(e,n){let r=x9.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==n)return o}else x9.set(e,r=new j8e);let i=r.elts[r.i]=q0.resolve(e,n);return r.i=(r.i+1)%P8e,i}}class j8e{constructor(){this.elts=[],this.i=0}}const P8e=12,x9=new WeakMap;class zS{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 R8e=Object.create(null);let zd=class cR{constructor(e,n,r,i=Nr.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||Nt.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&&IS(this.attrs,n||e.defaultAttrs||R8e)&&Nr.sameSet(this.marks,r||Nr.none)}copy(e=null){return e==this.content?this:new cR(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new cR(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 Ft.empty;let i=this.resolve(e),s=this.resolve(n),o=r?0:i.sharedDepth(n),l=i.start(o),u=i.node(o).content.cut(i.pos-l,s.pos-l);return new Ft(u,i.depth-o,s.depth-o)}replace(e,n,r){return A8e(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 q0.resolveCached(this,e)}resolveNoCache(e){return q0.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),yee(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=Nt.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let c=i;c<s;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Nr.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(!Nr.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=Nt.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};zd.prototype.text=void 0;class BS extends zd{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):yee(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 BS(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new BS(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 yee(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Qf{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new D8e(e,n);if(r.next==null)return Qf.empty;let i=vee(r);r.next&&r.err("Unexpected trailing text");let s=B8e(z8e(i));return $8e(s,r),s}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let s=n;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function s(o,l){let c=o.matchFragment(e,r);if(c&&(!n||c.validEnd))return Nt.from(l.map(u=>u.createAndFill()));for(let u=0;u<o.next.length;u++){let{type:d,next:f}=o.next[u];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let m=s(f,l.concat(d));if(m)return m}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:c}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||c.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
- `)}}Qf.empty=new Qf(!0);class D8e{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function vee(t){let e=[];do e.push(O8e(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function O8e(t){let e=[];do e.push(L8e(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function L8e(t){let e=U8e(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=I8e(t,e);else break;return e}function b9(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function I8e(t,e){let n=b9(t),r=n;return t.eat(",")&&(t.next!="}"?r=b9(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function F8e(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let o=n[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function U8e(t){if(t.eat("(")){let e=vee(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=F8e(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 z8e(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,c){let u={term:c,to:l};return e[o].push(u),u}function i(o,l){o.forEach(c=>c.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((c,u)=>c.concat(s(u,l)),[]);if(o.type=="seq")for(let c=0;;c++){let u=s(o.exprs[c],l);if(c==o.exprs.length-1)return u;i(u,l=n())}else if(o.type=="star"){let c=n();return r(l,c),i(s(o.expr,c),c),[r(c)]}else if(o.type=="plus"){let c=n();return i(s(o.expr,l),c),i(s(o.expr,c),c),[r(c)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let c=l;for(let u=0;u<o.min;u++){let d=n();i(s(o.expr,c),d),c=d}if(o.max==-1)i(s(o.expr,c),c);else for(let u=o.min;u<o.max;u++){let d=n();r(c,d),i(s(o.expr,c),d),c=d}return[r(c)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function _ee(t,e){return e-t}function y9(t,e){let n=[];return r(e),n.sort(_ee);function r(i){let s=t[i];if(s.length==1&&!s[0].term)return r(s[0].to);n.push(i);for(let o=0;o<s.length;o++){let{term:l,to:c}=s[o];!l&&n.indexOf(c)==-1&&r(c)}}}function B8e(t){let e=Object.create(null);return n(y9(t,0));function n(r){let i=[];r.forEach(o=>{t[o].forEach(({term:l,to:c})=>{if(!l)return;let u;for(let d=0;d<i.length;d++)i[d][0]==l&&(u=i[d][1]);y9(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let s=e[r.join(",")]=new Qf(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(_ee);s.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return s}}function $8e(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:c,next:u}=i.next[l];o.push(c.name),s&&!(c.isText||c.hasRequiredAttrs())&&(s=!1),r.indexOf(u)==-1&&r.push(u)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function wee(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 See(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let s=t[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function Nee(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let s=t[i];s.validate&&s.validate(e[i])}}function Mee(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new V8e(t,r,e[r]);return n}let v9=class Eee{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=Mee(e,r.attrs),this.defaultAttrs=wee(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==Qf.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:See(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new zd(this,this.computeAttrs(e),Nt.from(n),Nr.setFrom(r))}createChecked(e=null,n,r){return n=Nt.from(n),this.checkContent(n),new zd(this,this.computeAttrs(e),n,Nr.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=Nt.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(Nt.empty,!0);return s?new zd(this,e,n.append(s),Nr.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){Nee(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:Nr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,o)=>r[s]=new Eee(s,n,o));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function H8e(t,e,n){let r=n.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${s}`)}}class V8e{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?H8e(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class ZN{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Mee(e,i.attrs),this.excluded=null;let s=wee(this.attrs);this.instance=s?new Nr(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Nr(this,See(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new ZN(s,i++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){Nee(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Tee{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=ya.from(e.nodes),n.marks=ya.from(e.marks||{}),this.nodes=v9.compile(this.spec.nodes,this),this.marks=ZN.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=Qf.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?_9(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:_9(this,o.split(" "))}this.nodeFromJSON=i=>zd.fromJSON(this,i),this.markFromJSON=i=>Nr.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 v9){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 BS(r,r.defaultAttrs,e,Nr.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 _9(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],o=s;if(s)n.push(s);else for(let l in t.marks){let c=t.marks[l];(i=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=c)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function G8e(t){return t.tag!=null}function q8e(t){return t.style!=null}let Qb=class uR{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(G8e(i))this.tags.push(i);else if(q8e(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,n={}){let r=new S9(this,n,!1);return r.addAll(e,Nr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new S9(this,n,!0);return r.addAll(e,Nr.none,n.from,n.to),Ft.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(X8e(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,n,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let c=o.getAttrs(n);if(c===!1)continue;o.attrs=c||void 0}return o}}}static schemaRules(e){let n=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<s)break}n.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=N9(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=N9(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new uR(e,uR.schemaRules(e)))}};const Cee={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},W8e={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Aee={ol:!0,ul:!0},W0=1,dR=2,Zb=4;function w9(t,e,n){return e!=null?(e?W0:0)|(e==="full"?dR:0):t&&t.whitespace=="pre"?W0|dR:n&~Zb}class E1{constructor(e,n,r,i,s,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=Nr.none,this.match=s||(o&Zb?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Nt.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&W0)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let n=Nt.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Nt.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&&!Cee.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class S9{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,s,o=w9(null,n.preserveWhitespace,0)|(r?Zb:0);i?s=new E1(i.type,i.attrs,Nr.none,!0,n.topMatch||i.type.contentMatch,o):r?s=new E1(null,null,Nr.none,!0,null,o):s=new E1(e.schema.topNodeType,null,Nr.none,!0,null,o),this.nodes=[s],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,s=i.options&dR?"full":this.localPreserveWS||(i.options&W0)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
- `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[c]&&this.insertNode(o.text(l[c]),n,!/\S/.test(l[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],c=e.previousSibling;(!l||c&&c.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Aee.hasOwnProperty(o)&&this.parser.normalizeLists&&K8e(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:W8e.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(e=c.skip);let u,d=this.needsBlock;if(Cee.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),u=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=c&&c.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),u&&this.sync(s),this.needsBlock=d}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,c,u,c.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
- `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let l=void 0;;){let c=this.parser.matchStyle(s,o,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(u=>!c.clearMark(u)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return n}addElementByRule(e,n,r,i){let s,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let c=this.enter(o,n.attrs||null,r,n.preserveWhitespace);c&&(s=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=e;typeof n.contentElement=="string"?c=e.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(e):n.contentElement&&(c=n.contentElement),this.findAround(e,c,!0),this.addAll(c,r),this.findAround(e,c,!1)}s&&this.sync(l)&&this.open--}addAll(e,n,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,n);this.findAtPoint(e,s)}findPlace(e,n,r){let i,s;for(let o=this.open,l=0;o>=0;o--){let c=this.nodes[o],u=c.findWrapping(e);if(u&&(!i||i.length>u.length+l)&&(i=u,s=c,!u.length))break;if(c.solid){if(r)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)n=this.enterInner(i[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(n=this.enterInner(s,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=Nr.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):M9(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,n,r,i){let s=this.findPlace(e.create(n),r,!1);return s&&(s=this.enterInner(e,n,r,!0,i)),s}enterInner(e,n,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=w9(e,s,o.options);o.options&Zb&&o.content.length==0&&(l|=Zb);let c=Nr.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):M9(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new E1(e,n,c,i,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=W0)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(l,c)=>{for(;l>=0;l--){let u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;c>=s;c--)if(o(l-1,c))return!0;return!1}else{let d=c>0||c==0&&i?this.nodes[c].type:r&&c>=s?r.node(c-s).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;c--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function K8e(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Aee.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function X8e(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function N9(t){let e={};for(let n in t)e[n]=t[n];return e}function M9(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=l=>{s.push(l);for(let c=0;c<l.edgeCount;c++){let{type:u,next:d}=l.edge(c);if(u==e||s.indexOf(d)<0&&o(d))return!0}};if(o(i.contentMatch))return!0}}class cm{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Vk(n).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,c=0;for(;l<s.length&&c<o.marks.length;){let u=o.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(s[l][0])||u.type.spec.spanning===!1)break;l++,c++}for(;l<s.length;)i=s.pop()[1];for(;c<o.marks.length;){let u=o.marks[c++],d=this.serializeMark(u,o.isInline,n);d&&(s.push([u,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=ow(Vk(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&ow(Vk(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return ow(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new cm(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=E9(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return E9(e.marks)}}function E9(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Vk(t){return t.document||window.document}const T9=new WeakMap;function Y8e(t){let e=T9.get(t);return e===void 0&&T9.set(t,e=Q8e(t)),e}function Q8e(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 ow(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=Y8e(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(n=i.slice(0,o),i=i.slice(o+1));let l,c=n?t.createElementNS(n,i):t.createElement(i),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let m=f.indexOf(" ");m>0?c.setAttributeNS(f.slice(0,m),f.slice(m+1),u[f]):f=="style"&&c.style?c.style.cssText=u[f]:c.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let m=e[f];if(m===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:g,contentDOM:x}=ow(t,m,n,r);if(c.appendChild(g),x){if(l)throw new RangeError("Multiple content holes");l=x}}}return{dom:c,contentDOM:l}}const kee=65535,jee=Math.pow(2,16);function Z8e(t,e){return t+e*jee}function C9(t){return t&kee}function J8e(t){return(t-(t&kee))/jee}const Pee=1,Ree=2,lw=4,Dee=8;class hR{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Dee)>0}get deletedBefore(){return(this.delInfo&(Pee|lw))>0}get deletedAfter(){return(this.delInfo&(Ree|lw))>0}get deletedAcross(){return(this.delInfo&lw)>0}}class Gs{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Gs.empty)return Gs.empty}recover(e){let n=0,r=C9(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+J8e(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?i:0);if(c>e)break;let u=this.ranges[l+s],d=this.ranges[l+o],f=c+u;if(e<=f){let m=u?e==c?-1:e==f?1:n:n,g=c+i+(m<0?0:d);if(r)return g;let x=e==(n<0?c:f)?null:Z8e(l/3,e-c),y=e==c?Ree:e==f?Pee:lw;return(n<0?e!=c:e!=f)&&(y|=Dee),new hR(g,y,x)}i+=d-u}return r?e+i:new hR(e+i,0,null)}touches(e,n){let r=0,i=C9(n),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;let u=this.ranges[l+s],d=c+u;if(e<=d&&l==i*3)return!0;r+=this.ranges[l+o]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),c=o+(this.inverted?0:s),u=this.ranges[i+n],d=this.ranges[i+r];e(l,l+u,c,c+d),s+=d-u}}invert(){return new Gs(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Gs.empty:new Gs(e<0?[0,-e,0]:[0,0,e])}}Gs.empty=new Gs([]);class K0{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 K0(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 K0;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,n);if(l.recover!=null){let c=this.getMirror(s);if(c!=null&&c>s&&c<this.to){s=c,e=this._maps[c].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new hR(e,i,null)}}const Gk=Object.create(null);class $a{getMap(){return Gs.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Gk[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 Gk)throw new RangeError("Duplicate use of step JSON ID "+e);return Gk[e]=n,n.prototype.jsonID=e,n}}class Mi{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Mi(e,null)}static fail(e){return new Mi(null,e)}static fromReplace(e,n,r,i){try{return Mi.ok(e.replace(n,r,i))}catch(s){if(s instanceof FS)return Mi.fail(s.message);throw s}}}function YO(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(YO(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return Nt.fromArray(r)}class Cd extends $a{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new Ft(YO(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return Mi.fromReplace(e,this.from,this.to,s)}invert(){return new al(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 Cd(n.pos,r.pos,this.mark)}merge(e){return e instanceof Cd&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Cd(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 Cd(n.from,n.to,e.markFromJSON(n.mark))}}$a.jsonID("addMark",Cd);class al extends $a{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 Ft(YO(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Mi.fromReplace(e,this.from,this.to,r)}invert(){return new Cd(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 al(n.pos,r.pos,this.mark)}merge(e){return e instanceof al&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new al(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 al(n.from,n.to,e.markFromJSON(n.mark))}}$a.jsonID("removeMark",al);class Ad extends $a{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Mi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Mi.fromReplace(e,this.pos,this.pos+1,new Ft(Nt.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 Ad(this.pos,n.marks[i]);return new Ad(this.pos,this.mark)}}return new Zf(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ad(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 Ad(n.pos,e.markFromJSON(n.mark))}}$a.jsonID("addNodeMark",Ad);class Zf extends $a{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Mi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Mi.fromReplace(e,this.pos,this.pos+1,new Ft(Nt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Ad(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Zf(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 Zf(n.pos,e.markFromJSON(n.mark))}}$a.jsonID("removeNodeMark",Zf);class ta extends $a{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&fR(e,this.from,this.to)?Mi.fail("Structure replace would overwrite content"):Mi.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Gs([this.from,this.to-this.from,this.slice.size])}invert(e){return new ta(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 ta(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ta)||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?Ft.empty:new Ft(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ta(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?Ft.empty:new Ft(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ta(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 ta(n.from,n.to,Ft.fromJSON(e,n.slice),!!n.structure)}}$a.jsonID("replace",ta);class sa extends $a{constructor(e,n,r,i,s,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(fR(e,this.from,this.gapFrom)||fR(e,this.gapTo,this.to)))return Mi.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Mi.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Mi.fromReplace(e,this.from,this.to,r):Mi.fail("Content does not fit in gap")}getMap(){return new Gs([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 sa(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||s>r.pos?null:new sa(n.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new sa(n.from,n.to,n.gapFrom,n.gapTo,Ft.fromJSON(e,n.slice),n.insert,!!n.structure)}}$a.jsonID("replaceAround",sa);function fR(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function e6e(t,e,n,r){let i=[],s=[],o,l;t.doc.nodesBetween(e,n,(c,u,d)=>{if(!c.isInline)return;let f=c.marks;if(!r.isInSet(f)&&d.type.allowsMarkType(r.type)){let m=Math.max(u,e),g=Math.min(u+c.nodeSize,n),x=r.addToSet(f);for(let y=0;y<f.length;y++)f[y].isInSet(x)||(o&&o.to==m&&o.mark.eq(f[y])?o.to=g:i.push(o=new al(m,g,f[y])));l&&l.to==m?l.to=g:s.push(l=new Cd(m,g,r))}}),i.forEach(c=>t.step(c)),s.forEach(c=>t.step(c))}function t6e(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;s++;let c=null;if(r instanceof ZN){let u=o.marks,d;for(;d=r.isInSet(u);)(c||(c=[])).push(d),u=d.removeFromSet(u)}else r?r.isInSet(o.marks)&&(c=[r]):c=o.marks;if(c&&c.length){let u=Math.min(l+o.nodeSize,n);for(let d=0;d<c.length;d++){let f=c[d],m;for(let g=0;g<i.length;g++){let x=i[g];x.step==s-1&&f.eq(i[g].style)&&(m=x)}m?(m.to=u,m.step=s):i.push({style:f,from:Math.max(l,e),to:u,step:s})}}}),i.forEach(o=>t.step(new al(o.from,o.to,o.style)))}function QO(t,e,n,r=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),o=[],l=e+1;for(let c=0;c<s.childCount;c++){let u=s.child(c),d=l+u.nodeSize,f=r.matchType(u.type);if(!f)o.push(new ta(l,d,Ft.empty));else{r=f;for(let m=0;m<u.marks.length;m++)n.allowsMarkType(u.marks[m].type)||t.step(new al(l,d,u.marks[m]));if(i&&u.isText&&n.whitespace!="pre"){let m,g=/\r?\n|\r/g,x;for(;m=g.exec(u.text);)x||(x=new Ft(Nt.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new ta(l+m.index,l+m.index+m[0].length,x))}}l=d}if(!r.validEnd){let c=r.fillBefore(Nt.empty,!0);t.replace(l,l,new Ft(c,0,0))}for(let c=o.length-1;c>=0;c--)t.step(o[c])}function n6e(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function ax(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,s=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+i,c=t.$to.indexAfter(r)-s;if(r<t.depth&&o.canReplace(l,c,n))return r;if(r==0||o.type.spec.isolating||!n6e(o,l,c))break;l&&(i=1),c<o.childCount&&(s=1)}return null}function r6e(t,e,n){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),c=o,u=l,d=Nt.empty,f=0;for(let x=s,y=!1;x>n;x--)y||r.index(x)>0?(y=!0,d=Nt.from(r.node(x).copy(d)),f++):c--;let m=Nt.empty,g=0;for(let x=s,y=!1;x>n;x--)y||i.after(x+1)<i.end(x)?(y=!0,m=Nt.from(i.node(x).copy(m)),g++):u++;t.step(new sa(c,u,o,l,new Ft(d.append(m),f,g),d.size-f,!0))}function ZO(t,e,n=null,r=t){let i=i6e(t,e),s=i&&a6e(r,e);return s?i.map(A9).concat({type:e,attrs:n}).concat(s.map(A9)):null}function A9(t){return{type:t,attrs:null}}function i6e(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return n.canReplaceWith(r,i,o)?s:null}function a6e(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let c=(o.length?o[o.length-1]:e).contentMatch;for(let u=r;c&&u<i;u++)c=c.matchType(n.child(u).type);return!c||!c.validEnd?null:o}function s6e(t,e,n){let r=Nt.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let l=n[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=Nt.from(n[o].type.create(n[o].attrs,r))}let i=e.start,s=e.end;t.step(new sa(i,s,i,s,new Ft(r,0,0),n.length,!0))}function o6e(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let c=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,c)&&l6e(t.doc,t.mapping.slice(s).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let g=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);g&&!x?u=!1:!g&&x&&(u=!0)}u===!1&&Lee(t,o,l,s),QO(t,t.mapping.slice(s).map(l,1),r,void 0,u===null);let d=t.mapping.slice(s),f=d.map(l,1),m=d.map(l+o.nodeSize,1);return t.step(new sa(f,m,f+1,m-1,new Ft(Nt.from(r.create(c,null,o.marks)),0,0),1,!0)),u===!0&&Oee(t,o,l,s),!1}})}function Oee(t,e,n,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let c=t.mapping.slice(r).map(n+1+s+o.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function Lee(t,e,n,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+s);t.replaceWith(o,o+1,e.type.schema.text(`
- `))}})}function l6e(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function c6e(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new sa(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new Ft(Nt.from(o),0,0),1,!0))}function iu(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,d=n-2;u>s;u--,d--){let f=i.node(u),m=i.index(u);if(f.type.spec.isolating)return!1;let g=f.content.cutByIndex(m,f.childCount),x=r&&r[d+1];x&&(g=g.replaceChild(0,x.type.create(x.attrs)));let y=r&&r[d]||f;if(!f.canReplace(m+1,f.childCount)||!y.type.validContent(g))return!1}let l=i.indexAfter(s),c=r&&r[0];return i.node(s).canReplaceWith(l,l,c?c.type:i.node(s+1).type)}function u6e(t,e,n=1,r){let i=t.doc.resolve(e),s=Nt.empty,o=Nt.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){s=Nt.from(i.node(l).copy(s));let d=r&&r[u];o=Nt.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}t.step(new ta(e,e,new Ft(s.append(o),n,n),!0))}function mh(t,e){let n=t.resolve(e),r=n.index();return Iee(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function d6e(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==r?t.type.schema.nodes.text:s.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(s.marks))return!1}return n.validEnd}function Iee(t,e){return!!(t&&e&&!t.isLeaf&&d6e(t,e))}function JN(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let s,o,l=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):n>0?(s=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(s=r.node(i).maybeChild(l-1),o=r.node(i+1)),s&&!s.isTextblock&&Iee(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function h6e(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,s=t.doc.resolve(e-n),o=s.node().type;if(i&&o.inlineContent){let d=o.whitespace=="pre",f=!!o.contentMatch.matchType(i);d&&!f?r=!1:!d&&f&&(r=!0)}let l=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);Lee(t,d.node(),d.before(),l)}o.inlineContent&&QO(t,e+n-1,o,s.node().contentMatchAt(s.index()),r==null);let c=t.mapping.slice(l),u=c.map(e-n);if(t.step(new ta(u,c.map(e+n,-1),Ft.empty,!0)),r===!0){let d=t.doc.resolve(u);Oee(t,d.node(),d.before(),t.steps.length)}return t}function f6e(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,n))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,n))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function Fee(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let s=0;s<n.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,c=r.index(o)+(l>0?1:0),u=r.node(o),d=!1;if(s==1)d=u.canReplace(c,c,i);else{let f=u.contentMatchAt(c).findWrapping(i.firstChild.type);d=f&&u.canReplaceWith(c,c,f[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function eM(t,e,n=e,r=Ft.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return Uee(i,s,r)?new ta(e,n,r):new m6e(i,s,r).fit()}function Uee(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class m6e{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Nt.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=Nt.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let c=new Ft(s,o,l);return e>-1?new sa(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new ta(r.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=n.firstChild;if(n.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=qk(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:u}=this.frontier[l],d,f=null;if(n==1&&(o?u.matchType(o.type)||(f=u.fillBefore(Nt.from(o),!1)):s&&c.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:f};if(n==2&&o&&(d=u.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:d};if(s&&u.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=qk(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Ft(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=qk(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new Ft(Ob(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new Ft(Ob(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let y=0;y<s.length;y++)this.openFrontierNode(s[y]);let o=this.unplaced,l=r?r.content:o.content,c=o.openStart-e,u=0,d=[],{match:f,type:m}=this.frontier[n];if(i){for(let y=0;y<i.childCount;y++)d.push(i.child(y));f=f.matchFragment(i)}let g=l.size+e-(o.content.size-o.openEnd);for(;u<l.childCount;){let y=l.child(u),b=f.matchType(y.type);if(!b)break;u++,(u>1||c==0||y.content.size)&&(f=b,d.push(zee(y.mark(m.allowedMarks(y.marks)),u==1?c:0,u==l.childCount?g:-1)))}let x=u==l.childCount;x||(g=-1),this.placed=Lb(this.placed,n,Nt.from(d)),this.frontier[n].match=f,x&&g<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,b=l;y<g;y++){let v=b.lastChild;this.frontier.push({type:v.type,match:v.contentMatchAt(v.childCount)}),b=v.content}this.unplaced=x?e==0?Ft.empty:new Ft(Ob(o.content,e-1,1),e-1,g<0?o.openEnd:e-1):new Ft(Ob(o.content,e,u),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Wk(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],s=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=Wk(e,n,i,r,s);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=Wk(e,l,u,c,!0);if(!d||d.childCount)continue e}return{depth:n,fit:o,move:s?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Lb(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Lb(this.placed,this.depth,Nt.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Nt.empty,!0);n.childCount&&(this.placed=Lb(this.placed,this.frontier.length,n))}}function Ob(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Ob(t.firstChild.content,e-1,n)))}function Lb(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Lb(t.lastChild.content,e-1,n)))}function qk(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function zee(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,zee(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(Nt.empty,!0)))),t.copy(r)}function Wk(t,e,n,r,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!p6e(n,s.content,o)?l:null}function p6e(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function g6e(t){return t.spec.defining||t.spec.definingForContent}function x6e(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(Uee(i,s,r))return t.step(new ta(e,n,r));let o=$ee(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let m=i.depth,g=i.pos-1;m>0;m--,g--){let x=i.node(m).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;o.indexOf(m)>-1?l=m:i.before(m)==g&&o.splice(1,0,-m)}let c=o.indexOf(l),u=[],d=r.openStart;for(let m=r.content,g=0;;g++){let x=m.firstChild;if(u.push(x),g==r.openStart)break;m=x.content}for(let m=d-1;m>=0;m--){let g=u[m],x=g6e(g.type);if(x&&!g.sameMarkup(i.node(Math.abs(l)-1)))d=m;else if(x||!g.type.isTextblock)break}for(let m=r.openStart;m>=0;m--){let g=(m+d+1)%(r.openStart+1),x=u[g];if(x)for(let y=0;y<o.length;y++){let b=o[(y+c)%o.length],v=!0;b<0&&(v=!1,b=-b);let N=i.node(b-1),S=i.index(b-1);if(N.canReplaceWith(S,S,x.type,x.marks))return t.replace(i.before(b),v?s.after(b):n,new Ft(Bee(r.content,0,r.openStart,g),g,r.openEnd))}}let f=t.steps.length;for(let m=o.length-1;m>=0&&(t.replace(e,n,r),!(t.steps.length>f));m--){let g=o[m];g<0||(e=i.before(g),n=s.after(g))}}function Bee(t,e,n,r,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(Bee(s.content,e+1,n,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(t).append(t);t=o.append(s.matchFragment(o).fillBefore(Nt.empty,!0))}return t}function b6e(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=f6e(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Ft(Nt.from(r),0,0))}function y6e(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=$ee(r,i);for(let o=0;o<s.length;o++){let l=s[o],c=o==s.length-1;if(c&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),i.end(l));if(l>0&&(c||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function $ee(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let s=t.start(i);if(s<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&n.push(i)}return n}class ig extends $a{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 Mi.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return Mi.fromReplace(e,this.pos,this.pos+1,new Ft(Nt.from(i),0,n.isLeaf?0:1))}getMap(){return Gs.empty}invert(e){return new ig(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 ig(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 ig(n.pos,n.attr,n.value)}}$a.jsonID("attr",ig);class X0 extends $a{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 Mi.ok(r)}getMap(){return Gs.empty}invert(e){return new X0(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 X0(n.attr,n.value)}}$a.jsonID("docAttr",X0);let Ag=class extends Error{};Ag=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Ag.prototype=Object.create(Error.prototype);Ag.prototype.constructor=Ag;Ag.prototype.name="TransformError";class Hee{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new K0}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Ag(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=Ft.empty){let i=eM(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Ft(Nt.from(r),0,0))}delete(e,n){return this.replace(e,n,Ft.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return x6e(this,e,n,r),this}replaceRangeWith(e,n,r){return b6e(this,e,n,r),this}deleteRange(e,n){return y6e(this,e,n),this}lift(e,n){return r6e(this,e,n),this}join(e,n=1){return h6e(this,e,n),this}wrap(e,n){return s6e(this,e,n),this}setBlockType(e,n=e,r,i=null){return o6e(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return c6e(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new ig(e,n,r)),this}setDocAttribute(e,n){return this.step(new X0(e,n)),this}addNodeMark(e,n){return this.step(new Ad(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 Nr)n.isInSet(r.marks)&&this.step(new Zf(e,n));else{let i=r.marks,s,o=[];for(;s=n.isInSet(i);)o.push(new Zf(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return u6e(this,e,n,r),this}addMark(e,n,r){return e6e(this,e,n,r),this}removeMark(e,n,r){return t6e(this,e,n,r),this}clearIncompatible(e,n,r){return QO(this,e,n,r),this}}const Kk=Object.create(null);class Mn{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new v6e(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=Ft.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:c,$to:u}=o[l],d=e.mapping.slice(s);e.replaceRange(d.map(c.pos),d.map(u.pos),l?Ft.empty:n),l==0&&P9(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],c=e.mapping.slice(r),u=c.map(o.pos),d=c.map(l.pos);s?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),P9(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new dn(e):Op(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=n<0?Op(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):Op(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Qs(e.node(0))}static atStart(e){return Op(e,e,0,0,1)||new Qs(e)}static atEnd(e){return Op(e,e,e.content.size,e.childCount,-1)||new Qs(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Kk[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 Kk)throw new RangeError("Duplicate use of selection JSON ID "+e);return Kk[e]=n,n.prototype.jsonID=e,n}getBookmark(){return dn.between(this.$anchor,this.$head).getBookmark()}}Mn.prototype.visible=!0;class v6e{constructor(e,n){this.$from=e,this.$to=n}}let k9=!1;function j9(t){!k9&&!t.parent.inlineContent&&(k9=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class dn extends Mn{constructor(e,n=e){j9(e),j9(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 Mn.near(r);let i=e.resolve(n.map(this.anchor));return new dn(i.parent.inlineContent?i:r,r)}replace(e,n=Ft.empty){if(super.replace(e,n),n==Ft.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof dn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new tM(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 dn(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let s=Mn.findFrom(n,r,!0)||Mn.findFrom(n,-r,!0);if(s)n=s.$head;else return Mn.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(Mn.findFrom(e,-r,!0)||Mn.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new dn(e,n)}}Mn.jsonID("text",dn);class tM{constructor(e,n){this.anchor=e,this.head=n}map(e){return new tM(e.map(this.anchor),e.map(this.head))}resolve(e){return dn.between(e.resolve(this.anchor),e.resolve(this.head))}}class Zt extends Mn{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),s=e.resolve(i);return r?Mn.near(s):new Zt(s)}content(){return new Ft(Nt.from(this.node),0,0)}eq(e){return e instanceof Zt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new JO(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Zt(e.resolve(n.anchor))}static create(e,n){return new Zt(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Zt.prototype.visible=!1;Mn.jsonID("node",Zt);class JO{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new tM(r,r):new JO(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Zt.isSelectable(r)?new Zt(n):Mn.near(n)}}class Qs extends Mn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Ft.empty){if(n==Ft.empty){e.delete(0,e.doc.content.size);let r=Mn.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Qs(e)}map(e){return new Qs(e)}eq(e){return e instanceof Qs}getBookmark(){return _6e}}Mn.jsonID("all",Qs);const _6e={map(){return this},resolve(t){return new Qs(t)}};function Op(t,e,n,r,i,s=!1){if(e.inlineContent)return dn.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&Zt.isSelectable(l))return Zt.create(t,n-(i<0?l.nodeSize:0))}else{let c=Op(t,l,n+i,i<0?l.childCount:0,i,s);if(c)return c}n+=l.nodeSize*i}return null}function P9(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof ta||i instanceof sa))return;let s=t.mapping.maps[r],o;s.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(Mn.near(t.doc.resolve(o),n))}const R9=1,T1=2,D9=4;class w6e extends Hee{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|R9)&~T1,this.storedMarks=null,this}get selectionSet(){return(this.updated&R9)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=T1,this}ensureMarks(e){return Nr.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&T1)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~T1,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)||Nr.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(n);s=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,s)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Mn.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|=D9,this}get scrolledIntoView(){return(this.updated&D9)>0}}function O9(t,e){return!e||!t?t:t.bind(e)}class Ib{constructor(e,n,r){this.name=e,this.init=O9(n.init,r),this.apply=O9(n.apply,r)}}const S6e=[new Ib("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Ib("selection",{init(t,e){return t.selection||Mn.atStart(e.doc)},apply(t){return t.selection}}),new Ib("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Ib("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Xk{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=S6e.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 Ib(r.key,r.spec.state,r))})}}class Gp{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let c=i?i[o].n:0,u=i?i[o].state:this,d=c<n.length&&l.spec.appendTransaction.call(l,c?n.slice(c):n,u,r);if(d&&r.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<o?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),s=!0}i&&(i[o]={state:r,n:n.length})}}if(!s)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Gp(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];n[s.name]=s.apply(e,this[s.name],this,n)}return n}get tr(){return new w6e(this)}static create(e){let n=new Xk(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Gp(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 Xk(this.schema,e.plugins),r=n.fields,i=new Gp(n);for(let s=0;s<r.length;s++){let o=r[s].name;i[o]=this.hasOwnProperty(o)?this[o]:r[s].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(n[r]=s.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Xk(e.schema,e.plugins),s=new Gp(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=zd.fromJSON(e.schema,n.doc);else if(o.name=="selection")s.selection=Mn.fromJSON(s.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let c=r[l],u=c.spec.state;if(c.key==o.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){s[o.name]=u.fromJSON.call(c,e,n[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function Vee(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Vee(i,e,{})),n[r]=i}return n}class Qr{constructor(e){this.spec=e,this.props={},e.props&&Vee(e.props,this,this.props),this.key=e.key?e.key.key:Gee("plugin")}getState(e){return e[this.key]}}const Yk=Object.create(null);function Gee(t){return t in Yk?t+"$"+ ++Yk[t]:(Yk[t]=0,t+"$")}class Gi{constructor(e="key"){this.key=Gee(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const eL=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function qee(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Wee=(t,e,n)=>{let r=qee(t,n);if(!r)return!1;let i=tL(r);if(!i){let o=r.blockRange(),l=o&&ax(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(nte(t,i,e,-1))return!0;if(r.parent.content.size==0&&(kg(s,"end")||Zt.isSelectable(s)))for(let o=r.depth;;o--){let l=eM(t.doc,r.before(o),r.after(o),Ft.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(kg(s,"end")?Mn.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):Zt.create(c.doc,i.pos-s.nodeSize)),e(c.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},N6e=(t,e,n)=>{let r=qee(t,n);if(!r)return!1;let i=tL(r);return i?Kee(t,i,e):!1},M6e=(t,e,n)=>{let r=Yee(t,n);if(!r)return!1;let i=nL(r);return i?Kee(t,i,e):!1};function Kee(t,e,n){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let o=e.nodeAfter,l=o,c=e.pos+1;for(;!l.isTextblock;c++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let u=eM(t.doc,s,c,Ft.empty);if(!u||u.from!=s||u instanceof ta&&u.slice.size>=c-s)return!1;if(n){let d=t.tr.step(u);d.setSelection(dn.create(d.doc,s)),n(d.scrollIntoView())}return!0}function kg(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 Xee=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=tL(r)}let o=s&&s.nodeBefore;return!o||!Zt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Zt.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function tL(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 Yee(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Qee=(t,e,n)=>{let r=Yee(t,n);if(!r)return!1;let i=nL(r);if(!i)return!1;let s=i.nodeAfter;if(nte(t,i,e,1))return!0;if(r.parent.content.size==0&&(kg(s,"start")||Zt.isSelectable(s))){let o=eM(t.doc,r.before(),r.after(),Ft.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(kg(s,"start")?Mn.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):Zt.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},Zee=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;s=nL(r)}let o=s&&s.nodeAfter;return!o||!Zt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Zt.create(t.doc,s.pos)).scrollIntoView()),!0)};function nL(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 E6e=(t,e)=>{let n=t.selection,r=n instanceof Zt,i;if(r){if(n.node.isTextblock||!mh(t.doc,n.from))return!1;i=n.from}else if(i=JN(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(Zt.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},T6e=(t,e)=>{let n=t.selection,r;if(n instanceof Zt){if(n.node.isTextblock||!mh(t.doc,n.to))return!1;r=n.to}else if(r=JN(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},C6e=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&ax(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},Jee=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
- `).scrollIntoView()),!0)};function rL(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 A6e=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),o=rL(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=n.after(),c=t.tr.replaceWith(l,l,o.createAndFill());c.setSelection(Mn.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},ete=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Qs||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=rL(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(o,s.createAndFill());l.setSelection(dn.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},tte=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let s=n.before();if(iu(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&ax(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function k6e(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Zt&&e.selection.node.isBlock)return!r.parentOffset||!iu(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,l,c=!1,u=!1;for(let g=r.depth;;g--)if(r.node(g).isBlock){c=r.end(g)==r.pos+(r.depth-g),u=r.start(g)==r.pos-(r.depth-g),l=rL(r.node(g-1).contentMatchAt(r.indexAfter(g-1))),s.unshift(c&&l?{type:l}:null),o=g;break}else{if(g==1)return!1;s.unshift(null)}let d=e.tr;(e.selection instanceof dn||e.selection instanceof Qs)&&d.deleteSelection();let f=d.mapping.map(r.pos),m=iu(d.doc,f,s.length,s);if(m||(s[0]=l?{type:l}:null,m=iu(d.doc,f,s.length,s)),!m)return!1;if(d.split(f,s.length,s),!c&&u&&r.node(o).type!=l){let g=d.mapping.map(r.before(o)),x=d.doc.resolve(g);l&&r.node(o-1).canReplaceWith(x.index(),x.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(o)),l)}return n&&n(d.scrollIntoView()),!0}}const j6e=k6e(),P6e=(t,e)=>{let{$from:n,to:r}=t.selection,i,s=n.sharedDepth(r);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(Zt.create(t.doc,i))),!0)};function R6e(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||mh(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function nte(t,e,n,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,c=i.type.spec.isolating||s.type.spec.isolating;if(!c&&R6e(t,e,n))return!0;let u=!c&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(n){let g=e.pos+s.nodeSize,x=Nt.empty;for(let v=o.length-1;v>=0;v--)x=Nt.from(o[v].create(null,x));x=Nt.from(i.copy(x));let y=t.tr.step(new sa(e.pos-1,g,e.pos,g,new Ft(x,1,0),o.length,!0)),b=y.doc.resolve(g+2*o.length);b.nodeAfter&&b.nodeAfter.type==i.type&&mh(y.doc,b.pos)&&y.join(b.pos),n(y.scrollIntoView())}return!0}let d=s.type.spec.isolating||r>0&&c?null:Mn.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),m=f&&ax(f);if(m!=null&&m>=e.depth)return n&&n(t.tr.lift(f,m).scrollIntoView()),!0;if(u&&kg(s,"start",!0)&&kg(i,"end")){let g=i,x=[];for(;x.push(g),!g.isTextblock;)g=g.lastChild;let y=s,b=1;for(;!y.isTextblock;y=y.firstChild)b++;if(g.canReplace(g.childCount,g.childCount,y.content)){if(n){let v=Nt.empty;for(let S=x.length-1;S>=0;S--)v=Nt.from(x[S].copy(v));let N=t.tr.step(new sa(e.pos-x.length,e.pos+s.nodeSize,e.pos+b,e.pos+s.nodeSize-b,new Ft(v,x.length,0),0,!0));n(N.scrollIntoView())}return!0}}return!1}function rte(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(n&&n(e.tr.setSelection(dn.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const D6e=rte(-1),O6e=rte(1);function L6e(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),l=o&&ZO(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function L9(t,e=null){return function(n,r){let i=!1;for(let s=0;s<n.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[s];n.doc.nodesBetween(o,l,(c,u)=>{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(t,e)))if(c.type==t)i=!0;else{let d=n.doc.resolve(u),f=d.index();i=d.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let s=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:c}}=n.selection.ranges[o];s.setBlockType(l,c,t,e)}r(s.scrollIntoView())}return!0}}function iL(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}iL(eL,Wee,Xee);iL(eL,Qee,Zee);iL(Jee,ete,tte,j6e);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function I6e(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s);if(!o)return!1;let l=r?n.tr:null;return F6e(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function F6e(t,e,n,r=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let c=o.resolve(e.start-2);s=new zS(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new zS(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=ZO(s,n,r,e);return l?(t&&U6e(t,e,l,i,n),!0):!1}function U6e(t,e,n,r,i){let s=Nt.empty;for(let d=n.length-1;d>=0;d--)s=Nt.from(n[d].type.create(n[d].attrs,s));t.step(new sa(e.start-(r?2:0),e.end,e.start,e.end,new Ft(s,0,0),n.length,!0));let o=0;for(let d=0;d<n.length;d++)n[d].type==i&&(o=d+1);let l=n.length-o,c=e.start+n.length-(r?2:0),u=e.parent;for(let d=e.startIndex,f=e.endIndex,m=!0;d<f;d++,m=!1)!m&&iu(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function z6e(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==t);return s?n?r.node(s.depth-1).type==t?B6e(e,n,t,s):$6e(e,n,s):!0:!1}}function B6e(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new sa(s-1,o,s,o,new Ft(Nt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new zS(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=ax(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(s,-1)-1);return mh(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function $6e(t,e,n){let r=t.tr,i=n.parent;for(let g=n.end,x=n.endIndex-1,y=n.startIndex;x>y;x--)g-=i.child(x).nodeSize,r.delete(g-1,g+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,c=n.endIndex==i.childCount,u=s.node(-1),d=s.index(-1);if(!u.canReplace(d+(l?0:1),d+1,o.content.append(c?Nt.empty:Nt.from(i))))return!1;let f=s.pos,m=f+o.nodeSize;return r.step(new sa(f-(l?1:0),m+(c?1:0),f+1,m-1,new Ft((l?Nt.empty:Nt.from(i.copy(Nt.empty))).append(c?Nt.empty:Nt.from(i.copy(Nt.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function H6e(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,u=>u.childCount>0&&u.firstChild.type==t);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,c=l.child(o-1);if(c.type!=t)return!1;if(n){let u=c.lastChild&&c.lastChild.type==l.type,d=Nt.from(u?t.create():null),f=new Ft(Nt.from(t.create(null,Nt.from(l.type.create(null,d)))),u?3:1,0),m=s.start,g=s.end;n(e.tr.step(new sa(m-(u?3:1),g,m,g,f,1,!0)).scrollIntoView())}return!0}}const Sa=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},jg=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let mR=null;const Fc=function(t,e,n){let r=mR||(mR=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},V6e=function(){mR=null},Jf=function(t,e,n,r){return n&&(I9(t,e,n,r,-1)||I9(t,e,n,r,1))},G6e=/^(img|br|input|textarea|hr)$/i;function I9(t,e,n,r,i){for(var s;;){if(t==n&&e==r)return!0;if(e==(i<0?0:To(t))){let o=t.parentNode;if(!o||o.nodeType!=1||By(t)||G6e.test(t.nodeName)||t.contentEditable=="false")return!1;e=Sa(t)+(i<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else t=o,e=i<0?To(t):0}else return!1}}function To(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function q6e(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=To(t)}else if(t.parentNode&&!By(t))e=Sa(t),t=t.parentNode;else return null}}function W6e(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&&!By(t))e=Sa(t)+1,t=t.parentNode;else return null}}function K6e(t,e,n){for(let r=e==0,i=e==To(t);r||i;){if(t==n)return!0;let s=Sa(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,i=i&&s==To(t)}}function By(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 nM=function(t){return t.focusNode&&Jf(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function rf(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function X6e(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Y6e(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(To(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(To(r.startContainer),r.startOffset)}}}const Wl=typeof navigator<"u"?navigator:null,F9=typeof document<"u"?document:null,ph=Wl&&Wl.userAgent||"",pR=/Edge\/(\d+)/.exec(ph),ite=/MSIE \d/.exec(ph),gR=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ph),Ns=!!(ite||gR||pR),Bd=ite?document.documentMode:gR?+gR[1]:pR?+pR[1]:0,Po=!Ns&&/gecko\/(\d+)/i.test(ph);Po&&+(/Firefox\/(\d+)/.exec(ph)||[0,0])[1];const xR=!Ns&&/Chrome\/(\d+)/.exec(ph),Ia=!!xR,ate=xR?+xR[1]:0,ts=!Ns&&!!Wl&&/Apple Computer/.test(Wl.vendor),Pg=ts&&(/Mobile\/\w+/.test(ph)||!!Wl&&Wl.maxTouchPoints>2),_o=Pg||(Wl?/Mac/.test(Wl.platform):!1),Q6e=Wl?/Win/.test(Wl.platform):!1,Yc=/Android \d/.test(ph),$y=!!F9&&"webkitFontSmoothing"in F9.documentElement.style,Z6e=$y?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function J6e(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 jc(t,e){return typeof t=="number"?t:t[e]}function e$e(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 U9(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=jg(o);continue}let l=o,c=l==s.body,u=c?J6e(s):e$e(l),d=0,f=0;if(e.top<u.top+jc(r,"top")?f=-(u.top-e.top+jc(i,"top")):e.bottom>u.bottom-jc(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+jc(i,"top")-u.top:e.bottom-u.bottom+jc(i,"bottom")),e.left<u.left+jc(r,"left")?d=-(u.left-e.left+jc(i,"left")):e.right>u.right-jc(r,"right")&&(d=e.right-u.right+jc(i,"right")),d||f)if(c)s.defaultView.scrollBy(d,f);else{let g=l.scrollLeft,x=l.scrollTop;f&&(l.scrollTop+=f),d&&(l.scrollLeft+=d);let y=l.scrollLeft-g,b=l.scrollTop-x;e={left:e.left-y,top:e.top-b,right:e.right-y,bottom:e.bottom-b}}let m=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(m))break;o=m=="absolute"?o.offsetParent:jg(o)}}function t$e(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(s,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let c=l.getBoundingClientRect();if(c.top>=n-20){r=l,i=c.top;break}}return{refDOM:r,refTop:i,stack:ste(t.dom)}}function ste(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=jg(r));return e}function n$e({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;ote(n,r==0?0:r-e)}function ote(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:s}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let Tp=null;function r$e(t){if(t.setActive)return t.setActive();if(Tp)return t.focus(Tp);let e=ste(t);t.focus(Tp==null?{get preventScroll(){return Tp={preventScroll:!0},!0}}:void 0),Tp||(Tp=!1,ote(e,0))}function lte(t,e){let n,r=2e8,i,s=0,o=e.top,l=e.top,c,u;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let m;if(d.nodeType==1)m=d.getClientRects();else if(d.nodeType==3)m=Fc(d).getClientRects();else continue;for(let g=0;g<m.length;g++){let x=m[g];if(x.top<=o&&x.bottom>=l){o=Math.max(x.bottom,o),l=Math.min(x.top,l);let y=x.left>e.left?x.left-e.left:x.right<e.left?e.left-x.right:0;if(y<r){n=d,r=y,i=y&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,d.nodeType==1&&y&&(s=f+(e.left>=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!c&&x.left<=e.left&&x.right>=e.left&&(c=d,u={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!n&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(s=f+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?i$e(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:lte(n,i)}function i$e(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let s=ud(r,1);if(s.top!=s.bottom&&aL(e,s))return{node:t,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:t,offset:0}}function aL(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function a$e(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function s$e(t,e,n){let{node:r,offset:i}=lte(e,n),s=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();s=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}function o$e(t,e,n,r){let i=-1;for(let s=e,o=!1;s!=t.dom;){let l=t.docView.nearestDesc(s,!0),c;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&c.left>r.left||c.top>r.top?i=l.posBefore:(!o&&c.right<r.left||c.bottom<r.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function cte(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let o=t.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let c=0;c<l.length;c++){let u=l[c];if(aL(e,u))return cte(o,e,u)}}if((s=(s+1)%r)==i)break}return t}function l$e(t,e){let n=t.dom.ownerDocument,r,i=0,s=Y6e(n,e.left,e.top);s&&({node:r,offset:i}=s);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let u=t.dom.getBoundingClientRect();if(!aL(e,u)||(o=cte(t.dom,e,u),!o))return null}if(ts)for(let u=o;r&&u;u=jg(u))u.draggable&&(r=void 0);if(o=a$e(o,e),r){if(Po&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],f;d.nodeName=="IMG"&&(f=d.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let u;$y&&i&&r.nodeType==1&&(u=r.childNodes[i-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=o$e(t,r,i,e))}l==null&&(l=s$e(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function z9(t){return t.top<t.bottom||t.left<t.right}function ud(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(z9(r))return r}return Array.prototype.find.call(n,z9)||t.getBoundingClientRect()}const c$e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ute(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),o=$y||Po;if(r.nodeType==3)if(o&&(c$e.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=ud(Fc(r,i,i),n);if(Po&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=ud(Fc(r,i-1,i-1),-1);if(u.top==c.top){let d=ud(Fc(r,i,i+1),-1);if(d.top!=c.top)return Sb(d,d.left<u.left)}}return c}else{let c=i,u=i,d=n<0?1:-1;return n<0&&!i?(u++,d=-1):n>=0&&i==r.nodeValue.length?(c--,d=1):n<0?c--:u++,Sb(ud(Fc(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==To(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return Qk(c.getBoundingClientRect(),!1)}if(s==null&&i<To(r)){let c=r.childNodes[i];if(c.nodeType==1)return Qk(c.getBoundingClientRect(),!0)}return Qk(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==To(r))){let c=r.childNodes[i-1],u=c.nodeType==3?Fc(c,To(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return Sb(ud(u,1),!1)}if(s==null&&i<To(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?Fc(c,0,o?0:1):c.nodeType==1?c:null:null;if(u)return Sb(ud(u,-1),!0)}return Sb(ud(r.nodeType==3?Fc(r):r,-n),n>=0)}function Sb(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 Qk(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 dte(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 u$e(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return dte(t,e,()=>{let{node:s}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=ute(t,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let c;if(l.nodeType==1)c=l.getClientRects();else if(l.nodeType==3)c=Fc(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;u<c.length;u++){let d=c[u];if(d.bottom>d.top+1&&(n=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const d$e=/[\u0590-\u08ac]/;function h$e(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=t.domSelection();return l?!d$e.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?s:o:dte(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),m=l.caretBidiLevel;l.modify("move",n,"character");let g=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:y}=t.domSelectionRange(),b=x&&!g.contains(x.nodeType==1?x:x.parentNode)||c==x&&u==y;try{l.collapse(d,f),c&&(c!=d||u!=f)&&l.extend&&l.extend(c,u)}catch{}return m!=null&&(l.caretBidiLevel=m),b}):r.pos==r.start()||r.pos==r.end()}let B9=null,$9=null,H9=!1;function f$e(t,e,n){return B9==e&&$9==n?H9:(B9=e,$9=n,H9=n=="up"||n=="down"?u$e(t,e,n):h$e(t,e,n))}const Ro=0,V9=1,hf=2,Kl=3;class Hy{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Ro,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,o;if(e==this.contentDOM)s=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>Sa(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!n||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.size;if(l>e||o instanceof fte){i=e-s;break}s=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof hte&&s.side>=0;r--);if(n<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&n&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,n):{node:this.contentDOM,offset:s?Sa(s.dom)+1:0}}else{let s,o=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,n):{node:this.contentDOM,offset:s?Sa(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let o=r,l=0;;l++){let c=this.children[l],u=o+c.size;if(i==-1&&e<=u){let d=o+c.border;if(e>=d&&n<=u-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,n,d);e=o;for(let f=l;f>0;f--){let m=this.children[f-1];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(1)){i=Sa(m.dom)+1;break}e-=m.size}i==-1&&(i=0)}if(i>-1&&(u>n||l==this.children.length-1)){n=u;for(let d=l+1;d<this.children.length;d++){let f=this.children[d];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=Sa(f.dom);break}n+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=u}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let s=Math.min(e,n),o=Math.max(e,n);for(let g=0,x=0;g<this.children.length;g++){let y=this.children[g],b=x+y.size;if(s>x&&o<b)return y.setSelection(e-x-y.border,n-x-y.border,r,i);x=b}let l=this.domFromPos(e,e?-1:1),c=n==e?l:this.domFromPos(n,n?-1:1),u=r.root.getSelection(),d=r.domSelectionRange(),f=!1;if((Po||ts)&&e==n){let{node:g,offset:x}=l;if(g.nodeType==3){if(f=!!(x&&g.nodeValue[x-1]==`
- `),f&&x==g.nodeValue.length)for(let y=g,b;y;y=y.parentNode){if(b=y.nextSibling){b.nodeName=="BR"&&(l=c={node:b.parentNode,offset:Sa(b)+1});break}let v=y.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let y=g.childNodes[x-1];f=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(Po&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let g=d.focusNode.childNodes[d.focusOffset];g&&g.contentEditable=="false"&&(i=!0)}if(!(i||f&&ts)&&Jf(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Jf(c.node,c.offset,d.focusNode,d.focusOffset))return;let m=!1;if((u.extend||e==n)&&!(f&&Po)){u.collapse(l.node,l.offset);try{e!=n&&u.extend(c.node,c.offset),m=!0}catch{}}if(!m){if(e>n){let x=l;l=c,c=x}let g=document.createRange();g.setEnd(c.node,c.offset),g.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(g)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],o=r+s.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+s.border,c=o-s.border;if(e>=l&&n<=c){this.dirty=e==r||n==o?hf:V9,e==l&&n==c&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Kl:s.markDirty(e-l,n-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?hf:Kl}r=o}this.dirty=hf}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?hf:V9;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class hte extends Hy{constructor(e,n,r,i){let s,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!n.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,s=this}matchesWidget(e){return this.dirty==Ro&&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 m$e extends Hy{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 em extends Hy{constructor(e,n,r,i,s){super(e,[],r,i),this.mark=n,this.spec=s}static create(e,n,r,i){let s=i.nodeViews[n.type.name],o=s&&s(n,i,r);return(!o||!o.dom)&&(o=cm.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new em(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Kl||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Kl&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Ro){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Ro}}slice(e,n,r){let i=em.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;n<o&&(s=yR(s,n,o,r)),e>0&&(s=yR(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class $d extends Hy{constructor(e,n,r,i,s,o,l,c,u){super(e,[],s,o),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,s,o){let l=s.nodeViews[n.type.name],c,u=l&&l(n,s,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),d=u&&u.dom,f=u&&u.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:f}=cm.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let m=d;return d=gte(d,r,n),u?c=new p$e(e,n,r,i,d,f||null,m,u,s,o+1):n.isText?new rM(e,n,r,i,d,m,s):new $d(e,n,r,i,d,f||null,m,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Nt.empty)}return e}matchesNode(e,n,r){return this.dirty==Ro&&e.eq(this.node)&&$S(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,s=e.composing?this.localCompositionInfo(e,n):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,c=new x$e(this,o&&o.node,e);v$e(this.node,this.innerDeco,(u,d,f)=>{u.spec.marks?c.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!f&&c.syncToMarks(d==this.node.childCount?Nr.none:this.node.child(d).marks,r,e),c.placeWidget(u,e,i)},(u,d,f,m)=>{c.syncToMarks(u.marks,r,e);let g;c.findNodeMatch(u,d,f,m)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(g=c.findIndexWithChild(s.node))>-1&&c.updateNodeAt(u,d,f,g,e)||c.updateNextNode(u,d,f,e,m,i)||c.addNode(u,d,f,e,i),i+=u.nodeSize}),c.syncToMarks([],r,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==hf)&&(o&&this.protectLocalComposition(e,o),mte(this.contentDOM,this.children,e),Pg&&_$e(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof dn)||r<n||i>n+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=w$e(this.node.content,o,r-n,i-n);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let s=n;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new m$e(this,s,n,i);e.input.compositionNodes.push(o),this.children=yR(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==Kl||!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=Ro}updateOuterDeco(e){if($S(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=pte(this.dom,this.nodeDOM,bR(this.outerDeco,this.node,n),bR(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 G9(t,e,n,r,i){gte(r,e,t);let s=new $d(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class rM extends $d{constructor(e,n,r,i,s,o,l){super(e,n,r,i,s,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==Kl||this.dirty!=Ro&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Ro||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=Ro,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),s=document.createTextNode(i.text);return new rM(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Kl)}get domAtom(){return!1}isText(e){return this.node.text==e}}class fte extends Hy{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ro&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class p$e extends $d{constructor(e,n,r,i,s,o,l,c,u,d){super(e,n,r,i,s,o,l,u,d),this.spec=c}update(e,n,r,i){if(this.dirty==Kl)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,n,r);return s&&this.updateInner(e,n,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function mte(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=q9(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof em){let c=r?r.previousSibling:t.lastChild;mte(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=q9(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const Jb=function(t){t&&(this.nodeName=t)};Jb.prototype=Object.create(null);const ff=[new Jb];function bR(t,e,n){if(t.length==0)return ff;let r=n?ff[0]:new Jb,i=[r];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&i.push(r=new Jb(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new Jb(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+c:l=="style"?r.style=(r.style?r.style+";":"")+c:l!="nodeName"&&(r[l]=c))}}}return i}function pte(t,e,n,r){if(n==ff&&r==ff)return e;let i=e;for(let s=0;s<r.length;s++){let o=r[s],l=n[s];if(s){let c;l&&l.nodeName==o.nodeName&&i!=t&&(c=i.parentNode)&&c.nodeName.toLowerCase()==o.nodeName||(c=document.createElement(o.nodeName),c.pmIsDeco=!0,c.appendChild(i),l=ff[0]),i=c}g$e(i,l||ff[0],o)}return i}function g$e(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&t.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&t.classList.add(i[s]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function gte(t,e,n){return pte(t,t,ff,bR(e,n,t.nodeType!=1))}function $S(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 q9(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class x$e{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=b$e(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let i=0,s=this.stack.length>>1,o=Math.min(s,e.length);for(;i<o&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=Ro,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let c=this.index;c<Math.min(this.index+3,this.top.children.length);c++){let u=this.top.children[c];if(u.matchesMark(e[s])&&!this.isLocked(u.dom)){l=c;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let c=em.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,c=Math.min(this.top.children.length,l+5);l<c;l++){let u=this.top.children[l];if(u.matchesNode(e,n,r)&&!this.preMatch.matched.has(u)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,n,r,i,s){let o=this.top.children[i];return o.dirty==Kl&&o.dom==o.contentDOM&&(o.dirty=hf),o.update(e,n,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof $d){let u=this.preMatch.matched.get(c);if(u!=null&&u!=s)return!1;let d=c.dom,f,m=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=Kl&&$S(n,c.outerDeco));if(!m&&c.update(e,n,r,i))return this.destroyBetween(this.index,l),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!m&&(f=this.recreateWrapper(c,e,n,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=hf,f.updateChildren(i,o+1),f.dirty=Ro),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,s,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!$S(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=$d.create(this.top,n,r,i,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let c of l.children)c.parent=l}return e.destroy(),l}addNode(e,n,r,i,s){let o=$d.create(this.top,e,n,r,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new hte(this.top,e,n,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof em;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof rM)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ts||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 fte(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 b$e(t,e){let n=e,r=n.children.length,i=t.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof em)n=u,r=u.children.length;else{l=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let c=l.node;if(c){if(c!=t.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function y$e(t,e){return t.type.side-e.type.side}function v$e(t,e,n,r){let i=e.locals(t),s=0;if(i.length==0){for(let u=0;u<t.childCount;u++){let d=t.child(u);r(d,i,e.forChild(s,d),u),s+=d.nodeSize}return}let o=0,l=[],c=null;for(let u=0;;){let d,f;for(;o<i.length&&i[o].to==s;){let b=i[o++];b.widget&&(d?(f||(f=[d])).push(b):d=b)}if(d)if(f){f.sort(y$e);for(let b=0;b<f.length;b++)n(f[b],u,!!c)}else n(d,u,!!c);let m,g;if(c)g=-1,m=c,c=null;else if(u<t.childCount)g=u,m=t.child(u++);else break;for(let b=0;b<l.length;b++)l[b].to<=s&&l.splice(b--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let x=s+m.nodeSize;if(m.isText){let b=x;o<i.length&&i[o].from<b&&(b=i[o].from);for(let v=0;v<l.length;v++)l[v].to<b&&(b=l[v].to);b<x&&(c=m.cut(b-s),m=m.cut(0,b-s),x=b,g=-1)}else for(;o<i.length&&i[o].to<x;)o++;let y=m.isInline&&!m.isLeaf?l.filter(b=>!b.inline):l.slice();r(m,y,e.forChild(s,m),g),s=x}}function _$e(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 w$e(t,e,n,r){for(let i=0,s=0;i<t.childCount&&s<=r;){let o=t.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<t.childCount;){let u=t.child(i++);if(s+=u.nodeSize,!u.isText)break;c+=u.text}if(s>=n){if(s>=r&&c.slice(r-e.length-l,r-l)==e)return r-e.length;let u=l<r?c.lastIndexOf(e,r-l-1):-1;if(u>=0&&u+e.length+l>=n)return l+u;if(n==r&&c.length>=r+e.length-l&&c.slice(r-l,r-l+e.length)==e)return r}}return-1}function yR(t,e,n,r,i){let s=[];for(let o=0,l=0;o<t.length;o++){let c=t[o],u=l,d=l+=c.size;u>=n||d<=e?s.push(c):(u<e&&s.push(c.slice(0,e-u,r)),i&&(s.push(i),i=void 0),d>n&&s.push(c.slice(n-u,c.size,r)))}return s}function sL(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),c,u;if(nM(n)){for(c=o;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&Zt.isSelectable(f)&&i.parent&&!(f.isInline&&K6e(n.focusNode,n.focusOffset,i.dom))){let m=i.posBefore;u=new Zt(o==m?l:r.resolve(m))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=o,m=o;for(let g=0;g<n.rangeCount;g++){let x=n.getRangeAt(g);f=Math.min(f,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),m=Math.max(m,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(f<0)return null;[c,o]=m==t.state.selection.anchor?[m,f]:[f,m],l=r.resolve(o)}else c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let d=r.resolve(c);if(!u){let f=e=="pointer"||t.state.selection.head<l.pos&&!s?1:-1;u=oL(t,d,l,f)}return u}function xte(t){return t.editable?t.hasFocus():yte(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function au(t,e=!1){let n=t.state.selection;if(bte(t,n),!!xte(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Ia){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Jf(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)N$e(t);else{let{anchor:r,head:i}=n,s,o;W9&&!(n instanceof dn)&&(n.$from.parent.inlineContent||(s=K9(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=K9(t,n.to))),t.docView.setSelection(r,i,t,e),W9&&(s&&X9(s),o&&X9(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&S$e(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const W9=ts||Ia&&ate<63;function K9(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(ts&&i&&i.contentEditable=="false")return Zk(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Zk(i);if(s)return Zk(s)}}function Zk(t){return t.contentEditable="true",ts&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function X9(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function S$e(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!xte(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function N$e(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Sa(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ns&&Bd<=11&&(n.disabled=!0,n.disabled=!1)}function bte(t,e){if(e instanceof Zt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Y9(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Y9(t)}function Y9(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function oL(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||dn.between(e,n,r)}function Q9(t){return t.editable&&!t.hasFocus()?!1:yte(t)}function yte(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 M$e(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Jf(e.node,e.offset,n.anchorNode,n.anchorOffset)}function vR(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&Mn.findFrom(s,e)}function pd(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Z9(t,e,n){let r=t.state.selection;if(r instanceof dn)if(n.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return pd(t,new dn(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=vR(t.state,e);return i&&i instanceof Zt?pd(t,i):!1}else if(!(_o&&n.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?Zt.isSelectable(s)?pd(t,new Zt(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):$y?pd(t,new dn(t.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Zt&&r.node.isInline)return pd(t,new dn(e>0?r.$to:r.$from));{let i=vR(t.state,e);return i?pd(t,i):!1}}}function HS(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function e0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Cp(t,e){return e<0?E$e(t):T$e(t)}function E$e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(Po&&n.nodeType==1&&r<HS(n)&&e0(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(e0(l,-1))i=n,s=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(vte(n))break;{let l=n.previousSibling;for(;l&&e0(l,-1);)i=n.parentNode,s=Sa(l),l=l.previousSibling;if(l)n=l,r=HS(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?_R(t,n,r):i&&_R(t,i,s)}function T$e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=HS(n),s,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(e0(l,1))s=n,o=++r;else break}else{if(vte(n))break;{let l=n.nextSibling;for(;l&&e0(l,1);)s=l.parentNode,o=Sa(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=HS(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}s&&_R(t,s,o)}function vte(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function C$e(t,e){for(;t&&e==t.childNodes.length&&!By(t);)e=Sa(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 A$e(t,e){for(;t&&!e&&!By(t);)e=Sa(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 _R(t,e,n){if(e.nodeType!=3){let s,o;(o=C$e(e,n))?(e=o,n=0):(s=A$e(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(!r)return;if(nM(r)){let s=document.createRange();s.setEnd(e,n),s.setStart(e,n),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&au(t)},50)}function J9(t,e){let n=t.state.doc.resolve(e);if(!(Ia||Q6e)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let s=t.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<n.end()){let s=t.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function eG(t,e,n){let r=t.state.selection;if(r instanceof dn&&!r.empty||n.indexOf("s")>-1||_o&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=vR(t.state,e);if(o&&o instanceof Zt)return pd(t,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof Qs?Mn.near(o,e):Mn.findFrom(o,e);return l?pd(t,l):!1}return!1}function tG(t,e){if(!(t.state.selection instanceof dn))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let o=t.state.tr;return e<0?o.delete(n.pos-s.nodeSize,n.pos):o.delete(n.pos,n.pos+s.nodeSize),t.dispatch(o),!0}return!1}function nG(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function k$e(t){if(!ts||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;nG(t,r,"true"),setTimeout(()=>nG(t,r,"false"),20)}return!1}function j$e(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function P$e(t,e){let n=e.keyCode,r=j$e(e);if(n==8||_o&&n==72&&r=="c")return tG(t,-1)||Cp(t,-1);if(n==46&&!e.shiftKey||_o&&n==68&&r=="c")return tG(t,1)||Cp(t,1);if(n==13||n==27)return!0;if(n==37||_o&&n==66&&r=="c"){let i=n==37?J9(t,t.state.selection.from)=="ltr"?-1:1:-1;return Z9(t,i,r)||Cp(t,i)}else if(n==39||_o&&n==70&&r=="c"){let i=n==39?J9(t,t.state.selection.from)=="ltr"?1:-1:1;return Z9(t,i,r)||Cp(t,i)}else{if(n==38||_o&&n==80&&r=="c")return eG(t,-1,r)||Cp(t,-1);if(n==40||_o&&n==78&&r=="c")return k$e(t)||eG(t,1,r)||Cp(t,1);if(r==(_o?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function lL(t,e){t.someProp("transformCopied",g=>{e=g(e,t)});let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let g=r.firstChild;n.push(g.type.name,g.attrs!=g.type.defaultAttrs?g.attrs:null),r=g.content}let o=t.someProp("clipboardSerializer")||cm.fromSchema(t.state.schema),l=Ete(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=Mte[u.nodeName.toLowerCase()]);){for(let g=d.length-1;g>=0;g--){let x=l.createElement(d[g]);for(;c.firstChild;)x.appendChild(c.firstChild);c.appendChild(x),f++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${s}${f?` -${f}`:""} ${JSON.stringify(n)}`);let m=t.someProp("clipboardTextSerializer",g=>g(e,t))||e.content.textBetween(0,e.content.size,`
- `);return{dom:c,text:m,slice:e}}function _te(t,e,n,r,i){let s=i.parent.type.spec.code,o,l;if(!n&&!e)return null;let c=!!e&&(r||s||!n);if(c){if(t.someProp("transformPastedText",m=>{e=m(e,s||r,t)}),s)return l=new Ft(Nt.from(t.state.schema.text(e.replace(/\r\n?/g,`
- `))),0,0),t.someProp("transformPasted",m=>{l=m(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",m=>m(e,i,r,t));if(f)l=f;else{let m=i.marks(),{schema:g}=t.state,x=cm.fromSchema(g);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let b=o.appendChild(document.createElement("p"));y&&b.appendChild(x.serializeNode(g.text(y,m)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=L$e(n),$y&&I$e(o);let u=o&&o.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let m=o.firstChild;for(;m&&m.nodeType!=1;)m=m.nextSibling;if(!m)break;o=m}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Qb.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(m){return m.nodeName=="BR"&&!m.nextSibling&&m.parentNode&&!R$e.test(m.parentNode.nodeName)?{ignore:!0}:null}})),d)l=F$e(rG(l,+d[1],+d[2]),d[4]);else if(l=Ft.maxOpen(D$e(l.content,i),!0),l.openStart||l.openEnd){let f=0,m=0;for(let g=l.content.firstChild;f<l.openStart&&!g.type.spec.isolating;f++,g=g.firstChild);for(let g=l.content.lastChild;m<l.openEnd&&!g.type.spec.isolating;m++,g=g.lastChild);l=rG(l,f,m)}return t.someProp("transformPasted",f=>{l=f(l,t,c)}),l}const R$e=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function D$e(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),s,o=[];if(t.forEach(l=>{if(!o)return;let c=i.findWrapping(l.type),u;if(!c)return o=null;if(u=o.length&&s.length&&Ste(c,s,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=Nte(o[o.length-1],s.length));let d=wte(l,c);o.push(d),i=i.matchType(d.type),s=c}}),o)return Nt.from(o)}return t}function wte(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Nt.from(t));return t}function Ste(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=Ste(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(Nt.from(wte(n,t,i+1))))}}function Nte(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Nte(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(Nt.empty,!0);return t.copy(n.append(r))}function wR(t,e,n,r,i,s){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(s=0),i<r-1&&(l=wR(l,e,n,r,i+1,s)),i>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(Nt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function rG(t,e,n){return e<t.openStart&&(t=new Ft(wR(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Ft(wR(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Mte={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 iG=null;function Ete(){return iG||(iG=document.implementation.createHTMLDocument("title"))}let Jk=null;function O$e(t){let e=window.trustedTypes;return e?(Jk||(Jk=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Jk.createHTML(t)):t}function L$e(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Ete().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&Mte[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=O$e(t),i)for(let s=0;s<i.length;s++)n=n.querySelector(i[s])||n;return n}function I$e(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 F$e(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:s,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let c=n.nodes[r[l]];if(!c||c.hasRequiredAttrs())break;i=Nt.from(c.create(r[l+1],i)),s++,o++}return new Ft(i,s,o)}const ns={},rs={},U$e={touchstart:!0,touchmove:!0};class z$e{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function B$e(t){for(let e in ns){let n=ns[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{H$e(t,r)&&!cL(t,r)&&(t.editable||!(r.type in rs))&&n(t,r)},U$e[e]?{passive:!0}:void 0)}ts&&t.dom.addEventListener("input",()=>null),SR(t)}function kd(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function $$e(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function SR(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>cL(t,r))})}function cL(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function H$e(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function V$e(t,e){!cL(t,e)&&ns[e.type]&&(t.editable||!(e.type in rs))&&ns[e.type](t,e)}rs.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Cte(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Yc&&Ia&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Pg&&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,rf(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||P$e(t,n)?n.preventDefault():kd(t,"key")};rs.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};rs.keypress=(t,e)=>{let n=e;if(Cte(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||_o&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof dn)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),s=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i,s))&&t.dispatch(s()),n.preventDefault()}};function iM(t){return{left:t.clientX,top:t.clientY}}function G$e(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function uL(t,e,n,r,i){if(r==-1)return!1;let s=t.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(t.someProp(e,l=>o>s.depth?l(t,n,s.nodeAfter,s.before(o),i,!0):l(t,n,s.node(o),s.before(o),i,!1)))return!0;return!1}function ag(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 q$e(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Zt.isSelectable(r)?(ag(t,new Zt(n)),!0):!1}function W$e(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Zt&&(r=n.node);let s=t.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(Zt.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(o);break}}return i!=null?(ag(t,Zt.create(t.state.doc,i)),!0):!1}function K$e(t,e,n,r,i){return uL(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?W$e(t,n):q$e(t,n))}function X$e(t,e,n,r){return uL(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function Y$e(t,e,n,r){return uL(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||Q$e(t,n,r)}function Q$e(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(ag(t,dn.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)ag(t,dn.create(r,l+1,l+1+o.content.size));else if(Zt.isSelectable(o))ag(t,Zt.create(r,l));else continue;return!0}}function dL(t){return VS(t)}const Tte=_o?"metaKey":"ctrlKey";ns.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=dL(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&G$e(n,t.input.lastClick)&&!n[Tte]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?s="doubleClick":t.input.lastClick.type=="doubleClick"&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s,button:n.button};let o=t.posAtCoords(iM(n));o&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Z$e(t,o,n,!!r)):(s=="doubleClick"?X$e:Y$e)(t,o.pos,o.inside,n)?n.preventDefault():kd(t,"pointer"))};class Z$e{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Tte],this.allowDefault=r.shiftKey;let s,o;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),o=n.inside;else{let d=e.state.doc.resolve(n.pos);s=d.parent,o=d.depth?d.before():0}const l=i?null:r.target,c=l?e.docView.nearestDesc(l,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:u}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||u instanceof Zt&&u.from<=o&&u.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Po&&!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)),kd(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(()=>au(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(iM(e))),this.updateAllowDefault(e),this.allowDefault||!n?kd(this.view,"pointer"):K$e(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ts&&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)?(ag(this.view,Mn.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):kd(this.view,"pointer")}move(e){this.updateAllowDefault(e),kd(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)}}ns.touchstart=t=>{t.input.lastTouch=Date.now(),dL(t),kd(t,"pointer")};ns.touchmove=t=>{t.input.lastTouch=Date.now(),kd(t,"pointer")};ns.contextmenu=t=>dL(t);function Cte(t,e){return t.composing?!0:ts&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const J$e=Yc?5e3:-1;rs.compositionstart=rs.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof dn&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),VS(t,!0),t.markCursor=null;else if(VS(t,!e.selection.empty),Po&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}t.input.composing=!0}Ate(t,J$e)};rs.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++,Ate(t,20))};function Ate(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>VS(t),e))}function kte(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=tHe());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function eHe(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=q6e(e.focusNode,e.focusOffset),r=W6e(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,s=t.domObserver.lastChangedTextNode;if(n==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function tHe(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function VS(t,e=!1){if(!(Yc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),kte(t),e||t.docView&&t.docView.dirty){let n=sL(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 nHe(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 Y0=Ns&&Bd<15||Pg&&Z6e<604;ns.copy=rs.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=Y0?null:n.clipboardData,o=r.content(),{dom:l,text:c}=lL(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",c)):nHe(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function rHe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function iHe(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?Q0(t,r.value,null,i,e):Q0(t,r.textContent,r.innerHTML,i,e)},50)}function Q0(t,e,n,r,i){let s=_te(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,s||Ft.empty)))return!0;if(!s)return!1;let o=rHe(s),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(s);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function jte(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," "):""}rs.paste=(t,e)=>{let n=e;if(t.composing&&!Yc)return;let r=Y0?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Q0(t,jte(r),r.getData("text/html"),i,n)?n.preventDefault():iHe(t,n)};class Pte{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const aHe=_o?"altKey":"ctrlKey";function Rte(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[aHe]}ns.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords(iM(n)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof Zt?i.to-1:i.to))){if(r&&r.mightDrag)o=Zt.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(o=Zt.create(t.state.doc,f.posBefore))}}let l=(o||t.state.selection).content(),{dom:c,text:u,slice:d}=lL(t,l);(!n.dataTransfer.files.length||!Ia||ate>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Y0?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",Y0||n.dataTransfer.setData("text/plain",u),t.dragging=new Pte(d,Rte(t,n),o)};ns.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};rs.dragover=rs.dragenter=(t,e)=>e.preventDefault();rs.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(iM(n));if(!i)return;let s=t.state.doc.resolve(i.pos),o=r&&r.slice;o?t.someProp("transformPasted",x=>{o=x(o,t,!1)}):o=_te(t,jte(n.dataTransfer),Y0?null:n.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&Rte(t,n));if(t.someProp("handleDrop",x=>x(t,n,o||Ft.empty,l))){n.preventDefault();return}if(!o)return;n.preventDefault();let c=o?Fee(t.state.doc,s.pos,o):s.pos;c==null&&(c=s.pos);let u=t.state.tr;if(l){let{node:x}=r;x?x.replace(u):u.deleteSelection()}let d=u.mapping.map(c),f=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,m=u.doc;if(f?u.replaceRangeWith(d,d,o.content.firstChild):u.replaceRange(d,d,o),u.doc.eq(m))return;let g=u.doc.resolve(d);if(f&&Zt.isSelectable(o.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new Zt(g));else{let x=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((y,b,v,N)=>x=N),u.setSelection(oL(t,g,u.doc.resolve(x)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};ns.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())&&au(t)},20))};ns.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)};ns.beforeinput=(t,e)=>{if(Ia&&Yc&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",s=>s(t,rf(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 rs)ns[t]=rs[t];function Z0(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 GS{constructor(e,n){this.toDOM=e,this.spec=n||Cf,this.side=this.spec.side||0}map(e,n,r,i){let{pos:s,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new Ya(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof GS&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Z0(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Hd{constructor(e,n){this.attrs=e,this.spec=n||Cf}map(e,n,r,i){let s=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new Ya(s,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Hd&&Z0(this.attrs,e.attrs)&&Z0(this.spec,e.spec)}static is(e){return e.type instanceof Hd}destroy(){}}class hL{constructor(e,n){this.attrs=e,this.spec=n||Cf}map(e,n,r,i){let s=e.mapResult(n.from+i,1);if(s.deleted)return null;let o=e.mapResult(n.to+i,-1);return o.deleted||o.pos<=s.pos?null:new Ya(s.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),s;return i==n.from&&!(s=e.child(r)).isText&&i+s.nodeSize==n.to}eq(e){return this==e||e instanceof hL&&Z0(this.attrs,e.attrs)&&Z0(this.spec,e.spec)}destroy(){}}class Ya{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Ya(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 Ya(e,e,new GS(n,r))}static inline(e,n,r,i){return new Ya(e,n,new Hd(r,i))}static node(e,n,r,i){return new Ya(e,n,new hL(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Hd}get widget(){return this.type instanceof GS}}const Lp=[],Cf={};class Wr{constructor(e,n){this.local=e.length?e:Lp,this.children=n.length?n:Lp}static create(e,n){return n.length?qS(n,e,0,Cf):Da}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,i+l,s)}}map(e,n,r){return this==Da||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Cf)}mapInner(e,n,r,i,s){let o;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,r,i);c&&c.type.valid(n,c)?(o||(o=[])).push(c):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?sHe(this.children,o||[],e,n,r,i,s):o?new Wr(o.sort(Af),Lp):Da}add(e,n){return n.length?this==Da?Wr.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,s=0;e.forEach((l,c)=>{let u=c+r,d;if(d=Ote(n,l,u)){for(i||(i=this.children.slice());s<i.length&&i[s]<c;)s+=3;i[s]==c?i[s+2]=i[s+2].addInner(l,d,u+1):i.splice(s,0,c,c+l.nodeSize,qS(d,l,u+1,Cf)),s+=3}});let o=Dte(s?Lte(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new Wr(o.length?this.local.concat(o).sort(Af):this.local,i||this.children)}remove(e){return e.length==0||this==Da?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+n,c=r[s+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>l&&f.to<c&&(e[d]=null,(o||(o=[])).push(f));if(!o)continue;r==this.children&&(r=this.children.slice());let u=r[s+2].removeInner(o,l+1);u!=Da?r[s+2]=u:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new Wr(i,r):Da}forChild(e,n){if(this==Da)return this;if(n.isLeaf)return Wr.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,o=s+n.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<o&&c.to>s&&c.type instanceof Hd){let u=Math.max(s,c.from)-s,d=Math.min(o,c.to)-s;u<d&&(i||(i=[])).push(c.copy(u,d))}}if(i){let l=new Wr(i.sort(Af),Lp);return r?new _d([l,r]):l}return r||Da}eq(e){if(this==e)return!0;if(!(e instanceof Wr)||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 fL(this.localsInner(e))}localsInner(e){if(this==Da)return Lp;if(e.inlineContent||!this.local.some(Hd.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Hd||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Wr.empty=new Wr([],[]);Wr.removeOverlap=fL;const Da=Wr.empty;class _d{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Cf));return _d.from(r)}forChild(e,n){if(n.isLeaf)return Wr.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=Da&&(s instanceof _d?r=r.concat(s.members):r.push(s))}return _d.from(r)}eq(e){if(!(e instanceof _d)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!n)n=s;else{r&&(n=n.slice(),r=!1);for(let o=0;o<s.length;o++)n.push(s[o])}}return n?fL(r?n:n.sort(Af)):Lp}static from(e){switch(e.length){case 0:return Da;case 1:return e[0];default:return new _d(e.every(n=>n instanceof Wr)?e:e.reduce((n,r)=>n.concat(r instanceof Wr?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function sHe(t,e,n,r,i,s,o){let l=t.slice();for(let u=0,d=s;u<n.maps.length;u++){let f=0;n.maps[u].forEach((m,g,x,y)=>{let b=y-x-(g-m);for(let v=0;v<l.length;v+=3){let N=l[v+1];if(N<0||m>N+d-f)continue;let S=l[v]+d-f;g>=S?l[v+1]=m<=S?-2:-1:m>=d&&b&&(l[v]+=b,l[v+1]+=b)}f+=b}),d=n.maps[u].map(d,-1)}let c=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){c=!0,l[u+1]=-1;continue}let d=n.map(t[u]+s),f=d-i;if(f<0||f>=r.content.size){c=!0;continue}let m=n.map(t[u+1]+s,-1),g=m-i,{index:x,offset:y}=r.content.findIndex(f),b=r.maybeChild(x);if(b&&y==f&&y+b.nodeSize==g){let v=l[u+2].mapInner(n,b,d+1,t[u]+s+1,o);v!=Da?(l[u]=f,l[u+1]=g,l[u+2]=v):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=oHe(l,t,e,n,i,s,o),d=qS(u,r,0,o);e=d.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,m=0;f<d.children.length;f+=3){let g=d.children[f];for(;m<l.length&&l[m]<g;)m+=3;l.splice(m,0,d.children[f],d.children[f+1],d.children[f+2])}}return new Wr(e.sort(Af),l)}function Dte(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 Ya(i.from+e,i.to+e,i.type))}return n}function oHe(t,e,n,r,i,s,o){function l(c,u){for(let d=0;d<c.local.length;d++){let f=c.local[d].map(r,i,u);f?n.push(f):o.onRemove&&o.onRemove(c.local[d].spec)}for(let d=0;d<c.children.length;d+=3)l(c.children[d+2],c.children[d]+u+1)}for(let c=0;c<t.length;c+=3)t[c+1]==-1&&l(t[c+2],e[c]+s+1);return n}function Ote(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let s=0,o;s<t.length;s++)(o=t[s])&&o.from>n&&o.to<r&&((i||(i=[])).push(o),t[s]=null);return i}function Lte(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function qS(t,e,n,r){let i=[],s=!1;e.forEach((l,c)=>{let u=Ote(t,l,c+n);if(u){s=!0;let d=qS(u,l,n+c+1,r);d!=Da&&i.push(c,c+l.nodeSize,d)}});let o=Dte(s?Lte(t):t,-n).sort(Af);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new Wr(o,i):Da}function Af(t,e){return t.from-e.from||t.to-e.to}function fL(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==t&&(e=t.slice()),e[i]=s.copy(s.from,r.to),aG(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,s.from),aG(e,i,r.copy(s.from,r.to)));break}}}return e}function aG(t,e,n){for(;e<t.length&&Af(n,t[e])>0;)e++;t.splice(e,0,n)}function ej(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Da&&e.push(r)}),t.cursorWrapper&&e.push(Wr.create(t.state.doc,[t.cursorWrapper.deco])),_d.from(e)}const lHe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},cHe=Ns&&Bd<=11;class uHe{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 dHe{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new uHe,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]);Ns&&Bd<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),cHe&&(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,lHe)),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(Q9(this.view)){if(this.suppressingSelectionUpdates)return au(this.view);if(Ns&&Bd<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Jf(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let s=e.focusNode;s;s=jg(s))n.add(s);for(let s=e.anchorNode;s;s=jg(s))if(n.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Q9(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,c=[];if(e.editable)for(let d=0;d<n.length;d++){let f=this.registerMutation(n[d],c);f&&(s=s<0?f.from:Math.min(f.from,s),o=o<0?f.to:Math.max(f.to,o),f.typeOver&&(l=!0))}if(Po&&c.length){let d=c.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,m]=d;f.parentNode&&f.parentNode.parentNode==m.parentNode?m.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let m of d){let g=m.parentNode;g&&g.nodeName=="LI"&&(!f||mHe(e,f)!=g)&&m.remove()}}}let u=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&nM(r)&&(u=sL(e))&&u.eq(Mn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,au(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),hHe(e)),this.handleDOMChange(s,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||au(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(Ns&&Bd<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:f,nextSibling:m}=e.addedNodes[d];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!m||Array.prototype.indexOf.call(e.addedNodes,m)<0)&&(s=m)}let o=i&&i.parentNode==e.target?Sa(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=s&&s.parentNode==e.target?Sa(s):e.target.childNodes.length,u=r.localPosFromDOM(e.target,c,1);return{from:l,to:u}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let sG=new WeakMap,oG=!1;function hHe(t){if(!sG.has(t)&&(sG.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Po,oG)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."),oG=!0}}function lG(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Jf(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function fHe(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return lG(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?lG(t,n):null}function mHe(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 pHe(t,e,n){let{node:r,fromOffset:i,toOffset:s,from:o,to:l}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:c.anchorOffset}],nM(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Ia&&t.input.lastKeyCode===8)for(let b=s;b>i;b--){let v=r.childNodes[b-1],N=v.pmViewDesc;if(v.nodeName=="BR"&&!N){s=b;break}if(!N||N.size)break}let f=t.state.doc,m=t.someProp("domParser")||Qb.fromSchema(t.state.schema),g=f.resolve(o),x=null,y=m.parse(r,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:i,to:s,preserveWhitespace:g.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:gHe,context:g});if(u&&u[0].pos!=null){let b=u[0].pos,v=u[1]&&u[1].pos;v==null&&(v=b),x={anchor:b+o,head:v+o}}return{doc:y,sel:x,from:o,to:l}}function gHe(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ts&&/^(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||ts&&/^(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 xHe=/^(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 bHe(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let C=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,D=sL(t,C);if(D&&!t.state.selection.eq(D)){if(Ia&&Yc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",R=>R(t,rf(13,"Enter"))))return;let A=t.state.tr.setSelection(D);C=="pointer"?A.setMeta("pointer",!0):C=="key"&&A.scrollIntoView(),s&&A.setMeta("composition",s),t.dispatch(A)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let c=t.state.selection,u=pHe(t,e,n),d=t.state.doc,f=d.slice(u.from,u.to),m,g;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(m=t.state.selection.to,g="end"):(m=t.state.selection.from,g="start"),t.input.lastKeyCode=null;let x=_He(f.content,u.doc.content,u.from,m,g);if(x&&t.input.domChangeCount++,(Pg&&t.input.lastIOSEnter>Date.now()-225||Yc)&&i.some(C=>C.nodeType==1&&!xHe.test(C.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",C=>C(t,rf(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&c instanceof dn&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))x={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let C=cG(t,t.state.doc,u.sel);if(C&&!C.eq(t.state.selection)){let D=t.state.tr.setSelection(C);s&&D.setMeta("composition",s),t.dispatch(D)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof dn&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),Ns&&Bd<=11&&x.endB==x.start+1&&x.endA==x.start&&x.start>u.from&&u.doc.textBetween(x.start-u.from-1,x.start-u.from+1)==" "&&(x.start--,x.endA--,x.endB--);let y=u.doc.resolveNoCache(x.start-u.from),b=u.doc.resolveNoCache(x.endB-u.from),v=d.resolve(x.start),N=y.sameParent(b)&&y.parent.inlineContent&&v.end()>=x.endA;if((Pg&&t.input.lastIOSEnter>Date.now()-225&&(!N||i.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!N&&y.pos<u.doc.content.size&&(!y.sameParent(b)||!y.parent.inlineContent)&&y.pos<b.pos&&!/\S/.test(u.doc.textBetween(y.pos,b.pos,"","")))&&t.someProp("handleKeyDown",C=>C(t,rf(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&vHe(d,x.start,x.endA,y,b)&&t.someProp("handleKeyDown",C=>C(t,rf(8,"Backspace")))){Yc&&Ia&&t.domObserver.suppressSelectionUpdates();return}Ia&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),Yc&&!N&&y.start()!=b.start()&&b.parentOffset==0&&y.depth==b.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==x.endA&&(x.endB-=2,b=u.doc.resolveNoCache(x.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(C){return C(t,rf(13,"Enter"))})},20));let S=x.start,T=x.endA,E=C=>{let D=C||t.state.tr.replace(S,T,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let A=cG(t,D.doc,u.sel);A&&!(Ia&&t.composing&&A.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(A.head==S||A.head==D.mapping.map(T)-1)||Ns&&A.empty&&A.head==S)&&D.setSelection(A)}return s&&D.setMeta("composition",s),D.scrollIntoView()},k;if(N)if(y.pos==b.pos){Ns&&Bd<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>au(t),20));let C=E(t.state.tr.delete(S,T)),D=d.resolve(x.start).marksAcross(d.resolve(x.endA));D&&C.ensureMarks(D),t.dispatch(C)}else if(x.endA==x.endB&&(k=yHe(y.parent.content.cut(y.parentOffset,b.parentOffset),v.parent.content.cut(v.parentOffset,x.endA-v.start())))){let C=E(t.state.tr);k.type=="add"?C.addMark(S,T,k.mark):C.removeMark(S,T,k.mark),t.dispatch(C)}else if(y.parent.child(y.index()).isText&&y.index()==b.index()-(b.textOffset?0:1)){let C=y.parent.textBetween(y.parentOffset,b.parentOffset),D=()=>E(t.state.tr.insertText(C,S,T));t.someProp("handleTextInput",A=>A(t,S,T,C,D))||t.dispatch(D())}else t.dispatch(E());else t.dispatch(E())}function cG(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:oL(t,e.resolve(n.anchor),e.resolve(n.head))}function yHe(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=r,o,l,c;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<n.length;d++)s=n[d].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",c=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",c=d=>d.mark(l.removeFromSet(d.marks));else return null;let u=[];for(let d=0;d<e.childCount;d++)u.push(c(e.child(d)));if(Nt.from(u).eq(t))return{mark:l,type:o}}function vHe(t,e,n,r,i){if(n-e<=i.pos-r.pos||tj(r,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&n==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=t.resolve(tj(s,!0,!0));return!o.parent.isTextblock||o.pos>n||tj(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function tj(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let s=t.node(r).maybeChild(t.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function _He(t,e,n,r,i){let s=t.findDiffStart(e,n);if(s==null)return null;let{a:o,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let c=Math.max(0,s-Math.min(o,l));r-=o+c-s}if(o<s&&t.size<e.size){let c=r<=s&&r>=o?s-r:0;s-=c,s&&s<e.size&&uG(e.textBetween(s-1,s+1))&&(s+=c?1:-1),l=s+(l-o),o=s}else if(l<s){let c=r<=s&&r>=l?s-r:0;s-=c,s&&s<t.size&&uG(t.textBetween(s-1,s+1))&&(s+=c?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function uG(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 Ite{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 z$e,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(pG),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=fG(this),hG(this),this.nodeViews=mG(this),this.docView=G9(this.state.doc,dG(this),ej(this),this.dom,this),this.domObserver=new dHe(this,(r,i,s,o)=>bHe(this,r,i,s,o)),this.domObserver.start(),B$e(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&SR(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(pG),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(kte(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let g=mG(this);SHe(g,this.nodeViews)&&(this.nodeViews=g,s=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&SR(this),this.editable=fG(this),hG(this);let c=ej(this),u=dG(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=s||!this.docView.matchesNode(e.doc,u,c);(f||!e.selection.eq(i.selection))&&(o=!0);let m=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&t$e(this);if(o){this.domObserver.stop();let g=f&&(Ns||Ia)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&wHe(i.selection,e.selection);if(f){let x=Ia?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=eHe(this)),(s||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=G9(e.doc,u,c,this.dom,this)),x&&!this.trackWrites&&(g=!0)}g||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&M$e(this))?au(this,g):(bte(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():m&&n$e(m)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Zt){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&U9(this,n.getBoundingClientRect(),e)}else U9(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-n.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new Pte(e.slice,e.move,i<0?void 0:Zt.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=n?n(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(Ns){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&&r$e(this.dom),au(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 l$e(this,e)}coordsAtPos(e,n=1){return ute(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 f$e(this,n||this.state,e)}pasteHTML(e,n){return Q0(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Q0(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return lL(this,e)}destroy(){this.docView&&($$e(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ej(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,V6e())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return V$e(this,e)}domSelectionRange(){let e=this.domSelection();return e?ts&&this.root.nodeType===11&&X6e(this.dom.ownerDocument)==this.dom&&fHe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Ite.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function dG(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"),[Ya.node(0,t.state.doc.content.size,e)]}function hG(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:Ya.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function fG(t){return!t.someProp("editable",e=>e(t.state)===!1)}function wHe(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 mG(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 SHe(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 pG(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 sh={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:"'"},WS={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},NHe=typeof navigator<"u"&&/Mac/.test(navigator.platform),MHe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Na=0;Na<10;Na++)sh[48+Na]=sh[96+Na]=String(Na);for(var Na=1;Na<=24;Na++)sh[Na+111]="F"+Na;for(var Na=65;Na<=90;Na++)sh[Na]=String.fromCharCode(Na+32),WS[Na]=String.fromCharCode(Na);for(var nj in sh)WS.hasOwnProperty(nj)||(WS[nj]=sh[nj]);function EHe(t){var e=NHe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||MHe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?WS:sh)[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 THe=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),CHe=typeof navigator<"u"&&/Win/.test(navigator.platform);function AHe(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,s,o;for(let l=0;l<e.length-1;l++){let c=e[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))THe?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),o&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function kHe(t){let e=Object.create(null);for(let n in t)e[AHe(n)]=t[n];return e}function rj(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 jHe(t){return new Qr({props:{handleKeyDown:Fte(t)}})}function Fte(t){let e=kHe(t);return function(n,r){let i=EHe(r),s,o=e[rj(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[rj(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(CHe&&r.ctrlKey&&r.altKey)&&(s=sh[r.keyCode])&&s!=i){let l=e[rj(s,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var PHe=Object.defineProperty,mL=(t,e)=>{for(var n in e)PHe(t,n,{get:e[n],enumerable:!0})};function aM(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}var sM=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...u)=>{const d=l(...u)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o=[],l=!!t,c=t||i.tr,u=()=>(!l&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),o.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(n).map(([f,m])=>[f,(...x)=>{const y=this.buildProps(c,e),b=m(...x)(y);return o.push(b),d}])),run:u};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...u)=>c(...u)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o={tr:t,editor:r,view:s,state:aM({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(...u)=>c(...u)(o)]))}};return o}},Ute={};mL(Ute,{blur:()=>RHe,clearContent:()=>DHe,clearNodes:()=>OHe,command:()=>LHe,createParagraphNear:()=>IHe,cut:()=>FHe,deleteCurrentNode:()=>UHe,deleteNode:()=>zHe,deleteRange:()=>BHe,deleteSelection:()=>$He,enter:()=>HHe,exitCode:()=>VHe,extendMarkRange:()=>GHe,first:()=>qHe,focus:()=>KHe,forEach:()=>XHe,insertContent:()=>YHe,insertContentAt:()=>JHe,joinBackward:()=>nVe,joinDown:()=>tVe,joinForward:()=>rVe,joinItemBackward:()=>iVe,joinItemForward:()=>aVe,joinTextblockBackward:()=>sVe,joinTextblockForward:()=>oVe,joinUp:()=>eVe,keyboardShortcut:()=>cVe,lift:()=>uVe,liftEmptyBlock:()=>dVe,liftListItem:()=>hVe,newlineInCode:()=>fVe,resetAttributes:()=>mVe,scrollIntoView:()=>pVe,selectAll:()=>gVe,selectNodeBackward:()=>xVe,selectNodeForward:()=>bVe,selectParentNode:()=>yVe,selectTextblockEnd:()=>vVe,selectTextblockStart:()=>_Ve,setContent:()=>wVe,setMark:()=>zVe,setMeta:()=>BVe,setNode:()=>$Ve,setNodeSelection:()=>HVe,setTextDirection:()=>VVe,setTextSelection:()=>GVe,sinkListItem:()=>qVe,splitBlock:()=>WVe,splitListItem:()=>KVe,toggleList:()=>XVe,toggleMark:()=>YVe,toggleNode:()=>QVe,toggleWrap:()=>ZVe,undoInputRule:()=>JVe,unsetAllMarks:()=>e7e,unsetMark:()=>t7e,unsetTextDirection:()=>n7e,updateAttributes:()=>r7e,wrapIn:()=>i7e,wrapInList:()=>a7e});var RHe=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),DHe=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),OHe=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:s,$to:o})=>{t.doc.nodesBetween(s.pos,o.pos,(l,c)=>{if(l.type.isText)return;const{doc:u,mapping:d}=e,f=u.resolve(d.map(c)),m=u.resolve(d.map(c+l.nodeSize)),g=f.blockRange(m);if(!g)return;const x=ax(g);if(l.type.isTextblock){const{defaultType:y}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(g.start,y)}(x||x===0)&&e.lift(g,x)})}),!0},LHe=t=>e=>t(e),IHe=()=>({state:t,dispatch:e})=>ete(t,e),FHe=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,s=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new dn(r.doc.resolve(Math.max(o-1,0)))),!0},UHe=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const l=i.before(s),c=i.after(s);t.delete(l,c).scrollIntoView()}return!0}return!1};function Ai(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 zHe=t=>({tr:e,state:n,dispatch:r})=>{const i=Ai(t,n.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){const c=s.before(o),u=s.after(o);e.delete(c,u).scrollIntoView()}return!0}return!1},BHe=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},$He=()=>({state:t,dispatch:e})=>eL(t,e),HHe=()=>({commands:t})=>t.keyboardShortcut("Enter"),VHe=()=>({state:t,dispatch:e})=>A6e(t,e);function pL(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function KS(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:pL(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function zte(t,e,n={}){return t.find(r=>r.type===e&&KS(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function gG(t,e,n={}){return!!zte(t,e,n)}function gL(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(d=>d.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(d=>d.type===e)||(n=n||((r=i.node.marks[0])==null?void 0:r.attrs),!zte([...i.node.marks],e,n)))return;let o=i.index,l=t.start()+i.offset,c=o+1,u=l+i.node.nodeSize;for(;o>0&&gG([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&gG([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function Nu(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 GHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=Nu(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const f=gL(c,s,e);if(f&&f.from<=u&&f.to>=d){const m=dn.create(o,f.from,f.to);n.setSelection(m)}}return!0},qHe=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 Bte(t){return t instanceof dn}function mf(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function $te(t,e=null){if(!e)return null;const n=Mn.atStart(t),r=Mn.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,s=r.to;return e==="all"?dn.create(t,mf(0,i,s),mf(t.content.size,i,s)):dn.create(t,mf(e,i,s),mf(e,i,s))}function WHe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function xL(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var KHe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(xL()||WHe())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(s&&t===null&&!Bte(n.state.selection))return o(),!0;const l=$te(i.doc,t)||n.state.selection,c=n.state.selection.eq(l);return s&&(c||i.setSelection(l),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},XHe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),YHe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Hte=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&&Hte(r)}return t};function C1(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 Hte(n)}function J0(t,e,n){if(t instanceof zd||t instanceof Nt)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 Nt.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(s){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",s),J0("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new Tee({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:u=>(o=!0,l=typeof u=="string"?u:u.outerHTML,null)}]}})});if(n.slice?Qb.fromSchema(c).parseSlice(C1(t),n.parseOptions):Qb.fromSchema(c).parse(C1(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=Qb.fromSchema(e);return n.slice?s.parseSlice(C1(t),n.parseOptions).content:s.parse(C1(t),n.parseOptions)}return J0("",e,n)}function QHe(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof ta||i instanceof sa))return;const s=t.mapping.maps[r];let o=0;s.forEach((l,c,u,d)=>{o===0&&(o=d)}),t.setSelection(Mn.near(t.doc.resolve(o),n))}var ZHe=t=>!("type"in t),JHe=(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{var o;if(i){n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const c=b=>{s.emit("contentError",{editor:s,error:b,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{J0(e,s.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(b){c(b)}try{l=J0(e,s.schema,{parseOptions:u,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(b){return c(b),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},m=!0,g=!0;if((ZHe(l)?l:[l]).forEach(b=>{b.check(),m=m?b.isText&&b.marks.length===0:!1,g=g?b.isBlock:!1}),d===f&&g){const{parent:b}=r.doc.resolve(d);b.isTextblock&&!b.type.spec.code&&!b.childCount&&(d-=1,f+=1)}let y;if(m){if(Array.isArray(e))y=e.map(b=>b.text||"").join("");else if(e instanceof Nt){let b="";e.forEach(v=>{v.text&&(b+=v.text)}),y=b}else typeof e=="object"&&e&&e.text?y=e.text:y=e;r.insertText(y,d,f)}else{y=l;const b=r.doc.resolve(d),v=b.node(),N=b.parentOffset===0,S=v.isText||v.isTextblock,T=v.content.size>0;N&&S&&T&&(d=Math.max(0,d-1)),r.replaceWith(d,f,y)}n.updateSelection&&QHe(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:y}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:y})}return!0},eVe=()=>({state:t,dispatch:e})=>E6e(t,e),tVe=()=>({state:t,dispatch:e})=>T6e(t,e),nVe=()=>({state:t,dispatch:e})=>Wee(t,e),rVe=()=>({state:t,dispatch:e})=>Qee(t,e),iVe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=JN(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},aVe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=JN(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},sVe=()=>({state:t,dispatch:e})=>N6e(t,e),oVe=()=>({state:t,dispatch:e})=>M6e(t,e);function Vte(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function lVe(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,s,o;for(let l=0;l<e.length-1;l+=1){const c=e[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))xL()||Vte()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),s&&(n=`Shift-${n}`),n}var cVe=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=lVe(t).split(/-(?!$)/),o=s.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{n.someProp("handleKeyDown",u=>u(n,l))});return c?.steps.forEach(u=>{const d=u.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function oh(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,o=e?Ai(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(f,m)=>{if(f.isText)return;const g=Math.max(r,m),x=Math.min(i,m+f.nodeSize);l.push({node:f,from:g,to:x})});const c=i-r,u=l.filter(f=>o?o.name===f.node.type.name:!0).filter(f=>KS(f.node.attrs,n,{strict:!1}));return s?!!u.length:u.reduce((f,m)=>f+m.to-m.from,0)>=c}var uVe=(t,e={})=>({state:n,dispatch:r})=>{const i=Ai(t,n.schema);return oh(n,i,e)?C6e(n,r):!1},dVe=()=>({state:t,dispatch:e})=>tte(t,e),hVe=t=>({state:e,dispatch:n})=>{const r=Ai(t,e.schema);return z6e(r)(e,n)},fVe=()=>({state:t,dispatch:e})=>Jee(t,e);function oM(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function xG(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 mVe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=oM(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=Ai(t,r.schema)),l==="mark"&&(o=Nu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,f)=>{s&&s===d.type&&(c=!0,i&&n.setNodeMarkup(f,void 0,xG(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(m=>{o===m.type&&(c=!0,i&&n.addMark(f,f+d.nodeSize,o.create(xG(m.attrs,e))))})})}),c},pVe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),gVe=()=>({tr:t,dispatch:e})=>{if(e){const n=new Qs(t.doc);t.setSelection(n)}return!0},xVe=()=>({state:t,dispatch:e})=>Xee(t,e),bVe=()=>({state:t,dispatch:e})=>Zee(t,e),yVe=()=>({state:t,dispatch:e})=>P6e(t,e),vVe=()=>({state:t,dispatch:e})=>O6e(t,e),_Ve=()=>({state:t,dispatch:e})=>D6e(t,e);function NR(t,e,n={},r={}){return J0(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var wVe=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{const{doc:c}=s;if(r.preserveWhitespace!=="full"){const u=NR(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&s.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!n),!0}return o&&s.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:c.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function Gte(t,e){const n=Nu(e,t.schema),{from:r,to:i,empty:s}=t.selection,o=[];s?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,c=>{o.push(...c.marks)});const l=o.find(c=>c.type.name===n.name);return l?{...l.attrs}:{}}function qte(t,e){const n=new Hee(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function SVe(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 NVe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function MVe(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 lM(t){return e=>MVe(e.$from,t)}function Qt(t,e,n){return t.config[e]===void 0&&t.parent?Qt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Qt(t.parent,e,n):null}):t.config[e]}function bL(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Qt(e,"addExtensions",n);return r?[e,...bL(r())]:e}).flat(10)}function yL(t,e){const n=cm.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function Wte(t){return typeof t=="function"}function sr(t,e=void 0,...n){return Wte(t)?e?t.bind(e)(...n):t(...n):t}function EVe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Rg(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 Kte(t){const e=[],{nodeExtensions:n,markExtensions:r}=Rg(t),i=[...n,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:i},c=Qt(o,"addGlobalAttributes",l);if(!c)return;c().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([m,g])=>{e.push({type:f,name:m,attribute:{...s,...g}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},c=Qt(o,"addAttributes",l);if(!c)return;const u=c();Object.entries(u).forEach(([d,f])=>{const m={...s,...f};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:o.name,name:d,attribute:m})})}),e}function li(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const l=s?String(s).split(" "):[],c=r[i]?r[i].split(" "):[],u=l.filter(d=>!c.includes(d));r[i]=[...c,...u].join(" ")}else if(i==="style"){const l=s?s.split(";").map(d=>d.trim()).filter(Boolean):[],c=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],u=new Map;c.forEach(d=>{const[f,m]=d.split(":").map(g=>g.trim());u.set(f,m)}),l.forEach(d=>{const[f,m]=d.split(":").map(g=>g.trim());u.set(f,m)}),r[i]=Array.from(u.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=s}),r},{})}function XS(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)=>li(n,r),{})}function TVe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function bG(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((s,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):TVe(n.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...r,...i}}}}function yG(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&EVe(n)?!1:n!=null))}function vG(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 CVe(t,e){var n;const r=Kte(t),{nodeExtensions:i,markExtensions:s}=Rg(t),o=(n=i.find(u=>Qt(u,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(u=>{const d=r.filter(v=>v.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},m=t.reduce((v,N)=>{const S=Qt(N,"extendNodeSchema",f);return{...v,...S?S(u):{}}},{}),g=yG({...m,content:sr(Qt(u,"content",f)),marks:sr(Qt(u,"marks",f)),group:sr(Qt(u,"group",f)),inline:sr(Qt(u,"inline",f)),atom:sr(Qt(u,"atom",f)),selectable:sr(Qt(u,"selectable",f)),draggable:sr(Qt(u,"draggable",f)),code:sr(Qt(u,"code",f)),whitespace:sr(Qt(u,"whitespace",f)),linebreakReplacement:sr(Qt(u,"linebreakReplacement",f)),defining:sr(Qt(u,"defining",f)),isolating:sr(Qt(u,"isolating",f)),attrs:Object.fromEntries(d.map(vG))}),x=sr(Qt(u,"parseHTML",f));x&&(g.parseDOM=x.map(v=>bG(v,d)));const y=Qt(u,"renderHTML",f);y&&(g.toDOM=v=>y({node:v,HTMLAttributes:XS(v,d)}));const b=Qt(u,"renderText",f);return b&&(g.toText=b),[u.name,g]})),c=Object.fromEntries(s.map(u=>{const d=r.filter(b=>b.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},m=t.reduce((b,v)=>{const N=Qt(v,"extendMarkSchema",f);return{...b,...N?N(u):{}}},{}),g=yG({...m,inclusive:sr(Qt(u,"inclusive",f)),excludes:sr(Qt(u,"excludes",f)),group:sr(Qt(u,"group",f)),spanning:sr(Qt(u,"spanning",f)),code:sr(Qt(u,"code",f)),attrs:Object.fromEntries(d.map(vG))}),x=sr(Qt(u,"parseHTML",f));x&&(g.parseDOM=x.map(b=>bG(b,d)));const y=Qt(u,"renderHTML",f);return y&&(g.toDOM=b=>y({mark:b,HTMLAttributes:XS(b,d)})),[u.name,g]}));return new Tee({topNode:o,nodes:l,marks:c})}function AVe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function vL(t){return t.sort((n,r)=>{const i=Qt(n,"priority")||100,s=Qt(r,"priority")||100;return i>s?-1:i<s?1:0})}function Xte(t){const e=vL(bL(t)),n=AVe(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 Yte(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=`
- `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(c,u,d,f)=>{var m;c.isBlock&&u>r&&(l+=s);const g=o?.[c.type.name];if(g)return d&&(l+=g({node:c,pos:u,parent:d,index:f,range:e})),!1;c.isText&&(l+=(m=c?.text)==null?void 0:m.slice(Math.max(r,u)-u,i-u))}),l}function kVe(t,e){const n={from:0,to:t.content.size};return Yte(t,n,e)}function Qte(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function jVe(t,e){const n=Ai(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function Zte(t,e){const n=oM(typeof e=="string"?e:e.name,t.schema);return n==="node"?jVe(t,e):n==="mark"?Gte(t,e):{}}function PVe(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 RVe(t){const e=PVe(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,o)=>o!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function Jte(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((l,c)=>{o.push({from:l,to:c})});else{const{from:l,to:c}=n[s];if(l===void 0||c===void 0)return;o.push({from:l,to:c})}o.forEach(({from:l,to:c})=>{const u=e.slice(s).map(l,-1),d=e.slice(s).map(c),f=e.invert().map(u,-1),m=e.invert().map(d);r.push({oldRange:{from:f,to:m},newRange:{from:u,to:d}})})}),RVe(r)}function _L(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t),o=gL(s,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,s)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}var DVe=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let s=r,o=null;for(;s>0&&o===null;){const l=i.node(s);l?.type.name===e?o=l:s-=1}return[o,s]};function ij(t,e){return e.nodes[t]||e.marks[t]||null}function cw(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}var OVe=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,s,o,l)=>{var c,u;const d=((u=(c=i.type.spec).toText)==null?void 0:u.call(c,{node:i,pos:s,parent:o,index:l}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-s))}),n};function MR(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?Nu(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>s?s.name===f.type.name:!0).find(f=>KS(f.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:f,$to:m})=>{const g=f.pos,x=m.pos;t.doc.nodesBetween(g,x,(y,b)=>{if(!y.isText&&!y.marks.length)return;const v=Math.max(g,b),N=Math.min(x,b+y.nodeSize),S=N-v;o+=S,l.push(...y.marks.map(T=>({mark:T,from:v,to:N})))})}),o===0)return!1;const c=l.filter(f=>s?s.name===f.mark.type.name:!0).filter(f=>KS(f.mark.attrs,n,{strict:!1})).reduce((f,m)=>f+m.to-m.from,0),u=l.filter(f=>s?f.mark.type!==s&&f.mark.type.excludes(s):!0).reduce((f,m)=>f+m.to-m.from,0);return(c>0?c+u:c)>=o}function LVe(t,e,n={}){if(!e)return oh(t,null,n)||MR(t,null,n);const r=oM(e,t.schema);return r==="node"?oh(t,e,n):r==="mark"?MR(t,e,n):!1}var IVe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const s=lM(l=>l.type.name===e)(t.selection);if(!s)return!1;const o=t.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},FVe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function _G(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function wG(t,e){const{nodeExtensions:n}=Rg(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=sr(Qt(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function cM(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(s=>{i!==!1&&(cM(s,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function ene(t){return t instanceof Zt}function UVe(t,e,n){var r;const{selection:i}=e;let s=null;if(Bte(i)&&(s=i.$cursor),s){const l=(r=t.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(u=>u.type.excludes(n)))}const{ranges:o}=i;return o.some(({$from:l,$to:c})=>{let u=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,c.pos,(d,f,m)=>{if(u)return!1;if(d.isInline){const g=!m||m.type.allowsMarkType(n),x=!!n.isInSet(d.marks)||!d.marks.some(y=>y.type.excludes(n));u=g&&x}return!u}),u})}var zVe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:l}=s,c=Nu(t,r.schema);if(i)if(o){const u=Gte(r,c);n.addStoredMark(c.create({...u,...e}))}else l.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;r.doc.nodesBetween(d,f,(m,g)=>{const x=Math.max(g,d),y=Math.min(g+m.nodeSize,f);m.marks.find(v=>v.type===c)?m.marks.forEach(v=>{c===v.type&&n.addMark(x,y,c.create({...v.attrs,...e}))}):n.addMark(x,y,c.create(e))})});return UVe(r,n,c)},BVe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),$Ve=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=Ai(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>L9(s,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>L9(s,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},HVe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=mf(t,0,r.content.size),s=Zt.create(r,i);e.setSelection(s)}return!0},VVe=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=r;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=s.from,l=s.to),i&&n.doc.nodesBetween(o,l,(c,u)=>{c.isText||n.setNodeMarkup(u,void 0,{...c.attrs,dir:t})}),!0},GVe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,o=dn.atStart(r).from,l=dn.atEnd(r).to,c=mf(i,o,l),u=mf(s,o,l),d=dn.create(r,c,u);e.setSelection(d)}return!0},qVe=t=>({state:e,dispatch:n})=>{const r=Ai(t,e.schema);return H6e(r)(e,n)};function SG(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 WVe=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:c}=s,u=i.extensionManager.attributes,d=cw(u,l.node().type.name,l.node().attrs);if(s instanceof Zt&&s.node.isBlock)return!l.parentOffset||!iu(o,l.pos)?!1:(r&&(t&&SG(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,m=l.depth===0?void 0:SVe(l.node(-1).contentMatchAt(l.indexAfter(-1)));let g=f&&m?[{type:m,attrs:d}]:void 0,x=iu(e.doc,e.mapping.map(l.pos),1,g);if(!g&&!x&&iu(e.doc,e.mapping.map(l.pos),1,m?[{type:m}]:void 0)&&(x=!0,g=m?[{type:m,attrs:d}]:void 0),r){if(x&&(s instanceof dn&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,g),m&&!f&&!l.parentOffset&&l.parent.type!==m)){const y=e.mapping.map(l.before()),b=e.doc.resolve(y);l.node(-1).canReplaceWith(b.index(),b.index()+1,m)&&e.setNodeMarkup(e.mapping.map(l.before()),m)}t&&SG(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},KVe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var o;const l=Ai(t,r.schema),{$from:c,$to:u}=r.selection,d=r.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(u))return!1;const f=c.node(-1);if(f.type!==l)return!1;const m=s.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(i){let v=Nt.empty;const N=c.index(-1)?1:c.index(-2)?2:3;for(let D=c.depth-N;D>=c.depth-3;D-=1)v=Nt.from(c.node(D).copy(v));const S=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,T={...cw(m,c.node().type.name,c.node().attrs),...e},E=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(T))||void 0;v=v.append(Nt.from(l.createAndFill(null,E)||void 0));const k=c.before(c.depth-(N-1));n.replace(k,c.after(-S),new Ft(v,4-N,0));let C=-1;n.doc.nodesBetween(k,n.doc.content.size,(D,A)=>{if(C>-1)return!1;D.isTextblock&&D.content.size===0&&(C=A+1)}),C>-1&&n.setSelection(dn.near(n.doc.resolve(C))),n.scrollIntoView()}return!0}const g=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,x={...cw(m,f.type.name,f.attrs),...e},y={...cw(m,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const b=g?[{type:l,attrs:x},{type:g,attrs:y}]:[{type:l,attrs:x}];if(!iu(n.doc,c.pos,2))return!1;if(i){const{selection:v,storedMarks:N}=r,{splittableMarks:S}=s.extensionManager,T=N||v.$to.parentOffset&&v.$from.marks();if(n.split(c.pos,2,b).scrollIntoView(),!T||!i)return!0;const E=T.filter(k=>S.includes(k.type.name));n.ensureMarks(E)}return!0},aj=(t,e)=>{const n=lM(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&mh(t.doc,n.pos)&&t.join(n.pos),!0},sj=(t,e)=>{const n=lM(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&mh(t.doc,r)&&t.join(r),!0},XVe=(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:f,splittableMarks:m}=i.extensionManager,g=Ai(t,o.schema),x=Ai(e,o.schema),{selection:y,storedMarks:b}=o,{$from:v,$to:N}=y,S=v.blockRange(N),T=b||y.$to.parentOffset&&y.$from.marks();if(!S)return!1;const E=lM(k=>wG(k.type.name,f))(y);if(S.depth>=1&&E&&S.depth-E.depth<=1){if(E.node.type===g)return u.liftListItem(x);if(wG(E.node.type.name,f)&&g.validContent(E.node.content)&&l)return c().command(()=>(s.setNodeMarkup(E.pos,g),!0)).command(()=>aj(s,g)).command(()=>sj(s,g)).run()}return!n||!T||!l?c().command(()=>d().wrapInList(g,r)?!0:u.clearNodes()).wrapInList(g,r).command(()=>aj(s,g)).command(()=>sj(s,g)).run():c().command(()=>{const k=d().wrapInList(g,r),C=T.filter(D=>m.includes(D.type.name));return s.ensureMarks(C),k?!0:u.clearNodes()}).wrapInList(g,r).command(()=>aj(s,g)).command(()=>sj(s,g)).run()},YVe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=Nu(t,r.schema);return MR(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},QVe=(t,e,n={})=>({state:r,commands:i})=>{const s=Ai(t,r.schema),o=Ai(e,r.schema),l=oh(r,s,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),l?i.setNode(o,c):i.setNode(s,{...c,...n})},ZVe=(t,e={})=>({state:n,commands:r})=>{const i=Ai(t,n.schema);return oh(n,i,e)?r.lift(i):r.wrapIn(i,e)},JVe=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const o=t.tr,l=s.transform;for(let c=l.steps.length-1;c>=0;c-=1)o.step(l.steps[c].invert(l.docs[c]));if(s.text){const c=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,t.schema.text(s.text,c))}else o.delete(s.from,s.to)}return!0}}return!1},e7e=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(s=>{t.removeMark(s.$from.pos,s.$to.pos)}),!0},t7e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=Nu(t,r.schema),{$from:u,empty:d,ranges:f}=l;if(!i)return!0;if(d&&o){let{from:m,to:g}=l;const x=(s=u.marks().find(b=>b.type===c))==null?void 0:s.attrs,y=gL(u,c,x);y&&(m=y.from,g=y.to),n.removeMark(m,g,c)}else f.forEach(m=>{n.removeMark(m.$from.pos,m.$to.pos,c)});return n.removeStoredMark(c),!0},n7e=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let s,o;return typeof t=="number"?(s=t,o=t):t&&"from"in t&&"to"in t?(s=t.from,o=t.to):(s=i.from,o=i.to),r&&e.doc.nodesBetween(s,o,(l,c)=>{if(l.isText)return;const u={...l.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},r7e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=oM(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=Ai(t,r.schema)),l==="mark"&&(o=Nu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let m,g,x,y;n.selection.empty?r.doc.nodesBetween(d,f,(b,v)=>{s&&s===b.type&&(c=!0,x=Math.max(v,d),y=Math.min(v+b.nodeSize,f),m=v,g=b)}):r.doc.nodesBetween(d,f,(b,v)=>{v<d&&s&&s===b.type&&(c=!0,x=Math.max(v,d),y=Math.min(v+b.nodeSize,f),m=v,g=b),v>=d&&v<=f&&(s&&s===b.type&&(c=!0,i&&n.setNodeMarkup(v,void 0,{...b.attrs,...e})),o&&b.marks.length&&b.marks.forEach(N=>{if(o===N.type&&(c=!0,i)){const S=Math.max(v,d),T=Math.min(v+b.nodeSize,f);n.addMark(S,T,o.create({...N.attrs,...e}))}}))}),g&&(m!==void 0&&i&&n.setNodeMarkup(m,void 0,{...g.attrs,...e}),o&&g.marks.length&&g.marks.forEach(b=>{o===b.type&&i&&n.addMark(x,y,o.create({...b.attrs,...e}))}))}),c},i7e=(t,e={})=>({state:n,dispatch:r})=>{const i=Ai(t,n.schema);return L6e(i,e)(n,r)},a7e=(t,e={})=>({state:n,dispatch:r})=>{const i=Ai(t,n.schema);return I6e(i,e)(n,r)},s7e=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},uM=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},o7e=(t,e)=>{if(pL(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 A1(t){var e;const{editor:n,from:r,to:i,text:s,rules:o,plugin:l}=t,{view:c}=n;if(c.composing)return!1;const u=c.state.doc.resolve(r);if(u.parent.type.spec.code||(e=u.nodeBefore||u.nodeAfter)!=null&&e.marks.find(m=>m.type.spec.code))return!1;let d=!1;const f=OVe(u)+s;return o.forEach(m=>{if(d)return;const g=o7e(f,m.find);if(!g)return;const x=c.state.tr,y=aM({state:c.state,transaction:x}),b={from:r-(g[0].length-s.length),to:i},{commands:v,chain:N,can:S}=new sM({editor:n,state:y});m.handler({state:y,range:b,match:g,commands:v,chain:N,can:S})===null||!x.steps.length||(m.undoable&&x.setMeta(l,{transform:x,from:r,to:i,text:s}),c.dispatch(x),d=!0)}),d}function l7e(t){const{editor:e,rules:n}=t,r=new Qr({state:{init(){return null},apply(i,s,o){const l=i.getMeta(r);if(l)return l;const c=i.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:d}=c;typeof d=="string"?d=d:d=yL(Nt.from(d),o.schema);const{from:f}=c,m=f+d.length;A1({editor:e,from:f,to:m,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return A1({editor:e,from:s,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&A1({editor:e,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?A1({editor:e,from:o.pos,to:o.pos,text:`
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function c7e(t){return Object.prototype.toString.call(t).slice(8,-1)}function k1(t){return c7e(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function tne(t,e){const n={...t};return k1(t)&&k1(e)&&Object.keys(e).forEach(r=>{k1(e[r])&&k1(t[r])?n[r]=tne(t[r],e[r]):n[r]=e[r]}),n}var wL=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{...sr(Qt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...sr(Qt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>tne(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}},gh=class nne extends wL{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new nne(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(u=>u?.type.name===n.name))return!1;const c=o.find(u=>u?.type.name===n.name);return c&&r.removeStoredMark(c),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function u7e(t){return typeof t=="number"}var d7e=class{constructor(t){this.find=t.find,this.handler=t.handler}},h7e=(t,e,n)=>{if(pL(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=t,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function f7e(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:u,can:d}=new sM({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(g,x)=>{var y,b,v,N,S;if((b=(y=g.type)==null?void 0:y.spec)!=null&&b.code||!(g.isText||g.isTextblock||g.isInline))return;const T=(S=(N=(v=g.content)==null?void 0:v.size)!=null?N:g.nodeSize)!=null?S:0,E=Math.max(r,x),k=Math.min(i,x+T);if(E>=k)return;const C=g.isText?g.text||"":g.textBetween(E-x,k-x,void 0,"");h7e(C,s.find,o).forEach(A=>{if(A.index===void 0)return;const R=E+A.index+1,F=R+A[0].length,O={from:n.tr.mapping.map(R),to:n.tr.mapping.map(F)},q=s.handler({state:n,range:O,match:A,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});f.push(q)})}),f.every(g=>g!==null)}var j1=null,m7e=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function p7e(t){const{editor:e,rules:n}=t;let r=null,i=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const c=({state:d,from:f,to:m,rule:g,pasteEvt:x})=>{const y=d.tr,b=aM({state:d,transaction:y});if(!(!f7e({editor:e,state:b,from:Math.max(f-1,0),to:m.b-1,rule:g,pasteEvent:x,dropEvent:l})||!y.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,y}};return n.map(d=>new Qr({view(f){const m=x=>{var y;r=(y=f.dom.parentElement)!=null&&y.contains(x.target)?f.dom.parentElement:null,r&&(j1=e)},g=()=>{j1&&(j1=null)};return window.addEventListener("dragstart",m),window.addEventListener("dragend",g),{destroy(){window.removeEventListener("dragstart",m),window.removeEventListener("dragend",g)}}},props:{handleDOMEvents:{drop:(f,m)=>{if(s=r===f.dom.parentElement,l=m,!s){const g=j1;g?.isEditable&&setTimeout(()=>{const x=g.state.selection;x&&g.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(f,m)=>{var g;const x=(g=m.clipboardData)==null?void 0:g.getData("text/html");return o=m,i=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(f,m,g)=>{const x=f[0],y=x.getMeta("uiEvent")==="paste"&&!i,b=x.getMeta("uiEvent")==="drop"&&!s,v=x.getMeta("applyPasteRules"),N=!!v;if(!y&&!b&&!N)return;if(N){let{text:E}=v;typeof E=="string"?E=E:E=yL(Nt.from(E),g.schema);const{from:k}=v,C=k+E.length,D=m7e(E);return c({rule:d,state:g,from:k,to:{b:C},pasteEvt:D})}const S=m.doc.content.findDiffStart(g.doc.content),T=m.doc.content.findDiffEnd(g.doc.content);if(!(!u7e(S)||!T||S===T.b))return c({rule:d,state:g,from:S,to:T,pasteEvt:o})}}))}var dM=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=Xte(t),this.schema=CVe(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:ij(e.name,this.schema)},r=Qt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return vL([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:ij(r.name,this.schema)},s=[],o=Qt(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&Qt(r,"exitable",i)&&(l.ArrowRight=()=>gh.handleExit({editor:t,mark:r})),o){const m=Object.fromEntries(Object.entries(o()).map(([g,x])=>[g,()=>x({editor:t})]));l={...l,...m}}const c=jHe(l);s.push(c);const u=Qt(r,"addInputRules",i);if(_G(r,t.options.enableInputRules)&&u){const m=u();if(m&&m.length){const g=l7e({editor:t,rules:m}),x=Array.isArray(g)?g:[g];s.push(...x)}}const d=Qt(r,"addPasteRules",i);if(_G(r,t.options.enablePasteRules)&&d){const m=d();if(m&&m.length){const g=p7e({editor:t,rules:m});s.push(...g)}}const f=Qt(r,"addProseMirrorPlugins",i);if(f){const m=f();s.push(...m)}return s})}get attributes(){return Kte(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Rg(this.extensions);return Object.fromEntries(e.filter(n=>!!Qt(n,"addNodeView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ai(n.name,this.schema)},s=Qt(n,"addNodeView",i);if(!s)return[];const o=s();if(!o)return[];const l=(c,u,d,f,m)=>{const g=XS(c,r);return o({node:c,view:u,getPos:d,decorations:f,innerDecorations:m,editor:t,extension:n,HTMLAttributes:g})};return[n.name,l]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=Rg(this.extensions);return Object.fromEntries(e.filter(n=>!!Qt(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Nu(n.name,this.schema)},s=Qt(n,"addMarkView",i);if(!s)return[];const o=(l,c,u)=>{const d=XS(l,r);return s()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{k7e(l,t,f)}})};return[n.name,o]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ij(e.name,this.schema)};e.type==="mark"&&((n=sr(Qt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Qt(e,"onBeforeCreate",r),s=Qt(e,"onCreate",r),o=Qt(e,"onUpdate",r),l=Qt(e,"onSelectionUpdate",r),c=Qt(e,"onTransaction",r),u=Qt(e,"onFocus",r),d=Qt(e,"onBlur",r),f=Qt(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};dM.resolve=Xte;dM.sort=vL;dM.flatten=bL;var g7e={};mL(g7e,{ClipboardTextSerializer:()=>ine,Commands:()=>ane,Delete:()=>sne,Drop:()=>one,Editable:()=>lne,FocusEvents:()=>une,Keymap:()=>dne,Paste:()=>hne,Tabindex:()=>fne,TextDirection:()=>mne,focusEventsPluginKey:()=>cne});var _r=class rne extends wL{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new rne(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},ine=_r.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Qr({key:new Gi("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(d=>d.$from.pos)),l=Math.max(...s.map(d=>d.$to.pos)),c=Qte(n);return Yte(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),ane=_r.create({name:"commands",addCommands(){return{...Ute}}}),sne=_r.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const s=()=>{var o,l,c,u;if((u=(c=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:c.call(l,t))!=null?u:t.getMeta("y-sync$"))return;const d=qte(t.before,[t,...e]);Jte(d).forEach(g=>{d.mapping.mapResult(g.oldRange.from).deletedAfter&&d.mapping.mapResult(g.oldRange.to).deletedBefore&&d.before.nodesBetween(g.oldRange.from,g.oldRange.to,(x,y)=>{const b=y+x.nodeSize-2,v=g.oldRange.from<=y&&b<=g.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:y,to:b,newFrom:d.mapping.map(y),newTo:d.mapping.map(b),deletedRange:g.oldRange,newRange:g.newRange,partial:!v,editor:this.editor,transaction:t,combinedTransform:d})})});const m=d.mapping;d.steps.forEach((g,x)=>{var y,b;if(g instanceof al){const v=m.slice(x).map(g.from,-1),N=m.slice(x).map(g.to),S=m.invert().map(v,-1),T=m.invert().map(N),E=(y=d.doc.nodeAt(v-1))==null?void 0:y.marks.some(C=>C.eq(g.mark)),k=(b=d.doc.nodeAt(N))==null?void 0:b.marks.some(C=>C.eq(g.mark));this.editor.emit("delete",{type:"mark",mark:g.mark,from:g.from,to:g.to,deletedRange:{from:S,to:T},newRange:{from:v,to:N},partial:!!(k||E),editor:this.editor,transaction:t,combinedTransform:d})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),one=_r.create({name:"drop",addProseMirrorPlugins(){return[new Qr({key:new Gi("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),lne=_r.create({name:"editable",addProseMirrorPlugins(){return[new Qr({key:new Gi("editable"),props:{editable:()=>this.editor.options.editable}})]}}),cne=new Gi("focusEvents"),une=_r.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Qr({key:cne,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}}}})]}}),dne=_r.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:c,doc:u}=l,{empty:d,$anchor:f}=c,{pos:m,parent:g}=f,x=f.parent.isTextblock&&m>0?l.doc.resolve(m-1):f,y=x.parent.type.spec.isolating,b=f.pos-f.parentOffset,v=y&&x.parent.childCount===1?b===f.pos:Mn.atStart(u).from===m;return!d||!g.type.isTextblock||g.textContent.length||!v||v&&f.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return xL()||Vte()?s:i},addProseMirrorPlugins(){return[new Qr({key:new Gi("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(y=>y.getMeta("composition")))return;const r=t.some(y=>y.docChanged)&&!e.doc.eq(n.doc),i=t.some(y=>y.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:o,to:l}=e.selection,c=Mn.atStart(e.doc).from,u=Mn.atEnd(e.doc).to;if(s||!(o===c&&l===u)||!cM(n.doc))return;const m=n.tr,g=aM({state:n,transaction:m}),{commands:x}=new sM({editor:this.editor,state:g});if(x.clearNodes(),!!m.steps.length)return m}})]}}),hne=_r.create({name:"paste",addProseMirrorPlugins(){return[new Qr({key:new Gi("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),fne=_r.create({name:"tabindex",addProseMirrorPlugins(){return[new Qr({key:new Gi("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),mne=_r.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Rg(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 Qr({key:new Gi("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),x7e=class Ip{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 Ip(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 Ip(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 Ip(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,s=n.isAtom&&!n.isText,o=this.pos+r+(s?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!i&&l.depth<=this.depth)return;const c=new Ip(l,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),e.push(new Ip(l,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const s=i.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const c=o[l];if(s[c]!==n[c])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(n);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&s.every(c=>n[c]===o.node.attrs[c])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},b7e=`.ProseMirror {
- position: relative;
- }
- .ProseMirror {
- word-wrap: break-word;
- white-space: pre-wrap;
- white-space: break-spaces;
- -webkit-font-variant-ligatures: none;
- font-variant-ligatures: none;
- font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
- }
- .ProseMirror [contenteditable="false"] {
- white-space: normal;
- }
- .ProseMirror [contenteditable="false"] [contenteditable="true"] {
- white-space: pre-wrap;
- }
- .ProseMirror pre {
- white-space: pre-wrap;
- }
- img.ProseMirror-separator {
- display: inline !important;
- border: none !important;
- margin: 0 !important;
- width: 0 !important;
- height: 0 !important;
- }
- .ProseMirror-gapcursor {
- display: none;
- pointer-events: none;
- position: absolute;
- margin: 0;
- }
- .ProseMirror-gapcursor:after {
- content: "";
- display: block;
- position: absolute;
- top: -2px;
- width: 20px;
- border-top: 1px solid black;
- animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
- }
- @keyframes ProseMirror-cursor-blink {
- to {
- visibility: hidden;
- }
- }
- .ProseMirror-hideselection *::selection {
- background: transparent;
- }
- .ProseMirror-hideselection *::-moz-selection {
- background: transparent;
- }
- .ProseMirror-hideselection * {
- caret-color: transparent;
- }
- .ProseMirror-focused .ProseMirror-gapcursor {
- display: block;
- }`;function y7e(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 v7e=class extends s7e{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:i,moved:s})=>this.options.onDrop(r,i,s)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=$te(e,this.options.autofocus);this.editorState=Gp.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=y7e(b7e,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=Wte(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(i=>{const s=typeof i=="string"?`${i}$`:i.key;n=n.filter(o=>!o.key.startsWith(s))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[lne,ine.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),ane,une,dne,fne,one,hne,sne,mne.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 dM(r,this)}createCommandManager(){this.commandManager=new sM({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=NR(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=NR(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new Ite(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS();const r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(u=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(u)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),l=o?.getMeta("focus"),c=o?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),c&&this.emit("blur",{editor:this,event:c.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(u=>u.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Zte(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return LVe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return yL(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return kVe(this.state.doc,{blockSeparator:e,textSerializers:{...Qte(this.schema),...n}})}get isEmpty(){return cM(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 x7e(e,this)}get $doc(){return this.$pos(0)}};function Dg(t){return new uM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=sr(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,o=r[r.length-1],l=r[0];if(o){const c=l.search(/\S/),u=n.from+l.indexOf(o),d=u+o.length;if(_L(n.from,n.to,e.doc).filter(g=>g.mark.type.excluded.find(y=>y===t.type&&y!==g.mark.type)).filter(g=>g.to>u).length)return null;d<n.to&&s.delete(d,n.to),u>n.from&&s.delete(n.from+c,u);const m=n.from+c+o.length;s.addMark(n.from+c,m,t.type.create(i||{})),s.removeStoredMark(t.type)}},undoable:t.undoable})}function pne(t){return new uM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=sr(t.getAttributes,void 0,r)||{},{tr:s}=e,o=n.from;let l=n.to;const c=t.type.create(i);if(r[1]){const u=r[0].lastIndexOf(r[1]);let d=o+u;d>l?d=l:l=d+r[1].length;const f=r[0][r[0].length-1];s.insertText(f,o+r[0].length-1),s.replaceWith(d,l,c)}else if(r[0]){const u=t.type.isInline?o:o-1;s.insert(u,t.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:t.undoable})}function ER(t){return new uM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=sr(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)},undoable:t.undoable})}function Og(t){return new uM({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=sr(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),u=c&&ZO(c,t.type,s);if(!u)return null;if(o.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:m}=e,{splittableMarks:g}=t.editor.extensionManager,x=m||f.$to.parentOffset&&f.$from.marks();if(x){const y=x.filter(b=>g.includes(b.type.name));o.ensureMarks(y)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,s).run()}const d=o.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&mh(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}var _7e=t=>"touches"in t,w7e=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=o=>{if(!this.isResizing||!this.activeHandle)return;const l=o.clientX-this.startX,c=o.clientY-this.startY;this.handleResize(l,c)},this.handleTouchMove=o=>{if(!this.isResizing||!this.activeHandle)return;const l=o.touches[0];if(!l)return;const c=l.clientX-this.startX,u=l.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const o=this.element.offsetWidth,l=this.element.offsetHeight;this.onCommit(o,l),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=o=>{o.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=o=>{o.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,s;this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t?.options)!=null&&r.directions&&(this.directions=t.options.directions),(i=t.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(s=t.options)!=null&&s.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()}get dom(){return this.container}get contentDOM(){return this.contentElement}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",t.style.justifyContent="flex-start",t.style.alignItems="flex-start",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),s=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),s&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{const e=this.createHandle(t);this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.wrapper.appendChild(e)})}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,_7e(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,t,e),s=this.applyConstraints(r,i,n);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const s=t.includes("right"),o=t.includes("left"),l=t.includes("bottom"),c=t.includes("top");return s?r=this.startWidth+e:o&&(r=this.startWidth-e),l?i=this.startHeight+n:c&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(s?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,s,o;if(!n){let u=Math.max(this.minSize.width,t),d=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(u=Math.min(this.maxSize.width,u)),(i=this.maxSize)!=null&&i.height&&(d=Math.min(this.maxSize.height,d)),{width:u,height:d}}let l=t,c=e;return l<this.minSize.width&&(l=this.minSize.width,c=l/this.aspectRatio),c<this.minSize.height&&(c=this.minSize.height,l=c*this.aspectRatio),(s=this.maxSize)!=null&&s.width&&l>this.maxSize.width&&(l=this.maxSize.width,c=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&c>this.maxSize.height&&(c=this.maxSize.height,l=c*this.aspectRatio),{width:l,height:c}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function S7e(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Zt){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){const s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}var N7e={};mL(N7e,{createAtomBlockMarkdownSpec:()=>M7e,createBlockMarkdownSpec:()=>E7e,createInlineMarkdownSpec:()=>A7e,parseAttributes:()=>SL,parseIndentedBlocks:()=>TR,renderNestedMarkdownContent:()=>ML,serializeAttributes:()=>NL});function SL(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,u=>(n.push(u),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const u=i.map(d=>d.trim().slice(1));e.class=u.join(" ")}const s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,u,d])=>{var f;const m=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),g=n[m];g&&(e[u]=g.slice(1,-1))});const c=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return c&&c.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function NL(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 M7e(t){const{nodeName:e,name:n,parseAttributes:r=SL,serializeAttributes:i=NL,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const f={};return l.forEach(m=>{m in d&&(f[m]=d[m])}),f};return{parseMarkdown:(d,f)=>{const m={...s,...d.attributes};return f.createNode(e,m,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const m=new RegExp(`^:::${c}(?:\\s|$)`,"m"),g=(f=d.match(m))==null?void 0:f.index;return g!==void 0?g:-1},tokenize(d,f,m){const g=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=d.match(g);if(!x)return;const y=x[1]||"",b=r(y);if(!o.find(N=>!(N in b)))return{type:e,raw:x[0],attributes:b}}},renderMarkdown:d=>{const f=u(d.attrs||{}),m=i(f),g=m?` {${m}}`:"";return`:::${c}${g} :::`}}}function E7e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=SL,serializeAttributes:s=NL,defaultAttributes:o={},content:l="block",allowedAttributes:c}=t,u=n||e,d=f=>{if(!c)return f;const m={};return c.forEach(g=>{g in f&&(m[g]=f[g])}),m};return{parseMarkdown:(f,m)=>{let g;if(r){const y=r(f);g=typeof y=="string"?[{type:"text",text:y}]:y}else l==="block"?g=m.parseChildren(f.tokens||[]):g=m.parseInline(f.tokens||[]);const x={...o,...f.attributes};return m.createNode(e,x,g)},markdownTokenizer:{name:e,level:"block",start(f){var m;const g=new RegExp(`^:::${u}`,"m"),x=(m=f.match(g))==null?void 0:m.index;return x!==void 0?x:-1},tokenize(f,m,g){var x;const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),b=f.match(y);if(!b)return;const[v,N=""]=b,S=i(N);let T=1;const E=v.length;let k="";const C=/^:::([\w-]*)(\s.*)?/gm,D=f.slice(E);for(C.lastIndex=0;;){const A=C.exec(D);if(A===null)break;const R=A.index,F=A[1];if(!((x=A[2])!=null&&x.endsWith(":::"))){if(F)T+=1;else if(T-=1,T===0){const O=D.slice(0,R);k=O.trim();const q=f.slice(0,E+R+A[0].length);let j=[];if(k)if(l==="block")for(j=g.blockTokens(O),j.forEach(G=>{G.text&&(!G.tokens||G.tokens.length===0)&&(G.tokens=g.inlineTokens(G.text))});j.length>0;){const G=j[j.length-1];if(G.type==="paragraph"&&(!G.text||G.text.trim()===""))j.pop();else break}else j=g.inlineTokens(k);return{type:e,raw:q,attributes:S,content:k,tokens:j}}}}}},renderMarkdown:(f,m)=>{const g=d(f.attrs||{}),x=s(g),y=x?` {${x}}`:"",b=m.renderChildren(f.content||[],`
- `);return`:::${u}${y}
- ${b}
- :::`}}}function T7e(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,s,o]=r;e[i]=s||o,r=n.exec(t)}return e}function C7e(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function A7e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=T7e,serializeAttributes:s=C7e,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=m=>{if(!c)return m;const g={};return c.forEach(x=>{x in m&&(g[x]=m[x])}),g},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(m,g)=>{const x={...o,...m.attributes};if(l)return g.createNode(e,x);const y=r?r(m):m.content||"";return y?g.createNode(e,x,[g.createTextNode(y)]):g.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(m){const g=l?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),x=m.match(g),y=x?.index;return y!==void 0?y:-1},tokenize(m,g,x){const y=l?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),b=m.match(y);if(!b)return;let v="",N="";if(l){const[,T]=b;N=T}else{const[,T,E]=b;N=T,v=E||""}const S=i(N.trim());return{type:e,raw:b[0],content:v.trim(),attributes:S}}},renderMarkdown:m=>{let g="";r?g=r(m):m.content&&m.content.length>0&&(g=m.content.filter(v=>v.type==="text").map(v=>v.text).join(""));const x=d(m.attrs||{}),y=s(x),b=y?` ${y}`:"";return l?`[${u}${b}]`:`[${u}${b}]${g}[/${u}]`}}}function TR(t,e,n){var r,i,s,o;const l=t.split(`
- `),c=[];let u="",d=0;const f=e.baseIndentSize||2;for(;d<l.length;){const m=l[d],g=m.match(e.itemPattern);if(!g){if(c.length>0)break;if(m.trim()===""){d+=1,u=`${u}${m}
- `;continue}else return}const x=e.extractItemData(g),{indentLevel:y,mainContent:b}=x;u=`${u}${m}
- `;const v=[b];for(d+=1;d<l.length;){const E=l[d];if(E.trim()===""){const C=l.slice(d+1).findIndex(R=>R.trim()!=="");if(C===-1)break;if((((i=(r=l[d+1+C].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>y){v.push(E),u=`${u}${E}
- `,d+=1;continue}else break}if((((o=(s=E.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0)>y)v.push(E),u=`${u}${E}
- `,d+=1;else break}let N;const S=v.slice(1);if(S.length>0){const E=S.map(k=>k.slice(y+f)).join(`
- `);E.trim()&&(e.customNestedParser?N=e.customNestedParser(E):N=n.blockTokens(E))}const T=e.createToken(x,N);c.push(T)}if(c.length!==0)return{items:c,raw:u}}function ML(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[s,...o]=t.content,l=e.renderChildren([s]),c=[`${i}${l}`];return o&&o.length>0&&o.forEach(u=>{const d=e.renderChildren([u]);if(d){const f=d.split(`
- `).map(m=>m?e.indent(m):"").join(`
- `);c.push(f)}}),c.join(`
- `)}function k7e(t,e,n={}){const{state:r}=e,{doc:i,tr:s}=r,o=t;i.descendants((l,c)=>{const u=s.mapping.map(c),d=s.mapping.map(c)+l.nodeSize;let f=null;if(l.marks.forEach(g=>{if(g!==o)return!1;f=g}),!f)return;let m=!1;if(Object.keys(n).forEach(g=>{n[g]!==f.attrs[g]&&(m=!0)}),m){const g=t.type.create({...t.attrs,...n});s.removeMark(u,d,t.type),s.addMark(u,d,g)}}),s.docChanged&&e.view.dispatch(s)}var Cs=class gne extends wL{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new gne(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function tm(t){return new d7e({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=sr(t.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,l=r[r.length-1],c=r[0];let u=n.to;if(l){const d=c.search(/\S/),f=n.from+c.indexOf(l),m=f+l.length;if(_L(n.from,n.to,e.doc).filter(x=>x.mark.type.excluded.find(b=>b===t.type&&b!==x.mark.type)).filter(x=>x.to>f).length)return null;m<n.to&&o.delete(m,n.to),f>n.from&&o.delete(n.from+d,f),u=n.from+d+l.length,o.addMark(n.from+d,u,t.type.create(s||{})),o.removeStoredMark(t.type)}}})}var oj,NG;function j7e(){return NG||(NG=1,oj=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,s;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;for(i of e.entries())if(!t(i[1],n.get(i[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(e[i]!==n[i])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(s=Object.keys(e),r=s.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,s[i]))return!1;for(i=r;i--!==0;){var o=s[i];if(!(o==="_owner"&&e.$$typeof)&&!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}),oj}var P7e=j7e();const R7e=Uo(P7e);var D7e=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},O7e=({contentComponent:t})=>{const e=KR.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return a.jsx(a.Fragment,{children:Object.values(e)})};function L7e(){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]:Nle.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 I7e=class extends zr.Component{constructor(t){var e;super(t),this.editorContentRef=zr.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=L7e(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.firstChild))return;const n=document.createElement("div");n.append(e.view.dom),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return a.jsxs(a.Fragment,{children:[a.jsx("div",{ref:D7e(e,this.editorContentRef),...n}),t?.contentComponent&&a.jsx(O7e,{contentComponent:t.contentComponent})]})}},F7e=w.forwardRef((t,e)=>{const n=zr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return zr.createElement(I7e,{key:n,innerRef:e,...t})}),U7e=zr.memo(F7e),z7e=typeof window<"u"?w.useLayoutEffect:w.useEffect,B7e=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function $7e(t){var e;const[n]=w.useState(()=>new B7e(t.editor)),r=sK.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:R7e);return z7e(()=>n.watch(t.editor),[t.editor,n]),w.useDebugValue(r),r}var H7e=!1,CR=typeof window>"u",V7e=CR||!!(typeof window<"u"&&window.next),G7e=class xne{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||V7e?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onBeforeCreate)==null?void 0:s.call(i,...r)},onBlur:(...r)=>{var i,s;return(s=(i=this.options.current).onBlur)==null?void 0:s.call(i,...r)},onCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onCreate)==null?void 0:s.call(i,...r)},onDestroy:(...r)=>{var i,s;return(s=(i=this.options.current).onDestroy)==null?void 0:s.call(i,...r)},onFocus:(...r)=>{var i,s;return(s=(i=this.options.current).onFocus)==null?void 0:s.call(i,...r)},onSelectionUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onSelectionUpdate)==null?void 0:s.call(i,...r)},onTransaction:(...r)=>{var i,s;return(s=(i=this.options.current).onTransaction)==null?void 0:s.call(i,...r)},onUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onUpdate)==null?void 0:s.call(i,...r)},onContentError:(...r)=>{var i,s;return(s=(i=this.options.current).onContentError)==null?void 0:s.call(i,...r)},onDrop:(...r)=>{var i,s;return(s=(i=this.options.current).onDrop)==null?void 0:s.call(i,...r)},onPaste:(...r)=>{var i,s;return(s=(i=this.options.current).onPaste)==null?void 0:s.call(i,...r)},onDelete:(...r)=>{var i,s;return(s=(i=this.options.current).onDelete)==null?void 0:s.call(i,...r)}};return new v7e(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,s)=>{var o;return i===((o=n.extensions)==null?void 0:o[s])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?xne.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 q7e(t={},e=[]){const n=w.useRef(t);n.current=t;const[r]=w.useState(()=>new G7e(n)),i=KR.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return w.useDebugValue(i),w.useEffect(r.onRender(e)),$7e({editor:i,selector:({transactionNumber:s})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&s===0?0:s+1}),i}var W7e=w.createContext({editor:null});W7e.Consumer;var K7e=w.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),X7e=()=>w.useContext(K7e);zr.forwardRef((t,e)=>{const{onDragStart:n}=X7e(),r=t.as||"div";return a.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});zr.createContext({markViewContentRef:()=>{}});var YS=(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]},Y7e=/^\s*>\s$/,Q7e=Cs.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return YS("blockquote",{...li(this.options.HTMLAttributes,t),children:YS("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const l=e.renderChildren([i]).split(`
- `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
- `))}),r.join(`
- ${n}
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Og({find:Y7e,type:this.type})]}}),Z7e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,J7e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,e9e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,t9e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,n9e=gh.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 YS("strong",{...li(this.options.HTMLAttributes,t),children:YS("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[Dg({find:Z7e,type:this.type}),Dg({find:e9e,type:this.type})]},addPasteRules(){return[tm({find:J7e,type:this.type}),tm({find:t9e,type:this.type})]}}),r9e=/(^|[^`])`([^`]+)`(?!`)$/,i9e=/(^|[^`])`([^`]+)`(?!`)/g,a9e=gh.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",li(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[Dg({find:r9e,type:this.type})]},addPasteRules(){return[tm({find:i9e,type:this.type})]}}),lj=4,s9e=/^```([a-z]+)?[\s\n]$/,o9e=/^~~~([a-z]+)?[\s\n]$/,l9e=Cs.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:lj,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const s=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",li(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(`
- `):r=`\`\`\`${i}
- \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:lj,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;if(s.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:c})=>{const{from:u,to:d}=i,g=r.doc.textBetween(u,d,`
- `,`
- `).split(`
- `).map(x=>l+x).join(`
- `);return c.replaceWith(u,d,r.schema.text(g)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:lj,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;return s.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var c;const{pos:u}=s,d=s.start(),f=s.end(),g=r.doc.textBetween(d,f,`
- `,`
- `).split(`
- `);let x=0,y=0;const b=u-d;for(let k=0;k<g.length;k+=1){if(y+g[k].length>=b){x=k;break}y+=g[k].length+1}const N=((c=g[x].match(/^ */))==null?void 0:c[0])||"",S=Math.min(N.length,n);if(S===0)return!0;let T=d;for(let k=0;k<x;k+=1)T+=g[k].length+1;return l.delete(T,T+S),u-T<=S&&l.setSelection(dn.create(l.doc,T)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,m=r.doc.textBetween(c,u,`
- `,`
- `).split(`
- `).map(g=>{var x;const y=((x=g.match(/^ */))==null?void 0:x[0])||"",b=Math.min(y.length,n);return g.slice(b)}).join(`
- `);return l.replaceWith(c,u,r.schema.text(m)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
- `);return!s||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:s}=n;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const l=i.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:u})=>(u.setSelection(Mn.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[ER({find:s9e,type:this.type,getAttributes:t=>({language:t[1]})}),ER({find:o9e,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Qr({key:new Gi("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i?.mode;if(!n||!s)return!1;const{tr:o,schema:l}=t.state,c=l.text(n.replace(/\r\n?/g,`
- `));return o.replaceSelectionWith(this.type.create({language:s},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(dn.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),c9e=Cs.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),u9e=Cs.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",li(this.options.HTMLAttributes,t)]},renderText(){return`
- `},renderMarkdown:()=>`
- `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:s}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,c=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&c&&o){const f=c.filter(m=>l.includes(m.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),d9e=Cs.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]}`,li(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=>ER({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),h9e=Cs.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",li(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!S7e(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return ene(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,tr:o,dispatch:l})=>{if(l){const{$to:c}=o.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(dn.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(Zt.create(o.doc,c.pos)):o.setSelection(dn.create(o.doc,c.pos));else{const d=s.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,f=d?.create();f&&(o.insert(u,f),o.setSelection(dn.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[pne({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),f9e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,m9e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,p9e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,g9e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,x9e=gh.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",li(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[Dg({find:f9e,type:this.type}),Dg({find:p9e,type:this.type})]},addPasteRules(){return[tm({find:m9e,type:this.type}),tm({find:g9e,type:this.type})]}});const b9e="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",y9e="ελ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",AR="numeric",kR="ascii",jR="alpha",t0="asciinumeric",Fb="alphanumeric",PR="domain",bne="emoji",v9e="scheme",_9e="slashscheme",cj="whitespace";function w9e(t,e){return t in e||(e[t]=[]),e[t]}function pf(t,e,n){e[AR]&&(e[t0]=!0,e[Fb]=!0),e[kR]&&(e[t0]=!0,e[jR]=!0),e[t0]&&(e[Fb]=!0),e[jR]&&(e[Fb]=!0),e[Fb]&&(e[PR]=!0),e[bne]&&(e[PR]=!0);for(const r in e){const i=w9e(r,n);i.indexOf(t)<0&&i.push(t)}}function S9e(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function xs(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}xs.groups={};xs.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],s=e.jr[r][1];if(s&&i.test(t))return s}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||xs.groups;let i;return e&&e.j?i=e:(i=new xs(e),n&&r&&pf(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const s=t.length;if(!s)return i;for(let o=0;o<s-1;o++)i=i.tt(t[o]);return i.tt(t[s-1],e,n,r)},tt(t,e,n,r){r=r||xs.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const s=e;let o,l=i.go(t);if(l?(o=new xs,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new xs,s){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(S9e(o.t,r),n);pf(s,c,r)}else n&&pf(s,n,r);o.t=s}return i.j[t]=o,o}};const vn=(t,e,n,r,i)=>t.ta(e,n,r,i),ti=(t,e,n,r,i)=>t.tr(e,n,r,i),MG=(t,e,n,r,i)=>t.ts(e,n,r,i),Tt=(t,e,n,r,i)=>t.tt(e,n,r,i),Ic="WORD",RR="UWORD",yne="ASCIINUMERICAL",vne="ALPHANUMERICAL",ey="LOCALHOST",DR="TLD",OR="UTLD",uw="SCHEME",Fp="SLASH_SCHEME",EL="NUM",LR="WS",TL="NL",n0="OPENBRACE",r0="CLOSEBRACE",QS="OPENBRACKET",ZS="CLOSEBRACKET",JS="OPENPAREN",e2="CLOSEPAREN",t2="OPENANGLEBRACKET",n2="CLOSEANGLEBRACKET",r2="FULLWIDTHLEFTPAREN",i2="FULLWIDTHRIGHTPAREN",a2="LEFTCORNERBRACKET",s2="RIGHTCORNERBRACKET",o2="LEFTWHITECORNERBRACKET",l2="RIGHTWHITECORNERBRACKET",c2="FULLWIDTHLESSTHAN",u2="FULLWIDTHGREATERTHAN",d2="AMPERSAND",h2="APOSTROPHE",f2="ASTERISK",gd="AT",m2="BACKSLASH",p2="BACKTICK",g2="CARET",wd="COLON",CL="COMMA",x2="DOLLAR",Nl="DOT",b2="EQUALS",AL="EXCLAMATION",bo="HYPHEN",i0="PERCENT",y2="PIPE",v2="PLUS",_2="POUND",a0="QUERY",kL="QUOTE",_ne="FULLWIDTHMIDDLEDOT",jL="SEMI",Ml="SLASH",s0="TILDE",w2="UNDERSCORE",wne="EMOJI",S2="SYM";var Sne=Object.freeze({__proto__:null,ALPHANUMERICAL:vne,AMPERSAND:d2,APOSTROPHE:h2,ASCIINUMERICAL:yne,ASTERISK:f2,AT:gd,BACKSLASH:m2,BACKTICK:p2,CARET:g2,CLOSEANGLEBRACKET:n2,CLOSEBRACE:r0,CLOSEBRACKET:ZS,CLOSEPAREN:e2,COLON:wd,COMMA:CL,DOLLAR:x2,DOT:Nl,EMOJI:wne,EQUALS:b2,EXCLAMATION:AL,FULLWIDTHGREATERTHAN:u2,FULLWIDTHLEFTPAREN:r2,FULLWIDTHLESSTHAN:c2,FULLWIDTHMIDDLEDOT:_ne,FULLWIDTHRIGHTPAREN:i2,HYPHEN:bo,LEFTCORNERBRACKET:a2,LEFTWHITECORNERBRACKET:o2,LOCALHOST:ey,NL:TL,NUM:EL,OPENANGLEBRACKET:t2,OPENBRACE:n0,OPENBRACKET:QS,OPENPAREN:JS,PERCENT:i0,PIPE:y2,PLUS:v2,POUND:_2,QUERY:a0,QUOTE:kL,RIGHTCORNERBRACKET:s2,RIGHTWHITECORNERBRACKET:l2,SCHEME:uw,SEMI:jL,SLASH:Ml,SLASH_SCHEME:Fp,SYM:S2,TILDE:s0,TLD:DR,UNDERSCORE:w2,UTLD:OR,UWORD:RR,WORD:Ic,WS:LR});const Pc=/[a-z]/,Nb=new RegExp("\\p{L}","u"),uj=new RegExp("\\p{Emoji}","u"),Rc=/\d/,dj=/\s/,EG="\r",hj=`
- `,N9e="️",M9e="",fj="";let P1=null,R1=null;function E9e(t=[]){const e={};xs.groups=e;const n=new xs;P1==null&&(P1=TG(b9e)),R1==null&&(R1=TG(y9e)),Tt(n,"'",h2),Tt(n,"{",n0),Tt(n,"}",r0),Tt(n,"[",QS),Tt(n,"]",ZS),Tt(n,"(",JS),Tt(n,")",e2),Tt(n,"<",t2),Tt(n,">",n2),Tt(n,"(",r2),Tt(n,")",i2),Tt(n,"「",a2),Tt(n,"」",s2),Tt(n,"『",o2),Tt(n,"』",l2),Tt(n,"<",c2),Tt(n,">",u2),Tt(n,"&",d2),Tt(n,"*",f2),Tt(n,"@",gd),Tt(n,"`",p2),Tt(n,"^",g2),Tt(n,":",wd),Tt(n,",",CL),Tt(n,"$",x2),Tt(n,".",Nl),Tt(n,"=",b2),Tt(n,"!",AL),Tt(n,"-",bo),Tt(n,"%",i0),Tt(n,"|",y2),Tt(n,"+",v2),Tt(n,"#",_2),Tt(n,"?",a0),Tt(n,'"',kL),Tt(n,"/",Ml),Tt(n,";",jL),Tt(n,"~",s0),Tt(n,"_",w2),Tt(n,"\\",m2),Tt(n,"・",_ne);const r=ti(n,Rc,EL,{[AR]:!0});ti(r,Rc,r);const i=ti(r,Pc,yne,{[t0]:!0}),s=ti(r,Nb,vne,{[Fb]:!0}),o=ti(n,Pc,Ic,{[kR]:!0});ti(o,Rc,i),ti(o,Pc,o),ti(i,Rc,i),ti(i,Pc,i);const l=ti(n,Nb,RR,{[jR]:!0});ti(l,Pc),ti(l,Rc,s),ti(l,Nb,l),ti(s,Rc,s),ti(s,Pc),ti(s,Nb,s);const c=Tt(n,hj,TL,{[cj]:!0}),u=Tt(n,EG,LR,{[cj]:!0}),d=ti(n,dj,LR,{[cj]:!0});Tt(n,fj,d),Tt(u,hj,c),Tt(u,fj,d),ti(u,dj,d),Tt(d,EG),Tt(d,hj),ti(d,dj,d),Tt(d,fj,d);const f=ti(n,uj,wne,{[bne]:!0});Tt(f,"#"),ti(f,uj,f),Tt(f,N9e,f);const m=Tt(f,M9e);Tt(m,"#"),ti(m,uj,f);const g=[[Pc,o],[Rc,i]],x=[[Pc,null],[Nb,l],[Rc,s]];for(let y=0;y<P1.length;y++)ld(n,P1[y],DR,Ic,g);for(let y=0;y<R1.length;y++)ld(n,R1[y],OR,RR,x);pf(DR,{tld:!0,ascii:!0},e),pf(OR,{utld:!0,alpha:!0},e),ld(n,"file",uw,Ic,g),ld(n,"mailto",uw,Ic,g),ld(n,"http",Fp,Ic,g),ld(n,"https",Fp,Ic,g),ld(n,"ftp",Fp,Ic,g),ld(n,"ftps",Fp,Ic,g),pf(uw,{scheme:!0,ascii:!0},e),pf(Fp,{slashscheme:!0,ascii:!0},e),t=t.sort((y,b)=>y[0]>b[0]?1:-1);for(let y=0;y<t.length;y++){const b=t[y][0],N=t[y][1]?{[v9e]:!0}:{[_9e]:!0};b.indexOf("-")>=0?N[PR]=!0:Pc.test(b)?Rc.test(b)?N[t0]=!0:N[kR]=!0:N[AR]=!0,MG(n,b,b,N)}return MG(n,"localhost",ey,{ascii:!0}),n.jd=new xs(S2),{start:n,tokens:Object.assign({groups:e},Sne)}}function Nne(t,e){const n=T9e(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,i=[];let s=0,o=0;for(;o<r;){let l=t,c=null,u=0,d=null,f=-1,m=-1;for(;o<r&&(c=l.go(n[o]));)l=c,l.accepts()?(f=0,m=0,d=l):f>=0&&(f+=n[o].length,m++),u+=n[o].length,s+=n[o].length,o++;s-=f,o-=m,u-=f,i.push({t:d.t,v:e.slice(s-u,s),s:s-u,e:s})}return i}function T9e(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),s,o=i<55296||i>56319||r+1===n||(s=t.charCodeAt(r+1))<56320||s>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function ld(t,e,n,r,i){let s;const o=e.length;for(let l=0;l<o-1;l++){const c=e[l];t.j[c]?s=t.j[c]:(s=new xs(r),s.jr=i.slice(),t.j[c]=s),t=s}return s=new xs(n),s.jr=i.slice(),t.j[e[o-1]]=s,s}function TG(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let s=0;for(;i.indexOf(t[r+s])>=0;)s++;if(s>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+s),10);o>0;o--)n.pop();r+=s}else n.push(t[r]),r++}return e}const ty={defaultProtocol:"http",events:null,format:CG,formatHref:CG,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function PL(t,e=null){let n=Object.assign({},ty);t&&(n=Object.assign(n,t instanceof PL?t.o:t));const r=n.ignoreTags,i=[];for(let s=0;s<r.length;s++)i.push(r[s].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}PL.prototype={o:ty,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]:ty[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 CG(t){return t}function Mne(t,e){this.t="token",this.v=t,this.tk=e}Mne.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=ty.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),s=this.toFormattedString(t),o={},l=t.get("className",n,e),c=t.get("target",n,e),u=t.get("rel",n,e),d=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),c&&(o.target=c),u&&(o.rel=u),d&&Object.assign(o,d),{tagName:i,attributes:o,content:s,eventListeners:f}}};function hM(t,e){class n extends Mne{constructor(i,s){super(i,s),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const AG=hM("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),kG=hM("text"),C9e=hM("nl"),D1=hM("url",{isLink:!0,toHref(t=ty.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==ey&&t[1].t===wd}}),po=t=>new xs(t);function A9e({groups:t}){const e=t.domain.concat([d2,f2,gd,m2,p2,g2,x2,b2,bo,EL,i0,y2,v2,_2,Ml,S2,s0,w2]),n=[h2,wd,CL,Nl,AL,i0,a0,kL,jL,t2,n2,n0,r0,ZS,QS,JS,e2,r2,i2,a2,s2,o2,l2,c2,u2],r=[d2,h2,f2,m2,p2,g2,x2,b2,bo,n0,r0,i0,y2,v2,_2,a0,Ml,S2,s0,w2],i=po(),s=Tt(i,s0);vn(s,r,s),vn(s,t.domain,s);const o=po(),l=po(),c=po();vn(i,t.domain,o),vn(i,t.scheme,l),vn(i,t.slashscheme,c),vn(o,r,s),vn(o,t.domain,o);const u=Tt(o,gd);Tt(s,gd,u),Tt(l,gd,u),Tt(c,gd,u);const d=Tt(s,Nl);vn(d,r,s),vn(d,t.domain,s);const f=po();vn(u,t.domain,f),vn(f,t.domain,f);const m=Tt(f,Nl);vn(m,t.domain,f);const g=po(AG);vn(m,t.tld,g),vn(m,t.utld,g),Tt(u,ey,g);const x=Tt(f,bo);Tt(x,bo,x),vn(x,t.domain,f),vn(g,t.domain,f),Tt(g,Nl,m),Tt(g,bo,x);const y=Tt(g,wd);vn(y,t.numeric,AG);const b=Tt(o,bo),v=Tt(o,Nl);Tt(b,bo,b),vn(b,t.domain,o),vn(v,r,s),vn(v,t.domain,o);const N=po(D1);vn(v,t.tld,N),vn(v,t.utld,N),vn(N,t.domain,o),vn(N,r,s),Tt(N,Nl,v),Tt(N,bo,b),Tt(N,gd,u);const S=Tt(N,wd),T=po(D1);vn(S,t.numeric,T);const E=po(D1),k=po();vn(E,e,E),vn(E,n,k),vn(k,e,E),vn(k,n,k),Tt(N,Ml,E),Tt(T,Ml,E);const C=Tt(l,wd),D=Tt(c,wd),A=Tt(D,Ml),R=Tt(A,Ml);vn(l,t.domain,o),Tt(l,Nl,v),Tt(l,bo,b),vn(c,t.domain,o),Tt(c,Nl,v),Tt(c,bo,b),vn(C,t.domain,E),Tt(C,Ml,E),Tt(C,a0,E),vn(R,t.domain,E),vn(R,e,E),Tt(R,Ml,E);const F=[[n0,r0],[QS,ZS],[JS,e2],[t2,n2],[r2,i2],[a2,s2],[o2,l2],[c2,u2]];for(let O=0;O<F.length;O++){const[q,j]=F[O],G=Tt(E,q);Tt(k,q,G),Tt(G,j,E);const Y=po(D1);vn(G,e,Y);const K=po();vn(G,n),vn(Y,e,Y),vn(Y,n,K),vn(K,e,Y),vn(K,n,K),Tt(Y,j,E),Tt(K,j,E)}return Tt(i,ey,N),Tt(i,TL,C9e),{start:i,tokens:Sne}}function k9e(t,e,n){let r=n.length,i=0,s=[],o=[];for(;i<r;){let l=t,c=null,u=null,d=0,f=null,m=-1;for(;i<r&&!(c=l.go(n[i].t));)o.push(n[i++]);for(;i<r&&(u=c||l.go(n[i].t));)c=null,l=u,l.accepts()?(m=0,f=l):m>=0&&m++,i++,d++;if(m<0)i-=d,i<r&&(o.push(n[i]),i++);else{o.length>0&&(s.push(mj(kG,e,o)),o=[]),i-=m,d-=m;const g=f.t,x=n.slice(i-d,i);s.push(mj(g,e,x))}}return o.length>0&&s.push(mj(kG,e,o)),s}function mj(t,e,n){const r=n[0].s,i=n[n.length-1].e,s=e.slice(r,i);return new t(s,n)}const j9e=typeof console<"u"&&console&&console.warn||(()=>{}),P9e="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Or={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function R9e(){return xs.groups={},Or.scanner=null,Or.parser=null,Or.tokenQueue=[],Or.pluginQueue=[],Or.customSchemes=[],Or.initialized=!1,Or}function jG(t,e=!1){if(Or.initialized&&j9e(`linkifyjs: already initialized - will not register custom scheme "${t}" ${P9e}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
- 1. Must only contain digits, lowercase ASCII letters or "-"
- 2. Cannot start or end with "-"
- 3. "-" cannot repeat`);Or.customSchemes.push([t,e])}function D9e(){Or.scanner=E9e(Or.customSchemes);for(let t=0;t<Or.tokenQueue.length;t++)Or.tokenQueue[t][1]({scanner:Or.scanner});Or.parser=A9e(Or.scanner.tokens);for(let t=0;t<Or.pluginQueue.length;t++)Or.pluginQueue[t][1]({scanner:Or.scanner,parser:Or.parser});return Or.initialized=!0,Or}function RL(t){return Or.initialized||D9e(),k9e(Or.parser.start,t,Nne(Or.scanner.start,t))}RL.scan=Nne;function Ene(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 PL(n),i=RL(t),s=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&s.push(l.toFormattedObject(r))}return s}var DL="[\0- -\u2029 ]",O9e=new RegExp(DL),L9e=new RegExp(`${DL}$`),I9e=new RegExp(DL,"g");function F9e(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function U9e(t){return new Qr({key:new Gi("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),s=e.some(u=>u.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,l=qte(n.doc,[...e]);if(Jte(l).forEach(({newRange:u})=>{const d=NVe(r.doc,u,g=>g.isTextblock);let f,m;if(d.length>1)f=d[0],m=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(d.length){const g=r.doc.textBetween(u.from,u.to," "," ");if(!L9e.test(g))return;f=d[0],m=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&m){const g=m.split(O9e).filter(Boolean);if(g.length<=0)return!1;const x=g[g.length-1],y=f.pos+m.lastIndexOf(x);if(!x)return!1;const b=RL(x).map(v=>v.toObject(t.defaultProtocol));if(!F9e(b))return!1;b.filter(v=>v.isLink).map(v=>({...v,from:y+v.start+1,to:y+v.end+1})).filter(v=>r.schema.marks.code?!r.doc.rangeHasMark(v.from,v.to,r.schema.marks.code):!0).filter(v=>t.validate(v.value)).filter(v=>t.shouldAutoLink(v.value)).forEach(v=>{_L(v.from,v.to,r.doc).some(N=>N.mark.type===t.type)||o.addMark(v.from,v.to,t.type.create({href:v.href}))})}}),!!o.steps.length)return o}})}function z9e(t){return new Qr({key:new Gi("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let d=r.target;const f=[];for(;d.nodeName!=="DIV";)f.push(d),d=d.parentNode;o=f.find(m=>m.nodeName==="A")}if(!o)return!1;const l=Zte(e.state,t.type.name),c=(i=o?.href)!=null?i:l.href,u=(s=o?.target)!=null?s:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),o&&c?(window.open(c,u),!0):!1}}})}function B9e(t){return new Qr({key:new Gi("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:s}=e,{selection:o}=s,{empty:l}=o;if(l)return!1;let c="";r.content.forEach(d=>{c+=d.textContent});const u=Ene(c,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===c);return!c||!u||i!==void 0&&!i(u.href)?!1:t.editor.commands.setMark(t.type,{href:u.href})}}})}function qh(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(I9e,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Tne=gh.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"){jG(t);return}jG(t.scheme,t.optionalSlashes)})},onDestroy(){R9e()},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)=>!!qh(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=>!!qh(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=>!!qh(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",li(this.options.HTMLAttributes,t),0]:["a",li(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=>!!qh(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=>!!qh(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[tm({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=Ene(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!qh(o,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(U9e({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!qh(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(z9e({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(B9e({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),$9e=Tne,H9e=Object.defineProperty,V9e=(t,e)=>{for(var n in e)H9e(t,n,{get:e[n],enumerable:!0})},G9e="listItem",PG="textStyle",RG=/^\s*([-+*])\s$/,Cne=Cs.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",li(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(G9e,this.editor.getAttributes(PG)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Og({find:RG,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Og({find:RG,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(PG),editor:this.editor})),[t]}}),Ane=Cs.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",li(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(i=>i.type==="paragraph"))n=e.parseChildren(t.tokens);else{const i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(i.tokens)}],t.tokens.length>1){const o=t.tokens.slice(1),l=e.parseChildren(o);n.push(...l)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>ML(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)}}}),q9e={};V9e(q9e,{findListItemPos:()=>Vy,getNextListDepth:()=>OL,handleBackspace:()=>IR,handleDelete:()=>FR,hasListBefore:()=>kne,hasListItemAfter:()=>W9e,hasListItemBefore:()=>jne,listItemHasSubList:()=>Pne,nextListIsDeeper:()=>Rne,nextListIsHigher:()=>Dne});var Vy=(t,e)=>{const{$from:n}=e.selection,r=Ai(t,e.schema);let i=null,s=n.depth,o=n.pos,l=null;for(;s>0&&l===null;)i=n.node(s),i.type===r?l=s:(s-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},OL=(t,e)=>{const n=Vy(t,e);if(!n)return!1;const[,r]=DVe(e,t,n.$pos.pos+4);return r},kne=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),s=t.doc.resolve(i).node();return!(!s||!n.includes(s.type.name))},jne=(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)},Pne=(t,e,n)=>{if(!n)return!1;const r=Ai(t,e.schema);let i=!1;return n.descendants(s=>{s.type===r&&(i=!0)}),i},IR=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!oh(t.state,e)&&kne(t.state,e,n)){const{$anchor:l}=t.state.selection,c=t.state.doc.resolve(l.before()-1),u=[];c.node().descendants((m,g)=>{m.type.name===e&&u.push({node:m,pos:g})});const d=u.at(-1);if(!d)return!1;const f=t.state.doc.resolve(c.start()+d.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},f.end()).joinForward().run()}if(!oh(t.state,e)||!FVe(t.state))return!1;const r=Vy(e,t.state);if(!r)return!1;const s=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=Pne(e,t.state,s);return jne(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Rne=(t,e)=>{const n=OL(t,e),r=Vy(t,e);return!r||!n?!1:n>r.depth},Dne=(t,e)=>{const n=OL(t,e),r=Vy(t,e);return!r||!n?!1:n<r.depth},FR=(t,e)=>{if(!oh(t.state,e)||!IVe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Rne(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Dne(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},W9e=(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)},One=_r.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&&FR(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&&FR(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&&IR(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&&IR(t,n,r)&&(e=!0)}),e}}}}),DG=/^(\s*)(\d+)\.\s+(.*)$/,K9e=/^\s/;function X9e(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],s=i.match(DG);if(!s)break;const[,o,l,c]=s,u=o.length;let d=c,f=n+1;const m=[i];for(;f<t.length;){const g=t[f];if(g.match(DG))break;if(g.trim()==="")m.push(g),d+=`
- `,f+=1;else if(g.match(K9e))m.push(g),d+=`
- ${g.slice(u+2)}`,f+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:m.join(`
- `)}),r=f,n=f}return[e,r]}function Lne(t,e,n){var r;const i=[];let s=0;for(;s<t.length;){const o=t[s];if(o.indent===e){const l=o.content.split(`
- `),c=((r=l[0])==null?void 0:r.trim())||"",u=[];c&&u.push({type:"paragraph",raw:c,tokens:n.inlineTokens(c)});const d=l.slice(1).join(`
- `).trim();if(d){const g=n.blockTokens(d);u.push(...g)}let f=s+1;const m=[];for(;f<t.length&&t[f].indent>e;)m.push(t[f]),f+=1;if(m.length>0){const g=Math.min(...m.map(y=>y.indent)),x=Lne(m,g,n);u.push({type:"list",ordered:!0,start:m[0].number,items:x,raw:m.map(y=>y.raw).join(`
- `)})}i.push({type:"list_item",raw:o.raw,tokens:u}),s=f}else s+=1}return i}function Y9e(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const s=e.parseChildren([i]);r.push({type:"paragraph",content:s})}else{const s=e.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var Q9e="listItem",OG="textStyle",LG=/^(\d+)\.\s$/,Ine=Cs.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",li(this.options.HTMLAttributes,n),0]:["ol",li(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?Y9e(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const i=t.split(`
- `),[s,o]=X9e(i);if(s.length===0)return;const l=Lne(s,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:l,raw:i.slice(0,o).join(`
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Q9e,this.editor.getAttributes(OG)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Og({find:LG,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=Og({find:LG,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(OG)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Z9e=/^\s*(\[([( |x])?\])\s$/,J9e=Cs.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",li(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 ML(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),c=document.createElement("div"),u=d=>{var f,m;l.ariaLabel=((m=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:m.call(f,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return u(t),s.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:m})=>{const g=n();if(typeof g!="number")return!1;const x=m.doc.nodeAt(g);return m.setNodeMarkup(g,void 0,{...x?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{i.setAttribute(d,f)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,s.append(l,o),i.append(s,c),Object.entries(e).forEach(([d,f])=>{i.setAttribute(d,f)}),{dom:i,contentDOM:c,update:d=>d.type!==this.type?!1:(i.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,u(d),!0)}}},addInputRules(){return[Og({find:Z9e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),eGe=Cs.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",li(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=s=>{const o=TR(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,c)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:c}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(s)},i=TR(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,o)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:n.inlineTokens(s.mainContent),nestedTokens:o}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});_r.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Cne.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Ane.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(One.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Ine.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(J9e.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(eGe.configure(this.options.taskList)),t}});var tGe=Cs.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",li(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()}}}),nGe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,rGe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,iGe=gh.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",li(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[Dg({find:nGe,type:this.type})]},addPasteRules(){return[tm({find:rGe,type:this.type})]}}),aGe=Cs.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Fne=gh.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",li(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const s=i[2].trim();return{type:"underline",raw:i[0],text:s,tokens:n.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),sGe=Fne;function oGe(t={}){return new Qr({view(e){return new lGe(e,t)}})}class lGe{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(n){let f=e.nodeBefore,m=e.nodeAfter;if(f||m){let g=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(g){let x=g.getBoundingClientRect(),y=f?x.bottom:x.top;f&&m&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let b=this.width/2*l;r={left:x.left,right:x.right,top:y-b,bottom:y+b}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),m=this.width/2*o;r={left:f.left-m,right:f.left+m,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,d;if(!c||c==document.body&&getComputedStyle(c).position=="static")u=-pageXOffset,d=-pageYOffset;else{let f=c.getBoundingClientRect(),m=f.width/c.offsetWidth,g=f.height/c.offsetHeight;u=f.left-c.scrollLeft*m,d=f.top-c.scrollTop*g}this.element.style.left=(r.left-u)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!s){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Fee(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class ii extends Mn{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ii.valid(r)?new ii(r):Mn.near(r)}content(){return Ft.empty}eq(e){return e instanceof ii&&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 ii(e.resolve(n.pos))}getBookmark(){return new LL(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!cGe(e)||!uGe(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&&ii.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=n;let c=e.doc.resolve(i);if(ii.valid(c))return c}for(;;){let o=n>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!Zt.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),r=!1;continue e}break}s=o,i+=n;let l=e.doc.resolve(i);if(ii.valid(l))return l}return null}}}ii.prototype.visible=!1;ii.findFrom=ii.findGapCursorFrom;Mn.jsonID("gapcursor",ii);class LL{constructor(e){this.pos=e}map(e){return new LL(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ii.valid(n)?new ii(n):Mn.near(n)}}function Une(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function cGe(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||Une(i.type))return!0;if(i.inlineContent)return!1}}return!0}function uGe(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||Une(i.type))return!0;if(i.inlineContent)return!1}}return!0}function dGe(){return new Qr({props:{decorations:pGe,createSelectionBetween(t,e,n){return e.pos==n.pos&&ii.valid(n)?new ii(n):null},handleClick:fGe,handleKeyDown:hGe,handleDOMEvents:{beforeinput:mGe}}})}const hGe=Fte({ArrowLeft:O1("horiz",-1),ArrowRight:O1("horiz",1),ArrowUp:O1("vert",-1),ArrowDown:O1("vert",1)});function O1(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,l=e>0?o.$to:o.$from,c=o.empty;if(o instanceof dn){if(!s.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=ii.findGapCursorFrom(l,e,c);return u?(i&&i(r.tr.setSelection(new ii(u))),!0):!1}}function fGe(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!ii.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Zt.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new ii(r))),!0)}function mGe(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ii))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=Nt.empty;for(let o=r.length-1;o>=0;o--)i=Nt.from(r[o].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new Ft(i,0,0));return s.setSelection(dn.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function pGe(t){if(!(t.selection instanceof ii))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Wr.create(t.doc,[Ya.widget(t.selection.head,e,{key:"gapcursor"})])}var N2=200,oa=function(){};oa.prototype.append=function(e){return e.length?(e=oa.from(e),!this.length&&e||e.length<N2&&this.leafAppend(e)||this.length<N2&&e.leafPrepend(this)||this.appendInner(e)):this};oa.prototype.prepend=function(e){return e.length?oa.from(e).append(this):this};oa.prototype.appendInner=function(e){return new gGe(this,e)};oa.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?oa.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};oa.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};oa.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)};oa.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},n,r),i};oa.from=function(e){return e instanceof oa?e:e&&e.length?new zne(e):oa.empty};var zne=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var c=s;c<o;c++)if(i(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,l){for(var c=s-1;c>=o;c--)if(i(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=N2)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=N2)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})(oa);oa.empty=new zne([]);var gGe=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,s,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(i,l),s,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(oa);const xGe=500;class nl{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;n&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,l,c,u=[],d=[];return this.items.forEach((f,m)=>{if(!f.step){i||(i=this.remapping(r,m+1),s=i.maps.length),s--,d.push(f);return}if(i){d.push(new El(f.map));let g=f.step.map(i.slice(s)),x;g&&o.maybeStep(g).doc&&(x=o.mapping.maps[o.mapping.maps.length-1],u.push(new El(x,void 0,void 0,u.length+d.length))),s--,x&&i.appendMap(x,s)}else o.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(s)):f.selection,c=new nl(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:l}}addTransform(e,n,r,i){let s=[],o=this.eventCount,l=this.items,c=!i&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),m=new El(e.mapping.maps[d],f,n),g;(g=c&&c.merge(m))&&(m=g,d?s.pop():l=l.slice(0,l.length-1)),s.push(m),n&&(o++,n=void 0),i||(c=m)}let u=o-r.depth;return u>yGe&&(l=bGe(l,u),o-=u),new nl(l.append(s),o)}remapping(e,n){let r=new K0;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new nl(this.items.append(e.map(n=>new El(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(m=>{m.selection&&l--},i);let c=n;this.items.forEach(m=>{let g=s.getMirror(--c);if(g==null)return;o=Math.min(o,g);let x=s.maps[g];if(m.step){let y=e.steps[g].invert(e.docs[g]),b=m.selection&&m.selection.map(s.slice(c+1,g));b&&l++,r.push(new El(x,y,b))}else r.push(new El(x))},i);let u=[];for(let m=n;m<o;m++)u.push(new El(s.maps[m]));let d=this.items.slice(0,i).append(u).append(r),f=new nl(d,l);return f.emptyItemCount()>xGe&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;else if(o.step){let c=o.step.map(n.slice(r)),u=c&&c.getMap();if(r--,u&&n.appendMap(u,r),c){let d=o.selection&&o.selection.map(n.slice(r));d&&s++;let f=new El(u.invert(),c,d),m,g=i.length-1;(m=i.length&&i[g].merge(f))?i[g]=m:i.push(f)}}else o.map&&r--},this.items.length,0),new nl(oa.from(i.reverse()),s)}}nl.empty=new nl(oa.empty,0);function bGe(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class El{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new El(n.getMap().invert(),n,this.selection)}}}class xd{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const yGe=20;function vGe(t,e,n,r){let i=n.getMeta(kf),s;if(i)return i.historyState;n.getMeta(SGe)&&(t=new xd(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(kf))return o.getMeta(kf).redo?new xd(t.done.addTransform(n,void 0,r,dw(e)),t.undone,IG(n.mapping.maps),t.prevTime,t.prevComposition):new xd(t.done,t.undone.addTransform(n,void 0,r,dw(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),c=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!_Ge(n,t.prevRanges)),u=o?pj(t.prevRanges,n.mapping):IG(n.mapping.maps);return new xd(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,dw(e)),nl.empty,u,n.time,l??t.prevComposition)}else return(s=n.getMeta("rebased"))?new xd(t.done.rebased(n,s),t.undone.rebased(n,s),pj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new xd(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),pj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function _Ge(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(n=!0)}),n}function IG(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,s,o)=>e.push(s,o));return e}function pj(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),s=e.map(t[r+1],-1);i<=s&&n.push(i,s)}return n}function wGe(t,e,n){let r=dw(e),i=kf.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),c=new xd(n?l:s.remaining,n?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(kf,{redo:n,historyState:c})}let gj=!1,FG=null;function dw(t){let e=t.plugins;if(FG!=e){gj=!1,FG=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){gj=!0;break}}return gj}const kf=new Gi("history"),SGe=new Gi("closeHistory");function NGe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Qr({key:kf,state:{init(){return new xd(nl.empty,nl.empty,null,0,-1)},apply(e,n,r){return vGe(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?$ne:r=="historyRedo"?Hne:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function Bne(t,e){return(n,r)=>{let i=kf.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=wGe(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const $ne=Bne(!1,!0),Hne=Bne(!0,!0);_r.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 Qr({key:new Gi("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const s=this.storage.characters({node:r.doc});if(s>i){const o=s-i,l=0,c=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(l,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,c=s-r,u=l-c,d=l;return e.deleteRange(u,d),!(this.storage.characters({node:e.doc})>r)}})]}});var MGe=_r.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[oGe(this.options)]}});_r.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Qr({key:new Gi("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!n||!r)return Wr.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((c,u)=>{if(c.isText)return;if(!(i>=u&&i<=u+c.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((c,u)=>{if(c.isText||!(i>=u&&i<=u+c.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(Ya.node(u,u+c.nodeSize,{class:this.options.className}))}),Wr.create(t,s)}}})]}});var EGe=_r.create({name:"gapCursor",addProseMirrorPlugins(){return[dGe()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=sr(Qt(t,"allowGapCursor",n)))!=null?e:null}}});_r.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Qr({key:new Gi("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const s=this.editor.isEmpty;return t.descendants((o,l)=>{const c=r>=l&&r<=l+o.nodeSize,u=!o.isLeaf&&cM(o);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];s&&d.push(this.options.emptyEditorClass);const f=Ya.node(l,l+o.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:c}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),Wr.create(t,i)}}})]}});_r.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Qr({key:new Gi("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||ene(n.selection)||t.view.dragging?null:Wr.create(n.doc,[Ya.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function UG({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var TGe=_r.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Gi(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 Qr({key:e,appendTransaction:(i,s,o)=>{const{doc:l,tr:c,schema:u}=o,d=e.getState(o),f=l.content.size,m=u.nodes[n];if(d)return c.insert(f,m.create())},state:{init:(i,s)=>{const o=s.tr.doc.lastChild;return!UG({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const o=i.doc.lastChild;return!UG({node:o,types:r})}}})]}}),CGe=_r.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>$ne(t,e),redo:()=>({state:t,dispatch:e})=>Hne(t,e)}},addProseMirrorPlugins(){return[NGe(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()}}}),AGe=_r.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(n9e.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(Q7e.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Cne.configure(this.options.bulletList)),this.options.code!==!1&&i.push(a9e.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(l9e.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(c9e.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(MGe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(EGe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(u9e.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(d9e.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(CGe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(h9e.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(x9e.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Ane.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(One.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(Tne.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Ine.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(tGe.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(iGe.configure(this.options.strike)),this.options.text!==!1&&i.push(aGe.configure(this.options.text)),this.options.underline!==!1&&i.push(Fne.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(TGe.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),kGe=AGe,jGe=_r.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")}}}),PGe=jGe,RGe=20,Vne=(t,e=0)=>{const n=[];return!t.children.length||e>RGe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...Vne(r,e+1))}),n},DGe=t=>{if(!t.children.length)return;const e=Vne(t);e&&e.forEach(n=>{var r,i;const s=n.getAttribute("style"),o=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${o};${s}`)})},Gne=gh.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&DGe(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",li(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(s=>!!s))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),OGe=_r.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const s=r[i].split(":");if(s.length>=2){const o=s[0].trim().toLowerCase(),l=s.slice(1).join(":").trim();if(o==="background-color")return l.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),qne=_r.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const s=r[i].split(":");if(s.length>=2){const o=s[0].trim().toLowerCase(),l=s.slice(1).join(":").trim();if(o==="color")return l.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),LGe=_r.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()}}}),IGe=_r.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()}}}),FGe=_r.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()}}});_r.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(OGe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(qne.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(LGe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(IGe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(FGe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Gne.configure(this.options.textStyle)),t}});var UGe=qne,zGe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,BGe=Cs.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",li(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,i,s,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",c=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",u=(o=(s=t.attrs)==null?void 0:s.title)!=null?o:"";return u?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:s,HTMLAttributes:o})=>{const l=document.createElement("img");Object.entries(o).forEach(([d,f])=>{if(f!=null)switch(d){case"width":case"height":break;default:l.setAttribute(d,f);break}}),l.src=o.src;const c=new w7e({element:l,node:i,getPos:s,onResize:(d,f)=>{l.style.width=`${d}px`,l.style.height=`${f}px`},onCommit:(d,f)=>{const m=s();m!==void 0&&this.editor.chain().setNodeSelection(m).updateAttributes(this.name,{width:d,height:f}).run()},onUpdate:(d,f,m)=>d.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),u=c.dom;return u.style.visibility="hidden",u.style.pointerEvents="none",l.onload=()=>{u.style.visibility="",u.style.pointerEvents=""},c}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[pne({find:zGe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),$Ge=BGe;function UR({content:t,onChange:e,placeholder:n}){const r=q7e({extensions:[kGe.configure({heading:!1,codeBlock:!1,code:!1}),sGe,$9e.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),PGe.configure({types:["paragraph"]}),Gne,UGe,$Ge.configure({HTMLAttributes:{style:"max-width: 100%; height: auto;"}})],content:t,onUpdate:({editor:o})=>{e(o.getHTML())},editorProps:{attributes:{class:"prose prose-invert prose-sm max-w-none focus:outline-none min-h-[120px] px-3 py-2",placeholder:n||""}}});if(!r)return null;const i=({onClick:o,isActive:l=!1,children:c,title:u})=>a.jsx("button",{type:"button",onClick:o,title:u,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${l?"bg-bambu-dark-tertiary text-bambu-green":"text-bambu-gray"}`,children:c}),s=()=>{const o=window.prompt("Enter URL:");o&&r.chain().focus().setLink({href:o}).run()};return a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[a.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[a.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:a.jsx(bce,{className:"w-4 h-4"})}),a.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:a.jsx(cde,{className:"w-4 h-4"})}),a.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:a.jsx(Jhe,{className:"w-4 h-4"})}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),a.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:a.jsx(V2,{className:"w-4 h-4"})}),a.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:a.jsx(cW,{className:"w-4 h-4"})}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),a.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("left").run(),isActive:r.isActive({textAlign:"left"}),title:"Align Left",children:a.jsx(Ghe,{className:"w-4 h-4"})}),a.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:a.jsx(Bhe,{className:"w-4 h-4"})}),a.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("right").run(),isActive:r.isActive({textAlign:"right"}),title:"Align Right",children:a.jsx(Hhe,{className:"w-4 h-4"})}),a.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),a.jsx(i,{onClick:s,isActive:r.isActive("link"),title:"Add Link",children:a.jsx($g,{className:"w-4 h-4"})}),r.isActive("link")&&a.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:a.jsx(pD,{className:"w-4 h-4"})})]}),a.jsx(U7e,{editor:r})]})}function Wne({archiveId:t,archiveName:e,onClose:n}){const r=an(),[i,s]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState({}),{data:d,isLoading:f,error:m}=ct({queryKey:["archive-project-page",t],queryFn:()=>he.getArchiveProjectPage(t)}),g=ht({mutationFn:E=>he.updateArchiveProjectPage(t,E),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),s(!1),u({})}});w.useEffect(()=>{const E=k=>{k.key==="Escape"&&(o!==null?l(null):i?v():n())};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[o,i,n]);const x=[...d?.model_pictures||[],...d?.profile_pictures||[]],y=()=>{u({title:d?.title||"",description:d?.description||"",designer:d?.designer||"",license:d?.license||"",profile_title:d?.profile_title||"",profile_description:d?.profile_description||""}),s(!0)},b=()=>{g.mutate(c)},v=()=>{s(!1),u({})},N=E=>{const k=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],C=new DOMParser().parseFromString(E,"text/html"),D=A=>{if(A.nodeType===Node.TEXT_NODE)return A.textContent||"";if(A.nodeType===Node.ELEMENT_NODE){const R=A,F=R.tagName.toLowerCase();if(!k.includes(F))return Array.from(R.childNodes).map(D).join("");let O="";if(F==="a"&&R.getAttribute("href")){const j=R.getAttribute("href");j?.toLowerCase().startsWith("http")&&(O=` href="${j}" target="_blank" rel="noopener noreferrer"`)}if(F==="img"){const j=R.getAttribute("src");if(!j?.toLowerCase().startsWith("http"))return"";O=` src="${j}" style="max-width: 100%; height: auto;"`}const q=Array.from(R.childNodes).map(D).join("");return["br","img"].includes(F)?`<${F}${O} />`:`<${F}${O}>${q}</${F}>`}return""};return Array.from(C.body.childNodes).map(D).join("")},S=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),T=E=>{E.target===E.currentTarget&&n()};return a.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:T,children:[a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Ka,{className:"w-5 h-5 text-bambu-green"}),a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&a.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[!i&&S&&a.jsxs(Te,{variant:"ghost",size:"sm",onClick:y,children:[a.jsx(Of,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&a.jsxs(a.Fragment,{children:[a.jsx(Te,{variant:"ghost",size:"sm",onClick:v,children:"Cancel"}),a.jsxs(Te,{variant:"primary",size:"sm",onClick:b,disabled:g.isPending,children:[a.jsx(bs,{className:"w-4 h-4 mr-1"}),"Save"]})]}),a.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Ot,{className:"w-5 h-5 text-bambu-gray"})})]})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),m&&a.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!S&&a.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[a.jsx(Ka,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),a.jsx("p",{children:"No project page data found in this 3MF file."}),a.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&S&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-4",children:[i?a.jsx("input",{type:"text",value:c.title||"",onChange:E=>u({...c,title:E.target.value}),placeholder:"Title",className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold"}):d.title&&a.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),a.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(e3,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:c.designer||"",onChange:E=>u({...c,designer:E.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[a.jsx(e3,{className:"w-4 h-4"}),a.jsx("span",{children:d.designer}),d.designer_user_id&&a.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:a.jsx($r,{className:"w-3 h-3"})})]}),d.creation_date&&a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[a.jsx(si,{className:"w-4 h-4"}),a.jsx("span",{children:d.creation_date})]}),i?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ka,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:c.license||"",onChange:E=>u({...c,license:E.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[a.jsx(Ka,{className:"w-4 h-4"}),a.jsx("span",{children:d.license})]}),d.origin&&a.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?a.jsx(UR,{content:c.description||"",onChange:E=>u({...c,description:E}),placeholder:"Enter description..."}):a.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:N(d.description||"")}})]}),(d.profile_title||d.profile_description||i)&&a.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?a.jsxs("div",{className:"space-y-2",children:[a.jsx("input",{type:"text",value:c.profile_title||"",onChange:E=>u({...c,profile_title:E.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),a.jsx(UR,{content:c.profile_description||"",onChange:E=>u({...c,profile_description:E}),placeholder:"Profile description..."})]}):a.jsxs(a.Fragment,{children:[d.profile_title&&a.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&a.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:N(d.profile_description)}}),d.profile_user_name&&a.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),x.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[a.jsx(cu,{className:"w-4 h-4"}),"Images (",x.length,")"]}),a.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:x.map((E,k)=>a.jsx("button",{onClick:()=>l(k),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:a.jsx("img",{src:E.url,alt:E.name,className:"w-full h-full object-cover"})},E.path))})]}),d.design_model_id&&a.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:a.jsxs("a",{href:`https://makerworld.com/en/models/${d.design_model_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-bambu-green hover:underline",children:[a.jsx($r,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),o!==null&&x[o]&&a.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>l(null),children:[a.jsx("button",{onClick:E=>{E.stopPropagation(),l(Math.max(0,o-1))},disabled:o===0,className:"absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:a.jsx(Vd,{className:"w-6 h-6 text-white"})}),a.jsx("img",{src:x[o].url,alt:x[o].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:E=>E.stopPropagation()}),a.jsx("button",{onClick:E=>{E.stopPropagation(),l(Math.min(x.length-1,o+1))},disabled:o===x.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:a.jsx(Ms,{className:"w-6 h-6 text-white"})}),a.jsx("button",{onClick:()=>l(null),className:"absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary",children:a.jsx(Ot,{className:"w-6 h-6 text-white"})}),a.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",x.length]})]})]})}const HGe=[.25,.5,.75,1,1.5,2,3,4];function Ap(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function VGe({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=Gn(),s=w.useRef(null),o=w.useRef(null),[l,c]=w.useState(!1),[u,d]=w.useState(0),[f,m]=w.useState(0),[g,x]=w.useState(0),[y,b]=w.useState(0),[v,N]=w.useState(1),[S,T]=w.useState(null),[E,k]=w.useState(null),[C,D]=w.useState(.8),[A,R]=w.useState(!1),{data:F,isLoading:O}=ct({queryKey:["timelapse-info",t],queryFn:()=>he.getTimelapseInfo(t)}),{data:q}=ct({queryKey:["timelapse-thumbnails",t],queryFn:()=>he.getTimelapseThumbnails(t,15)}),j=ht({mutationFn:()=>he.processTimelapse(t,{trimStart:g,trimEnd:y,speed:v,saveMode:"replace"},S||void 0),onSuccess:z=>{i(z.message,"success"),r?.(),n()},onError:z=>{i(z.message||"Processing failed","error")}});w.useEffect(()=>{F?.duration&&y===0&&b(F.duration)},[F?.duration,y]),w.useEffect(()=>{const z=W=>{W.key==="Escape"&&n()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[n]),w.useEffect(()=>{const z=s.current;if(!z)return;const W=()=>{const me=z.currentTime;d(me),me>=y&&(z.currentTime=g)},se=()=>{m(z.duration),y===0&&b(z.duration)},ae=()=>c(!0),de=()=>c(!1);return z.addEventListener("timeupdate",W),z.addEventListener("durationchange",se),z.addEventListener("play",ae),z.addEventListener("pause",de),()=>{z.removeEventListener("timeupdate",W),z.removeEventListener("durationchange",se),z.removeEventListener("play",ae),z.removeEventListener("pause",de)}},[g,y]),w.useEffect(()=>{const z=o.current,W=s.current;!z||!W||!E||(z.currentTime=W.currentTime,z.playbackRate=W.playbackRate,l&&!A?z.play().catch(()=>{}):z.pause())},[l,E,A]),w.useEffect(()=>{o.current&&(o.current.volume=A?0:C)},[C,A]),w.useEffect(()=>{s.current&&(s.current.playbackRate=v),o.current&&(o.current.playbackRate=v)},[v]);const G=w.useCallback(()=>{const z=s.current;z&&(l?z.pause():(z.currentTime<g&&(z.currentTime=g),z.play()))},[l,g]),Y=z=>{const W=s.current;W&&(W.currentTime=Math.max(g,Math.min(y,z)))},K=z=>{const W=z.target.files?.[0];W&&(E&&URL.revokeObjectURL(E),T(W),k(URL.createObjectURL(W)))},Z=()=>{E&&URL.revokeObjectURL(E),T(null),k(null)};w.useEffect(()=>()=>{E&&URL.revokeObjectURL(E)},[E]);const te=y-g,ne=te/v;return O?a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:a.jsxs("div",{className:"flex items-center gap-3 text-white",children:[a.jsx(ut,{className:"w-6 h-6 animate-spin"}),"Loading video info..."]})}):a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:a.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-5xl w-full mx-4 max-h-[90vh] overflow-hidden flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Rd,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Te,{variant:"primary",size:"sm",onClick:()=>j.mutate(),disabled:j.isPending,children:j.isPending?a.jsxs(a.Fragment,{children:[a.jsx(ut,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(bs,{className:"w-4 h-4"}),"Save"]})}),a.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:a.jsx(Ot,{className:"w-5 h-5 text-bambu-gray"})})]})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[a.jsxs("div",{className:"relative",children:[a.jsx("video",{ref:s,src:e,className:"w-full rounded-lg bg-black",onClick:G,muted:!!E}),!l&&a.jsx("button",{onClick:G,className:"absolute inset-0 flex items-center justify-center bg-black/30 hover:bg-black/40 transition-colors",children:a.jsx("div",{className:"p-4 bg-bambu-green rounded-full",children:a.jsx(vs,{className:"w-8 h-8 text-white"})})}),E&&a.jsx("audio",{ref:o,src:E,loop:!0})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(phe,{className:"w-4 h-4"}),a.jsx("span",{children:"Trim"}),a.jsxs("span",{className:"ml-auto",children:[Ap(g)," - ",Ap(y)," (",Ap(te),")"]})]}),a.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsx("div",{className:"absolute inset-0 flex",children:q?.thumbnails.map((z,W)=>a.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${z})`}},W))}),a.jsx("div",{className:"absolute inset-y-0 left-0 bg-black/60",style:{width:`${g/f*100}%`}}),a.jsx("div",{className:"absolute inset-y-0 right-0 bg-black/60",style:{width:`${(f-y)/f*100}%`}}),a.jsx("div",{className:"absolute inset-y-0 border-2 border-bambu-green",style:{left:`${g/f*100}%`,right:`${(f-y)/f*100}%`}}),a.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-white shadow-lg",style:{left:`${u/f*100}%`}}),a.jsx("input",{type:"range",min:0,max:f,step:.1,value:g,onChange:z=>{const W=parseFloat(z.target.value);W<y-1&&(x(W),s.current&&s.current.currentTime<W&&(s.current.currentTime=W))},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 50% 0 0)"}}),a.jsx("input",{type:"range",min:0,max:f,step:.1,value:y,onChange:z=>{const W=parseFloat(z.target.value);W>g+1&&b(W)},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 0 0 50%)"}})]}),a.jsx("input",{type:"range",min:0,max:f,step:.1,value:u,onChange:z=>Y(parseFloat(z.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),a.jsx("div",{className:"flex items-center justify-center gap-2",children:a.jsx("button",{onClick:G,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?a.jsx(hD,{className:"w-5 h-5 text-white"}):a.jsx(vs,{className:"w-5 h-5 text-white"})})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(z2,{className:"w-4 h-4"}),a.jsx("span",{children:"Speed"}),a.jsxs("span",{className:"ml-auto",children:[v,"x (output: ",Ap(ne),")"]})]}),a.jsx("div",{className:"flex gap-1",children:HGe.map(z=>a.jsxs("button",{onClick:()=>N(z),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${v===z?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[z,"x"]},z))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(Qj,{className:"w-4 h-4"}),a.jsx("span",{children:"Music Overlay"})]}),S?a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx(Qj,{className:"w-5 h-5 text-bambu-green"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:S.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[(S.size/1024/1024).toFixed(1)," MB"]})]}),a.jsx("button",{onClick:()=>R(!A),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:A?a.jsx(lfe,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(sfe,{className:"w-4 h-4 text-bambu-green"})}),a.jsx("input",{type:"range",min:0,max:1,step:.1,value:C,onChange:z=>D(parseFloat(z.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full`}),a.jsx("button",{onClick:Z,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:a.jsx(on,{className:"w-4 h-4 text-red-400"})})]}):a.jsxs("label",{className:"flex flex-col items-center justify-center gap-2 p-6 border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green/50 transition-colors",children:[a.jsx(fi,{className:"w-8 h-8 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:"Drop audio file or click to upload"}),a.jsx("span",{className:"text-xs text-bambu-gray/60",children:"MP3, WAV, M4A, AAC, OGG"}),a.jsx("input",{type:"file",accept:".mp3,.wav,.m4a,.aac,.ogg,audio/*",onChange:K,className:"hidden"})]})]}),a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg text-sm space-y-1",children:[a.jsxs("p",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white",children:"Original:"})," ",Ap(f)," @ ",F?.width,"x",F?.height]}),a.jsxs("p",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white",children:"Output:"})," ",Ap(ne)," @ ",v,"x speed",S&&" + music overlay"]})]})]}),j.isPending&&a.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4",children:[a.jsx(ut,{className:"w-12 h-12 text-bambu-green animate-spin"}),a.jsx("p",{className:"text-white text-lg",children:"Processing timelapse..."}),a.jsx("p",{className:"text-bambu-gray text-sm",children:"This may take a few moments"})]})]})})}const GGe=[.25,.5,.75,1,1.5,2,3,4];function Kne({src:t,title:e,downloadFilename:n,archiveId:r,onClose:i,onEdit:s}){const o=w.useRef(null),[l,c]=w.useState(!0),[u,d]=w.useState(1),[f,m]=w.useState(0),[g,x]=w.useState(0),[y,b]=w.useState(!1);w.useEffect(()=>{const C=o.current;C&&(C.playbackRate=u)},[u]),w.useEffect(()=>{const C=D=>{D.key==="Escape"&&i()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[i]),w.useEffect(()=>{const C=o.current;if(!C)return;const D=()=>m(C.currentTime),A=()=>x(C.duration),R=()=>c(!0),F=()=>c(!1);return C.addEventListener("timeupdate",D),C.addEventListener("durationchange",A),C.addEventListener("play",R),C.addEventListener("pause",F),()=>{C.removeEventListener("timeupdate",D),C.removeEventListener("durationchange",A),C.removeEventListener("play",R),C.removeEventListener("pause",F)}},[]);const v=()=>{const C=o.current;C&&(l?C.pause():C.play())},N=C=>{const D=o.current;D&&(D.currentTime=parseFloat(C.target.value))},S=()=>{const C=o.current;C&&(C.currentTime=Math.max(0,C.currentTime-5))},T=()=>{const C=o.current;C&&(C.currentTime=Math.min(g,C.currentTime+5))},E=C=>{const D=Math.floor(C/60),A=Math.floor(C%60);return`${D}:${A.toString().padStart(2,"0")}`},k=()=>{const C=document.createElement("a");C.href=t,C.download=n,C.click()};return a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:[a.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Rd,{className:"w-5 h-5 text-bambu-green"}),e]}),a.jsxs("div",{className:"flex items-center gap-2",children:[r&&a.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>b(!0),children:[a.jsx(Oi,{className:"w-4 h-4"}),"Edit"]}),a.jsxs(Te,{variant:"secondary",size:"sm",onClick:k,children:[a.jsx(Gr,{className:"w-4 h-4"}),"Download"]}),a.jsx("button",{onClick:i,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:a.jsx(Ot,{className:"w-5 h-5 text-bambu-gray"})})]})]}),a.jsxs("div",{className:"p-4",children:[a.jsx("video",{ref:o,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:v}),a.jsxs("div",{className:"mt-4 space-y-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:E(f)}),a.jsx("input",{type:"range",min:0,max:g||100,value:f,onChange:N,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),a.jsx("span",{className:"text-xs text-bambu-gray w-12",children:E(g)})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:S,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:a.jsx(Ehe,{className:"w-5 h-5 text-bambu-gray"})}),a.jsx("button",{onClick:v,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?a.jsx(hD,{className:"w-5 h-5 text-white"}):a.jsx(vs,{className:"w-5 h-5 text-white"})}),a.jsx("button",{onClick:T,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:a.jsx(x0,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),a.jsx("div",{className:"flex gap-1",children:GGe.map(C=>a.jsxs("button",{onClick:()=>d(C),className:`px-2 py-1 text-xs rounded transition-colors ${u===C?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[C,"x"]},C))})]})]})]})]})]}),y&&r&&a.jsx(VGe,{archiveId:r,timelapseSrc:t,onClose:()=>b(!1),onSave:s})]})}function qGe({archiveIds:t,onClose:e}){w.useEffect(()=>{const s=o=>{o.key==="Escape"&&e()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e]);const{data:n,isLoading:r,error:i}=ct({queryKey:["archive-comparison",t],queryFn:()=>he.compareArchives(t)});return a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:e,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[90vh] flex flex-col border border-bambu-dark-tertiary",onClick:s=>s.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Compare Archives (",t.length,")"]}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white p-1",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"flex-1 overflow-auto p-4 bg-bambu-dark-secondary",children:r?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(ut,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i?a.jsxs("div",{className:"text-center py-12 text-red-400",children:[a.jsx(xn,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),a.jsx("p",{children:"Failed to load comparison"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:i instanceof Error?i.message:"Unknown error"})]}):n?a.jsx(WGe,{comparison:n}):null}),a.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:a.jsx(Te,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function WGe({comparison:t}){return a.jsxs("div",{className:"space-y-6",children:[a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{className:"text-left text-sm text-bambu-gray font-medium pb-2 pr-4 min-w-[150px]",children:"Setting"}),t.archives.map(e=>a.jsxs("th",{className:"text-left text-sm font-medium pb-2 px-2 min-w-[120px]",children:[a.jsx("div",{className:"text-white truncate max-w-[150px]",title:e.print_name,children:e.print_name}),a.jsx("div",{className:`text-xs ${e.status==="completed"?"text-status-ok":e.status==="failed"?"text-status-error":"text-bambu-gray"}`,children:e.status})]},e.id))]})}),a.jsx("tbody",{className:"divide-y divide-bambu-gray/20",children:t.comparison.map(e=>a.jsxs("tr",{className:e.has_difference?"bg-yellow-500/5":"",children:[a.jsx("td",{className:"py-2 pr-4 text-sm",children:a.jsxs("div",{className:"flex items-center gap-2",children:[e.has_difference&&a.jsx(xn,{className:"w-3 h-3 text-yellow-400 flex-shrink-0"}),a.jsx("span",{className:e.has_difference?"text-yellow-400":"text-bambu-gray",children:e.label})]})}),e.values.map((n,r)=>a.jsxs("td",{className:"py-2 px-2 text-sm text-white",children:[n??a.jsx("span",{className:"text-bambu-gray/50",children:"-"}),e.unit&&n!==null&&a.jsx("span",{className:"text-bambu-gray ml-1",children:e.unit})]},r))]},e.field))})]})}),t.differences.length>0&&a.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[a.jsxs("h4",{className:"text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2",children:[a.jsx(xn,{className:"w-4 h-4"}),t.differences.length," Difference",t.differences.length>1?"s":""," Found"]}),a.jsxs("ul",{className:"text-sm text-white/80 space-y-1",children:[t.differences.slice(0,5).map(e=>a.jsxs("li",{children:[a.jsx("span",{className:"text-yellow-400",children:e.label}),": ",e.values.join(" vs ")," ",e.unit||""]},e.field)),t.differences.length>5&&a.jsxs("li",{className:"text-bambu-gray",children:["...and ",t.differences.length-5," more"]})]})]}),t.success_correlation.has_both_outcomes?a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg",children:[a.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-2",children:[a.jsx(Ua,{className:"w-4 h-4 text-bambu-green"}),"Success/Failure Analysis"]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm mb-3",children:[a.jsxs("span",{className:"text-bambu-green",children:[t.success_correlation.successful_count," successful"]}),a.jsxs("span",{className:"text-red-400",children:[t.success_correlation.failed_count," failed"]})]}),t.success_correlation.insights&&t.success_correlation.insights.length>0?a.jsx("div",{className:"space-y-2",children:t.success_correlation.insights.map(e=>a.jsxs("div",{className:"text-sm p-2 bg-bambu-dark-secondary rounded",children:[a.jsxs("span",{className:"text-white font-medium",children:[e.label,":"]})," ",a.jsx("span",{className:"text-white/80",children:e.insight})]},e.field))}):a.jsx("p",{className:"text-sm text-bambu-gray",children:"No clear correlations found between settings and outcomes."})]}):a.jsx("div",{className:"p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray",children:a.jsx("p",{children:t.success_correlation.message||"Need both successful and failed prints for correlation analysis."})})]})}function KGe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function XGe(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4);if(i<1)return"Just now";if(i<60)return`${i}m ago`;const s=Math.floor(i/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function YGe({upload:t,projects:e,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:s}){const[o,l]=w.useState(!1),[c,u]=w.useState(t.tags||""),[d,f]=w.useState(t.notes||""),[m,g]=w.useState(t.project_id),[x,y]=w.useState(!1);return a.jsx(_t,{children:a.jsxs(St,{className:"py-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(xf,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium",children:t.filename}),a.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[a.jsx("span",{children:KGe(t.file_size)}),a.jsx("span",{children:"·"}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(qn,{className:"w-3 h-3"}),XGe(t.uploaded_at)]}),t.source_ip&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"·"}),a.jsxs("span",{children:["from ",t.source_ip]})]})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>l(!o),className:"p-1 text-bambu-gray hover:text-white transition-colors",children:o?a.jsx(ou,{className:"w-5 h-5"}):a.jsx(Br,{className:"w-5 h-5"})}),a.jsx(Te,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:m||void 0}),disabled:i,children:i?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(Qa,{className:"w-4 h-4"}),"Archive"]})}),a.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>y(!0),disabled:s,children:s?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(on,{className:"w-4 h-4 text-red-400"})})]})]}),x&&a.jsx(Hn,{title:"Discard Upload",message:`Are you sure you want to discard "${t.filename}"? This cannot be undone.`,confirmText:"Discard",variant:"danger",onConfirm:()=>{r(t.id),y(!1)},onCancel:()=>y(!1)}),o&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),a.jsx("input",{type:"text",value:c,onChange:b=>u(b.target.value),placeholder:"e.g., functional, prototype, gift",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),a.jsx("textarea",{value:d,onChange:b=>f(b.target.value),placeholder:"Add notes about this print...",rows:2,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm resize-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Project"}),a.jsxs("select",{value:m||"",onChange:b=>g(b.target.value?Number(b.target.value):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm",children:[a.jsx("option",{value:"",children:"No project"}),e.map(b=>a.jsx("option",{value:b.id,children:b.name},b.id))]})]})]})]})})}function QGe(){const t=an(),{showToast:e}=Gn(),[n,r]=w.useState(!1),[i,s]=w.useState(!1),[o,l]=w.useState(new Set),[c,u]=w.useState(new Set),{data:d,isLoading:f}=ct({queryKey:["pending-uploads"],queryFn:Pp.list,refetchInterval:1e4}),{data:m}=ct({queryKey:["projects"],queryFn:()=>he.getProjects()}),g=ht({mutationFn:({id:v,data:N})=>Pp.archive(v,N),onMutate:({id:v})=>{l(N=>new Set(N).add(v))},onSettled:(v,N,{id:S})=>{l(T=>{const E=new Set(T);return E.delete(S),E})},onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived: ${v.print_name}`)},onError:v=>{e(v.message||"Failed to archive","error")}}),x=ht({mutationFn:v=>Pp.discard(v),onMutate:v=>{u(N=>new Set(N).add(v))},onSettled:(v,N,S)=>{u(T=>{const E=new Set(T);return E.delete(S),E})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:v=>{e(v.message||"Failed to discard","error")}}),y=ht({mutationFn:Pp.archiveAll,onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived ${v.archived} files${v.failed>0?`, ${v.failed} failed`:""}`)},onError:v=>{e(v.message||"Failed to archive all","error")}}),b=ht({mutationFn:Pp.discardAll,onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e(`Discarded ${v.discarded} files`)},onError:v=>{e(v.message||"Failed to discard all","error")}});return f?a.jsx(_t,{children:a.jsx(St,{className:"py-8 flex justify-center",children:a.jsx(ut,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:a.jsxs("div",{className:"mb-6",children:[a.jsxs(_t,{className:"border-l-4 border-l-yellow-500",children:[a.jsx(tr,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(fi,{className:"w-5 h-5 text-yellow-500"}),a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Pending Uploads (",d.length,")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Te,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:y.isPending,children:y.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(Qa,{className:"w-4 h-4"}),"Archive All"]})}),a.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>s(!0),disabled:b.isPending,children:b.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(on,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),a.jsxs(St,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"These files were uploaded via the virtual printer. Review and archive them to add to your collection."}),a.jsx("div",{className:"space-y-3",children:d.map(v=>a.jsx(YGe,{upload:v,projects:m||[],onArchive:(N,S)=>g.mutate({id:N,data:S}),onDiscard:N=>x.mutate(N),isArchiving:o.has(v.id),isDiscarding:c.has(v.id)},v.id))})]})]}),n&&a.jsx(Hn,{title:"Archive All Uploads",message:`Are you sure you want to archive all ${d.length} pending uploads?`,confirmText:"Archive All",onConfirm:()=>{y.mutate(),r(!1)},onCancel:()=>r(!1)}),i&&a.jsx(Hn,{title:"Discard All Uploads",message:`Are you sure you want to discard all ${d.length} pending uploads? This cannot be undone.`,confirmText:"Discard All",variant:"danger",onConfirm:()=>{b.mutate(),s(!1)},onCancel:()=>s(!1)})]})}function ZGe({onClose:t}){const e=an(),{showToast:n}=Gn(),[r,i]=w.useState(""),[s,o]=w.useState(null),[l,c]=w.useState(""),[u,d]=w.useState(null),[f,m]=w.useState("count");w.useEffect(()=>{const A=R=>{R.key==="Escape"&&(s?o(null):u?d(null):t())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t,s,u]);const{data:g,isLoading:x}=ct({queryKey:["tags"],queryFn:he.getTags}),y=ht({mutationFn:({oldName:A,newName:R})=>he.renameTag(A,R),onSuccess:(A,{oldName:R,newName:F})=>{e.invalidateQueries({queryKey:["tags"]}),e.invalidateQueries({queryKey:["archives"]}),n(`Renamed "${R}" to "${F}" in ${A.affected} archive${A.affected!==1?"s":""}`),o(null)},onError:A=>{n(A.message||"Failed to rename tag","error")}}),b=ht({mutationFn:A=>he.deleteTag(A),onSuccess:(A,R)=>{e.invalidateQueries({queryKey:["tags"]}),e.invalidateQueries({queryKey:["archives"]}),n(`Deleted "${R}" from ${A.affected} archive${A.affected!==1?"s":""}`),d(null)},onError:A=>{n(A.message||"Failed to delete tag","error")}}),v=A=>{o(A.name),c(A.name),d(null)},N=()=>{o(null),c("")},S=()=>{if(!s||!l.trim())return;const A=l.trim();if(A===s){N();return}y.mutate({oldName:s,newName:A})},T=A=>{A.key==="Enter"?(A.preventDefault(),S()):A.key==="Escape"&&(A.preventDefault(),N())},E=A=>{d(A),o(null)},k=()=>{u&&b.mutate(u)},C=g?.filter(A=>A.name.toLowerCase().includes(r.toLowerCase())).sort((A,R)=>f==="count"&&R.count-A.count||A.name.localeCompare(R.name)),D=g?.reduce((A,R)=>A+R.count,0)||0;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-lg max-h-[80vh] flex flex-col",children:a.jsxs(St,{className:"p-0 flex flex-col min-h-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qd,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:"Manage Tags"})]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(na,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:"Search tags...",className:"w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:r,onChange:A=>i(A.target.value)})]}),a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:f,onChange:A=>m(A.target.value),children:[a.jsx("option",{value:"count",children:"Sort by Count"}),a.jsx("option",{value:"name",children:"Sort by Name"})]})]}),g&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[g.length," tag",g.length!==1?"s":""," across ",D," usage",D!==1?"s":""]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 p-4",children:x?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(ut,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):C?.length?a.jsx("div",{className:"space-y-2",children:C.map(A=>a.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary transition-colors group",children:s===A.name?a.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[a.jsx("input",{type:"text",className:"flex-1 px-2 py-1 bg-bambu-dark-tertiary border border-bambu-green rounded text-white text-sm focus:outline-none",value:l,onChange:R=>c(R.target.value),onKeyDown:T,autoFocus:!0}),a.jsx(Te,{size:"sm",variant:"primary",onClick:S,disabled:!l.trim()||y.isPending,className:"p-1.5",children:y.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(Ua,{className:"w-4 h-4"})}),a.jsx(Te,{size:"sm",variant:"ghost",onClick:N,className:"p-1.5",children:a.jsx(Ot,{className:"w-4 h-4"})})]}):u===A.name?a.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[a.jsx(xn,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),a.jsxs("span",{className:"text-sm text-bambu-gray-light flex-1",children:['Delete "',A.name,'" from ',A.count," archive",A.count!==1?"s":"","?"]}),a.jsx(Te,{size:"sm",variant:"danger",onClick:k,disabled:b.isPending,className:"p-1.5",children:b.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(on,{className:"w-4 h-4"})}),a.jsx(Te,{size:"sm",variant:"ghost",onClick:()=>d(null),className:"p-1.5",children:a.jsx(Ot,{className:"w-4 h-4"})})]}):a.jsxs(a.Fragment,{children:[a.jsx(qd,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"text-white flex-1 truncate",children:A.name}),a.jsx("span",{className:"px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray text-xs",children:A.count}),a.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[a.jsx("button",{onClick:()=>v(A),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Rename tag",children:a.jsx(Oi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>E(A.name),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",title:"Delete tag",children:a.jsx(on,{className:"w-4 h-4"})})]})]})},A.name))}):a.jsx("div",{className:"text-center py-8 text-bambu-gray",children:r?"No tags match your search":"No tags found"})}),a.jsx("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary flex-shrink-0",children:a.jsx(Te,{variant:"secondary",onClick:t,className:"flex-1",children:"Close"})})]})})})}function M2(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Mb(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function af(t){if(!t)return!1;const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function JGe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:s,isHighlighted:o,timeFormat:l="system"}){o&&console.log("ArchiveCard isHighlighted=true for archive:",t.id);const c=an(),{showToast:u}=Gn(),d=yD(),[f,m]=w.useState(!1),[g,x]=w.useState(!1),[y,b]=w.useState(!1),[v,N]=w.useState(!1),[S,T]=w.useState(!1),[E,k]=w.useState(!1),[C,D]=w.useState([]),[A,R]=w.useState(!1),[F,O]=w.useState(!1),[q,j]=w.useState(!1),[G,Y]=w.useState(!1),[K,Z]=w.useState(!1),[te,ne]=w.useState(!1),[z,W]=w.useState(null),[se,ae]=w.useState(null),[de,me]=w.useState(!1),xe=w.useRef(null),be=w.useRef(null),{data:fe}=ct({queryKey:["archive-plates",t.id],queryFn:()=>he.getArchivePlates(t.id),enabled:de,staleTime:300*1e3}),Ce=fe?.plates??[],Ne=fe?.is_multi_plate??!1,re=se??0,He=ht({mutationFn:ie=>he.uploadSource3mf(t.id,ie),onSuccess:ie=>{c.invalidateQueries({queryKey:["archives"]}),u(`Source 3MF attached: ${ie.filename}`)},onError:ie=>{u(ie.message||"Failed to upload source 3MF","error")}}),H=ht({mutationFn:()=>he.deleteSource3mf(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Source 3MF removed")},onError:ie=>{u(ie.message||"Failed to remove source 3MF","error")}}),B=ht({mutationFn:ie=>he.uploadF3d(t.id,ie),onSuccess:ie=>{c.invalidateQueries({queryKey:["archives"]}),u(`F3D attached: ${ie.filename}`)},onError:ie=>{u(ie.message||"Failed to upload F3D","error")}}),X=ht({mutationFn:()=>he.deleteF3d(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("F3D removed")},onError:ie=>{u(ie.message||"Failed to remove F3D","error")}}),U=ht({mutationFn:()=>he.scanArchiveTimelapse(t.id),onSuccess:ie=>{ie.status==="attached"?(c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${ie.filename}`)):ie.status==="exists"?u("Timelapse already attached"):ie.status==="not_found"&&ie.available_files&&ie.available_files.length>0?(D(ie.available_files),k(!0)):u(ie.message||"No matching timelapse found","warning")},onError:ie=>{u(ie.message||"Failed to scan for timelapse","error")}}),Q=ht({mutationFn:ie=>he.selectArchiveTimelapse(t.id,ie),onSuccess:ie=>{c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${ie.filename}`),k(!1),D([])},onError:ie=>{u(ie.message||"Failed to attach timelapse","error")}}),le=ht({mutationFn:()=>he.deleteArchive(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Archive deleted")},onError:()=>{u("Failed to delete archive","error")}}),Pe=ht({mutationFn:()=>he.toggleFavorite(t.id),onSuccess:ie=>{c.invalidateQueries({queryKey:["archives"]}),u(ie.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:Oe}=ct({queryKey:["archive-folders",t.id],queryFn:()=>he.getLibraryFoldersByArchive(t.id)}),je=ht({mutationFn:ie=>he.updateArchive(t.id,{project_id:ie}),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),c.invalidateQueries({queryKey:["projects"]}),u("Project updated")},onError:()=>{u("Failed to update project","error")}}),$=ie=>{ie.preventDefault(),W({x:ie.clientX,y:ie.clientY})},V=[...af(t.filename)?[{label:"Print",icon:a.jsx(Ar,{className:"w-4 h-4"}),onClick:()=>x(!0)},{label:"Schedule",icon:a.jsx(si,{className:"w-4 h-4"}),onClick:()=>Y(!0)},{label:"Open in Bambu Studio",icon:a.jsx($r,{className:"w-4 h-4"}),onClick:()=>{const ie=t.print_name||t.filename||"model",Se=`${window.location.origin}${he.getArchiveForSlicer(t.id,ie)}`;$c(Se)}}]:[{label:"Slice",icon:a.jsx($r,{className:"w-4 h-4"}),onClick:()=>{const ie=t.print_name||t.filename||"model",Se=`${window.location.origin}${he.getArchiveForSlicer(t.id,ie)}`;$c(Se)}}],{label:t.external_url?"External Link":"View on MakerWorld",icon:a.jsx(Dd,{className:"w-4 h-4"}),onClick:()=>{const ie=t.external_url||t.makerworld_url;ie&&window.open(ie,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:a.jsx(Hs,{className:"w-4 h-4"}),onClick:()=>m(!0)},{label:"View Timelapse",icon:a.jsx(Rd,{className:"w-4 h-4"}),onClick:()=>T(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:a.jsx(Sw,{className:"w-4 h-4"}),onClick:()=>U.mutate(),disabled:!t.printer_id||!!t.timelapse_path||U.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:a.jsx(vw,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const ie=document.createElement("a");ie.href=he.getSource3mfDownloadUrl(t.id),ie.download=`${t.print_name||t.filename}_source.3mf`,ie.click()}else xe.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:a.jsx(fi,{className:"w-4 h-4"}),onClick:()=>xe.current?.click()},{label:"Remove Source 3MF",icon:a.jsx(on,{className:"w-4 h-4"}),onClick:()=>Z(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:a.jsx(Hs,{className:"w-4 h-4"}),onClick:()=>be.current?.click()},...t.f3d_path?[{label:"Download F3D",icon:a.jsx(Gr,{className:"w-4 h-4"}),onClick:()=>{const ie=document.createElement("a");ie.href=he.getF3dDownloadUrl(t.id),ie.download=`${t.print_name||t.filename}.f3d`,ie.click()}},{label:"Remove F3D",icon:a.jsx(on,{className:"w-4 h-4"}),onClick:()=>ne(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:a.jsx(Gr,{className:"w-4 h-4"}),onClick:()=>{const ie=document.createElement("a");ie.href=he.getArchiveDownload(t.id),ie.download=`${t.print_name||t.filename}.3mf`,ie.click()}},{label:"Copy Download Link",icon:a.jsx(ll,{className:"w-4 h-4"}),onClick:()=>{const ie=`${window.location.origin}${he.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(ie).then(()=>{u("Link copied to clipboard")}).catch(()=>{u("Failed to copy link","error")})}},{label:"QR Code",icon:a.jsx(fW,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:a.jsx(Df,{className:"w-4 h-4"}),onClick:()=>O(!0),disabled:!t.photos?.length},{label:"Project Page",icon:a.jsx(Ka,{className:"w-4 h-4"}),onClick:()=>j(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:a.jsx(Lf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>Pe.mutate()},{label:"Edit",icon:a.jsx(Oi,{className:"w-4 h-4"}),onClick:()=>N(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:a.jsx(Ma,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:a.jsx(Ma,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const ie=[];if(t.project_id&&ie.push({label:"Remove from Project",icon:a.jsx(Ot,{className:"w-4 h-4"}),onClick:()=>je.mutate(null)}),!s)ie.push({label:"Loading...",icon:a.jsx(ut,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const Se=s.filter(ye=>ye.status==="active");Se.length===0?ie.push({label:"No projects available",icon:a.jsx(Ma,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):Se.forEach(ye=>{ie.push({label:ye.name,icon:a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:ye.color||"#888"}}),onClick:()=>je.mutate(ye.id),disabled:t.project_id===ye.id})})}return ie})()},{label:n?"Deselect":"Select",icon:n?a.jsx(Do,{className:"w-4 h-4"}):a.jsx(Oo,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:a.jsx(on,{className:"w-4 h-4"}),onClick:()=>b(!0),danger:!0}];return a.jsxs(_t,{"data-archive-id":t.id,className:`relative flex flex-col group ${n?"ring-2 ring-bambu-green":""} ${i?"cursor-pointer":""}`,style:o?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,onContextMenu:$,onClick:i?()=>r(t.id):void 0,children:[i&&a.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:ie=>{ie.stopPropagation(),r(t.id)},children:n?a.jsx(Do,{className:"w-5 h-5 text-bambu-green"}):a.jsx(Oo,{className:"w-5 h-5 text-white"})}),a.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",onMouseEnter:()=>me(!0),onMouseLeave:()=>me(!1),children:[t.thumbnail_path?a.jsx("img",{src:se!==null&&Ce.length>0?he.getArchivePlateThumbnail(t.id,Ce[re]?.index??0):he.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:a.jsx(cu,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),Ne&&Ce.length>1&&a.jsxs(a.Fragment,{children:[a.jsx("button",{className:`absolute left-1 top-1/2 -translate-y-1/2 p-1 rounded-full bg-black/60 hover:bg-black/80 transition-all ${d?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:ie=>{ie.stopPropagation(),ae(Se=>{const ye=Se??0;return ye>0?ye-1:Ce.length-1})},title:"Previous plate",children:a.jsx(Vd,{className:"w-4 h-4 text-white"})}),a.jsx("button",{className:`absolute right-1 top-1/2 -translate-y-1/2 p-1 rounded-full bg-black/60 hover:bg-black/80 transition-all ${d?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:ie=>{ie.stopPropagation(),ae(Se=>{const ye=Se??0;return ye<Ce.length-1?ye+1:0})},title:"Next plate",children:a.jsx(Ms,{className:"w-4 h-4 text-white"})}),a.jsx("div",{className:`absolute bottom-1 left-1/2 -translate-x-1/2 flex gap-1 px-2 py-1 rounded-full bg-black/50 transition-all ${d?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:Ce.map((ie,Se)=>a.jsx("button",{className:`w-2 h-2 rounded-full transition-colors ${Se===re?"bg-bambu-green":"bg-white/50 hover:bg-white/80"}`,onClick:ye=>{ye.stopPropagation(),ae(Se)},title:ie.name||`Plate ${ie.index}`},ie.index))})]}),a.jsx("button",{className:`absolute top-2 left-2 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-all ${d?"opacity-100":"opacity-0 group-hover:opacity-100"} ${i?"left-10":""}`,onClick:ie=>{ie.stopPropagation();const Se=ie.currentTarget.getBoundingClientRect();W({x:Se.left,y:Se.bottom+4})},title:"Right-click for more options",children:a.jsx(Pd,{className:"w-5 h-5 text-white"})}),a.jsx("button",{className:"absolute top-2 right-2 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:ie=>{ie.stopPropagation(),Pe.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:a.jsx(Lf,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),(t.status==="failed"||t.status==="aborted")&&a.jsx("div",{className:"absolute top-2 left-12 px-2 py-1 rounded text-xs bg-status-error/80 text-white",children:t.status==="aborted"?"cancelled":"failed"}),t.duplicate_count>0&&a.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 rounded text-xs bg-purple-500/80 text-white flex items-center gap-1",title:"This model has been printed before",children:[a.jsx(ll,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&a.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:ie=>{ie.stopPropagation();const Se=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",ye=`${window.location.origin}${he.getSource3mfForSlicer(t.id,Se)}`;$c(ye)},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:a.jsx(vw,{className:"w-4 h-4 text-orange-400"})}),t.f3d_path&&a.jsx("button",{className:`absolute bottom-2 ${t.source_3mf_path?"left-12":"left-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:ie=>{ie.stopPropagation(),window.location.href=he.getF3dDownloadUrl(t.id)},title:"Download Fusion 360 design file",children:a.jsx(Hs,{className:"w-4 h-4 text-cyan-400"})}),t.timelapse_path&&a.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:ie=>{ie.stopPropagation(),T(!0)},title:"View timelapse",children:a.jsx(Rd,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&a.jsxs("button",{className:`absolute bottom-2 ${t.timelapse_path?"right-12":"right-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:ie=>{ie.stopPropagation(),O(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[a.jsx(Df,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&a.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 bg-blue-500 rounded-full text-[10px] text-white flex items-center justify-center",children:t.photos.length})]}),Oe&&Oe.length>0&&a.jsx(ps,{to:`/files?folder=${Oe[0].id}`,className:"absolute bottom-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:ie=>ie.stopPropagation(),title:`Open folder: ${Oe[0].name}`,style:{left:t.source_3mf_path?t.f3d_path?"5.5rem":"3rem":t.f3d_path?"3rem":"0.5rem"},children:a.jsx(cl,{className:"w-4 h-4 text-yellow-400"})})]}),a.jsxs(St,{className:"p-4 flex-1 flex flex-col",children:[a.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:e}),a.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${af(t.filename)?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:af(t.filename)?"Sliced file - ready to print":"Source file only - no AMS mapping available",children:af(t.filename)?"GCODE":"SOURCE"}),t.project_name&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${s?.find(ie=>ie.id===t.project_id)?.color||"#6b7280"}20`,color:s?.find(ie=>ie.id===t.project_id)?.color||"#6b7280"},title:`Project: ${t.project_name}`,children:t.project_name})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs mb-4 min-h-[48px]",children:[(t.print_time_seconds||t.actual_time_seconds)&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${Mb(t.print_time_seconds||0)}
- Actual: ${Mb(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Mb(t.actual_time_seconds)}`:`Estimated: ${Mb(t.print_time_seconds||0)}`,children:[a.jsx(qn,{className:"w-3 h-3"}),Mb(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&a.jsxs("span",{className:`text-[10px] px-1 rounded ${t.time_accuracy>=95&&t.time_accuracy<=105?"bg-bambu-green/20 text-bambu-green":t.time_accuracy>105?"bg-blue-500/20 text-blue-400":"bg-orange-500/20 text-orange-400"}`,children:[t.time_accuracy>100?"+":"",(t.time_accuracy-100).toFixed(0),"%"]})]}),t.filament_used_grams&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[a.jsx(zl,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[a.jsx(ul,{className:"w-3 h-3"}),t.total_layers&&a.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&a.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&a.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.object_count!=null&&t.object_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:`${t.object_count} object${t.object_count>1?"s":""}`,children:[a.jsx(Hs,{className:"w-3 h-3"}),t.object_count," object",t.object_count>1?"s":""]}),t.sliced_for_model&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:`Sliced for ${t.sliced_for_model}`,children:[a.jsx(Ar,{className:"w-3 h-3"}),t.sliced_for_model]}),t.filament_type&&a.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[a.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&a.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((ie,Se)=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:ie},title:ie},Se))})]})]}),(t.tags||t.notes)&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&a.jsx("div",{className:"flex items-center gap-1 px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded text-xs",title:t.notes,children:a.jsx(pW,{className:"w-3 h-3"})}),t.tags?.split(",").map((ie,Se)=>a.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:ie.trim()},Se))]}),a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[a.jsx("span",{children:ug(t.created_at,l)}),a.jsx("span",{children:M2(t.file_size)})]}),a.jsxs("div",{className:"flex gap-1 mt-3",children:[af(t.filename)?a.jsxs(a.Fragment,{children:[a.jsxs(Te,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>x(!0),children:[a.jsx(Ar,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:"Reprint"})]}),a.jsx(Te,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ie=t.print_name||t.filename||"model",Se=`${window.location.origin}${he.getArchiveForSlicer(t.id,ie)}`;$c(Se)},title:"Open in Bambu Studio",children:a.jsx($r,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):a.jsxs(Te,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const ie=t.print_name||t.filename||"model",Se=`${window.location.origin}${he.getArchiveForSlicer(t.id,ie)}`;$c(Se)},title:"Open in Bambu Studio to slice",children:[a.jsx($r,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:"Slice"})]}),a.jsx(Te,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ie=t.external_url||t.makerworld_url;ie&&window.open(ie,"_blank")},disabled:!t.external_url&&!t.makerworld_url,title:t.external_url?"External Link":t.makerworld_url?`MakerWorld: ${t.designer||"View project"}`:"No external link",children:a.jsx(Dd,{className:`w-3 h-3 sm:w-4 sm:h-4 ${!t.external_url&&!t.makerworld_url?"opacity-20":""}`})}),a.jsx(Te,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>m(!0),title:"3D Preview",children:a.jsx(Hs,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),a.jsx(Te,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ie=document.createElement("a");ie.href=he.getArchiveDownload(t.id),ie.download=`${t.print_name||t.filename}.3mf`,ie.click()},title:"Download",children:a.jsx(Gr,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),a.jsx(Te,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>N(!0),title:"Edit",children:a.jsx(Oi,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),a.jsx(Te,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>b(!0),title:"Delete",children:a.jsx(on,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),v&&a.jsx(lee,{archive:t,onClose:()=>N(!1)}),f&&a.jsx(iee,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>m(!1)}),g&&a.jsx(ah,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>x(!1)}),y&&a.jsx(Hn,{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:()=>{le.mutate(),b(!1)},onCancel:()=>b(!1)}),K&&a.jsx(Hn,{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:()=>{H.mutate(),Z(!1)},onCancel:()=>Z(!1)}),te&&a.jsx(Hn,{title:"Remove F3D",message:`Are you sure you want to remove the Fusion 360 design file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{X.mutate(),ne(!1)},onCancel:()=>ne(!1)}),z&&a.jsx(cee,{x:z.x,y:z.y,items:V,onClose:()=>W(null)}),S&&t.timelapse_path&&a.jsx(Kne,{src:he.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>T(!1),onEdit:()=>{c.invalidateQueries({queryKey:["archives"]}),T(!1)}}),E&&C.length>0&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),a.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),a.jsx("button",{onClick:()=>{k(!1),D([])},className:"text-gray-400 hover:text-white p-1",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:C.map(ie=>a.jsxs("button",{onClick:()=>Q.mutate(ie.name),disabled:Q.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors flex items-center gap-3 disabled:opacity-50",children:[a.jsx(Rd,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-white font-medium truncate",children:ie.name}),a.jsxs("p",{className:"text-sm text-gray-400",children:[M2(ie.size),ie.mtime&&` • ${ug(ie.mtime,l)}`]})]})]},ie.name))}),a.jsx("div",{className:"p-4 border-t border-gray-700",children:a.jsx(Te,{variant:"secondary",onClick:()=>{k(!1),D([])},className:"w-full",children:"Cancel"})})]})}),A&&a.jsx(uee,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),F&&t.photos&&t.photos.length>0&&a.jsx(dee,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>O(!1),onDelete:async ie=>{try{await he.deleteArchivePhoto(t.id,ie),c.invalidateQueries({queryKey:["archives"]}),u("Photo deleted")}catch{u("Failed to delete photo","error")}}}),q&&a.jsx(Wne,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>j(!1)}),G&&a.jsx(ah,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>Y(!1)}),a.jsx("input",{ref:xe,type:"file",accept:".3mf",className:"hidden",onChange:ie=>{const Se=ie.target.files?.[0];Se&&He.mutate(Se),ie.target.value=""}}),a.jsx("input",{ref:be,type:"file",accept:".f3d",className:"hidden",onChange:ie=>{const Se=ie.target.files?.[0];Se&&B.mutate(Se),ie.target.value=""}})]})}function eqe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:s,isHighlighted:o}){const l=an(),{showToast:c}=Gn(),[u,d]=w.useState(!1),[f,m]=w.useState(!1),[g,x]=w.useState(!1),[y,b]=w.useState(!1),[v,N]=w.useState(!1),[S,T]=w.useState(!1),[E,k]=w.useState(!1),[C,D]=w.useState([]),[A,R]=w.useState(!1),[F,O]=w.useState(!1),[q,j]=w.useState(!1),[G,Y]=w.useState(!1),[K,Z]=w.useState(!1),[te,ne]=w.useState(null),z=w.useRef(null),W=w.useRef(null),se=ht({mutationFn:X=>he.uploadSource3mf(t.id,X),onSuccess:X=>{l.invalidateQueries({queryKey:["archives"]}),c(`Source 3MF attached: ${X.filename}`)},onError:X=>{c(X.message||"Failed to upload source 3MF","error")}}),ae=ht({mutationFn:()=>he.deleteSource3mf(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Source 3MF removed")},onError:X=>{c(X.message||"Failed to remove source 3MF","error")}}),de=ht({mutationFn:X=>he.uploadF3d(t.id,X),onSuccess:X=>{l.invalidateQueries({queryKey:["archives"]}),c(`F3D attached: ${X.filename}`)},onError:X=>{c(X.message||"Failed to upload F3D","error")}}),me=ht({mutationFn:()=>he.deleteF3d(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("F3D removed")},onError:X=>{c(X.message||"Failed to remove F3D","error")}}),xe=ht({mutationFn:()=>he.scanArchiveTimelapse(t.id),onSuccess:X=>{X.status==="attached"?(l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${X.filename}`)):X.status==="exists"?c("Timelapse already attached"):X.status==="not_found"&&X.available_files&&X.available_files.length>0?(D(X.available_files),k(!0)):c(X.message||"No matching timelapse found","warning")},onError:X=>{c(X.message||"Failed to scan for timelapse","error")}}),be=ht({mutationFn:X=>he.selectArchiveTimelapse(t.id,X),onSuccess:X=>{l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${X.filename}`),k(!1),D([])},onError:X=>{c(X.message||"Failed to attach timelapse","error")}}),fe=ht({mutationFn:()=>he.deleteArchive(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Archive deleted")},onError:()=>{c("Failed to delete archive","error")}}),Ce=ht({mutationFn:()=>he.toggleFavorite(t.id),onSuccess:X=>{l.invalidateQueries({queryKey:["archives"]}),c(X.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:Ne}=ct({queryKey:["archive-folders",t.id],queryFn:()=>he.getLibraryFoldersByArchive(t.id)}),re=ht({mutationFn:X=>he.updateArchive(t.id,{project_id:X}),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),l.invalidateQueries({queryKey:["projects"]}),c("Project updated")},onError:()=>{c("Failed to update project","error")}}),He=X=>{X.preventDefault(),ne({x:X.clientX,y:X.clientY})},B=[...af(t.filename)?[{label:"Print",icon:a.jsx(Ar,{className:"w-4 h-4"}),onClick:()=>x(!0)},{label:"Schedule",icon:a.jsx(si,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:"Open in Bambu Studio",icon:a.jsx($r,{className:"w-4 h-4"}),onClick:()=>{const X=t.print_name||t.filename||"model",U=`${window.location.origin}${he.getArchiveForSlicer(t.id,X)}`;$c(U)}}]:[{label:"Slice",icon:a.jsx($r,{className:"w-4 h-4"}),onClick:()=>{const X=t.print_name||t.filename||"model",U=`${window.location.origin}${he.getArchiveForSlicer(t.id,X)}`;$c(U)}}],{label:t.external_url?"External Link":"View on MakerWorld",icon:a.jsx(Dd,{className:"w-4 h-4"}),onClick:()=>{const X=t.external_url||t.makerworld_url;X&&window.open(X,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:a.jsx(Hs,{className:"w-4 h-4"}),onClick:()=>N(!0)},{label:"View Timelapse",icon:a.jsx(Rd,{className:"w-4 h-4"}),onClick:()=>T(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:a.jsx(Sw,{className:"w-4 h-4"}),onClick:()=>xe.mutate(),disabled:!t.printer_id||!!t.timelapse_path||xe.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:a.jsx(vw,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const X=document.createElement("a");X.href=he.getSource3mfDownloadUrl(t.id),X.download=`${t.print_name||t.filename}_source.3mf`,X.click()}else z.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:a.jsx(fi,{className:"w-4 h-4"}),onClick:()=>z.current?.click()},{label:"Remove Source 3MF",icon:a.jsx(on,{className:"w-4 h-4"}),onClick:()=>Y(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:a.jsx(Hs,{className:"w-4 h-4"}),onClick:()=>W.current?.click()},...t.f3d_path?[{label:"Download F3D",icon:a.jsx(Gr,{className:"w-4 h-4"}),onClick:()=>{const X=document.createElement("a");X.href=he.getF3dDownloadUrl(t.id),X.download=`${t.print_name||t.filename}.f3d`,X.click()}},{label:"Remove F3D",icon:a.jsx(on,{className:"w-4 h-4"}),onClick:()=>Z(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:a.jsx(Gr,{className:"w-4 h-4"}),onClick:()=>{const X=document.createElement("a");X.href=he.getArchiveDownload(t.id),X.download=`${t.print_name||t.filename}.3mf`,X.click()}},{label:"Copy Download Link",icon:a.jsx(ll,{className:"w-4 h-4"}),onClick:()=>{const X=`${window.location.origin}${he.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(X).then(()=>{c("Link copied to clipboard")}).catch(()=>{c("Failed to copy link","error")})}},{label:"QR Code",icon:a.jsx(fW,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:a.jsx(Df,{className:"w-4 h-4"}),onClick:()=>O(!0),disabled:!t.photos?.length},{label:"Project Page",icon:a.jsx(Ka,{className:"w-4 h-4"}),onClick:()=>j(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:a.jsx(Lf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>Ce.mutate()},{label:"Edit",icon:a.jsx(Oi,{className:"w-4 h-4"}),onClick:()=>d(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:a.jsx(Ma,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:a.jsx(Ma,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const X=[];if(t.project_id&&X.push({label:"Remove from Project",icon:a.jsx(Ot,{className:"w-4 h-4"}),onClick:()=>re.mutate(null)}),!s)X.push({label:"Loading...",icon:a.jsx(ut,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const U=s.filter(Q=>Q.status==="active");U.length===0?X.push({label:"No projects available",icon:a.jsx(Ma,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):U.forEach(Q=>{X.push({label:Q.name,icon:a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Q.color||"#888"}}),onClick:()=>re.mutate(Q.id),disabled:t.project_id===Q.id})})}return X})()},{label:n?"Deselect":"Select",icon:n?a.jsx(Do,{className:"w-4 h-4"}):a.jsx(Oo,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:a.jsx(on,{className:"w-4 h-4"}),onClick:()=>m(!0),danger:!0}];return a.jsxs(a.Fragment,{children:[a.jsxs("div",{"data-archive-id":t.id,className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${n?"bg-bambu-green/10":""}`,style:o?{outline:"4px solid #facc15",outlineOffset:"-4px"}:void 0,onContextMenu:He,children:[a.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[i&&a.jsx("button",{onClick:()=>r(t.id),children:n?a.jsx(Do,{className:"w-4 h-4 text-bambu-green"}):a.jsx(Oo,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?a.jsx("img",{src:he.getArchiveThumbnail(t.id),alt:"",className:"w-10 h-10 object-cover rounded"}):a.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:a.jsx(cu,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),a.jsxs("div",{className:"col-span-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"text-white text-sm truncate",children:t.print_name||t.filename}),t.timelapse_path&&a.jsx("span",{title:"Has timelapse",children:a.jsx(Rd,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})}),Ne&&Ne.length>0&&a.jsx(ps,{to:`/files?folder=${Ne[0].id}`,className:"flex-shrink-0",title:`Open folder: ${Ne[0].name}`,onClick:X=>X.stopPropagation(),children:a.jsx(cl,{className:"w-3.5 h-3.5 text-yellow-400"})})]}),(t.filament_type||t.sliced_for_model)&&a.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.sliced_for_model&&a.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",title:`Sliced for ${t.sliced_for_model}`,children:[a.jsx(Ar,{className:"w-2.5 h-2.5"}),t.sliced_for_model]}),t.sliced_for_model&&t.filament_type&&a.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.filament_type&&a.jsx("span",{className:"text-xs text-bambu-gray",children:t.filament_type}),t.filament_color&&a.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((X,U)=>a.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:X},title:X},U))})]})]}),a.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:e}),a.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:cg(t.created_at)}),a.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:M2(t.file_size)}),a.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[a.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{const X=t.print_name||t.filename||"model",U=`${window.location.origin}${he.getArchiveForSlicer(t.id,X)}`;$c(U)},title:"Open in Bambu Studio",children:a.jsx($r,{className:"w-4 h-4"})}),(t.external_url||t.makerworld_url)&&a.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>window.open(t.external_url||t.makerworld_url,"_blank"),title:t.external_url?"External Link":"MakerWorld",children:a.jsx(Dd,{className:"w-4 h-4"})}),a.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{const X=document.createElement("a");X.href=he.getArchiveDownload(t.id),X.download=`${t.print_name||t.filename}.3mf`,X.click()},title:"Download",children:a.jsx(Gr,{className:"w-4 h-4"})}),a.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>d(!0),title:"Edit",children:a.jsx(Oi,{className:"w-4 h-4"})}),a.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>m(!0),title:"Delete",children:a.jsx(on,{className:"w-4 h-4 text-red-400"})}),a.jsx(Te,{variant:"ghost",size:"sm",onClick:X=>{const U=X.currentTarget.getBoundingClientRect();ne({x:U.left,y:U.bottom+4})},title:"More options",children:a.jsx(Pd,{className:"w-4 h-4"})})]})]}),u&&a.jsx(lee,{archive:t,onClose:()=>d(!1)}),v&&a.jsx(iee,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>N(!1)}),g&&a.jsx(ah,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>x(!1)}),f&&a.jsx(Hn,{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:()=>{fe.mutate(),m(!1)},onCancel:()=>m(!1)}),G&&a.jsx(Hn,{title:"Remove Source 3MF",message:`Are you sure you want to remove the source 3MF file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{ae.mutate(),Y(!1)},onCancel:()=>Y(!1)}),K&&a.jsx(Hn,{title:"Remove F3D",message:`Are you sure you want to remove the Fusion 360 design file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{me.mutate(),Z(!1)},onCancel:()=>Z(!1)}),te&&a.jsx(cee,{x:te.x,y:te.y,items:B,onClose:()=>ne(null)}),S&&t.timelapse_path&&a.jsx(Kne,{src:he.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>T(!1),onEdit:()=>{l.invalidateQueries({queryKey:["archives"]}),T(!1)}}),E&&C.length>0&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),a.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),a.jsx("button",{onClick:()=>{k(!1),D([])},className:"text-gray-400 hover:text-white p-1",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:C.map(X=>a.jsxs("button",{onClick:()=>be.mutate(X.name),disabled:be.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors mb-1",children:[a.jsx("div",{className:"font-medium text-white",children:X.name}),a.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[a.jsx("span",{children:M2(X.size)}),X.mtime&&a.jsx("span",{children:cg(X.mtime)})]})]},X.name))})]})}),A&&a.jsx(uee,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),F&&t.photos&&a.jsx(dee,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>O(!1),onDelete:async X=>{try{await he.deleteArchivePhoto(t.id,X),l.invalidateQueries({queryKey:["archives"]}),c("Photo deleted")}catch{c("Failed to delete photo","error")}}}),q&&a.jsx(Wne,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>j(!1)}),y&&a.jsx(ah,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>b(!1)}),a.jsx("input",{ref:z,type:"file",accept:".3mf",className:"hidden",onChange:X=>{const U=X.target.files?.[0];U&&se.mutate(U),X.target.value=""}}),a.jsx("input",{ref:W,type:"file",accept:".f3d",className:"hidden",onChange:X=>{const U=X.target.files?.[0];U&&de.mutate(U),X.target.value=""}})]})}const tqe=[{id:"all",label:"All Archives",icon:a.jsx(cl,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:a.jsx(qn,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:a.jsx(si,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:a.jsx(si,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:a.jsx(Lf,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:a.jsx(Ei,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:a.jsx(ll,{className:"w-4 h-4"})}];function nqe(){const t=an(),{showToast:e}=Gn(),n=w.useRef(null),[r,i]=w.useState(""),[s,o]=w.useState(()=>{const ee=localStorage.getItem("archiveFilterPrinter");return ee?Number(ee):null}),[l,c]=w.useState(()=>localStorage.getItem("archiveFilterMaterial")),[u,d]=w.useState(()=>{const ee=localStorage.getItem("archiveFilterColors");return ee?new Set(JSON.parse(ee)):new Set}),[f,m]=w.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[g,x]=w.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[y,b]=w.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[v,N]=w.useState(()=>localStorage.getItem("archiveFilterTag")),[S,T]=w.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[E,k]=w.useState(!1),[C,D]=w.useState([]),[A,R]=w.useState(!1),[F,O]=w.useState(new Set),[q,j]=w.useState(!1),[G,Y]=w.useState(!1),[K,Z]=w.useState(!1),[te,ne]=w.useState(!1),[z,W]=w.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[se,ae]=w.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[de,me]=w.useState(()=>localStorage.getItem("archiveCollection")||"all"),[xe,be]=w.useState(!1),[fe,Ce]=w.useState(!1),[Ne,re]=w.useState(!1),[He,H]=w.useState(!1),[B,X]=w.useState(null);w.useEffect(()=>{if(B){const ee=setTimeout(()=>{const De=document.querySelector(`[data-archive-id="${B}"]`);De&&De.scrollIntoView({behavior:"smooth",block:"center"})},100),ke=setTimeout(()=>X(null),5e3);return()=>{clearTimeout(ee),clearTimeout(ke)}}},[B]);const{data:U,isLoading:Q}=ct({queryKey:["archives",s],queryFn:()=>he.getArchives(s||void 0)}),{data:le}=ct({queryKey:["printers"],queryFn:he.getPrinters}),{data:Pe}=ct({queryKey:["projects"],queryFn:()=>he.getProjects()}),{data:Oe}=ct({queryKey:["settings"],queryFn:he.getSettings}),je=Oe?.time_format||"system",$=ht({mutationFn:async ee=>(await Promise.all(ee.map(ke=>he.deleteArchive(ke))),ee.length),onSuccess:ee=>{t.invalidateQueries({queryKey:["archives"]}),O(new Set),e(`${ee} archive${ee!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}});w.useEffect(()=>{s!==null?localStorage.setItem("archiveFilterPrinter",s.toString()):localStorage.removeItem("archiveFilterPrinter")},[s]),w.useEffect(()=>{l?localStorage.setItem("archiveFilterMaterial",l):localStorage.removeItem("archiveFilterMaterial")},[l]),w.useEffect(()=>{localStorage.setItem("archiveFilterColors",JSON.stringify([...u]))},[u]),w.useEffect(()=>{localStorage.setItem("archiveColorFilterMode",f)},[f]),w.useEffect(()=>{localStorage.setItem("archiveFilterFavorites",g.toString())},[g]),w.useEffect(()=>{localStorage.setItem("archiveHideFailed",y.toString())},[y]),w.useEffect(()=>{v?localStorage.setItem("archiveFilterTag",v):localStorage.removeItem("archiveFilterTag")},[v]),w.useEffect(()=>{localStorage.setItem("archiveFilterFileType",S)},[S]),w.useEffect(()=>{localStorage.setItem("archiveViewMode",z)},[z]),w.useEffect(()=>{localStorage.setItem("archiveSortBy",se)},[se]),w.useEffect(()=>{localStorage.setItem("archiveCollection",de)},[de]);const I=new Map(le?.map(ee=>[ee.id,ee.name])||[]),V=[...new Set(U?.flatMap(ee=>ee.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),ie=[...new Set(U?.flatMap(ee=>ee.filament_color?.split(",")||[]).filter(Boolean)||[])],Se=[...new Set(U?.flatMap(ee=>ee.tags?.split(",").map(ke=>ke.trim())||[]).filter(Boolean)||[])].sort(),ye=U?.filter(ee=>{const ke=new Date,De=wi(ee.created_at)||new Date(0);let Ae=!0;switch(de){case"recent":Ae=ke.getTime()-De.getTime()<1440*60*1e3;break;case"this-week":Ae=ke.getTime()-De.getTime()<10080*60*1e3;break;case"this-month":Ae=De.getMonth()===ke.getMonth()&&De.getFullYear()===ke.getFullYear();break;case"favorites":Ae=ee.is_favorite===!0;break;case"failed":Ae=ee.status==="failed"||ee.status==="aborted";break;case"duplicates":Ae=ee.duplicate_count>0;break}const Je=(ee.print_name||ee.filename).toLowerCase().includes(r.toLowerCase()),gt=!l||ee.filament_type?.split(", ").includes(l),At=ee.filament_color?.split(",")||[],jt=u.size===0||(f==="or"?At.some(Un=>u.has(Un)):[...u].every(Un=>At.includes(Un))),ln=de==="favorites"||!g||ee.is_favorite,Lt=de==="failed"||!y||ee.status!=="failed"&&ee.status!=="aborted",Cn=ee.tags?.split(",").map(Un=>Un.trim())||[],en=!v||Cn.includes(v),er=af(ee.filename);return Ae&&Je&>&&jt&&ln&&Lt&&en&&(S==="all"||S==="gcode"&&er||S==="source"&&!er)}).sort((ee,ke)=>{switch(se){case"date-desc":return(wi(ke.created_at)?.getTime()||0)-(wi(ee.created_at)?.getTime()||0);case"date-asc":return(wi(ee.created_at)?.getTime()||0)-(wi(ke.created_at)?.getTime()||0);case"name-asc":return(ee.print_name||ee.filename).localeCompare(ke.print_name||ke.filename);case"name-desc":return(ke.print_name||ke.filename).localeCompare(ee.print_name||ee.filename);case"size-desc":return ke.file_size-ee.file_size;case"size-asc":return ee.file_size-ke.file_size;default:return 0}}),$e=q||F.size>0,Ue=ee=>{O(ke=>{const De=new Set(ke);return De.has(ee)?De.delete(ee):De.add(ee),De})},Ge=()=>{ye&&O(new Set(ye.map(ee=>ee.id)))},We=()=>{O(new Set),j(!1)},Ye=ee=>{d(ke=>{const De=new Set(ke);return De.has(ee)?De.delete(ee):De.add(ee),De})},oe=()=>{d(new Set)},ve=()=>{i(""),o(null),c(null),x(!1),b(!1),N(null),T("all")},Le=r||s||l||g||y||v||S!=="all",Ke=w.useCallback(ee=>{ee.preventDefault(),ee.dataTransfer.types.includes("Files")&&R(!0)},[]),lt=w.useCallback(ee=>{ee.preventDefault(),ee.currentTarget===ee.target&&R(!1)},[]),_e=w.useCallback(ee=>{ee.preventDefault(),R(!1);const ke=Array.from(ee.dataTransfer.files).filter(De=>De.name.endsWith(".3mf"));ke.length>0?(D(ke),k(!0)):ee.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),ce=w.useCallback(ee=>{const ke=ee.target;if(ke.tagName==="INPUT"||ke.tagName==="TEXTAREA"||ke.isContentEditable){ee.key==="Escape"&&ke.blur();return}switch(ee.key){case"/":ee.preventDefault(),n.current?.focus();break;case"u":case"U":!ee.metaKey&&!ee.ctrlKey&&(ee.preventDefault(),k(!0));break;case"Escape":$e&&We();break}},[$e]);return w.useEffect(()=>(document.addEventListener("keydown",ce),()=>document.removeEventListener("keydown",ce)),[ce]),a.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:Ke,onDragLeave:lt,onDrop:_e,children:[A&&a.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:a.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[a.jsx(fi,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),a.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),a.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),$e&&a.jsxs("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-40 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl px-4 py-3 flex items-center gap-4",children:[a.jsxs(Te,{variant:"secondary",size:"sm",onClick:We,children:[a.jsx(Ot,{className:"w-4 h-4"}),"Close"]}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsxs("span",{className:"text-white font-medium",children:[F.size," selected"]}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsx(Te,{variant:"secondary",size:"sm",onClick:Ge,children:"Select All"}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>Z(!0),children:[a.jsx(qd,{className:"w-4 h-4"}),"Tags"]}),a.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>ne(!0),children:[a.jsx(Ma,{className:"w-4 h-4"}),"Project"]}),a.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>{const ee=Array.from(F);Promise.all(ee.map(ke=>he.toggleFavorite(ke))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${ee.length} archive${ee.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[a.jsx(Lf,{className:"w-4 h-4"}),"Favorite"]}),a.jsxs(Te,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>Y(!0),children:[a.jsx(on,{className:"w-4 h-4"}),"Delete"]})]}),a.jsxs("div",{className:"flex items-center justify-between mb-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),a.jsx("select",{className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray-light text-sm focus:border-bambu-green focus:outline-none",value:de,onChange:ee=>me(ee.target.value),children:tqe.map(ee=>a.jsx("option",{value:ee.id,children:ee.label},ee.id))})]}),a.jsxs("p",{className:"text-bambu-gray",children:[ye?.length||0," of ",U?.length||0," prints"]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"relative",children:[a.jsxs(Te,{variant:"secondary",onClick:()=>be(!xe),disabled:fe,children:[fe?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(_w,{className:"w-4 h-4"}),"Export"]}),xe&&a.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[a.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:async()=>{be(!1),Ce(!0);try{const{blob:ee,filename:ke}=await he.exportArchives({format:"csv",printerId:s||void 0,status:de==="failed"?"failed":void 0,search:r||void 0}),De=URL.createObjectURL(ee),Ae=document.createElement("a");Ae.href=De,Ae.download=ke,Ae.click(),URL.revokeObjectURL(De),e("Export downloaded")}catch{e("Export failed","error")}finally{Ce(!1)}},children:[a.jsx(Ka,{className:"w-4 h-4"}),"Export as CSV"]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:async()=>{be(!1),Ce(!0);try{const{blob:ee,filename:ke}=await he.exportArchives({format:"xlsx",printerId:s||void 0,status:de==="failed"?"failed":void 0,search:r||void 0}),De=URL.createObjectURL(ee),Ae=document.createElement("a");Ae.href=De,Ae.download=ke,Ae.click(),URL.revokeObjectURL(De),e("Export downloaded")}catch{e("Export failed","error")}finally{Ce(!1)}},children:[a.jsx(_w,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),F.size>=2&&F.size<=5&&a.jsxs(Te,{variant:"secondary",onClick:()=>re(!0),children:[a.jsx(qp,{className:"w-4 h-4"}),"Compare (",F.size,")"]}),!$e&&a.jsxs(Te,{variant:"secondary",onClick:()=>j(!0),children:[a.jsx(Do,{className:"w-4 h-4"}),"Select"]}),a.jsxs(Te,{onClick:()=>k(!0),children:[a.jsx(fi,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),a.jsx(_t,{className:"mb-6",children:a.jsxs(St,{className:"py-4",children:[a.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap",children:[a.jsxs("div",{className:"w-full md:flex-1 relative md:min-w-[200px]",children:[a.jsx(na,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{ref:n,type:"text",placeholder:"Search archives...",className:"w-full pl-10 pr-4 py-3 md:py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r,onChange:ee=>i(ee.target.value)})]}),a.jsxs("div",{className:"flex gap-2 md:gap-4 overflow-x-auto pb-1 md:pb-0 -mx-4 px-4 md:mx-0 md:px-0 md:flex-wrap scrollbar-hide",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(U2,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:s||"",onChange:ee=>o(ee.target.value?Number(ee.target.value):null),children:[a.jsx("option",{value:"",children:"All Printers"}),le?.map(ee=>a.jsx("option",{value:ee.id,children:ee.name},ee.id))]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(zl,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:l||"",onChange:ee=>c(ee.target.value||null),children:[a.jsx("option",{value:"",children:"All Materials"}),V.map(ee=>a.jsx("option",{value:ee,children:ee},ee))]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(vw,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:S,onChange:ee=>T(ee.target.value),children:[a.jsx("option",{value:"all",children:"All Files"}),a.jsx("option",{value:"gcode",children:"Sliced (GCODE)"}),a.jsx("option",{value:"source",children:"Source Only"})]})]}),a.jsxs("button",{onClick:()=>x(!g),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${g?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:g?"Show all":"Show favorites only",children:[a.jsx(Lf,{className:`w-4 h-4 ${g?"fill-yellow-400":""}`}),a.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),a.jsxs("button",{onClick:()=>b(!y),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${y?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:y?"Show failed prints":"Hide failed prints",children:[a.jsx(Ei,{className:"w-4 h-4 "}),a.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),Se.length>0&&a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(qd,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:v||"",onChange:ee=>N(ee.target.value||null),children:[a.jsx("option",{value:"",children:"All Tags"}),Se.map(ee=>a.jsx("option",{value:ee,children:ee},ee))]}),a.jsx("button",{onClick:()=>H(!0),className:"p-2 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-green transition-colors",title:"Manage Tags",children:a.jsx(ly,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(rW,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:se,onChange:ee=>ae(ee.target.value),children:[a.jsx("option",{value:"date-desc",children:"Newest first"}),a.jsx("option",{value:"date-asc",children:"Oldest first"}),a.jsx("option",{value:"name-asc",children:"Name A-Z"}),a.jsx("option",{value:"name-desc",children:"Name Z-A"}),a.jsx("option",{value:"size-desc",children:"Largest first"}),a.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),a.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[a.jsx("button",{className:`p-2 ${z==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>W("grid"),title:"Grid view",children:a.jsx(H2,{className:"w-4 h-4"})}),a.jsx("button",{className:`p-2 ${z==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>W("list"),title:"List view",children:a.jsx(V2,{className:"w-4 h-4"})}),a.jsx("button",{className:`p-2 ${z==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>W("calendar"),title:"Calendar view",children:a.jsx(jce,{className:"w-4 h-4"})})]})]}),Le&&a.jsxs(Te,{variant:"ghost",size:"sm",onClick:ve,className:"text-bambu-gray hover:text-white",children:[a.jsx(Ot,{className:"w-4 h-4"}),"Reset"]})]}),ie.length>0&&a.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),u.size>1&&a.jsx("button",{onClick:()=>m(ee=>ee==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${f==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:f==="or"?"Match ANY selected color":"Match ALL selected colors",children:f.toUpperCase()}),a.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:ie.map(ee=>a.jsx("button",{onClick:()=>Ye(ee),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(ee)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:ee},title:ee},ee))}),u.size>0&&a.jsxs("button",{onClick:oe,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[a.jsx(Ot,{className:"w-3 h-3"}),"Clear"]})]})]})}),a.jsx(QGe,{}),Q?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):ye?.length===0?a.jsx(_t,{children:a.jsxs(St,{className:"text-center py-12",children:[a.jsx("p",{className:"text-bambu-gray",children:r?"No archives match your search":"No archives yet"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):z==="calendar"?a.jsx(_t,{className:"p-6",children:a.jsx(C8e,{archives:ye||[],onArchiveClick:ee=>{i(""),W("grid"),X(ee.id)},highlightedArchiveId:B})}):z==="grid"?a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:ye?.map(ee=>a.jsx(JGe,{archive:ee,printerName:ee.printer_id?I.get(ee.printer_id)||"Unknown":ee.sliced_for_model?`Sliced for ${ee.sliced_for_model}`:"No Printer",isSelected:F.has(ee.id),onSelect:Ue,selectionMode:$e,projects:Pe,isHighlighted:ee.id===B,timeFormat:je},ee.id))}):z==="list"?a.jsx(_t,{children:a.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[a.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[a.jsx("div",{className:"col-span-1"}),a.jsx("div",{className:"col-span-4",children:"Name"}),a.jsx("div",{className:"col-span-2",children:"Printer"}),a.jsx("div",{className:"col-span-2",children:"Date"}),a.jsx("div",{className:"col-span-1",children:"Size"}),a.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),ye?.map(ee=>a.jsx(eqe,{archive:ee,printerName:ee.printer_id?I.get(ee.printer_id)||"Unknown":ee.sliced_for_model?`Sliced for ${ee.sliced_for_model}`:"No Printer",isSelected:F.has(ee.id),onSelect:Ue,selectionMode:$e,projects:Pe,isHighlighted:ee.id===B},ee.id))]})}):null,E&&a.jsx(y8e,{onClose:()=>{k(!1),D([])},initialFiles:C}),G&&a.jsx(Hn,{title:"Delete Archives",message:`Are you sure you want to delete ${F.size} archive${F.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${F.size}`,variant:"danger",onConfirm:()=>{$.mutate(Array.from(F)),Y(!1)},onCancel:()=>Y(!1)}),K&&a.jsx(w8e,{selectedIds:Array.from(F),existingTags:Se,onClose:()=>Z(!1)}),te&&a.jsx(S8e,{selectedIds:Array.from(F),onClose:()=>ne(!1)}),Ne&&F.size>=2&&F.size<=5&&a.jsx(qGe,{archiveIds:Array.from(F),onClose:()=>{re(!1),O(new Set),j(!1)}}),He&&a.jsx(ZGe,{onClose:()=>H(!1)})]})}function rqe(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return w.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const fM=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function sx(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function IL(t){return"nodeType"in t}function As(t){var e,n;return t?sx(t)?t:IL(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function FL(t){const{Document:e}=As(t);return t instanceof e}function Gy(t){return sx(t)?!1:t instanceof As(t).HTMLElement}function Xne(t){return t instanceof As(t).SVGElement}function ox(t){return t?sx(t)?t.document:IL(t)?FL(t)?t:Gy(t)||Xne(t)?t.ownerDocument:document:document:document}const Xl=fM?w.useLayoutEffect:w.useEffect;function UL(t){const e=w.useRef(t);return Xl(()=>{e.current=t}),w.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function iqe(){const t=w.useRef(null),e=w.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=w.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function ny(t,e){e===void 0&&(e=[t]);const n=w.useRef(t);return Xl(()=>{n.current!==t&&(n.current=t)},e),n}function qy(t,e){const n=w.useRef();return w.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function E2(t){const e=UL(t),n=w.useRef(null),r=w.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function zR(t){const e=w.useRef();return w.useEffect(()=>{e.current=t},[t]),e.current}let xj={};function Wy(t,e){return w.useMemo(()=>{if(e)return e;const n=xj[t]==null?0:xj[t]+1;return xj[t]=n,t+"-"+n},[t,e])}function Yne(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((s,o)=>{const l=Object.entries(o);for(const[c,u]of l){const d=s[c];d!=null&&(s[c]=d+t*u)}return s},{...e})}}const sg=Yne(1),ry=Yne(-1);function aqe(t){return"clientX"in t&&"clientY"in t}function zL(t){if(!t)return!1;const{KeyboardEvent:e}=As(t.target);return e&&t instanceof e}function sqe(t){if(!t)return!1;const{TouchEvent:e}=As(t.target);return e&&t instanceof e}function BR(t){if(sqe(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 aqe(t)?{x:t.clientX,y:t.clientY}:null}const Lg=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[Lg.Translate.toString(t),Lg.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),zG="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function oqe(t){return t.matches(zG)?t:t.querySelector(zG)}const lqe={display:"none"};function cqe(t){let{id:e,value:n}=t;return zr.createElement("div",{id:e,style:lqe},n)}function uqe(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 zr.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function dqe(){const[t,e]=w.useState("");return{announce:w.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const Qne=w.createContext(null);function hqe(t){const e=w.useContext(Qne);w.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function fqe(){const[t]=w.useState(()=>new Set),e=w.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[w.useCallback(r=>{let{type:i,event:s}=r;t.forEach(o=>{var l;return(l=o[i])==null?void 0:l.call(o,s)})},[t]),e]}const mqe={draggable:`
- To pick up a draggable item, press the space bar.
- While dragging, use the arrow keys to move the item.
- Press space again to drop the item in its new position, or press escape to cancel.
- `},pqe={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 gqe(t){let{announcements:e=pqe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=mqe}=t;const{announce:s,announcement:o}=dqe(),l=Wy("DndLiveRegion"),[c,u]=w.useState(!1);if(w.useEffect(()=>{u(!0)},[]),hqe(w.useMemo(()=>({onDragStart(f){let{active:m}=f;s(e.onDragStart({active:m}))},onDragMove(f){let{active:m,over:g}=f;e.onDragMove&&s(e.onDragMove({active:m,over:g}))},onDragOver(f){let{active:m,over:g}=f;s(e.onDragOver({active:m,over:g}))},onDragEnd(f){let{active:m,over:g}=f;s(e.onDragEnd({active:m,over:g}))},onDragCancel(f){let{active:m,over:g}=f;s(e.onDragCancel({active:m,over:g}))}}),[s,e])),!c)return null;const d=zr.createElement(zr.Fragment,null,zr.createElement(cqe,{id:r,value:i.draggable}),zr.createElement(uqe,{id:l,announcement:o}));return n?Vc.createPortal(d,n):d}var Di;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(Di||(Di={}));function T2(){}function C2(t,e){return w.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function Zne(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return w.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const hl=Object.freeze({x:0,y:0});function Jne(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function ere(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function xqe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function BG(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 tre(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function $G(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 nre=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=$G(e,e.left,e.top),s=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=Jne($G(c),i);s.push({id:l,data:{droppableContainer:o,value:u}})}}return s.sort(ere)},bqe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=BG(e),s=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=BG(c),d=i.reduce((m,g,x)=>m+Jne(u[x],g),0),f=Number((d/4).toFixed(4));s.push({id:l,data:{droppableContainer:o,value:f}})}}return s.sort(ere)};function yqe(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),s=Math.min(e.top+e.height,t.top+t.height),o=i-r,l=s-n;if(r<i&&n<s){const c=e.width*e.height,u=t.width*t.height,d=o*l,f=d/(c+u-d);return Number(f.toFixed(4))}return 0}const vqe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const s of r){const{id:o}=s,l=n.get(o);if(l){const c=yqe(l,e);c>0&&i.push({id:o,data:{droppableContainer:s,value:c}})}}return i.sort(xqe)};function _qe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function rre(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:hl}function wqe(t){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),s=1;s<r;s++)i[s-1]=arguments[s];return i.reduce((o,l)=>({...o,top:o.top+t*l.y,bottom:o.bottom+t*l.y,left:o.left+t*l.x,right:o.right+t*l.x}),{...n})}}const Sqe=wqe(1);function Nqe(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 Mqe(t,e,n){const r=Nqe(e);if(!r)return t;const{scaleX:i,scaleY:s,x:o,y:l}=r,c=t.left-o-(1-i)*parseFloat(n),u=t.top-l-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,f=s?t.height/s:t.height;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c}}const Eqe={ignoreTransform:!1};function lx(t,e){e===void 0&&(e=Eqe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=As(t).getComputedStyle(t);u&&(n=Mqe(n,u,d))}const{top:r,left:i,width:s,height:o,bottom:l,right:c}=n;return{top:r,left:i,width:s,height:o,bottom:l,right:c}}function HG(t){return lx(t,{ignoreTransform:!0})}function Tqe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function Cqe(t,e){return e===void 0&&(e=As(t).getComputedStyle(t)),e.position==="fixed"}function Aqe(t,e){e===void 0&&(e=As(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const s=e[i];return typeof s=="string"?n.test(s):!1})}function mM(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(FL(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Gy(i)||Xne(i)||n.includes(i))return n;const s=As(t).getComputedStyle(i);return i!==t&&Aqe(i,s)&&n.push(i),Cqe(i,s)?n:r(i.parentNode)}return t?r(t):n}function ire(t){const[e]=mM(t,1);return e??null}function bj(t){return!fM||!t?null:sx(t)?t:IL(t)?FL(t)||t===ox(t).scrollingElement?window:Gy(t)?t:null:null}function are(t){return sx(t)?t.scrollX:t.scrollLeft}function sre(t){return sx(t)?t.scrollY:t.scrollTop}function $R(t){return{x:are(t),y:sre(t)}}var ea;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(ea||(ea={}));function ore(t){return!fM||!t?!1:t===document.scrollingElement}function lre(t){const e={x:0,y:0},n=ore(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},i=t.scrollTop<=e.y,s=t.scrollLeft<=e.x,o=t.scrollTop>=r.y,l=t.scrollLeft>=r.x;return{isTop:i,isLeft:s,isBottom:o,isRight:l,maxScroll:r,minScroll:e}}const kqe={x:.2,y:.2};function jqe(t,e,n,r,i){let{top:s,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=kqe);const{isTop:u,isBottom:d,isLeft:f,isRight:m}=lre(t),g={x:0,y:0},x={x:0,y:0},y={height:e.height*i.y,width:e.width*i.x};return!u&&s<=e.top+y.height?(g.y=ea.Backward,x.y=r*Math.abs((e.top+y.height-s)/y.height)):!d&&c>=e.bottom-y.height&&(g.y=ea.Forward,x.y=r*Math.abs((e.bottom-y.height-c)/y.height)),!m&&l>=e.right-y.width?(g.x=ea.Forward,x.x=r*Math.abs((e.right-y.width-l)/y.width)):!f&&o<=e.left+y.width&&(g.x=ea.Backward,x.x=r*Math.abs((e.left+y.width-o)/y.width)),{direction:g,speed:x}}function Pqe(t){if(t===document.scrollingElement){const{innerWidth:s,innerHeight:o}=window;return{top:0,left:0,right:s,bottom:o,width:s,height:o}}const{top:e,left:n,right:r,bottom:i}=t.getBoundingClientRect();return{top:e,left:n,right:r,bottom:i,width:t.clientWidth,height:t.clientHeight}}function cre(t){return t.reduce((e,n)=>sg(e,$R(n)),hl)}function Rqe(t){return t.reduce((e,n)=>e+are(n),0)}function Dqe(t){return t.reduce((e,n)=>e+sre(n),0)}function Oqe(t,e){if(e===void 0&&(e=lx),!t)return;const{top:n,left:r,bottom:i,right:s}=e(t);ire(t)&&(i<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const Lqe=[["x",["left","right"],Rqe],["y",["top","bottom"],Dqe]];class BL{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=mM(n),i=cre(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[s,o,l]of Lqe)for(const c of o)Object.defineProperty(this,c,{get:()=>{const u=l(r),d=i[s]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class o0{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 Iqe(t){const{EventTarget:e}=As(t);return t instanceof e?t:ox(t)}function yj(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 wo;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(wo||(wo={}));function VG(t){t.preventDefault()}function Fqe(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 ure={start:[$n.Space,$n.Enter],cancel:[$n.Esc],end:[$n.Space,$n.Enter,$n.Tab]},Uqe=(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 pM{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 o0(ox(n)),this.windowListeners=new o0(As(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(wo.Resize,this.handleCancel),this.windowListeners.add(wo.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(wo.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&Oqe(r),n(hl)}handleKeyDown(e){if(zL(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:s=ure,coordinateGetter:o=Uqe,scrollBehavior:l="smooth"}=i,{code:c}=e;if(s.end.includes(c)){this.handleEnd(e);return}if(s.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:hl;this.referenceCoordinates||(this.referenceCoordinates=d);const f=o(e,{active:n,context:r.current,currentCoordinates:d});if(f){const m=ry(f,d),g={x:0,y:0},{scrollableAncestors:x}=r.current;for(const y of x){const b=e.code,{isTop:v,isRight:N,isLeft:S,isBottom:T,maxScroll:E,minScroll:k}=lre(y),C=Pqe(y),D={x:Math.min(b===$n.Right?C.right-C.width/2:C.right,Math.max(b===$n.Right?C.left:C.left+C.width/2,f.x)),y:Math.min(b===$n.Down?C.bottom-C.height/2:C.bottom,Math.max(b===$n.Down?C.top:C.top+C.height/2,f.y))},A=b===$n.Right&&!N||b===$n.Left&&!S,R=b===$n.Down&&!T||b===$n.Up&&!v;if(A&&D.x!==f.x){const F=y.scrollLeft+m.x,O=b===$n.Right&&F<=E.x||b===$n.Left&&F>=k.x;if(O&&!m.y){y.scrollTo({left:F,behavior:l});return}O?g.x=y.scrollLeft-F:g.x=b===$n.Right?y.scrollLeft-E.x:y.scrollLeft-k.x,g.x&&y.scrollBy({left:-g.x,behavior:l});break}else if(R&&D.y!==f.y){const F=y.scrollTop+m.y,O=b===$n.Down&&F<=E.y||b===$n.Up&&F>=k.y;if(O&&!m.x){y.scrollTo({top:F,behavior:l});return}O?g.y=y.scrollTop-F:g.y=b===$n.Down?y.scrollTop-E.y:y.scrollTop-k.y,g.y&&y.scrollBy({top:-g.y,behavior:l});break}}this.handleMove(e,sg(ry(f,this.referenceCoordinates),g))}}}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()}}pM.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=ure,onActivation:i}=e,{active:s}=n;const{code:o}=t.nativeEvent;if(r.start.includes(o)){const l=s.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function GG(t){return!!(t&&"distance"in t)}function qG(t){return!!(t&&"delay"in t)}class $L{constructor(e,n,r){var i;r===void 0&&(r=Iqe(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:s}=e,{target:o}=s;this.props=e,this.events=n,this.document=ox(o),this.documentListeners=new o0(this.document),this.listeners=new o0(r),this.windowListeners=new o0(As(o)),this.initialCoordinates=(i=BR(s))!=null?i:hl,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(wo.Resize,this.handleCancel),this.windowListeners.add(wo.DragStart,VG),this.windowListeners.add(wo.VisibilityChange,this.handleCancel),this.windowListeners.add(wo.ContextMenu,VG),this.documentListeners.add(wo.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(qG(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(GG(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(wo.Click,Fqe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(wo.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:s}=this,{onMove:o,options:{activationConstraint:l}}=s;if(!i)return;const c=(n=BR(e))!=null?n:hl,u=ry(i,c);if(!r&&l){if(GG(l)){if(l.tolerance!=null&&yj(u,l.tolerance))return this.handleCancel();if(yj(u,l.distance))return this.handleStart()}if(qG(l)&&yj(u,l.tolerance))return this.handleCancel();this.handlePending(l,u);return}e.cancelable&&e.preventDefault(),o(c)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===$n.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const zqe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class gM extends $L{constructor(e){const{event:n}=e,r=ox(n.target);super(e,zqe,r)}}gM.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 Bqe={move:{name:"mousemove"},end:{name:"mouseup"}};var HR;(function(t){t[t.RightClick=2]="RightClick"})(HR||(HR={}));class $qe extends $L{constructor(e){super(e,Bqe,ox(e.event.target))}}$qe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===HR.RightClick?!1:(r?.({event:n}),!0)}}];const vj={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Hqe extends $L{constructor(e){super(e,vj)}static setup(){return window.addEventListener(vj.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(vj.move.name,e)};function e(){}}}Hqe.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 l0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(l0||(l0={}));var A2;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(A2||(A2={}));function Vqe(t){let{acceleration:e,activator:n=l0.Pointer,canScroll:r,draggingRect:i,enabled:s,interval:o=5,order:l=A2.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:m}=t;const g=qqe({delta:f,disabled:!s}),[x,y]=iqe(),b=w.useRef({x:0,y:0}),v=w.useRef({x:0,y:0}),N=w.useMemo(()=>{switch(n){case l0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case l0.DraggableRect:return i}},[n,i,c]),S=w.useRef(null),T=w.useCallback(()=>{const k=S.current;if(!k)return;const C=b.current.x*v.current.x,D=b.current.y*v.current.y;k.scrollBy(C,D)},[]),E=w.useMemo(()=>l===A2.TreeOrder?[...u].reverse():u,[l,u]);w.useEffect(()=>{if(!s||!u.length||!N){y();return}for(const k of E){if(r?.(k)===!1)continue;const C=u.indexOf(k),D=d[C];if(!D)continue;const{direction:A,speed:R}=jqe(k,D,N,e,m);for(const F of["x","y"])g[F][A[F]]||(R[F]=0,A[F]=0);if(R.x>0||R.y>0){y(),S.current=k,x(T,o),b.current=R,v.current=A;return}}b.current={x:0,y:0},v.current={x:0,y:0},y()},[e,T,r,y,s,o,JSON.stringify(N),JSON.stringify(g),x,u,E,d,JSON.stringify(m)])}const Gqe={x:{[ea.Backward]:!1,[ea.Forward]:!1},y:{[ea.Backward]:!1,[ea.Forward]:!1}};function qqe(t){let{delta:e,disabled:n}=t;const r=zR(e);return qy(i=>{if(n||!r||!i)return Gqe;const s={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[ea.Backward]:i.x[ea.Backward]||s.x===-1,[ea.Forward]:i.x[ea.Forward]||s.x===1},y:{[ea.Backward]:i.y[ea.Backward]||s.y===-1,[ea.Forward]:i.y[ea.Forward]||s.y===1}}},[n,e,r])}function Wqe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return qy(i=>{var s;return e==null?null:(s=r??i)!=null?s:null},[r,e])}function Kqe(t,e){return w.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,s=i.activators.map(o=>({eventName:o.eventName,handler:e(o.handler,r)}));return[...n,...s]},[]),[t,e])}var iy;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(iy||(iy={}));var VR;(function(t){t.Optimized="optimized"})(VR||(VR={}));const WG=new Map;function Xqe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[s,o]=w.useState(null),{frequency:l,measure:c,strategy:u}=i,d=w.useRef(t),f=b(),m=ny(f),g=w.useCallback(function(v){v===void 0&&(v=[]),!m.current&&o(N=>N===null?v:N.concat(v.filter(S=>!N.includes(S))))},[m]),x=w.useRef(null),y=qy(v=>{if(f&&!n)return WG;if(!v||v===WG||d.current!==t||s!=null){const N=new Map;for(let S of t){if(!S)continue;if(s&&s.length>0&&!s.includes(S.id)&&S.rect.current){N.set(S.id,S.rect.current);continue}const T=S.node.current,E=T?new BL(c(T),T):null;S.rect.current=E,E&&N.set(S.id,E)}return N}return v},[t,s,n,f,c]);return w.useEffect(()=>{d.current=t},[t]),w.useEffect(()=>{f||g()},[n,f]),w.useEffect(()=>{s&&s.length>0&&o(null)},[JSON.stringify(s)]),w.useEffect(()=>{f||typeof l!="number"||x.current!==null||(x.current=setTimeout(()=>{g(),x.current=null},l))},[l,f,g,...r]),{droppableRects:y,measureDroppableContainers:g,measuringScheduled:s!=null};function b(){switch(u){case iy.Always:return!1;case iy.BeforeDragging:return n;default:return!n}}}function dre(t,e){return qy(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function Yqe(t,e){return dre(t,e)}function Qqe(t){let{callback:e,disabled:n}=t;const r=UL(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function xM(t){let{callback:e,disabled:n}=t;const r=UL(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function Zqe(t){return new BL(lx(t),t)}function KG(t,e,n){e===void 0&&(e=Zqe);const[r,i]=w.useState(null);function s(){i(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??n)!=null?u:null}const d=e(t);return JSON.stringify(c)===JSON.stringify(d)?c:d})}const o=Qqe({callback(c){if(t)for(const u of c){const{type:d,target:f}=u;if(d==="childList"&&f instanceof HTMLElement&&f.contains(t)){s();break}}}}),l=xM({callback:s});return Xl(()=>{s(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function Jqe(t){const e=dre(t);return rre(t,e)}const XG=[];function eWe(t){const e=w.useRef(t),n=qy(r=>t?r&&r!==XG&&t&&e.current&&t.parentNode===e.current.parentNode?r:mM(t):XG,[t]);return w.useEffect(()=>{e.current=t},[t]),n}function tWe(t){const[e,n]=w.useState(null),r=w.useRef(t),i=w.useCallback(s=>{const o=bj(s.target);o&&n(l=>l?(l.set(o,$R(o)),new Map(l)):null)},[]);return w.useEffect(()=>{const s=r.current;if(t!==s){o(s);const l=t.map(c=>{const u=bj(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,$R(u)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),r.current=t}return()=>{o(t),o(s)};function o(l){l.forEach(c=>{const u=bj(c);u?.removeEventListener("scroll",i)})}},[i,t]),w.useMemo(()=>t.length?e?Array.from(e.values()).reduce((s,o)=>sg(s,o),hl):cre(t):hl,[t,e])}function YG(t,e){e===void 0&&(e=[]);const n=w.useRef(null);return w.useEffect(()=>{n.current=null},e),w.useEffect(()=>{const r=t!==hl;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?ry(t,n.current):hl}function nWe(t){w.useEffect(()=>{if(!fM)return;const e=t.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of e)n?.()}},t.map(e=>{let{sensor:n}=e;return n}))}function rWe(t,e){return w.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:s}=r;return n[i]=o=>{s(o,e)},n},{}),[t,e])}function hre(t){return w.useMemo(()=>t?Tqe(t):null,[t])}const QG=[];function iWe(t,e){e===void 0&&(e=lx);const[n]=t,r=hre(n?As(n):null),[i,s]=w.useState(QG);function o(){s(()=>t.length?t.map(c=>ore(c)?r:new BL(e(c),c)):QG)}const l=xM({callback:o});return Xl(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function aWe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return Gy(e)?e:t}function sWe(t){let{measure:e}=t;const[n,r]=w.useState(null),i=w.useCallback(u=>{for(const{target:d}of u)if(Gy(d)){r(f=>{const m=e(d);return f?{...f,width:m.width,height:m.height}:m});break}},[e]),s=xM({callback:i}),o=w.useCallback(u=>{const d=aWe(u);s?.disconnect(),d&&s?.observe(d),r(d?e(d):null)},[e,s]),[l,c]=E2(o);return w.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const oWe=[{sensor:gM,options:{}},{sensor:pM,options:{}}],lWe={current:{}},hw={draggable:{measure:HG},droppable:{measure:HG,strategy:iy.WhileDragging,frequency:VR.Optimized},dragOverlay:{measure:lx}};class c0 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 cWe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new c0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:T2},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:hw,measureDroppableContainers:T2,windowRect:null,measuringScheduled:!1},uWe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:T2,draggableNodes:new Map,over:null,measureDroppableContainers:T2},bM=w.createContext(uWe),fre=w.createContext(cWe);function dWe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new c0}}}function hWe(t,e){switch(e.type){case Di.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Di.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case Di.DragEnd:case Di.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Di.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new c0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case Di.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,s=t.droppable.containers.get(n);if(!s||r!==s.key)return t;const o=new c0(t.droppable.containers);return o.set(n,{...s,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case Di.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const s=new c0(t.droppable.containers);return s.delete(n),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function fWe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=w.useContext(bM),s=zR(r),o=zR(n?.id);return w.useEffect(()=>{if(!e&&!r&&s&&o!=null){if(!zL(s)||document.activeElement===s.target)return;const l=i.get(o);if(!l)return;const{activatorNode:c,node:u}=l;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[c.current,u.current]){if(!d)continue;const f=oqe(d);if(f){f.focus();break}}})}},[r,e,i,o,s]),null}function mWe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,s)=>s({transform:i,...r}),n):n}function pWe(t){return w.useMemo(()=>({draggable:{...hw.draggable,...t?.draggable},droppable:{...hw.droppable,...t?.droppable},dragOverlay:{...hw.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function gWe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const s=w.useRef(!1),{x:o,y:l}=typeof i=="boolean"?{x:i,y:i}:i;Xl(()=>{if(!o&&!l||!e){s.current=!1;return}if(s.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),f=rre(d,r);if(o||(f.x=0),l||(f.y=0),s.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const m=ire(u);m&&m.scrollBy({top:f.y,left:f.x})}},[e,o,l,r,n])}const mre=w.createContext({...hl,scaleX:1,scaleY:1});var bd;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(bd||(bd={}));const pre=w.memo(function(e){var n,r,i,s;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=oWe,collisionDetection:f=vqe,measuring:m,modifiers:g,...x}=e;const y=w.useReducer(hWe,void 0,dWe),[b,v]=y,[N,S]=fqe(),[T,E]=w.useState(bd.Uninitialized),k=T===bd.Initialized,{draggable:{active:C,nodes:D,translate:A},droppable:{containers:R}}=b,F=C!=null?D.get(C):null,O=w.useRef({initial:null,translated:null}),q=w.useMemo(()=>{var ke;return C!=null?{id:C,data:(ke=F?.data)!=null?ke:lWe,rect:O}:null},[C,F]),j=w.useRef(null),[G,Y]=w.useState(null),[K,Z]=w.useState(null),te=ny(x,Object.values(x)),ne=Wy("DndDescribedBy",o),z=w.useMemo(()=>R.getEnabled(),[R]),W=pWe(m),{droppableRects:se,measureDroppableContainers:ae,measuringScheduled:de}=Xqe(z,{dragging:k,dependencies:[A.x,A.y],config:W.droppable}),me=Wqe(D,C),xe=w.useMemo(()=>K?BR(K):null,[K]),be=ee(),fe=Yqe(me,W.draggable.measure);gWe({activeNode:C!=null?D.get(C):null,config:be.layoutShiftCompensation,initialRect:fe,measure:W.draggable.measure});const Ce=KG(me,W.draggable.measure,fe),Ne=KG(me?me.parentElement:null),re=w.useRef({activatorEvent:null,active:null,activeNode:me,collisionRect:null,collisions:null,droppableRects:se,draggableNodes:D,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),He=R.getNodeFor((n=re.current.over)==null?void 0:n.id),H=sWe({measure:W.dragOverlay.measure}),B=(r=H.nodeRef.current)!=null?r:me,X=k?(i=H.rect)!=null?i:Ce:null,U=!!(H.nodeRef.current&&H.rect),Q=Jqe(U?null:Ce),le=hre(B?As(B):null),Pe=eWe(k?He??me:null),Oe=iWe(Pe),je=mWe(g,{transform:{x:A.x-Q.x,y:A.y-Q.y,scaleX:1,scaleY:1},activatorEvent:K,active:q,activeNodeRect:Ce,containerNodeRect:Ne,draggingNodeRect:X,over:re.current.over,overlayNodeRect:H.rect,scrollableAncestors:Pe,scrollableAncestorRects:Oe,windowRect:le}),$=xe?sg(xe,A):null,I=tWe(Pe),V=YG(I),ie=YG(I,[Ce]),Se=sg(je,V),ye=X?Sqe(X,je):null,$e=q&&ye?f({active:q,collisionRect:ye,droppableRects:se,droppableContainers:z,pointerCoordinates:$}):null,Ue=tre($e,"id"),[Ge,We]=w.useState(null),Ye=U?je:sg(je,ie),oe=_qe(Ye,(s=Ge?.rect)!=null?s:null,Ce),ve=w.useRef(null),Le=w.useCallback((ke,De)=>{let{sensor:Ae,options:Je}=De;if(j.current==null)return;const gt=D.get(j.current);if(!gt)return;const At=ke.nativeEvent,jt=new Ae({active:j.current,activeNode:gt,event:At,options:Je,context:re,onAbort(Lt){if(!D.get(Lt))return;const{onDragAbort:en}=te.current,er={id:Lt};en?.(er),N({type:"onDragAbort",event:er})},onPending(Lt,Cn,en,er){if(!D.get(Lt))return;const{onDragPending:Un}=te.current,wr={id:Lt,constraint:Cn,initialCoordinates:en,offset:er};Un?.(wr),N({type:"onDragPending",event:wr})},onStart(Lt){const Cn=j.current;if(Cn==null)return;const en=D.get(Cn);if(!en)return;const{onDragStart:er}=te.current,ur={activatorEvent:At,active:{id:Cn,data:en.data,rect:O}};Vc.unstable_batchedUpdates(()=>{er?.(ur),E(bd.Initializing),v({type:Di.DragStart,initialCoordinates:Lt,active:Cn}),N({type:"onDragStart",event:ur}),Y(ve.current),Z(At)})},onMove(Lt){v({type:Di.DragMove,coordinates:Lt})},onEnd:ln(Di.DragEnd),onCancel:ln(Di.DragCancel)});ve.current=jt;function ln(Lt){return async function(){const{active:en,collisions:er,over:ur,scrollAdjustedTranslate:Un}=re.current;let wr=null;if(en&&Un){const{cancelDrop:jr}=te.current;wr={activatorEvent:At,active:en,collisions:er,delta:Un,over:ur},Lt===Di.DragEnd&&typeof jr=="function"&&await Promise.resolve(jr(wr))&&(Lt=Di.DragCancel)}j.current=null,Vc.unstable_batchedUpdates(()=>{v({type:Lt}),E(bd.Uninitialized),We(null),Y(null),Z(null),ve.current=null;const jr=Lt===Di.DragEnd?"onDragEnd":"onDragCancel";if(wr){const Zn=te.current[jr];Zn?.(wr),N({type:jr,event:wr})}})}}},[D]),Ke=w.useCallback((ke,De)=>(Ae,Je)=>{const gt=Ae.nativeEvent,At=D.get(Je);if(j.current!==null||!At||gt.dndKit||gt.defaultPrevented)return;const jt={active:At};ke(Ae,De.options,jt)===!0&&(gt.dndKit={capturedBy:De.sensor},j.current=Je,Le(Ae,De))},[D,Le]),lt=Kqe(d,Ke);nWe(d),Xl(()=>{Ce&&T===bd.Initializing&&E(bd.Initialized)},[Ce,T]),w.useEffect(()=>{const{onDragMove:ke}=te.current,{active:De,activatorEvent:Ae,collisions:Je,over:gt}=re.current;if(!De||!Ae)return;const At={active:De,activatorEvent:Ae,collisions:Je,delta:{x:Se.x,y:Se.y},over:gt};Vc.unstable_batchedUpdates(()=>{ke?.(At),N({type:"onDragMove",event:At})})},[Se.x,Se.y]),w.useEffect(()=>{const{active:ke,activatorEvent:De,collisions:Ae,droppableContainers:Je,scrollAdjustedTranslate:gt}=re.current;if(!ke||j.current==null||!De||!gt)return;const{onDragOver:At}=te.current,jt=Je.get(Ue),ln=jt&&jt.rect.current?{id:jt.id,rect:jt.rect.current,data:jt.data,disabled:jt.disabled}:null,Lt={active:ke,activatorEvent:De,collisions:Ae,delta:{x:gt.x,y:gt.y},over:ln};Vc.unstable_batchedUpdates(()=>{We(ln),At?.(Lt),N({type:"onDragOver",event:Lt})})},[Ue]),Xl(()=>{re.current={activatorEvent:K,active:q,activeNode:me,collisionRect:ye,collisions:$e,droppableRects:se,draggableNodes:D,draggingNode:B,draggingNodeRect:X,droppableContainers:R,over:Ge,scrollableAncestors:Pe,scrollAdjustedTranslate:Se},O.current={initial:X,translated:ye}},[q,me,$e,ye,D,B,X,se,R,Ge,Pe,Se]),Vqe({...be,delta:A,draggingRect:ye,pointerCoordinates:$,scrollableAncestors:Pe,scrollableAncestorRects:Oe});const _e=w.useMemo(()=>({active:q,activeNode:me,activeNodeRect:Ce,activatorEvent:K,collisions:$e,containerNodeRect:Ne,dragOverlay:H,draggableNodes:D,droppableContainers:R,droppableRects:se,over:Ge,measureDroppableContainers:ae,scrollableAncestors:Pe,scrollableAncestorRects:Oe,measuringConfiguration:W,measuringScheduled:de,windowRect:le}),[q,me,Ce,K,$e,Ne,H,D,R,se,Ge,ae,Pe,Oe,W,de,le]),ce=w.useMemo(()=>({activatorEvent:K,activators:lt,active:q,activeNodeRect:Ce,ariaDescribedById:{draggable:ne},dispatch:v,draggableNodes:D,over:Ge,measureDroppableContainers:ae}),[K,lt,q,Ce,v,ne,D,Ge,ae]);return zr.createElement(Qne.Provider,{value:S},zr.createElement(bM.Provider,{value:ce},zr.createElement(fre.Provider,{value:_e},zr.createElement(mre.Provider,{value:oe},u)),zr.createElement(fWe,{disabled:l?.restoreFocus===!1})),zr.createElement(gqe,{...l,hiddenTextDescribedById:ne}));function ee(){const ke=G?.autoScrollEnabled===!1,De=typeof c=="object"?c.enabled===!1:c===!1,Ae=k&&!ke&&!De;return typeof c=="object"?{...c,enabled:Ae}:{enabled:Ae}}}),xWe=w.createContext(null),ZG="button",bWe="Draggable";function yWe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const s=Wy(bWe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:m}=w.useContext(bM),{role:g=ZG,roleDescription:x="draggable",tabIndex:y=0}=i??{},b=c?.id===e,v=w.useContext(b?mre:xWe),[N,S]=E2(),[T,E]=E2(),k=rWe(o,e),C=ny(n);Xl(()=>(f.set(e,{id:e,key:s,node:N,activatorNode:T,data:C}),()=>{const A=f.get(e);A&&A.key===s&&f.delete(e)}),[f,e]);const D=w.useMemo(()=>({role:g,tabIndex:y,"aria-disabled":r,"aria-pressed":b&&g===ZG?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,g,y,b,x,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:D,isDragging:b,listeners:r?void 0:k,node:N,over:m,setNodeRef:S,setActivatorNodeRef:E,transform:v}}function vWe(){return w.useContext(fre)}const _We="Droppable",wWe={timeout:25};function SWe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const s=Wy(_We),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=w.useContext(bM),d=w.useRef({disabled:n}),f=w.useRef(!1),m=w.useRef(null),g=w.useRef(null),{disabled:x,updateMeasurementsFor:y,timeout:b}={...wWe,...i},v=ny(y??r),N=w.useCallback(()=>{if(!f.current){f.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),g.current=null},b)},[b]),S=xM({callback:N,disabled:x||!o}),T=w.useCallback((D,A)=>{S&&(A&&(S.unobserve(A),f.current=!1),D&&S.observe(D))},[S]),[E,k]=E2(T),C=ny(e);return w.useEffect(()=>{!S||!E.current||(S.disconnect(),f.current=!1,S.observe(E.current))},[E,S]),w.useEffect(()=>(l({type:Di.RegisterDroppable,element:{id:r,key:s,disabled:n,node:E,rect:m,data:C}}),()=>l({type:Di.UnregisterDroppable,key:s,id:r})),[r]),w.useEffect(()=>{n!==d.current.disabled&&(l({type:Di.SetDroppableDisabled,id:r,key:s,disabled:n}),d.current.disabled=n)},[r,s,n,l]),{active:o,rect:m,isOver:c?.id===r,node:E,over:c,setNodeRef:k}}function yM(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function NWe(t,e){return t.reduce((n,r,i)=>{const s=e.get(r);return s&&(n[i]=s),n},Array(t.length))}function L1(t){return t!==null&&t>=0}function MWe(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 EWe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const HL=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const s=yM(e,r,n),o=e[i],l=s[i];return!l||!o?null:{x:l.left-o.left,y:l.top-o.top,scaleX:l.width/o.width,scaleY:l.height/o.height}},I1={scaleX:1,scaleY:1},TWe=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:s,overIndex:o}=t;const l=(e=s[n])!=null?e:r;if(!l)return null;if(i===n){const u=s[o];return u?{x:0,y:n<o?u.top+u.height-(l.top+l.height):u.top-l.top,...I1}:null}const c=CWe(s,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...I1}:i<n&&i>=o?{x:0,y:l.height+c,...I1}:{x:0,y:0,...I1}};function CWe(t,e,n){const r=t[e],i=t[e-1],s=t[e+1];return r?n<e?i?r.top-(i.top+i.height):s?s.top-(r.top+r.height):0:s?s.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}const gre="Sortable",xre=zr.createContext({activeIndex:-1,containerId:gre,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:HL,disabled:{draggable:!1,droppable:!1}});function bre(t){let{children:e,id:n,items:r,strategy:i=HL,disabled:s=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=vWe(),f=Wy(gre,n),m=l.rect!==null,g=w.useMemo(()=>r.map(k=>typeof k=="object"&&"id"in k?k.id:k),[r]),x=o!=null,y=o?g.indexOf(o.id):-1,b=u?g.indexOf(u.id):-1,v=w.useRef(g),N=!MWe(g,v.current),S=b!==-1&&y===-1||N,T=EWe(s);Xl(()=>{N&&x&&d(g)},[N,g,x,d]),w.useEffect(()=>{v.current=g},[g]);const E=w.useMemo(()=>({activeIndex:y,containerId:f,disabled:T,disableTransforms:S,items:g,overIndex:b,useDragOverlay:m,sortedRects:NWe(g,c),strategy:i}),[y,f,T.draggable,T.droppable,S,g,b,c,m,i]);return zr.createElement(xre.Provider,{value:E},e)}const AWe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return yM(n,r,i).indexOf(e)},kWe=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:s,newIndex:o,previousItems:l,previousContainerId:c,transition:u}=t;return!u||!r||l!==s&&i===o?!1:n?!0:o!==i&&e===c},jWe={duration:200,easing:"ease"},yre="transform",PWe=Lg.Transition.toString({property:yre,duration:0,easing:"linear"}),RWe={roleDescription:"sortable"};function DWe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[s,o]=w.useState(null),l=w.useRef(n);return Xl(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=lx(r.current,{ignoreTransform:!0}),d={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(d.x||d.y)&&o(d)}}n!==l.current&&(l.current=n)},[e,n,r,i]),w.useEffect(()=>{s&&o(null)},[s]),s}function vre(t){let{animateLayoutChanges:e=kWe,attributes:n,disabled:r,data:i,getNewIndex:s=AWe,id:o,strategy:l,resizeObserverConfig:c,transition:u=jWe}=t;const{items:d,containerId:f,activeIndex:m,disabled:g,disableTransforms:x,sortedRects:y,overIndex:b,useDragOverlay:v,strategy:N}=w.useContext(xre),S=OWe(r,g),T=d.indexOf(o),E=w.useMemo(()=>({sortable:{containerId:f,index:T,items:d},...i}),[f,i,T,d]),k=w.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:C,node:D,isOver:A,setNodeRef:R}=SWe({id:o,data:E,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...c}}),{active:F,activatorEvent:O,activeNodeRect:q,attributes:j,setNodeRef:G,listeners:Y,isDragging:K,over:Z,setActivatorNodeRef:te,transform:ne}=yWe({id:o,data:E,attributes:{...RWe,...n},disabled:S.draggable}),z=rqe(R,G),W=!!F,se=W&&!x&&L1(m)&&L1(b),ae=!v&&K,de=ae&&se?ne:null,xe=se?de??(l??N)({rects:y,activeNodeRect:q,activeIndex:m,overIndex:b,index:T}):null,be=L1(m)&&L1(b)?s({id:o,items:d,activeIndex:m,overIndex:b}):T,fe=F?.id,Ce=w.useRef({activeId:fe,items:d,newIndex:be,containerId:f}),Ne=d!==Ce.current.items,re=e({active:F,containerId:f,isDragging:K,isSorting:W,id:o,index:T,items:d,newIndex:Ce.current.newIndex,previousItems:Ce.current.items,previousContainerId:Ce.current.containerId,transition:u,wasDragging:Ce.current.activeId!=null}),He=DWe({disabled:!re,index:T,node:D,rect:C});return w.useEffect(()=>{W&&Ce.current.newIndex!==be&&(Ce.current.newIndex=be),f!==Ce.current.containerId&&(Ce.current.containerId=f),d!==Ce.current.items&&(Ce.current.items=d)},[W,be,f,d]),w.useEffect(()=>{if(fe===Ce.current.activeId)return;if(fe!=null&&Ce.current.activeId==null){Ce.current.activeId=fe;return}const B=setTimeout(()=>{Ce.current.activeId=fe},50);return()=>clearTimeout(B)},[fe]),{active:F,activeIndex:m,attributes:j,data:E,rect:C,index:T,newIndex:be,items:d,isOver:A,isSorting:W,isDragging:K,listeners:Y,node:D,overIndex:b,over:Z,setNodeRef:z,setActivatorNodeRef:te,setDroppableNodeRef:R,setDraggableNodeRef:G,transform:He??xe,transition:H()};function H(){if(He||Ne&&Ce.current.newIndex===T)return PWe;if(!(ae&&!zL(O)||!u)&&(W||re))return Lg.Transition.toString({...u,property:yre})}}function OWe(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 k2(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 LWe=[$n.Down,$n.Right,$n.Up,$n.Left],_re=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:s,over:o,scrollableAncestors:l}}=e;if(LWe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];s.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const m=i.get(f.id);if(m)switch(t.code){case $n.Down:r.top<m.top&&c.push(f);break;case $n.Up:r.top>m.top&&c.push(f);break;case $n.Left:r.left>m.left&&c.push(f);break;case $n.Right:r.left<m.left&&c.push(f);break}});const u=bqe({collisionRect:r,droppableRects:i,droppableContainers:c});let d=tre(u,"id");if(d===o?.id&&u.length>1&&(d=u[1].id),d!=null){const f=s.get(n.id),m=s.get(d),g=m?i.get(m.id):null,x=m?.node.current;if(x&&g&&f&&m){const b=mM(x).some((k,C)=>l[C]!==k),v=wre(f,m),N=IWe(f,m),S=b||!v?{x:0,y:0}:{x:N?r.width-g.width:0,y:N?r.height-g.height:0},T={x:g.left,y:g.top};return S.x&&S.y?T:ry(T,S)}}}};function wre(t,e){return!k2(t)||!k2(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function IWe(t,e){return!k2(t)||!k2(e)||!wre(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function Sre(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 FWe(t,e="system"){if(!t)return"ASAP";const n=wi(t);if(!n)return"ASAP";const r=new Date,i=n.getTime()-r.getTime();return i<-6e4?"Overdue":i<0?"Now":i<6e4?"In less than a minute":i<36e5?`In ${Math.round(i/6e4)} min`:i<864e5?`In ${Math.round(i/36e5)} hours`:ug(t,e)}function UWe({status:t,waitingReason:e}){if(t==="pending"&&e)return a.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border text-purple-400 bg-purple-400/10 border-purple-400/20",children:[a.jsx(qn,{className:"w-3.5 h-3.5"}),"Waiting"]});const n={pending:{icon:qn,color:"text-status-warning bg-status-warning/10 border-status-warning/20",label:"Pending"},printing:{icon:vs,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:Fn,color:"text-status-ok bg-status-ok/10 border-status-ok/20",label:"Completed"},failed:{icon:aa,color:"text-status-error bg-status-error/10 border-status-error/20",label:"Failed"},skipped:{icon:x0,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:Ot,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:"Cancelled"}},{icon:r,color:i,label:s}=n[t];return a.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${i}`,children:[a.jsx(r,{className:"w-3.5 h-3.5"}),s]})}function zWe({selectedCount:t,printers:e,onSave:n,onClose:r,isSaving:i}){const[s,o]=w.useState("unchanged"),[l,c]=w.useState("unchanged"),[u,d]=w.useState("unchanged"),[f,m]=w.useState("unchanged"),[g,x]=w.useState("unchanged"),[y,b]=w.useState("unchanged"),[v,N]=w.useState("unchanged"),[S,T]=w.useState("unchanged"),[E,k]=w.useState("unchanged"),[C,D]=w.useState("unchanged"),A=()=>{const F={};s!=="unchanged"&&(F.printer_id=s),l!=="unchanged"&&(F.manual_start=l),u!=="unchanged"&&(F.auto_off_after=u),f!=="unchanged"&&(F.require_previous_success=f),g!=="unchanged"&&(F.bed_levelling=g),y!=="unchanged"&&(F.flow_cali=y),v!=="unchanged"&&(F.vibration_cali=v),S!=="unchanged"&&(F.layer_inspect=S),E!=="unchanged"&&(F.timelapse=E),C!=="unchanged"&&(F.use_ams=C),n(F)},R=s!=="unchanged"||l!=="unchanged"||u!=="unchanged"||f!=="unchanged"||g!=="unchanged"||y!=="unchanged"||v!=="unchanged"||S!=="unchanged"||E!=="unchanged"||C!=="unchanged";return a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit ",t," Item",t!==1?"s":""]}),a.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Ot,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Only changed settings will be applied to selected items."}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Printer"}),a.jsxs("select",{value:s===null?"null":s==="unchanged"?"unchanged":String(s),onChange:F=>{const O=F.target.value;o(O==="unchanged"?"unchanged":O==="null"?null:Number(O))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"unchanged",children:"— No change —"}),a.jsx("option",{value:"null",children:"Unassigned"}),e.map(F=>a.jsx("option",{value:F.id,children:F.name},F.id))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Queue Options"}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(Dc,{label:"Staged (manual start)",value:l,onChange:c}),a.jsx(Dc,{label:"Auto power off after print",value:u,onChange:d}),a.jsx(Dc,{label:"Require previous success",value:f,onChange:m})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Print Options"}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(Dc,{label:"Bed levelling",value:g,onChange:x}),a.jsx(Dc,{label:"Flow calibration",value:y,onChange:b}),a.jsx(Dc,{label:"Vibration calibration",value:v,onChange:N}),a.jsx(Dc,{label:"First layer inspection",value:S,onChange:T}),a.jsx(Dc,{label:"Timelapse",value:E,onChange:k}),a.jsx(Dc,{label:"Use AMS",value:C,onChange:D})]})]})]}),a.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Te,{variant:"secondary",onClick:r,children:"Cancel"}),a.jsx(Te,{onClick:A,disabled:!R||i,children:i?"Saving...":"Apply Changes"})]})]})})}function Dc({label:t,value:e,onChange:n}){return a.jsxs("div",{className:"flex items-center justify-between py-1",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:t}),a.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded-lg p-0.5",children:[a.jsx("button",{onClick:()=>n("unchanged"),className:`px-2 py-1 text-xs rounded ${e==="unchanged"?"bg-bambu-dark-tertiary text-white":"text-bambu-gray hover:text-white"}`,children:"—"}),a.jsx("button",{onClick:()=>n(!1),className:`px-2 py-1 text-xs rounded ${e===!1?"bg-red-500/20 text-red-400":"text-bambu-gray hover:text-white"}`,children:"Off"}),a.jsx("button",{onClick:()=>n(!0),className:`px-2 py-1 text-xs rounded ${e===!0?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white"}`,children:"On"})]})]})}function _j({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:s,onRequeue:o,onStart:l,timeFormat:c="system",isSelected:u=!1,onToggleSelect:d}){const{attributes:f,listeners:m,setNodeRef:g,transform:x,transition:y,isDragging:b}=vre({id:t.id,disabled:t.status!=="pending"}),v={transform:Lg.Transform.toString(x),transition:y},N=t.status==="printing",S=t.status==="pending",T=["completed","failed","skipped","cancelled"].includes(t.status);return a.jsx("div",{ref:g,style:v,className:`
- group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
- transition-all duration-200 hover:border-bambu-dark-tertiary/80
- ${b?"opacity-50 scale-[1.02] shadow-xl z-50":""}
- ${N?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
- `,children:a.jsxs("div",{className:"flex items-center gap-4 p-4",children:[S&&d&&a.jsx("button",{onClick:E=>{E.stopPropagation(),d()},className:`flex items-center justify-center w-6 h-6 rounded border transition-colors ${u?"bg-bambu-green border-bambu-green text-white":"border-white/30 bg-black/30 hover:border-bambu-green/50"}`,children:u&&a.jsx(Ua,{className:"w-4 h-4"})}),S?a.jsx("div",{...f,...m,className:"flex items-center justify-center w-10 h-10 md:w-8 md:h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation",children:a.jsx(lg,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}):e!==void 0?a.jsxs("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark text-bambu-gray text-sm font-medium",children:["#",e]}):a.jsx("div",{className:"w-8"}),a.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?a.jsx("img",{src:t.plate_id!=null?he.getArchivePlateThumbnail(t.archive_id,t.plate_id):he.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?a.jsx("img",{src:t.plate_id!=null?he.getLibraryFilePlateThumbnail(t.library_file_id,t.plate_id):he.getLibraryFileThumbnailUrl(t.library_file_id),alt:"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:a.jsx(ul,{className:"w-6 h-6"})})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||t.library_file_name||`File #${t.archive_id||t.library_file_id}`}),t.archive_id?a.jsx(ps,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:a.jsx($r,{className:"w-3.5 h-3.5"})}):t.library_file_id?a.jsx(ps,{to:`/library?highlight=${t.library_file_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View in File Manager",children:a.jsx($r,{className:"w-3.5 h-3.5"})}):null]}),a.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[a.jsxs("span",{className:`flex items-center gap-1.5 ${t.printer_id===null&&!t.target_model?"text-orange-400":""} ${t.target_model?"text-blue-400":""}`,children:[a.jsx(Ar,{className:"w-3.5 h-3.5"}),t.target_model?`Any ${t.target_model}${t.required_filament_types?.length?` (${t.required_filament_types.join(", ")})`:""}`:t.printer_id===null?"Unassigned":t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(Sd,{className:"w-3.5 h-3.5"}),Sre(t.print_time_seconds)]}),S&&!t.manual_start&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(qn,{className:"w-3.5 h-3.5"}),FWe(t.scheduled_time,c)]})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.manual_start&&a.jsxs("span",{className:"text-xs px-2 py-0.5 bg-purple-500/10 text-purple-400 rounded-full border border-purple-500/20 flex items-center gap-1",children:[a.jsx(lW,{className:"w-3 h-3"}),"Staged"]}),t.require_previous_success&&a.jsx("span",{className:"text-xs px-2 py-0.5 bg-orange-500/10 text-orange-400 rounded-full border border-orange-500/20",children:"Requires previous success"}),t.auto_off_after&&a.jsxs("span",{className:"text-xs px-2 py-0.5 bg-blue-500/10 text-blue-400 rounded-full border border-blue-500/20 flex items-center gap-1",children:[a.jsx(yu,{className:"w-3 h-3"}),"Auto power off"]})]}),N&&a.jsxs("div",{className:"mt-3",children:[a.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Printing in progress..."})]}),t.waiting_reason&&t.status==="pending"&&a.jsxs("p",{className:"text-xs text-purple-400 mt-2 flex items-start gap-1",children:[a.jsx(Ei,{className:"w-3 h-3 mt-0.5 flex-shrink-0"}),a.jsx("span",{children:t.waiting_reason})]}),t.error_message&&a.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[a.jsx(Ei,{className:"w-3 h-3"}),t.error_message]})]}),a.jsx(UWe,{status:t.status,waitingReason:t.waiting_reason}),a.jsxs("div",{className:"flex items-center gap-1",children:[N&&a.jsx(Te,{variant:"ghost",size:"sm",onClick:s,title:"Stop Print",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:a.jsx(Kce,{className:"w-4 h-4"})}),S&&a.jsxs(a.Fragment,{children:[t.manual_start&&a.jsx(Te,{variant:"ghost",size:"sm",onClick:l,title:"Start Print",className:"text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10",children:a.jsx(vs,{className:"w-4 h-4"})}),a.jsx(Te,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:a.jsx(Oi,{className:"w-4 h-4"})}),a.jsx(Te,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:a.jsx(Ot,{className:"w-4 h-4"})})]}),T&&a.jsxs(a.Fragment,{children:[a.jsx(Te,{variant:"ghost",size:"sm",onClick:o,title:"Re-queue",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:a.jsx(vr,{className:"w-4 h-4"})}),a.jsx(Te,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:a.jsx(on,{className:"w-4 h-4"})})]})]})]})})}function BWe(){const t=an(),{showToast:e}=Gn(),[n,r]=w.useState(null),[i,s]=w.useState(""),[o,l]=w.useState(!1),[c,u]=w.useState(null),[d,f]=w.useState(null),[m,g]=w.useState(null),[x,y]=w.useState([]),[b,v]=w.useState(!1),[N,S]=w.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[T,E]=w.useState(()=>{const Ne=localStorage.getItem("queue.historySortAsc");return Ne!==null?Ne==="true":!1}),[k,C]=w.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[D,A]=w.useState(()=>{const Ne=localStorage.getItem("queue.pendingSortAsc");return Ne!==null?Ne==="true":!0});w.useEffect(()=>{localStorage.setItem("queue.historySortBy",N)},[N]),w.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(T))},[T]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",k)},[k]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(D))},[D]);const R=Zne(C2(gM,{activationConstraint:{distance:8}}),C2(pM,{coordinateGetter:_re})),{data:F}=ct({queryKey:["settings"],queryFn:he.getSettings}),O=F?.time_format||"system",{data:q,isLoading:j}=ct({queryKey:["queue",n,i],queryFn:()=>he.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:G}=ct({queryKey:["printers"],queryFn:()=>he.getPrinters()}),Y=ht({mutationFn:Ne=>he.cancelQueueItem(Ne),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),K=ht({mutationFn:Ne=>he.removeFromQueue(Ne),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),Z=ht({mutationFn:Ne=>he.stopQueueItem(Ne),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),te=ht({mutationFn:Ne=>he.startQueueItem(Ne),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print released to queue")},onError:()=>e("Failed to start print","error")}),ne=ht({mutationFn:Ne=>he.reorderQueue(Ne),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),z=ht({mutationFn:async()=>{const Ne=q?.filter(re=>["completed","failed","skipped","cancelled"].includes(re.status))||[];for(const re of Ne)await he.removeFromQueue(re.id);return Ne.length},onSuccess:Ne=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${Ne} history item${Ne!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),W=ht({mutationFn:Ne=>he.bulkUpdateQueue(Ne),onSuccess:Ne=>{t.invalidateQueries({queryKey:["queue"]}),y([]),v(!1),e(Ne.message)},onError:()=>e("Failed to update items","error")}),se=ht({mutationFn:async Ne=>{for(const re of Ne)await he.cancelQueueItem(re);return Ne.length},onSuccess:Ne=>{t.invalidateQueries({queryKey:["queue"]}),y([]),e(`Cancelled ${Ne} item${Ne!==1?"s":""}`)},onError:()=>e("Failed to cancel items","error")}),ae=Ne=>{y(re=>re.includes(Ne)?re.filter(He=>He!==Ne):[...re,Ne])},de=w.useMemo(()=>{const Ne=q?.filter(He=>He.status==="pending")||[],re=He=>{if(!He.scheduled_time)return 0;const H=new Date(He.scheduled_time).getTime(),B=Date.now()+4320*60*60*1e3;return H>B?0:H};return[...Ne].sort((He,H)=>{let B;if(k==="name"){const X=He.archive_name||He.library_file_name||"",U=H.archive_name||H.library_file_name||"";B=X.localeCompare(U)}else k==="printer"?B=(He.printer_name||"").localeCompare(H.printer_name||""):k==="time"?B=re(He)-re(H):B=He.position-H.position;return D?B:-B})},[q,k,D]),me=()=>{const Ne=de.map(re=>re.id);x.length===Ne.length?y([]):y(Ne)},xe=q?.filter(Ne=>Ne.status==="printing")||[],be=w.useMemo(()=>[...q?.filter(re=>["completed","failed","skipped","cancelled"].includes(re.status))||[]].sort((re,He)=>{let H;if(N==="name"){const B=re.archive_name||re.library_file_name||"",X=He.archive_name||He.library_file_name||"";H=B.localeCompare(X)}else N==="printer"?H=(re.printer_name||"").localeCompare(He.printer_name||""):H=new Date(He.completed_at||He.created_at).getTime()-new Date(re.completed_at||re.created_at).getTime();return T?-H:H}),[q,N,T]),fe=w.useMemo(()=>de.reduce((Ne,re)=>Ne+(re.print_time_seconds||0),0),[de]),Ce=Ne=>{const{active:re,over:He}=Ne;if(!He||re.id===He.id)return;const H=de.findIndex(X=>X.id===re.id),B=de.findIndex(X=>X.id===He.id);if(H!==-1&&B!==-1){const U=yM(de,H,B).map((Q,le)=>({id:Q.id,position:le+1}));ne.mutate(U)}};return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsx("div",{className:"flex items-center justify-between mb-8",children:a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx(cW,{className:"w-7 h-7 text-bambu-green"}),"Print Queue"]}),a.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage your print jobs"})]})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[a.jsx(_t,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:a.jsx(St,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:a.jsx(vs,{className:"w-5 h-5 text-blue-400"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:xe.length}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),a.jsx(_t,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:a.jsx(St,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:a.jsx(qn,{className:"w-5 h-5 text-yellow-400"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:de.length}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),a.jsx(_t,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:a.jsx(St,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:a.jsx(Sd,{className:"w-5 h-5 text-bambu-green"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:Sre(fe)}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),a.jsx(_t,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:a.jsx(St,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:a.jsx(Fn,{className:"w-5 h-5 text-gray-400"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:be.length}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"History"})]})]})})})]}),a.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n===-1?"unassigned":n||"",onChange:Ne=>{const re=Ne.target.value;r(re==="unassigned"?-1:re===""?null:Number(re))},children:[a.jsx("option",{value:"",children:"All Printers"}),a.jsx("option",{value:"unassigned",children:"Unassigned"}),G?.map(Ne=>a.jsx("option",{value:Ne.id,children:Ne.name},Ne.id))]}),a.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i,onChange:Ne=>s(Ne.target.value),children:[a.jsx("option",{value:"",children:"All Status"}),a.jsx("option",{value:"pending",children:"Pending"}),a.jsx("option",{value:"printing",children:"Printing"}),a.jsx("option",{value:"completed",children:"Completed"}),a.jsx("option",{value:"failed",children:"Failed"}),a.jsx("option",{value:"skipped",children:"Skipped"}),a.jsx("option",{value:"cancelled",children:"Cancelled"})]}),a.jsx("div",{className:"flex-1"}),be.length>0&&a.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>l(!0),children:[a.jsx(on,{className:"w-4 h-4"}),"Clear History"]})]}),j?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):q?.length===0?a.jsxs(_t,{className:"p-12 text-center border-dashed",children:[a.jsx(si,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),a.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:"No prints scheduled"}),a.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.'})]}):a.jsxs("div",{className:"space-y-8",children:[xe.length>0&&a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),"Currently Printing"]}),a.jsx("div",{className:"space-y-3",children:xe.map(Ne=>a.jsx(_j,{item:Ne,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>g({type:"stop",item:Ne}),onRequeue:()=>{},onStart:()=>{},timeFormat:O},Ne.id))})]}),de.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(qn,{className:"w-5 h-5 text-yellow-400"}),"Queued",a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",de.length," item",de.length!==1?"s":"",")"]}),a.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)"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:k,onChange:Ne=>C(Ne.target.value),children:[a.jsx("option",{value:"position",children:"Sort by Position"}),a.jsx("option",{value:"name",children:"Sort by Name"}),a.jsx("option",{value:"printer",children:"Sort by Printer"}),a.jsx("option",{value:"time",children:"Sort by Schedule"})]}),a.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>A(!D),title:D?"Ascending":"Descending",className:"px-2",children:D?a.jsx(og,{className:"w-4 h-4"}):a.jsx(p0,{className:"w-4 h-4"})})]})]}),a.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-bambu-dark rounded-lg",children:[a.jsxs(Te,{variant:"ghost",size:"sm",onClick:me,className:"flex items-center gap-2",children:[x.length===de.length&&de.length>0?a.jsx(Do,{className:"w-4 h-4 text-bambu-green"}):a.jsx(Oo,{className:"w-4 h-4"}),x.length===de.length&&de.length>0?"Deselect All":"Select All"]}),x.length>0&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"text-sm text-bambu-gray",children:[x.length," selected"]}),a.jsx("div",{className:"h-4 w-px bg-bambu-dark-tertiary"}),a.jsxs(Te,{variant:"ghost",size:"sm",onClick:()=>v(!0),className:"flex items-center gap-2 text-bambu-green hover:text-bambu-green-light",children:[a.jsx(Oi,{className:"w-4 h-4"}),"Edit Selected"]}),a.jsxs(Te,{variant:"ghost",size:"sm",onClick:()=>se.mutate(x),className:"flex items-center gap-2 text-red-400 hover:text-red-300",disabled:se.isPending,children:[a.jsx(Ot,{className:"w-4 h-4"}),"Cancel Selected"]})]})]}),a.jsx(pre,{sensors:R,collisionDetection:nre,onDragEnd:Ce,children:a.jsx(bre,{items:de.map(Ne=>Ne.id),strategy:TWe,children:a.jsx("div",{className:"space-y-3",children:de.map((Ne,re)=>a.jsx(_j,{item:Ne,position:re+1,onEdit:()=>u(Ne),onCancel:()=>g({type:"cancel",item:Ne}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>te.mutate(Ne.id),timeFormat:O,isSelected:x.includes(Ne.id),onToggleSelect:()=>ae(Ne.id)},Ne.id))})})})]}),be.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Fn,{className:"w-5 h-5 text-bambu-gray"}),"History",a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",be.length," item",be.length!==1?"s":"",")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:N,onChange:Ne=>S(Ne.target.value),children:[a.jsx("option",{value:"date",children:"Sort by Date"}),a.jsx("option",{value:"name",children:"Sort by Name"}),a.jsx("option",{value:"printer",children:"Sort by Printer"})]}),a.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>E(!T),title:T?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:T?a.jsx(og,{className:"w-4 h-4"}):a.jsx(p0,{className:"w-4 h-4"})})]})]}),a.jsx("div",{className:"space-y-3",children:be.slice(0,20).map((Ne,re)=>a.jsx(_j,{item:Ne,position:re+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>g({type:"remove",item:Ne}),onStop:()=>{},onRequeue:()=>f(Ne),onStart:()=>{},timeFormat:O},Ne.id))})]})]}),c&&a.jsx(ah,{mode:"edit-queue-item",archiveId:c.archive_id??void 0,libraryFileId:c.library_file_id??void 0,archiveName:c.archive_name||c.library_file_name||`File #${c.archive_id||c.library_file_id}`,queueItem:c,onClose:()=>u(null)}),d&&a.jsx(ah,{mode:"add-to-queue",archiveId:d.archive_id??void 0,libraryFileId:d.library_file_id??void 0,archiveName:d.archive_name||d.library_file_name||`File #${d.archive_id||d.library_file_id}`,onClose:()=>f(null)}),m&&a.jsx(Hn,{title:m.type==="cancel"?"Cancel Scheduled Print":m.type==="stop"?"Stop Print":"Remove from History",message:m.type==="cancel"?`Are you sure you want to cancel "${m.item.archive_name||m.item.library_file_name||"this print"}"?`:m.type==="stop"?`Are you sure you want to stop the current print "${m.item.archive_name||m.item.library_file_name||"this print"}"? This will cancel the print job on the printer.`:`Are you sure you want to remove "${m.item.archive_name||m.item.library_file_name||"this item"}" from the queue history?`,confirmText:m.type==="cancel"?"Cancel Print":m.type==="stop"?"Stop Print":"Remove",variant:"danger",onConfirm:()=>{m.type==="cancel"?Y.mutate(m.item.id):m.type==="stop"?Z.mutate(m.item.id):K.mutate(m.item.id),g(null)},onCancel:()=>g(null)}),o&&a.jsx(Hn,{title:"Clear History",message:`Are you sure you want to remove all ${be.length} item${be.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{z.mutate(),l(!1)},onCancel:()=>l(!1)}),b&&a.jsx(zWe,{selectedCount:x.length,printers:G?.map(Ne=>({id:Ne.id,name:Ne.name}))||[],onSave:Ne=>{Object.keys(Ne).length>0&&W.mutate({item_ids:x,...Ne})},onClose:()=>v(!1),isSaving:W.isPending})]})}function $We({printDates:t,months:e=3}){const n=w.useRef(null),[r,i]=w.useState(0);w.useEffect(()=>{const N=n.current;if(!N)return;const S=new ResizeObserver(T=>{const E=T[0]?.contentRect.width||0;i(E)});return S.observe(N),()=>S.disconnect()},[]);const{weeks:s,monthLabels:o,printCounts:l}=w.useMemo(()=>{const N={};t.forEach(F=>{const O=F.split("T")[0];N[O]=(N[O]||0)+1});const S=new Date,T=new Date(S);T.setMonth(T.getMonth()-e),T.setDate(T.getDate()-T.getDay());const E=[],k=[];let C=[],D=-1;const A=new Date(T);let R=0;for(;A<=S;)A.getDay()===0&&C.length>0&&(E.push(C),C=[],R++),A.getMonth()!==D&&(k.push({month:A.toLocaleDateString("en-US",{month:"short"}),weekIndex:R}),D=A.getMonth()),C.push(new Date(A)),A.setDate(A.getDate()+1);return C.length>0&&E.push(C),{weeks:E,monthLabels:k,printCounts:N}},[t,e]),c=Math.max(1,...Object.values(l)),u=N=>{if(N===0)return"bg-bambu-dark";const S=N/c;return S<=.25?"bg-bambu-green/30":S<=.5?"bg-bambu-green/50":S<=.75?"bg-bambu-green/75":"bg-bambu-green"},d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],f=s.length,m=32,g=2,x=r-m-16,y=f>0?Math.floor((x-(f-1)*g)/f):12,b=Math.max(8,Math.min(20,y)),v=b<=10?10:12;return a.jsx("div",{ref:n,className:"w-full flex justify-center",children:r>0&&a.jsxs("div",{children:[a.jsx("div",{className:"flex mb-1",style:{marginLeft:m+4},children:o.map(({month:N,weekIndex:S},T)=>a.jsx("div",{className:"text-bambu-gray",style:{fontSize:v,marginLeft:T===0?0:`${(S-(o[T-1]?.weekIndex||0))*(b+g)-24}px`},children:N},T))}),a.jsxs("div",{className:"flex",style:{gap:g},children:[a.jsx("div",{className:"flex flex-col",style:{gap:g,marginRight:4,width:m},children:d.map((N,S)=>a.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:m,height:b,fontSize:v,visibility:S%2===1?"visible":"hidden"},children:N},N))}),s.map((N,S)=>a.jsx("div",{className:"flex flex-col",style:{gap:g},children:[0,1,2,3,4,5,6].map(T=>{const E=N.find(A=>A.getDay()===T);if(!E)return a.jsx("div",{style:{width:b,height:b}},T);const k=E.toISOString().split("T")[0],C=l[k]||0,D=k===new Date().toISOString().split("T")[0];return a.jsx("div",{className:`rounded-sm ${u(C)} ${D?"ring-1 ring-white":""}`,style:{width:b,height:b},title:`${E.toLocaleDateString()}: ${C} print${C!==1?"s":""}`},T)})},S))]}),a.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:v},children:[a.jsx("span",{children:"Less"}),a.jsxs("div",{className:"flex",style:{gap:g},children:[a.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:b,height:b}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:b,height:b}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:b,height:b}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:b,height:b}}),a.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:b,height:b}})]}),a.jsx("span",{children:"More"})]})]})})}const F1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function HWe(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 VWe({archives:t,currency:e="$"}){const[n,r]=w.useState("30d"),i=w.useMemo(()=>{const m=HWe(n);return t.filter(g=>(wi(g.completed_at||g.created_at)||new Date(0))>=m)},[t,n]),s=w.useMemo(()=>{const m=new Map;return i.forEach(g=>{const x=wi(g.completed_at||g.created_at)||new Date,y=`${x.getFullYear()}-${String(x.getMonth()+1).padStart(2,"0")}-${String(x.getDate()).padStart(2,"0")}`,b=m.get(y)||{date:y,filament:0,cost:0,prints:0};b.filament+=g.filament_used_grams||0,b.cost+=g.cost||0,b.prints+=1,m.set(y,b)}),Array.from(m.values()).sort((g,x)=>g.date.localeCompare(x.date)).map(g=>({...g,dateLabel:new Date(g.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),o=w.useMemo(()=>{if(n==="7d"||n==="30d")return s;const m=new Map;return i.forEach(g=>{const x=wi(g.completed_at||g.created_at)||new Date,y=new Date(x);y.setDate(x.getDate()-x.getDay());const b=`${y.getFullYear()}-${String(y.getMonth()+1).padStart(2,"0")}-${String(y.getDate()).padStart(2,"0")}`,v=m.get(b)||{week:b,filament:0,cost:0,prints:0};v.filament+=g.filament_used_grams||0,v.cost+=g.cost||0,v.prints+=1,m.set(b,v)}),Array.from(m.values()).sort((g,x)=>g.week.localeCompare(x.week)).map(g=>({date:g.week,dateLabel:`Week of ${new Date(g.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...g}))},[i,s,n]),l=w.useMemo(()=>{const m=new Map;return i.forEach(g=>{const y=(g.filament_type||"Unknown").split(", ");y.forEach(b=>{const v=(g.filament_used_grams||0)/y.length;m.set(b,(m.get(b)||0)+v)})}),Array.from(m.entries()).map(([g,x])=>({name:g,value:Math.round(x)})).sort((g,x)=>x.value-g.value)},[i]),c=w.useMemo(()=>{const m=new Date,g=[];for(let x=5;x>=0;x--){const y=new Date(m.getFullYear(),m.getMonth()-x,1),b=new Date(m.getFullYear(),m.getMonth()-x+1,0),v=y.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),N=t.filter(S=>{const T=wi(S.completed_at||S.created_at)||new Date(0);return T>=y&&T<=b});g.push({month:v,filament:Math.round(N.reduce((S,T)=>S+(T.filament_used_grams||0),0)),cost:N.reduce((S,T)=>S+(T.cost||0),0),prints:N.length})}return g},[t]),u=n==="7d"||n==="30d"?s:o,d=i.reduce((m,g)=>m+(g.filament_used_grams||0),0),f=i.reduce((m,g)=>m+(g.cost||0),0);return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),a.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(m=>a.jsx("button",{onClick:()=>r(m),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===m?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:m==="all"?"All":m.replace("d","D")},m))})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),a.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),a.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),a.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(d/i.length).toFixed(0):0,"g"]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(f/i.length).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),a.jsx(K1,{width:"100%",height:250,children:a.jsxs(Uke,{data:u,children:[a.jsx("defs",{children:a.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[a.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),a.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),a.jsx(xS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(yS,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),a.jsx(vS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),a.jsx(Y1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:m=>[`${Number(m??0).toFixed(0)}g`,"Filament"]}),a.jsx(_Z,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):a.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),l.length>0?a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(K1,{width:160,height:160,children:a.jsxs(Ike,{children:[a.jsx(GQ,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((m,g)=>a.jsx(Dy,{fill:F1[g%F1.length]},`cell-${g}`))}),a.jsx(Y1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:m=>[`${m??0}g`,"Usage"]})]})}),a.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:l.map((m,g)=>{const x=l.reduce((b,v)=>b+v.value,0),y=x>0?(m.value/x*100).toFixed(0):0;return a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:F1[g%F1.length]}}),a.jsx("span",{className:"text-white truncate flex-1",children:m.name}),a.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[y,"%"]})]},m.name)})})]}):a.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[a.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),a.jsx(K1,{width:"100%",height:200,children:a.jsxs(Mke,{data:c,children:[a.jsx(xS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(yS,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),a.jsx(vS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),a.jsx(Y1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(m,g)=>[g==="filament"?`${m??0}g`:g==="cost"?`${e}${Number(m??0).toFixed(2)}`:m??0,g==="filament"?"Filament":g==="cost"?"Cost":"Prints"]}),a.jsx(qD,{}),a.jsx(QQ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function GWe({id:t,title:e,component:n,isHidden:r,size:i,onToggleVisibility:s,onToggleSize:o}){const{attributes:l,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:m}=vre({id:t}),g={transform:Lg.Transform.toString(d),transition:f,opacity:m?.5:1};return r?null:a.jsxs("div",{ref:u,style:{...g,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${m?"ring-2 ring-bambu-green shadow-lg":""}`,children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{...l,...c,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:a.jsx(lg,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),a.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:o,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:`Size: ${i===1?"1/4":i===2?"1/2":"Full"} - Click to cycle`,children:i===4?a.jsx(dW,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):a.jsx(uW,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),a.jsx("button",{onClick:s,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:a.jsx(I2,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),a.jsx("div",{className:"p-4",children:typeof n=="function"?n(i):n})]})}function qWe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:s}){const o=()=>{const T={};return t.forEach(E=>{T[E.id]=E.defaultSize||4}),T},[l,c]=w.useState(()=>{const T=localStorage.getItem(e);if(T)try{const E=JSON.parse(T);return E.sizes||(E.sizes=o()),E}catch{}return{order:t.map(E=>E.id),hidden:t.filter(E=>E.defaultVisible===!1).map(E=>E.id),sizes:o()}}),[u,d]=w.useState(!1);w.useEffect(()=>{const T=()=>d(E=>!E);return window.addEventListener("toggle-hidden-panel",T),()=>window.removeEventListener("toggle-hidden-panel",T)},[]),w.useEffect(()=>{localStorage.setItem(e,JSON.stringify(l))},[l,e]),w.useEffect(()=>{const E=t.map(k=>k.id).filter(k=>!l.order.includes(k));E.length>0&&c(k=>({...k,order:[...k.order,...E]}))},[t,l.order]);const f=Zne(C2(gM,{activationConstraint:{distance:8}}),C2(pM,{coordinateGetter:_re})),m=T=>{const{active:E,over:k}=T;k&&E.id!==k.id&&c(C=>{const D=C.order.indexOf(E.id),A=C.order.indexOf(k.id);return{...C,order:yM(C.order,D,A)}})},g=T=>{c(E=>({...E,hidden:E.hidden.includes(T)?E.hidden.filter(k=>k!==T):[...E.hidden,T]}))},x=T=>{c(E=>{const k=E.sizes[T]||4,C=k===1?2:k===2?4:1;return{...E,sizes:{...E.sizes,[T]:C}}})},y=()=>{const T={order:t.map(E=>E.id),hidden:t.filter(E=>E.defaultVisible===!1).map(E=>E.id),sizes:o()};c(T),i?.()},b=l.order.map(T=>t.find(E=>E.id===T)).filter(Boolean),v=b.filter(T=>!l.hidden.includes(T.id)),N=b.filter(T=>l.hidden.includes(T.id)),S=s?.({hiddenCount:N.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:y});return a.jsxs("div",{className:"space-y-4",children:[S,!r&&!s&&a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[a.jsxs(Te,{variant:"secondary",size:"sm",onClick:y,children:[a.jsx(rm,{className:"w-4 h-4"}),"Reset Layout"]}),N.length>0&&a.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[a.jsx(lu,{className:"w-4 h-4"}),N.length," Hidden"]})]}),u&&N.length>0&&a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(T=>a.jsxs("button",{onClick:()=>g(T.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[a.jsx(lu,{className:"w-3 h-3"}),T.title]},T.id))})]}),a.jsx(pre,{sensors:f,collisionDetection:nre,onDragEnd:m,children:a.jsx(bre,{items:v.map(T=>T.id),strategy:HL,children:a.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:v.map(T=>a.jsx(GWe,{id:T.id,title:T.title,component:T.component,isHidden:l.hidden.includes(T.id),size:l.sizes[T.id]||2,onToggleVisibility:()=>g(T.id),onToggleSize:()=>x(T.id)},T.id))})})}),v.length===0&&a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx("p",{children:"All widgets are hidden."}),a.jsx(Te,{className:"mt-4",onClick:y,children:"Reset Layout"})]})]})}function WWe({stats:t,currency:e}){return a.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:a.jsx(zl,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),a.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:a.jsx(qn,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:a.jsx(zl,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:a.jsx(Gj,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:a.jsx(Kd,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:a.jsx(Gj,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function KWe({stats:t,printerMap:e,size:n=1}){const r=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0,i=n===1?112:n===2?128:144,s=i/2-8,o=s*2*Math.PI;return a.jsxs("div",{className:"flex items-center gap-6",children:[a.jsxs("div",{className:"relative flex-shrink-0",style:{width:i,height:i},children:[a.jsxs("svg",{className:"w-full h-full -rotate-90",children:[a.jsx("circle",{cx:i/2,cy:i/2,r:s,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),a.jsx("circle",{cx:i/2,cy:i/2,r:s,fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${r/100*o} ${o}`})]}),a.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:a.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[r,"%"]})})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Fn,{className:"w-4 h-4 text-status-ok flex-shrink-0"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),a.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(aa,{className:"w-4 h-4 text-status-error flex-shrink-0"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),a.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]}),n>=2&&t?.prints_by_printer&&Object.keys(t.prints_by_printer).length>0&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:"Prints by Printer"}),a.jsx("div",{className:`grid gap-x-6 gap-y-1 ${n===4?"grid-cols-3":"grid-cols-2"}`,style:{width:"fit-content"},children:Object.entries(t.prints_by_printer).map(([l,c])=>a.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[a.jsx("span",{className:"text-bambu-gray truncate max-w-[120px]",children:e.get(l)||`Printer ${l}`}),a.jsx("span",{className:"text-white font-medium",children:c})]},l))})]})]})]})}function XWe({stats:t,printerMap:e,size:n=1}){const r=t?.average_time_accuracy;if(r==null)return a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No time accuracy data yet"})});const s=(Math.min(150,Math.max(50,r))-50)/100*100,l=(x=>x>=95&&x<=105?"#00ae42":x>105?"#3b82f6":"#f97316")(r),c=r-100,u=n===1?112:n===2?128:144,d=u/2-8,f=d*2*Math.PI,m=n===1?3:n===2?6:999,g=t?.time_accuracy_by_printer?Object.entries(t.time_accuracy_by_printer).slice(0,m):[];return a.jsxs("div",{className:"flex items-center gap-6",children:[a.jsxs("div",{className:"relative flex-shrink-0",style:{width:u,height:u},children:[a.jsxs("svg",{className:"w-full h-full -rotate-90",children:[a.jsx("circle",{cx:u/2,cy:u/2,r:d,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),a.jsx("circle",{cx:u/2,cy:u/2,r:d,fill:"none",stroke:l,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${s/100*f} ${f}`})]}),a.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[a.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[r.toFixed(0),"%"]}),a.jsxs("span",{className:`text-xs ${c>=0?"text-blue-400":"text-orange-400"}`,children:[c>=0?"+":"",c.toFixed(0),"%"]})]})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[a.jsx(gW,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{children:"100% = perfect estimate"})]}),g.length>0&&a.jsx("div",{className:`mt-2 ${n===4?"grid grid-cols-3 gap-x-6 gap-y-1":n===2?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,style:{width:"fit-content"},children:g.map(([x,y])=>a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(x)||`Printer ${x}`}),a.jsxs("span",{className:`font-medium ${y>=95&&y<=105?"text-status-ok":y>105?"text-blue-400":"text-status-warning"}`,children:[y.toFixed(0),"%"]})]},x))})]})]})}function YWe({stats:t,size:e=1}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return a.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No filament data available"});const n=Object.entries(t.prints_by_filament_type).sort(([,o],[,l])=>l-o),r=e===1?5:e===2?8:999,i=n.slice(0,r),s=n.length>r;return e===4&&i.length>4?a.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:i.map(([o,l])=>{const c=Math.round(l/(t.total_prints||1)*100);return a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-white truncate max-w-[120px]",children:o}),a.jsx("span",{className:"text-bambu-gray",children:l})]}),a.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:a.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${c}%`}})})]},o)})}):a.jsxs("div",{className:"space-y-3",children:[i.map(([o,l])=>{const c=Math.round(l/(t.total_prints||1)*100);return a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-white",children:o}),a.jsxs("span",{className:"text-bambu-gray",children:[l," prints"]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:a.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${c}%`}})})]},o)}),s&&a.jsxs("p",{className:"text-xs text-bambu-gray text-center pt-1",children:["+",n.length-r," more types"]})]})}function QWe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return a.jsx($We,{printDates:t,months:n})}function ZWe({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?a.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:a.jsx(Ar,{className:"w-4 h-4 text-bambu-green"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function JWe({archives:t,currency:e}){return!t||t.length===0?a.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):a.jsx(VWe,{archives:t,currency:e})}function eKe({size:t=1}){const{data:e,isLoading:n}=ct({queryKey:["failureAnalysis"],queryFn:()=>he.getFailureAnalysis({days:30})});if(n)return a.jsx("div",{className:"flex justify-center py-4",children:a.jsx(ut,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!e||e.total_prints===0)return a.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data in the last 30 days"});const r=t===1?5:t===2?8:999,i=Object.entries(e.failures_by_reason).sort(([,l],[,c])=>c-l),s=i.slice(0,r),o=i.length>r;return a.jsxs("div",{className:`${t>=2?"flex gap-8":"space-y-4"}`,children:[a.jsxs("div",{className:t>=2?"flex-shrink-0":"",children:[a.jsx("div",{className:"flex items-center gap-4",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(xn,{className:`w-5 h-5 ${e.failure_rate>20?"text-status-error":e.failure_rate>10?"text-status-warning":"text-status-ok"}`}),a.jsxs("span",{className:`font-bold text-white ${t>=2?"text-3xl":"text-2xl"}`,children:[e.failure_rate.toFixed(1),"%"]})]})}),a.jsxs("div",{className:"text-sm text-bambu-gray mt-1",children:[e.failed_prints," / ",e.total_prints," prints failed"]}),e.trend&&e.trend.length>=2&&a.jsx("div",{className:`${t>=2?"mt-4":"mt-2 pt-2 border-t border-bambu-dark-tertiary"}`,children:a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(bW,{className:`w-4 h-4 ${e.trend[e.trend.length-1].failure_rate<e.trend[e.trend.length-2].failure_rate?"text-status-ok":"text-status-error"}`}),a.jsxs("span",{className:"text-bambu-gray",children:["Last week: ",e.trend[e.trend.length-1].failure_rate.toFixed(1),"%"]})]})})]}),s.length>0&&a.jsxs("div",{className:`flex-1 ${t>=2?"border-l border-bambu-dark-tertiary pl-8":"pt-2"}`,children:[a.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:t>=2?"Failure Reasons":"Top Failure Reasons"}),a.jsx("div",{className:`${t===4?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,children:s.map(([l,c])=>a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:`text-white truncate ${t===4?"max-w-[200px]":"max-w-[160px]"}`,children:l||"Unknown"}),a.jsx("span",{className:"text-bambu-gray ml-2",children:c})]},l))}),o&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["+",i.length-r," more reasons"]})]})]})}function tKe(){const{showToast:t}=Gn(),[e,n]=w.useState(!1),[r,i]=w.useState(!1),[s,o]=w.useState(0),[l,c]=w.useState(0),[u,d]=w.useState(!1);w.useEffect(()=>{const C=()=>{try{const A=localStorage.getItem("bambusy-dashboard-layout");if(A){const R=JSON.parse(A);c(R.hidden?.length||0)}}catch{c(0)}};C(),window.addEventListener("storage",C);const D=setInterval(C,500);return()=>{window.removeEventListener("storage",C),clearInterval(D)}},[s]);const{data:f,isLoading:m,refetch:g}=ct({queryKey:["archiveStats"],queryFn:he.getArchiveStats}),{data:x}=ct({queryKey:["printers"],queryFn:he.getPrinters}),{data:y}=ct({queryKey:["archives"],queryFn:()=>he.getArchives(void 0,void 0,1e3,0)}),{data:b}=ct({queryKey:["settings"],queryFn:he.getSettings}),v=async C=>{i(!1),n(!0);try{const{blob:D,filename:A}=await he.exportStats({format:C,days:90}),R=URL.createObjectURL(D),F=document.createElement("a");F.href=R,F.download=A,F.click(),URL.revokeObjectURL(R),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},N=async()=>{d(!0);try{const C=await he.recalculateCosts();await g(),t(`Recalculated costs for ${C.updated} archives`)}catch{t("Failed to recalculate costs","error")}finally{d(!1)}},S=b?.currency||"$",T=new Map(x?.map(C=>[String(C.id),C.name])||[]),E=y?.map(C=>C.created_at)||[];if(m)return a.jsx("div",{className:"p-4 md:p-8",children:a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const k=[{id:"quick-stats",title:"Quick Stats",component:a.jsx(WWe,{stats:f,currency:S}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:C=>a.jsx(KWe,{stats:f,printerMap:T,size:C}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:C=>a.jsx(XWe,{stats:f,printerMap:T,size:C}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:C=>a.jsx(YWe,{stats:f,size:C}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:C=>a.jsx(eKe,{size:C}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:C=>a.jsx(QWe,{printDates:E,size:C}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:a.jsx(ZWe,{stats:f,printerMap:T}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:a.jsx(JWe,{archives:y||[],currency:S}),defaultSize:4}];return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),a.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[l>0&&a.jsxs(Te,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[a.jsx(lu,{className:"w-4 h-4"}),l," Hidden"]}),a.jsxs(Te,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),o(C=>C+1),t("Layout reset")},children:[a.jsx(rm,{className:"w-4 h-4"}),"Reset Layout"]}),a.jsxs(Te,{variant:"secondary",onClick:N,disabled:u,title:"Recalculate all archive costs using current filament prices",children:[u?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(Ace,{className:"w-4 h-4"}),"Recalculate Costs"]}),a.jsxs("div",{className:"relative",children:[a.jsxs(Te,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(_w,{className:"w-4 h-4"}),"Export Stats"]}),r&&a.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[a.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>v("csv"),children:[a.jsx(Ka,{className:"w-4 h-4"}),"Export as CSV"]}),a.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>v("xlsx"),children:[a.jsx(_w,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),a.jsx(qWe,{widgets:k,storageKey:"bambusy-dashboard-layout",hideControls:!0},s)]})}function nKe({plug:t,onEdit:e}){const n=an(),{showToast:r}=Gn(),[i,s]=w.useState(!1),[o,l]=w.useState(!1),[c,u]=w.useState(!1),[d,f]=w.useState(!1),{data:m,isLoading:g}=ct({queryKey:["smart-plug-status",t.id],queryFn:()=>he.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:x}=ct({queryKey:["printers"],queryFn:he.getPrinters}),y=x?.find(A=>A.id===t.printer_id),b=ht({mutationFn:A=>he.controlSmartPlug(t.id,A),onMutate:async A=>{await n.cancelQueries({queryKey:["smart-plug-status",t.id]});const R=n.getQueryData(["smart-plug-status",t.id]),F=A==="on"?"ON":A==="off"||m?.state==="ON"?"OFF":"ON";return n.setQueryData(["smart-plug-status",t.id],O=>({...O,state:F})),{previousStatus:R}},onError:(A,R,F)=>{F?.previousStatus&&n.setQueryData(["smart-plug-status",t.id],F.previousStatus),r(`Failed to turn ${R} "${t.name}"`,"error")},onSettled:()=>{setTimeout(()=>{n.invalidateQueries({queryKey:["smart-plug-status",t.id]}),n.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),v=ht({mutationFn:A=>he.updateSmartPlug(t.id,A),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),N=ht({mutationFn:()=>he.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),S=m?.state==="ON",T=t.plug_type==="mqtt"&&m?.energy?.power!==null&&m?.energy?.power!==void 0,E=(m?.reachable??!1)||T,k=b.isPending,D=(()=>{if(t.plug_type!=="tasmota"||!t.ip_address)return null;const A=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${A}/`:`http://${A}/`})();return a.jsxs(a.Fragment,{children:[a.jsx(_t,{className:"relative",children:a.jsxs(St,{className:"p-4",children:[a.jsxs("div",{className:"flex items-start justify-between gap-2 mb-3",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("div",{className:`p-2 rounded-lg flex-shrink-0 ${t.plug_type==="mqtt"?E?"bg-teal-500/20":"bg-red-500/20":E?S?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="mqtt"?a.jsx(fD,{className:`w-5 h-5 ${E?"text-teal-400":"text-red-400"}`}):t.plug_type==="homeassistant"?a.jsx($2,{className:`w-5 h-5 ${E?S?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):a.jsx(Ws,{className:`w-5 h-5 ${E?S?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("h3",{className:"font-medium text-white truncate",children:t.name}),a.jsx("p",{className:"text-sm text-bambu-gray truncate",title:t.plug_type==="mqtt"?t.mqtt_topic??void 0:t.plug_type==="homeassistant"?t.ha_entity_id??void 0:t.ip_address??void 0,children:t.plug_type==="mqtt"?t.mqtt_topic:t.plug_type==="homeassistant"?t.ha_entity_id:t.ip_address})]})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[g?a.jsx(ut,{className:"w-4 h-4 text-bambu-gray animate-spin"}):t.plug_type==="mqtt"?a.jsxs("div",{className:"flex items-center gap-1.5 text-sm whitespace-nowrap",children:[a.jsx("span",{className:"px-1.5 py-0.5 bg-teal-500/20 text-teal-400 text-[10px] font-medium rounded flex-shrink-0",children:"MQTT"}),E&&a.jsx("span",{className:"text-status-ok",children:"✓"})]}):t.plug_type==="homeassistant"?a.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[a.jsx("span",{className:"px-1 py-0.5 bg-blue-500/20 text-blue-400 text-[10px] font-medium rounded",children:"HA"}),a.jsx("span",{className:E?S?"text-status-ok":"text-bambu-gray":"text-status-error",children:E?m?.state||"?":"Offline"})]}):E?a.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[a.jsx(Wp,{className:"w-4 h-4 text-status-ok"}),a.jsx("span",{className:S?"text-status-ok":"text-bambu-gray",children:m?.state||"Unknown"})]}):a.jsxs("div",{className:"flex items-center gap-1 text-sm text-status-error",children:[a.jsx(If,{className:"w-4 h-4"}),a.jsx("span",{children:"Offline"})]}),D&&a.jsxs("a",{href:D,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2 py-0.5 bg-bambu-dark hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white text-xs rounded-full transition-colors",title:"Open plug admin page",children:[a.jsx($r,{className:"w-3 h-3"}),"Admin"]})]})]}),y&&a.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),a.jsx("span",{className:"text-sm text-white",children:y.name})]}),(t.power_alert_enabled||t.schedule_enabled||t.plug_type==="mqtt")&&a.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.plug_type==="mqtt"&&a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-teal-500/20 text-teal-400 text-xs rounded-full",children:[a.jsx(lu,{className:"w-3 h-3"}),"Monitor Only"]}),t.power_alert_enabled&&a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full",children:[a.jsx(gf,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full",children:[a.jsx(si,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?`On ${t.schedule_on_time}`:`Off ${t.schedule_off_time}`]})]}),t.plug_type!=="mqtt"&&a.jsxs("div",{className:"flex gap-2 mb-3",children:[a.jsxs(Te,{size:"sm",variant:S?"primary":"secondary",disabled:!E||k,onClick:()=>l(!0),className:"flex-1",children:[k?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(yu,{className:"w-4 h-4"}),"On"]}),a.jsxs(Te,{size:"sm",variant:S?"secondary":"primary",disabled:!E||k,onClick:()=>u(!0),className:"flex-1",children:[k?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(q2,{className:"w-4 h-4"}),"Off"]})]}),t.plug_type==="mqtt"&&m?.energy&&a.jsxs("div",{className:"flex gap-2 mb-3 px-3 py-2 bg-bambu-dark rounded-lg",children:[m.energy.power!==null&&m.energy.power!==void 0&&a.jsxs("div",{className:"flex-1 text-center",children:[a.jsxs("p",{className:"text-lg font-semibold text-white",children:[Math.round(m.energy.power),"W"]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Power"})]}),m.energy.today!==null&&m.energy.today!==void 0&&a.jsxs("div",{className:"flex-1 text-center border-l border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-lg font-semibold text-white",children:m.energy.today.toFixed(2)}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"kWh Today"})]})]}),a.jsxs("button",{onClick:()=>f(!d),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(Gd,{className:"w-4 h-4"}),t.plug_type==="mqtt"?"Settings":"Automation Settings"]}),a.jsx("span",{children:d?"-":"+"})]}),d&&a.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(H2,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Show in Switchbar"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.show_in_switchbar,onChange:A=>v.mutate({show_in_switchbar:A.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.plug_type!=="mqtt"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Enabled"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.enabled,onChange:A=>v.mutate({enabled:A.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Auto On"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:A=>v.mutate({auto_on:A.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:A=>v.mutate({auto_off:A.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&a.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>v.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[a.jsx(qn,{className:"w-4 h-4"}),"Time"]}),a.jsxs("button",{onClick:()=>v.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[a.jsx(W2,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),a.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:A=>v.mutate({off_delay_minutes:parseInt(A.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),a.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:A=>v.mutate({off_temp_threshold:parseInt(A.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]})]}),a.jsxs("div",{className:"flex gap-2 pt-2",children:[a.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[a.jsx(G2,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>s(!0),className:"text-red-400 hover:text-red-300",children:a.jsx(on,{className:"w-4 h-4"})})]})]})]})}),i&&a.jsx(Hn,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{N.mutate(),s(!1)},onCancel:()=>s(!1)}),o&&a.jsx(Hn,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{b.mutate("on"),l(!1)},onCancel:()=>l(!1)}),c&&a.jsx(Hn,{title:"Turn Off Smart Plug",message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:"Turn Off",variant:"danger",onConfirm:()=>{b.mutate("off"),u(!1)},onCancel:()=>u(!1)})]})}function rKe({plug:t,onClose:e}){const n=an(),r=!!t,[i,s]=w.useState(t?.plug_type||"tasmota"),[o,l]=w.useState(t?.name||""),[c,u]=w.useState(t?.ip_address||""),[d,f]=w.useState(t?.username||""),[m,g]=w.useState(t?.password||""),[x,y]=w.useState(t?.ha_entity_id||""),[b,v]=w.useState(t?.mqtt_power_topic||t?.mqtt_topic||""),[N,S]=w.useState(t?.mqtt_power_path||""),[T,E]=w.useState((t?.mqtt_power_multiplier??t?.mqtt_multiplier??1).toString()),[k,C]=w.useState(t?.mqtt_energy_topic||""),[D,A]=w.useState(t?.mqtt_energy_path||""),[R,F]=w.useState((t?.mqtt_energy_multiplier??1).toString()),[O,q]=w.useState(t?.mqtt_state_topic||""),[j,G]=w.useState(t?.mqtt_state_path||""),[Y,K]=w.useState(t?.mqtt_state_on_value||""),[Z,te]=w.useState(t?.ha_power_entity||""),[ne,z]=w.useState(t?.ha_energy_today_entity||""),[W,se]=w.useState(t?.ha_energy_total_entity||""),[ae,de]=w.useState(""),[me,xe]=w.useState(""),[be,fe]=w.useState(!1),Ce=w.useRef(null),[Ne,re]=w.useState(""),[He,H]=w.useState(!1),B=w.useRef(null),[X,U]=w.useState(""),[Q,le]=w.useState(!1),Pe=w.useRef(null),[Oe,je]=w.useState(""),[$,I]=w.useState(!1),V=w.useRef(null),[ie,Se]=w.useState(t?.printer_id||null),[ye,$e]=w.useState(null),[Ue,Ge]=w.useState(null),[We,Ye]=w.useState(t?.power_alert_enabled||!1),[oe,ve]=w.useState(t?.power_alert_high?.toString()||""),[Le,Ke]=w.useState(t?.power_alert_low?.toString()||""),[lt,_e]=w.useState(t?.schedule_enabled||!1),[ce,ee]=w.useState(t?.schedule_on_time||""),[ke,De]=w.useState(t?.schedule_off_time||""),[Ae,Je]=w.useState(t?.show_in_switchbar||!1),[gt,At]=w.useState(!1),[jt,ln]=w.useState({scanned:0,total:0}),[Lt,Cn]=w.useState([]),en=w.useRef(null),{data:er}=ct({queryKey:["printers"],queryFn:he.getPrinters}),{data:ur}=ct({queryKey:["smart-plugs"],queryFn:he.getSmartPlugs}),{data:Un}=ct({queryKey:["settings"],queryFn:he.getSettings}),wr=!!(Un?.ha_enabled&&Un?.ha_url&&Un?.ha_token);w.useEffect(()=>{const ge=setTimeout(()=>{xe(ae)},300);return()=>clearTimeout(ge)},[ae]),w.useEffect(()=>{const ge=Fe=>{Ce.current&&!Ce.current.contains(Fe.target)&&fe(!1),B.current&&!B.current.contains(Fe.target)&&H(!1),Pe.current&&!Pe.current.contains(Fe.target)&&le(!1),V.current&&!V.current.contains(Fe.target)&&I(!1)};return document.addEventListener("mousedown",ge),()=>document.removeEventListener("mousedown",ge)},[]);const{data:jr,isLoading:Zn,error:Xt}=ct({queryKey:["ha-entities",me],queryFn:()=>he.getHAEntities(me||void 0),enabled:i==="homeassistant"&&wr,retry:!1,staleTime:0}),{data:zn}=ct({queryKey:["ha-sensor-entities"],queryFn:he.getHASensorEntities,enabled:i==="homeassistant"&&wr,retry:!1,staleTime:0});w.useEffect(()=>{const ge=Fe=>{Fe.key==="Escape"&&e()};return window.addEventListener("keydown",ge),()=>{window.removeEventListener("keydown",ge),en.current&&clearInterval(en.current)}},[e]);const Wn=async()=>{At(!0),Cn([]),ln({scanned:0,total:0}),Ge(null);try{await he.startTasmotaScan();const ge=async()=>{try{const Fe=await he.getTasmotaScanStatus();ln({scanned:Fe.scanned,total:Fe.total});const Ie=await he.getDiscoveredTasmotaDevices();Cn(Ie),Fe.running||(At(!1),en.current&&(clearInterval(en.current),en.current=null))}catch(Fe){console.error("Polling error:",Fe)}};await ge(),en.current=setInterval(ge,500)}catch(ge){At(!1);const Fe=ge instanceof Error?ge.message:typeof ge=="string"?ge:JSON.stringify(ge);Ge(Fe||"Failed to start scan")}},Zr=async()=>{try{await he.stopTasmotaScan()}catch{}At(!1),en.current&&(clearInterval(en.current),en.current=null)},Ee=ge=>{u(ge.ip_address),l(ge.name),$e(null)},Xe=ht({mutationFn:()=>he.testSmartPlugConnection(c,d||null,m||null),onSuccess:ge=>{$e(ge),Ge(null),!o&&ge.device_name&&l(ge.device_name)},onError:ge=>{$e(null),Ge(ge.message)}}),it=ht({mutationFn:ge=>he.createSmartPlug(ge),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:ge=>{Ge(ge.message)}}),st=ht({mutationFn:ge=>he.updateSmartPlug(t.id,ge),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:ge=>{Ge(ge.message)}}),et=er?.filter(ge=>!ur?.some(Ie=>Ie.printer_id===ge.id&&Ie.id!==t?.id)),Ct=ge=>{if(ge.preventDefault(),Ge(null),!o.trim()){Ge("Name is required");return}if(i==="tasmota"&&!c.trim()){Ge("IP address is required for Tasmota plugs");return}if(i==="homeassistant"&&!x){Ge("Entity is required for Home Assistant plugs");return}if(i==="mqtt"){const Ie=b.trim(),Me=k.trim(),mt=O.trim();if(!Ie&&!Me&&!mt){Ge("At least one MQTT topic must be configured for power, energy, or state monitoring");return}}const Fe={name:o.trim(),plug_type:i,ip_address:i==="tasmota"?c.trim():null,ha_entity_id:i==="homeassistant"?x:null,ha_power_entity:i==="homeassistant"&&Z||null,ha_energy_today_entity:i==="homeassistant"&&ne||null,ha_energy_total_entity:i==="homeassistant"&&W||null,mqtt_power_topic:i==="mqtt"&&b.trim()||null,mqtt_power_path:i==="mqtt"&&N.trim()||null,mqtt_power_multiplier:i==="mqtt"&&parseFloat(T)||1,mqtt_energy_topic:i==="mqtt"&&k.trim()||null,mqtt_energy_path:i==="mqtt"&&D.trim()||null,mqtt_energy_multiplier:i==="mqtt"&&parseFloat(R)||1,mqtt_state_topic:i==="mqtt"&&O.trim()||null,mqtt_state_path:i==="mqtt"&&j.trim()||null,mqtt_state_on_value:i==="mqtt"&&Y.trim()||null,username:i==="tasmota"&&d.trim()||null,password:i==="tasmota"&&m.trim()||null,printer_id:ie,power_alert_enabled:We,power_alert_high:oe?parseFloat(oe):null,power_alert_low:Le?parseFloat(Le):null,schedule_enabled:lt,schedule_on_time:ce||null,schedule_off_time:ke||null,show_in_switchbar:Ae};r?st.mutate(Fe):it.mutate(Fe)},ue=it.isPending||st.isPending;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:ge=>ge.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:Ct,className:"p-6 space-y-4 overflow-y-auto",children:[Ue&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:Ue}),!r&&a.jsxs("div",{className:"flex gap-2 mb-2",children:[a.jsxs("button",{type:"button",onClick:()=>{s("tasmota"),$e(null),Ge(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${i==="tasmota"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[a.jsx(Ws,{className:"w-4 h-4"}),"Tasmota"]}),a.jsxs("button",{type:"button",onClick:()=>{s("homeassistant"),$e(null),Ge(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${i==="homeassistant"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[a.jsx($2,{className:"w-4 h-4"}),"HA"]}),a.jsxs("button",{type:"button",onClick:()=>{s("mqtt"),$e(null),Ge(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${i==="mqtt"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[a.jsx(fD,{className:"w-4 h-4"}),"MQTT"]})]}),!r&&i==="tasmota"&&a.jsxs("div",{className:"space-y-3",children:[gt?a.jsxs(Te,{type:"button",variant:"secondary",onClick:Zr,className:"w-full",children:[a.jsx(Ot,{className:"w-4 h-4"}),"Stop Scanning"]}):a.jsxs(Te,{type:"button",variant:"primary",onClick:Wn,className:"w-full",children:[a.jsx(na,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),gt&&jt.total>0&&a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray",children:[a.jsx("span",{children:"Scanning network..."}),a.jsxs("span",{children:[jt.scanned," / ",jt.total]})]}),a.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:a.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${jt.scanned/jt.total*100}%`}})})]}),Lt.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",Lt.length," device(s) - click to select:"]}),a.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:Lt.map(ge=>a.jsxs("button",{type:"button",onClick:()=>Ee(ge),className:"w-full flex items-center justify-between p-2 bg-bambu-dark hover:bg-bambu-dark-tertiary rounded-lg transition-colors text-left border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ws,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:ge.name}),a.jsx("p",{className:"text-xs text-bambu-gray",children:ge.ip_address})]})]}),ge.state&&a.jsxs("span",{className:`flex items-center gap-1 text-xs ${ge.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[a.jsx(yu,{className:"w-3 h-3"}),ge.state]})]},ge.ip_address))})]}),!gt&&Lt.length===0&&jt.total>0&&a.jsx("p",{className:"text-xs text-bambu-gray text-center py-2",children:"No Tasmota devices found on your network"})]}),i==="homeassistant"&&a.jsxs("div",{className:"space-y-3",children:[!wr&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:["Home Assistant is not configured. Set it up in"," ",a.jsx("span",{className:"font-medium",children:"Settings → Network → Home Assistant"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1 opacity-50",children:"Select Entity *"}),a.jsx("select",{disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed opacity-50",children:a.jsx("option",{children:"Choose an entity..."})})]})]}),wr&&a.jsxs(a.Fragment,{children:[Zn&&a.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[a.jsx(ut,{className:"w-5 h-5 animate-spin mr-2"}),"Loading entities..."]}),Xt&&a.jsxs("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:["Failed to load entities: ",Xt.message]}),(()=>{const ge=ur?.filter(Me=>Me.ha_entity_id&&Me.id!==t?.id).map(Me=>Me.ha_entity_id)||[],Fe=(jr||[]).filter(Me=>!ge.includes(Me.entity_id)),Ie=jr?.find(Me=>Me.entity_id===x);return a.jsxs("div",{ref:Ce,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Select Entity *"}),a.jsxs("div",{className:"relative",children:[a.jsx(na,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:be?ae:Ie?`${Ie.friendly_name} (${Ie.entity_id})`:"",onChange:Me=>{de(Me.target.value),be||fe(!0)},onFocus:()=>{fe(!0),de("")},placeholder:"Search entities...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),x&&!be&&a.jsx("button",{type:"button",onClick:()=>{y(""),de("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ot,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),Zn&&a.jsx(ut,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),be&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-60 overflow-y-auto",children:[Zn&&a.jsxs("div",{className:"px-3 py-2 text-sm text-bambu-gray flex items-center gap-2",children:[a.jsx(ut,{className:"w-4 h-4 animate-spin"}),"Loading..."]}),!Zn&&Fe.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:me?`No entities found matching "${me}"`:"No entities available"}),!Zn&&Fe.map(Me=>a.jsxs("button",{type:"button",onClick:()=>{y(Me.entity_id),fe(!1),de(""),o||l(Me.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${Me.entity_id===x?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:Me.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[a.jsx("span",{children:Me.entity_id}),a.jsx("span",{className:Me.state==="on"?"text-bambu-green":"",children:Me.state})]})]},Me.entity_id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:me?`Searching all entities (${Fe.length} found)`:`Showing switch, light, input_boolean (${Fe.length} available)`})]})})(),x&&zn&&zn.length>0&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4 space-y-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium mb-1",children:"Energy Monitoring (Optional)"}),a.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Search and select sensors that provide power/energy data."})]}),(()=>{const ge=zn.filter(Me=>Me.unit_of_measurement==="W"||Me.unit_of_measurement==="kW"||Me.unit_of_measurement==="mW"),Fe=Ne?ge.filter(Me=>Me.entity_id.toLowerCase().includes(Ne.toLowerCase())||Me.friendly_name.toLowerCase().includes(Ne.toLowerCase())):ge,Ie=zn.find(Me=>Me.entity_id===Z);return a.jsxs("div",{ref:B,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Power Sensor (W)"}),a.jsxs("div",{className:"relative",children:[a.jsx(na,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:He?Ne:Ie?`${Ie.friendly_name} (${Ie.state} ${Ie.unit_of_measurement})`:"",onChange:Me=>{re(Me.target.value),He||H(!0)},onFocus:()=>{H(!0),re("")},placeholder:"Search power sensors...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),Z&&!He&&a.jsx("button",{type:"button",onClick:()=>{te(""),re("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ot,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),He&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{te(""),H(!1),re("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Fe.map(Me=>a.jsxs("button",{type:"button",onClick:()=>{te(Me.entity_id),H(!1),re("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Me.entity_id===Z?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:Me.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[Me.entity_id," • ",Me.state," ",Me.unit_of_measurement]})]},Me.entity_id)),Fe.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const ge=zn.filter(Me=>Me.unit_of_measurement==="kWh"||Me.unit_of_measurement==="Wh"||Me.unit_of_measurement==="MWh"),Fe=X?ge.filter(Me=>Me.entity_id.toLowerCase().includes(X.toLowerCase())||Me.friendly_name.toLowerCase().includes(X.toLowerCase())):ge,Ie=zn.find(Me=>Me.entity_id===ne);return a.jsxs("div",{ref:Pe,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy Today (kWh)"}),a.jsxs("div",{className:"relative",children:[a.jsx(na,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:Q?X:Ie?`${Ie.friendly_name} (${Ie.state} ${Ie.unit_of_measurement})`:"",onChange:Me=>{U(Me.target.value),Q||le(!0)},onFocus:()=>{le(!0),U("")},placeholder:"Search energy sensors...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),ne&&!Q&&a.jsx("button",{type:"button",onClick:()=>{z(""),U("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ot,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),Q&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{z(""),le(!1),U("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Fe.map(Me=>a.jsxs("button",{type:"button",onClick:()=>{z(Me.entity_id),le(!1),U("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Me.entity_id===ne?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:Me.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[Me.entity_id," • ",Me.state," ",Me.unit_of_measurement]})]},Me.entity_id)),Fe.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const ge=zn.filter(Me=>Me.unit_of_measurement==="kWh"||Me.unit_of_measurement==="Wh"||Me.unit_of_measurement==="MWh"),Fe=Oe?ge.filter(Me=>Me.entity_id.toLowerCase().includes(Oe.toLowerCase())||Me.friendly_name.toLowerCase().includes(Oe.toLowerCase())):ge,Ie=zn.find(Me=>Me.entity_id===W);return a.jsxs("div",{ref:V,className:"relative",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Total Energy (kWh)"}),a.jsxs("div",{className:"relative",children:[a.jsx(na,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),a.jsx("input",{type:"text",value:$?Oe:Ie?`${Ie.friendly_name} (${Ie.state} ${Ie.unit_of_measurement})`:"",onChange:Me=>{je(Me.target.value),$||I(!0)},onFocus:()=>{I(!0),je("")},placeholder:"Search energy sensors...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),W&&!$&&a.jsx("button",{type:"button",onClick:()=>{se(""),je("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ot,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),$&&a.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[a.jsx("button",{type:"button",onClick:()=>{se(""),I(!1),je("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Fe.map(Me=>a.jsxs("button",{type:"button",onClick:()=>{se(Me.entity_id),I(!1),je("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Me.entity_id===W?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:Me.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[Me.entity_id," • ",Me.state," ",Me.unit_of_measurement]})]},Me.entity_id)),Fe.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})()]})]})]}),i==="mqtt"&&a.jsxs("div",{className:"space-y-3",children:[!Un?.mqtt_broker&&a.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:["MQTT broker not configured. Set broker address in"," ",a.jsx("span",{className:"font-medium",children:"Settings → Network → MQTT Publishing"})," ","(you don't need to enable publishing, just fill in the broker details)."]}),Un?.mqtt_broker&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg text-sm text-blue-300",children:[a.jsx("p",{className:"font-medium mb-1",children:"Monitor Only"}),a.jsx("p",{className:"text-xs opacity-80",children:"MQTT plugs receive power/energy data via MQTT subscription. On/off control is not available - use your MQTT broker or home automation system."})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-white font-medium text-sm",children:"Power Monitoring"}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:b,onChange:ge=>v(ge.target.value),placeholder:"zigbee2mqtt/shelly-working-room",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),a.jsx("input",{type:"text",value:N,onChange:ge=>S(ge.target.value),placeholder:"power_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Multiplier"}),a.jsx("input",{type:"text",value:T,onChange:ge=>E(ge.target.value),placeholder:"1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:['JSON path extracts value from JSON payload (e.g., "power_l1"). Leave empty if topic publishes raw numeric values.',a.jsx("br",{}),"Use multiplier 0.001 for mW→W, 1000 for kW→W."]})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("p",{className:"text-white font-medium text-sm",children:["Energy Monitoring ",a.jsx("span",{className:"text-bambu-gray font-normal",children:"(optional)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:k,onChange:ge=>C(ge.target.value),placeholder:"Same as power topic, or different",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),a.jsx("input",{type:"text",value:D,onChange:ge=>A(ge.target.value),placeholder:"energy_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Multiplier"}),a.jsx("input",{type:"text",value:R,onChange:ge=>F(ge.target.value),placeholder:"1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:["JSON path extracts value from JSON payload. Leave empty for raw values.",a.jsx("br",{}),"Use multiplier 0.001 for Wh→kWh, 1000 for MWh→kWh."]})]}),a.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("p",{className:"text-white font-medium text-sm",children:["State Monitoring ",a.jsx("span",{className:"text-bambu-gray font-normal",children:"(optional)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),a.jsx("input",{type:"text",value:O,onChange:ge=>q(ge.target.value),placeholder:"Same as power topic, or different",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),a.jsx("input",{type:"text",value:j,onChange:ge=>G(ge.target.value),placeholder:"state_l1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"ON Value"}),a.jsx("input",{type:"text",value:Y,onChange:ge=>K(ge.target.value),placeholder:"ON, true, 1",className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]})]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:["JSON path extracts value from JSON payload. Leave empty for raw values.",a.jsx("br",{}),'ON value: the exact string that means "ON". Leave empty for auto-detect (ON, true, 1).']})]})]})]}),i==="tasmota"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:c,onChange:ge=>{u(ge.target.value),$e(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsxs(Te,{type:"button",variant:"secondary",onClick:()=>Xe.mutate(),disabled:!c.trim()||Xe.isPending,children:[Xe.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(Wp,{className:"w-4 h-4"}),"Test"]})]})]}),i==="tasmota"&&ye&&a.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ye.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:ye.success?a.jsxs(a.Fragment,{children:[a.jsx(Fn,{className:"w-5 h-5"}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium",children:"Connected!"}),a.jsxs("p",{className:"text-sm opacity-80",children:[ye.device_name&&`Device: ${ye.device_name} - `,"State: ",ye.state]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx(If,{className:"w-5 h-5"}),a.jsx("span",{children:"Connection failed"})]})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),a.jsx("input",{type:"text",value:o,onChange:ge=>l(ge.target.value),placeholder:"Living Room Plug",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),i==="tasmota"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),a.jsx("input",{type:"text",value:d,onChange:ge=>f(ge.target.value),placeholder:"admin",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),a.jsx("input",{type:"password",value:m,onChange:ge=>g(ge.target.value),placeholder:"********",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"})]}),i!=="mqtt"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),a.jsxs("select",{value:ie??"",onChange:ge=>Se(ge.target.value?Number(ge.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"No printer (manual control only)"}),et?.map(ge=>a.jsx("option",{value:ge.id,children:ge.name},ge.id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(gf,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:We,onChange:ge=>Ye(ge.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),We&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),a.jsx("input",{type:"number",value:oe,onChange:ge=>ve(ge.target.value),placeholder:"e.g. 200",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),a.jsx("input",{type:"number",value:Le,onChange:ge=>Ke(ge.target.value),placeholder:"e.g. 10",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),i!=="mqtt"&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qn,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:lt,onChange:ge=>_e(ge.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),lt&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),a.jsx("input",{type:"time",value:ce,onChange:ge=>ee(ge.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),a.jsx("input",{type:"time",value:ke,onChange:ge=>De(ge.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Automatically turn the plug on/off at these times daily. Leave empty to skip that action."})]})]}),a.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(H2,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white font-medium",children:"Show in Switchbar"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:Ae,onChange:ge=>Je(ge.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Te,{type:"submit",disabled:ue,className:"flex-1",children:[ue?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(bs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Sn({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return a.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-11 h-7 md:w-9 md:h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:a.jsx("span",{className:`pointer-events-none absolute top-[3px] md:top-[2px] left-[3px] md:left-[2px] w-5 h-5 md:w-4 md:h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const iKe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function aKe({provider:t,onEdit:e}){const n=an(),[r,i]=w.useState(!1),[s,o]=w.useState(!1),[l,c]=w.useState(null),{data:u}=ct({queryKey:["printers"],queryFn:he.getPrinters}),d=u?.find(y=>y.id===t.printer_id),f=ht({mutationFn:y=>he.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=ht({mutationFn:()=>he.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=ht({mutationFn:()=>he.testNotificationProvider(t.id),onSuccess:y=>{c(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{c({success:!1,message:y.message})}}),x=y=>y||"";return a.jsxs(a.Fragment,{children:[a.jsx(_t,{className:"relative",children:a.jsxs(St,{className:"p-4",children:[a.jsxs("div",{className:"flex items-start justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:a.jsx(gf,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium text-white",children:t.name}),a.jsx("p",{className:"text-sm text-bambu-gray",children:iKe[t.provider_type]||t.provider_type})]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&a.jsxs("span",{className:"text-xs text-status-ok hidden sm:inline",children:["Last: ",cg(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(wi(t.last_error_at)?.getTime()||0)>(wi(t.last_success)?.getTime()||0))&&a.jsx("span",{className:"text-xs text-status-error",title:t.last_error,children:"Error"}),a.jsx(Sn,{checked:t.enabled,onChange:y=>f.mutate({enabled:y})})]})]}),d&&a.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),a.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&a.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:a.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),a.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&a.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_plate_not_empty&&a.jsx("span",{className:"px-2 py-0.5 bg-rose-600/20 text-rose-300 text-xs rounded",children:"Plate Check"}),t.on_print_complete&&a.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&a.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&a.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&a.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&a.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&a.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&a.jsx("span",{className:"px-2 py-0.5 bg-cyan-500/20 text-cyan-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&a.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.on_ams_humidity_high&&a.jsx("span",{className:"px-2 py-0.5 bg-blue-600/20 text-blue-300 text-xs rounded",children:"AMS Humidity"}),t.on_ams_temperature_high&&a.jsx("span",{className:"px-2 py-0.5 bg-orange-600/20 text-orange-300 text-xs rounded",children:"AMS Temp"}),t.on_ams_ht_humidity_high&&a.jsx("span",{className:"px-2 py-0.5 bg-cyan-600/20 text-cyan-300 text-xs rounded",children:"AMS-HT Humidity"}),t.on_ams_ht_temperature_high&&a.jsx("span",{className:"px-2 py-0.5 bg-amber-600/20 text-amber-300 text-xs rounded",children:"AMS-HT Temp"}),t.quiet_hours_enabled&&a.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[a.jsx(ww,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&a.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[a.jsx(si,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),a.jsx("div",{className:"mb-3",children:a.jsxs(Te,{size:"sm",variant:"secondary",disabled:g.isPending,onClick:()=>{c(null),g.mutate()},className:"w-full",children:[g.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(mD,{className:"w-4 h-4"}),"Send Test Notification"]})}),l&&a.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${l.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[l.success?a.jsx(Fn,{className:"w-4 h-4"}):a.jsx(aa,{className:"w-4 h-4"}),a.jsx("span",{children:l.message})]}),a.jsxs("button",{onClick:()=>o(!s),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx(Gd,{className:"w-4 h-4"}),"Event Settings"]}),s?a.jsx(ou,{className:"w-4 h-4"}):a.jsx(Br,{className:"w-4 h-4"})]}),s&&a.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Enabled"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),a.jsx(Sn,{checked:t.enabled,onChange:y=>f.mutate({enabled:y})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Started"}),a.jsx(Sn,{checked:t.on_print_start,onChange:y=>f.mutate({on_print_start:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Plate Not Empty"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Objects detected before print"})]}),a.jsx(Sn,{checked:t.on_plate_not_empty??!0,onChange:y=>f.mutate({on_plate_not_empty:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),a.jsx(Sn,{checked:t.on_print_complete,onChange:y=>f.mutate({on_print_complete:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),a.jsx(Sn,{checked:t.on_print_failed,onChange:y=>f.mutate({on_print_failed:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),a.jsx(Sn,{checked:t.on_print_stopped,onChange:y=>f.mutate({on_print_stopped:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),a.jsx(Sn,{checked:t.on_print_progress,onChange:y=>f.mutate({on_print_progress:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),a.jsx(Sn,{checked:t.on_printer_offline,onChange:y=>f.mutate({on_printer_offline:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),a.jsx(Sn,{checked:t.on_printer_error,onChange:y=>f.mutate({on_printer_error:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),a.jsx(Sn,{checked:t.on_filament_low,onChange:y=>f.mutate({on_filament_low:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),a.jsx(Sn,{checked:t.on_maintenance_due??!1,onChange:y=>f.mutate({on_maintenance_due:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS Humidity High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS humidity exceeds threshold"})]}),a.jsx(Sn,{checked:t.on_ams_humidity_high??!1,onChange:y=>f.mutate({on_ams_humidity_high:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS Temperature High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS temperature exceeds threshold"})]}),a.jsx(Sn,{checked:t.on_ams_temperature_high??!1,onChange:y=>f.mutate({on_ams_temperature_high:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS-HT Alarms"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS-HT Humidity High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT humidity exceeds threshold"})]}),a.jsx(Sn,{checked:t.on_ams_ht_humidity_high??!1,onChange:y=>f.mutate({on_ams_ht_humidity_high:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"AMS-HT Temperature High"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT temperature exceeds threshold"})]}),a.jsx(Sn,{checked:t.on_ams_ht_temperature_high??!1,onChange:y=>f.mutate({on_ams_ht_temperature_high:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Queue"}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Added"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job added to queue"})]}),a.jsx(Sn,{checked:t.on_queue_job_added??!1,onChange:y=>f.mutate({on_queue_job_added:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Assigned"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Model-based job assigned to printer"})]}),a.jsx(Sn,{checked:t.on_queue_job_assigned??!1,onChange:y=>f.mutate({on_queue_job_assigned:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Started"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Queue job started printing"})]}),a.jsx(Sn,{checked:t.on_queue_job_started??!1,onChange:y=>f.mutate({on_queue_job_started:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Waiting"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job waiting for filament"})]}),a.jsx(Sn,{checked:t.on_queue_job_waiting??!0,onChange:y=>f.mutate({on_queue_job_waiting:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Skipped"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job skipped (previous failed)"})]}),a.jsx(Sn,{checked:t.on_queue_job_skipped??!0,onChange:y=>f.mutate({on_queue_job_skipped:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Job Failed"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Job failed to start"})]}),a.jsx(Sn,{checked:t.on_queue_job_failed??!0,onChange:y=>f.mutate({on_queue_job_failed:y})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Queue Complete"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"All queue jobs finished"})]}),a.jsx(Sn,{checked:t.on_queue_completed??!1,onChange:y=>f.mutate({on_queue_completed:y})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ww,{className:"w-4 h-4 text-purple-400"}),a.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),a.jsx(Sn,{checked:t.quiet_hours_enabled,onChange:y=>f.mutate({quiet_hours_enabled:y})})]}),t.quiet_hours_enabled&&a.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qn,{className:"w-4 h-4 text-bambu-gray"}),a.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(si,{className:"w-4 h-4 text-emerald-400"}),a.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),a.jsx(Sn,{checked:t.daily_digest_enabled,onChange:y=>f.mutate({daily_digest_enabled:y})})]}),t.daily_digest_enabled&&a.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qn,{className:"w-4 h-4 text-bambu-gray"}),a.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),a.jsxs("div",{className:"flex gap-2 pt-2",children:[a.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[a.jsx(G2,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:a.jsx(on,{className:"w-4 h-4"})})]})]})]})}),r&&a.jsx(Hn,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{m.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const JG=[{value:"email",label:"Email",description:"SMTP email notifications"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"discord",label:"Discord",description:"Send to Discord channel via webhook"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"webhook",label:"Webhook",description:"Generic HTTP POST to any URL"}];function sKe({provider:t,onClose:e}){const n=an(),r=!!t,[i,s]=w.useState(t?.name||""),[o,l]=w.useState(t?.provider_type||"email"),[c,u]=w.useState(t?.printer_id||null),[d,f]=w.useState(t?.quiet_hours_enabled||!1),[m,g]=w.useState(t?.quiet_hours_start||"22:00"),[x,y]=w.useState(t?.quiet_hours_end||"07:00"),[b,v]=w.useState(t?.daily_digest_enabled||!1),[N,S]=w.useState(t?.daily_digest_time||"08:00"),[T,E]=w.useState(t?.on_print_start??!1),[k,C]=w.useState(t?.on_print_complete??!0),[D,A]=w.useState(t?.on_print_failed??!0),[R,F]=w.useState(t?.on_print_stopped??!0),[O,q]=w.useState(t?.on_print_progress??!1),[j,G]=w.useState(t?.on_printer_offline??!1),[Y,K]=w.useState(t?.on_printer_error??!1),[Z,te]=w.useState(t?.on_filament_low??!1),[ne,z]=w.useState(t?.on_maintenance_due??!1),[W,se]=w.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([U,Q])=>[U,String(Q)])):{}),[ae,de]=w.useState(null),[me,xe]=w.useState(null),{data:be}=ct({queryKey:["printers"],queryFn:he.getPrinters});w.useEffect(()=>{const U=Q=>{Q.key==="Escape"&&e()};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[e]);const fe=ht({mutationFn:()=>he.testNotificationConfig({provider_type:o,config:W}),onSuccess:U=>{de(U),xe(null)},onError:U=>{de({success:!1,message:U.message})}}),Ce=ht({mutationFn:U=>he.createNotificationProvider(U),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:U=>{xe(U.message)}}),Ne=ht({mutationFn:U=>he.updateNotificationProvider(t.id,U),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:U=>{xe(U.message)}}),re=U=>{if(U.preventDefault(),xe(null),!i.trim()){xe("Name is required");return}const Q=B(o);for(const Pe of Q)if(!W[Pe.key]?.trim()){xe(`${Pe.label} is required`);return}const le={name:i.trim(),provider_type:o,config:W,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?m:null,quiet_hours_end:d?x:null,daily_digest_enabled:b,daily_digest_time:b?N:null,on_print_start:T,on_print_complete:k,on_print_failed:D,on_print_stopped:R,on_print_progress:O,on_printer_offline:j,on_printer_error:Y,on_filament_low:Z,on_maintenance_due:ne};r?Ne.mutate(le):Ce.mutate(le)},He=Ce.isPending||Ne.isPending,H=U=>{switch(U){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"payload_format",label:"Payload Format",type:"select",required:!1,options:[{value:"generic",label:"Generic JSON"},{value:"slack",label:"Slack / Mattermost"}]},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1,showIf:Q=>Q.payload_format!=="slack"},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1,showIf:Q=>Q.payload_format!=="slack"}];default:return[]}},B=U=>H(U).filter(Q=>Q.required),X=H(o);return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto",onClick:U=>U.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:re,className:"p-6 space-y-4",children:[me&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:me}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),a.jsx("input",{type:"text",value:i,onChange:U=>s(U.target.value),placeholder:"My Notifications",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),a.jsx("select",{value:o,onChange:U=>{l(U.target.value),se({}),de(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:JG.map(U=>a.jsx("option",{value:U.value,children:U.label},U.value))}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:JG.find(U=>U.value===o)?.description})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),X.filter(U=>!("showIf"in U)||U.showIf?.(W)!==!1).map(U=>a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[U.label," ",U.required&&"*"]}),U.type==="select"&&"options"in U&&U.options?a.jsx("select",{value:W[U.key]||U.options[0]?.value||"",onChange:Q=>{se({...W,[U.key]:Q.target.value}),de(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:U.options.map(Q=>a.jsx("option",{value:Q.value,children:Q.label},Q.value))}):a.jsx("input",{type:U.type,value:W[U.key]||"",onChange:Q=>{se({...W,[U.key]:Q.target.value}),de(null)},placeholder:U.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"})]},U.key))]}),a.jsx("div",{className:"flex gap-2",children:a.jsxs(Te,{type:"button",variant:"secondary",onClick:()=>{de(null),fe.mutate()},disabled:fe.isPending||!W[B(o)[0]?.key],className:"flex-1",children:[fe.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(mD,{className:"w-4 h-4"}),"Test Configuration"]})}),ae&&a.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ae.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:ae.success?a.jsxs(a.Fragment,{children:[a.jsx(Fn,{className:"w-5 h-5"}),a.jsx("span",{children:ae.message})]}):a.jsxs(a.Fragment,{children:[a.jsx(aa,{className:"w-5 h-5"}),a.jsx("span",{children:ae.message})]})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),a.jsxs("select",{value:c??"",onChange:U=>u(U.target.value?Number(U.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"All printers"}),be?.map(U=>a.jsx("option",{value:U.id,children:U.name},U.id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),a.jsx(Sn,{checked:d,onChange:f})]}),d&&a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),a.jsx("input",{type:"time",value:m,onChange:U=>g(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),a.jsx("input",{type:"time",value:x,onChange:U=>y(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),a.jsx(Sn,{checked:b,onChange:v})]}),b&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),a.jsx("input",{type:"time",value:N,onChange:U=>S(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),a.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Start"}),a.jsx(Sn,{checked:T,onChange:E})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Complete"}),a.jsx(Sn,{checked:k,onChange:C})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Failed"}),a.jsx(Sn,{checked:D,onChange:A})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Stopped"}),a.jsx(Sn,{checked:R,onChange:F})]}),a.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-white",children:"Progress"}),a.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),a.jsx(Sn,{checked:O,onChange:q})]})]})]}),a.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Offline"}),a.jsx(Sn,{checked:j,onChange:G})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Error"}),a.jsx(Sn,{checked:Y,onChange:K})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),a.jsx(Sn,{checked:Z,onChange:te})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),a.jsx(Sn,{checked:ne,onChange:z})]})]})]})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Te,{type:"submit",disabled:He,className:"flex-1",children:[He?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(bs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function oKe({template:t,onClose:e}){const n=an(),r=w.useRef(null),[i,s]=w.useState(t.title_template),[o,l]=w.useState(t.body_template),[c,u]=w.useState(null),[d,f]=w.useState(!0),{data:m}=ct({queryKey:["template-variables"],queryFn:he.getTemplateVariables}),g=m?.find(E=>E.event_type===t.event_type),{data:x,isLoading:y}=ct({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>he.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:d&&i.length>0&&o.length>0});w.useEffect(()=>{const E=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[e]);const b=ht({mutationFn:E=>he.updateNotificationTemplate(t.id,E),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:E=>{u(E.message)}}),v=ht({mutationFn:()=>he.resetNotificationTemplate(t.id),onSuccess:E=>{s(E.title_template),l(E.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:E=>{u(E.message)}}),N=E=>{if(E.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!o.trim()){u("Body is required");return}b.mutate({title_template:i,body_template:o})},S=E=>{const k=r.current;if(!k)return;const C=k.selectionStart,D=k.selectionEnd,A=o,R=A.substring(0,C),F=A.substring(D),O=R+`{${E}}`+F;l(O),setTimeout(()=>{k.focus();const q=C+E.length+2;k.setSelectionRange(q,q)},0)},T=i!==t.title_template||o!==t.body_template;return a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:a.jsx(Ot,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("form",{onSubmit:N,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),a.jsx("input",{type:"text",value:i,onChange:E=>s(E.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green",placeholder:"Notification title..."})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),a.jsx("textarea",{ref:r,value:o,onChange:E=>l(E.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),g&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:g.variables.map(E=>a.jsxs("button",{type:"button",onClick:()=>S(E),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[a.jsx(rr,{className:"w-3 h-3"}),E]},E))}),a.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[a.jsx(lu,{className:"w-4 h-4"}),"Live Preview"]}),a.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&a.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:y?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[a.jsx(ut,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):x?a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),a.jsx("div",{className:"text-white font-medium",children:x.title})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),a.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:x.body})]})]}):a.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),a.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[a.jsxs(Te,{type:"button",variant:"ghost",onClick:()=>v.mutate(),disabled:v.isPending,className:"text-orange-400 hover:text-orange-300",children:[v.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(rm,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Te,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),a.jsxs(Te,{onClick:N,disabled:b.isPending||!T,children:[b.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(bs,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const lKe={print_start:"Print Started",print_complete:"Print Complete",print_failed:"Print Failed",print_stopped:"Print Stopped",print_progress:"Progress",printer_offline:"Printer Offline",printer_error:"Printer Error",filament_low:"Low Filament",maintenance_due:"Maintenance Due",test:"Test"},cKe={print_start:"text-blue-400",print_complete:"text-bambu-green",print_failed:"text-red-400",print_stopped:"text-orange-400",print_progress:"text-yellow-400",printer_offline:"text-gray-400",printer_error:"text-rose-400",filament_low:"text-cyan-400",maintenance_due:"text-purple-400",test:"text-bambu-gray"};function uKe({onClose:t}){const e=an(),{showToast:n}=Gn(),[r,i]=w.useState(7),[s,o]=w.useState(null),[l,c]=w.useState(!1),{data:u}=ct({queryKey:["settings"],queryFn:he.getSettings}),d=u?.time_format||"system",{data:f,isLoading:m,refetch:g,isRefetching:x}=ct({queryKey:["notification-logs",r,l],queryFn:()=>he.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:y}=ct({queryKey:["notification-log-stats",r],queryFn:()=>he.getNotificationLogStats(r)}),b=ht({mutationFn:()=>he.clearNotificationLogs(30),onSuccess:N=>{n(N.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:N=>{n(`Failed to clear logs: ${N.message}`,"error")}}),v=N=>{const S=wi(N);if(!S)return"";const E=new Date().getTime()-S.getTime();return E<6e4?"Just now":E<36e5?`${Math.floor(E/6e4)}m ago`:E<864e5?`${Math.floor(E/36e5)}h ago`:S.toLocaleDateString()+" "+Afe(S,d)};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(g0,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),y&&a.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:a.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[a.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",a.jsx("span",{className:"text-white font-medium",children:y.total})," notifications"]}),a.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[a.jsx(Fn,{className:"w-4 h-4"}),y.success_count," sent"]}),y.failure_count>0&&a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(aa,{className:"w-4 h-4"}),y.failure_count," failed"]})]})}),a.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[a.jsxs("select",{value:r,onChange:N=>i(Number(N.target.value)),className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:[a.jsx("option",{value:1,children:"Last 24 hours"}),a.jsx("option",{value:7,children:"Last 7 days"}),a.jsx("option",{value:30,children:"Last 30 days"}),a.jsx("option",{value:90,children:"Last 90 days"})]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:l,onChange:N=>c(N.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),a.jsx("div",{className:"flex-1"}),a.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>g(),disabled:x,children:[x?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(vr,{className:"w-4 h-4"}),"Refresh"]}),a.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>b.mutate(),disabled:b.isPending,className:"text-red-400 hover:text-red-300",children:[b.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(on,{className:"w-4 h-4"}),"Clear Old"]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:m?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(ut,{className:"w-6 h-6 text-bambu-green animate-spin"})}):f&&f.length>0?a.jsx("div",{className:"space-y-2",children:f.map(N=>a.jsx(dKe,{log:N,isExpanded:s===N.id,onToggle:()=>o(s===N.id?null:N.id),formatDate:v,formatFullDate:S=>ug(S,d)},N.id))}):a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(g0,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm",children:l?"No failed notifications":"No notifications logged"})]})})]})})}function dKe({log:t,isExpanded:e,onToggle:n,formatDate:r,formatFullDate:i}){return a.jsxs("div",{className:`border rounded-lg overflow-hidden transition-colors ${t.success?"border-bambu-dark-tertiary bg-bambu-dark/30":"border-red-500/30 bg-red-500/5"}`,children:[a.jsxs("button",{className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-bambu-dark/50 transition-colors",onClick:n,children:[t.success?a.jsx(Fn,{className:"w-4 h-4 text-bambu-green shrink-0"}):a.jsx(aa,{className:"w-4 h-4 text-red-400 shrink-0"}),a.jsx("span",{className:`text-xs font-medium ${cKe[t.event_type]||"text-bambu-gray"}`,children:lKe[t.event_type]||t.event_type}),a.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&a.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),a.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?a.jsx(ou,{className:"w-4 h-4 text-bambu-gray shrink-0"}):a.jsx(Br,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&a.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),a.jsx("p",{className:"text-sm text-white",children:t.title})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),a.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),a.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),a.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[a.jsxs("span",{children:["Provider: ",t.provider_type]}),a.jsxs("span",{children:["Time: ",i(t.created_at)]})]})]})]})}async function hKe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function fKe(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 mKe(){const t=an(),[e,n]=w.useState(!1),[r,i]=w.useState(""),[s,o]=w.useState("auto"),[l,c]=w.useState(!1),[u,d]=w.useState("all"),[f,m]=w.useState(!1),[g,x]=w.useState(!1),{data:y,isLoading:b}=ct({queryKey:["spoolman-settings"],queryFn:hKe}),{data:v,isLoading:N,refetch:S}=ct({queryKey:["spoolman-status"],queryFn:he.getSpoolmanStatus,refetchInterval:3e4}),{data:T}=ct({queryKey:["printers"],queryFn:he.getPrinters});w.useEffect(()=>{y&&(n(y.spoolman_enabled==="true"),i(y.spoolman_url||""),o(y.spoolman_sync_mode||"auto"),m(!0))},[y]),w.useEffect(()=>{if(!f||!y)return;if(y.spoolman_enabled==="true"!==e||(y.spoolman_url||"")!==r||(y.spoolman_sync_mode||"auto")!==s){const G=setTimeout(()=>{E.mutate()},500);return()=>clearTimeout(G)}},[e,r,s,f]);const E=ht({mutationFn:()=>fKe({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:s}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),c(!0),setTimeout(()=>c(!1),2e3)}}),k=ht({mutationFn:he.connectSpoolman,onSuccess:()=>{S()}}),C=ht({mutationFn:he.disconnectSpoolman,onSuccess:()=>{S()}}),D=ht({mutationFn:he.syncAllPrintersAms,onSuccess:j=>{j.success}}),A=ht({mutationFn:j=>he.syncPrinterAms(j),onSuccess:j=>{j.success}}),R=()=>{u==="all"?D.mutate():A.mutate(u)},F=D.isPending||A.isPending,O=u==="all"?D.data:A.data,q=u==="all"?D.isSuccess:A.isSuccess;return b?a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Zc,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),a.jsx(St,{children:a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(ut,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Zc,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),E.isPending&&a.jsx(ut,{className:"w-4 h-4 text-bambu-green animate-spin"}),l&&a.jsx(Ua,{className:"w-4 h-4 text-bambu-green"})]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),a.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ul,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-xs text-blue-300",children:[a.jsx("p",{className:"font-medium mb-1",children:"How Sync Works"}),a.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-blue-300/80",children:[a.jsx("li",{children:"Only official Bambu Lab spools with RFID are synced"}),a.jsx("li",{children:"New spools are auto-created in Spoolman on first sync"}),a.jsx("li",{children:"Non-Bambu Lab spools (third-party, refilled) are skipped"})]}),a.jsx("p",{className:"font-medium mt-2 mb-1",children:"Linking Existing Spools"}),a.jsx("p",{className:"text-blue-300/80",children:'To link existing Spoolman spools to your AMS, hover over an AMS slot and click "Link to Spoolman".'})]})]})}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Enable Spoolman"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e,onChange:j=>n(j.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),a.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:j=>i(j.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"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),a.jsxs("select",{value:s,onChange:j=>o(j.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:[a.jsx("option",{value:"auto",children:"Automatic"}),a.jsx("option",{value:"manual",children:"Manual Only"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:s==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&a.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),N?a.jsx(ut,{className:"w-4 h-4 text-bambu-gray animate-spin"}):v?.connected?a.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[a.jsx(Ua,{className:"w-4 h-4"}),"Connected"]}):a.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[a.jsx(Ot,{className:"w-4 h-4"}),"Disconnected"]})]}),a.jsx("div",{className:"flex gap-2",children:v?.connected?a.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>C.mutate(),disabled:C.isPending,children:[C.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(pde,{className:"w-4 h-4"}),"Disconnect"]}):a.jsxs(Te,{size:"sm",onClick:()=>k.mutate(),disabled:k.isPending||!r,children:[k.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(Ol,{className:"w-4 h-4"}),"Connect"]})})]}),k.isError&&a.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:k.error.message}),v?.connected&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsxs("select",{value:u,onChange:j=>d(j.target.value==="all"?"all":Number(j.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"all",children:"All Printers"}),T?.map(j=>a.jsx("option",{value:j.id,children:j.name},j.id))]}),a.jsx(Br,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsxs(Te,{variant:"secondary",size:"sm",onClick:R,disabled:F,children:[F?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(vr,{className:"w-4 h-4"}),"Sync"]})]})]}),q&&O&&a.jsxs("div",{className:"mt-3 space-y-2",children:[a.jsx("div",{className:`p-2 rounded text-sm ${O.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:O.success?`Synced ${O.synced_count} spool${O.synced_count!==1?"s":""} successfully`:`Synced ${O.synced_count} spool${O.synced_count!==1?"s":""} with ${O.errors.length} error${O.errors.length!==1?"s":""}`}),O.skipped_count>0&&a.jsxs("div",{className:"p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm",children:[a.jsxs("div",{className:"flex items-center justify-between text-amber-400 mb-1",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(xn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{className:"font-medium",children:[O.skipped_count," spool",O.skipped_count!==1?"s":""," skipped"]})]}),O.skipped_count>5&&a.jsx("button",{onClick:()=>x(!g),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:g?"Show less":"Show all"})]}),a.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(g?O.skipped:O.skipped.slice(0,5)).map((j,G)=>a.jsxs("li",{className:"flex items-center gap-2",children:[j.color&&a.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${j.color}`}}),a.jsx("span",{children:j.location}),a.jsxs("span",{className:"text-amber-300/60",children:["- ",j.reason]})]},G)),!g&&O.skipped_count>5&&a.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",O.skipped_count-5," more"]})]})]}),O.errors.length>0&&a.jsxs("div",{className:"p-2 bg-red-500/10 border border-red-500/30 rounded text-sm",children:[a.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Errors:"}),a.jsx("ul",{className:"text-xs text-red-300/80 space-y-0.5",children:O.errors.map((j,G)=>a.jsx("li",{children:j},G))})]})]})]})]})]})}function pKe({link:t,onClose:e}){const n=an(),{mode:r}=lh(),i=!!t,s=w.useRef(null),[o,l]=w.useState(t?.name||""),[c,u]=w.useState(t?.url||""),[d,f]=w.useState(t?.icon||"link"),[m,g]=w.useState(!!t?.custom_icon),[x,y]=w.useState(t?.custom_icon?he.getExternalLinkIconUrl(t.id):null),[b,v]=w.useState(null),[N,S]=w.useState(null);w.useEffect(()=>{const F=O=>{O.key==="Escape"&&e()};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[e]);const T=ht({mutationFn:async F=>{const O=await he.createExternalLink(F);return b?await he.uploadExternalLinkIcon(O.id,b):O},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{S(F.message)}}),E=ht({mutationFn:async F=>{let O=await he.updateExternalLink(t.id,F);return b?O=await he.uploadExternalLinkIcon(t.id,b):!m&&t?.custom_icon&&(O=await he.deleteExternalLinkIcon(t.id)),O},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{S(F.message)}}),k=F=>{const O=F.target.files?.[0];if(O){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(O.type)){S("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(O.size>1024*1024){S("Image file must be less than 1MB");return}v(O),g(!0);const j=new FileReader;j.onload=G=>{y(G.target?.result)},j.readAsDataURL(O)}},C=()=>{v(null),y(null),g(!1),s.current&&(s.current.value="")},D=F=>{if(F.preventDefault(),S(null),!o.trim()){S("Name is required");return}if(!c.trim()){S("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){S("URL must start with http:// or https://");return}const O={name:o.trim(),url:c.trim(),icon:d};i?E.mutate(O):T.mutate(O)},A=T.isPending||E.isPending,R=K2(d);return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:F=>F.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:m&&x?a.jsx("img",{src:x,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):a.jsx(R,{className:"w-5 h-5"})}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:D,className:"p-6 space-y-4",children:[N&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:N}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),a.jsx("input",{type:"text",value:o,onChange:F=>l(F.target.value),placeholder:"My Link",maxLength:50,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),a.jsx("input",{type:"text",value:c,onChange:F=>u(F.target.value),placeholder:"https://example.com",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),a.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),a.jsx("input",{ref:s,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:k}),m&&x?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("img",{src:x,alt:"Custom icon",className:`w-8 h-8 rounded border border-bambu-dark-tertiary ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}),a.jsx("button",{type:"button",onClick:C,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:a.jsx(on,{className:"w-4 h-4"})})]}):a.jsxs(Te,{type:"button",variant:"secondary",size:"sm",onClick:()=>s.current?.click(),children:[a.jsx(fi,{className:"w-4 h-4"}),"Upload"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!m&&a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),a.jsx(Sfe,{value:d,onChange:f})]})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Te,{type:"submit",disabled:A,className:"flex-1",children:[A?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(bs,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function gKe(){const t=an(),[e,n]=w.useState(!1),[r,i]=w.useState(null),[s,o]=w.useState(null),[l,c]=w.useState(null),{data:u,isLoading:d}=ct({queryKey:["external-links"],queryFn:he.getExternalLinks}),f=ht({mutationFn:N=>he.deleteExternalLink(N),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=ht({mutationFn:N=>he.reorderExternalLinks(N),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),g=(N,S)=>{c(S),N.dataTransfer.effectAllowed="move"},x=N=>{N.preventDefault(),N.dataTransfer.dropEffect="move"},y=(N,S)=>{if(N.preventDefault(),l===null||l===S||!u)return;const T=u.map(D=>D.id),E=T.indexOf(l),k=T.indexOf(S);if(E===-1||k===-1)return;const C=[...T];C.splice(E,1),C.splice(k,0,l),m.mutate(C),c(null)},b=N=>{o(N)},v=()=>{s&&(f.mutate(s.id),o(null))};return a.jsxs(a.Fragment,{children:[a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ol,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),a.jsxs(Te,{size:"sm",onClick:()=>n(!0),children:[a.jsx(rr,{className:"w-4 h-4"}),"Add Link"]})]})}),a.jsxs(St,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),d?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(ut,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?a.jsx("div",{className:"space-y-2",children:u.map(N=>{const S=K2(N.icon);return a.jsxs("div",{draggable:!0,onDragStart:T=>g(T,N.id),onDragOver:x,onDrop:T=>y(T,N.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${l===N.id?"opacity-50":""}`,children:[a.jsx(lg,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:a.jsx(S,{className:"w-4 h-4"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-white font-medium truncate",children:N.name}),a.jsx($r,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),a.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:N.url})]}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[a.jsx("button",{onClick:()=>i(N),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Edit",children:a.jsx(Oi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>b(N),disabled:f.isPending,className:"p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50",title:"Delete",children:a.jsx(on,{className:"w-4 h-4"})})]})]},N.id)})}):a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(Ol,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:"No external links configured"}),a.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(e||r)&&a.jsx(pKe,{link:r,onClose:()=>{n(!1),i(null)}}),s&&a.jsx(Hn,{title:"Delete Link",message:`Are you sure you want to delete "${s.name}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",variant:"danger",onConfirm:v,onCancel:()=>o(null)})]})}function xKe(){const t=an(),{showToast:e}=Gn(),[n,r]=w.useState(!1),[i,s]=w.useState(""),[o,l]=w.useState("immediate"),[c,u]=w.useState("3DPrinter-X1-Carbon"),[d,f]=w.useState(!1),[m,g]=w.useState(null),{data:x,isLoading:y}=ct({queryKey:["virtual-printer-settings"],queryFn:H1.getSettings,refetchInterval:1e4}),{data:b}=ct({queryKey:["virtual-printer-models"],queryFn:H1.getModels});w.useEffect(()=>{if(x){r(x.enabled);let D=x.mode==="queue"?"review":x.mode;D!=="immediate"&&D!=="review"&&D!=="print_queue"&&(D="immediate"),l(D),u(x.model)}},[x]);const v=ht({mutationFn:D=>H1.updateSettings(D),onSuccess:()=>{t.invalidateQueries({queryKey:["virtual-printer-settings"]}),e("Virtual printer settings updated"),g(null)},onError:D=>{if(e(D.message||"Failed to update settings","error"),x){r(x.enabled);const A=x.mode==="queue"?"review":x.mode;l(A==="print_queue"||A==="review"?A:"immediate"),u(x.model)}g(null)}}),N=()=>{const D=!n;if(D&&!i&&!x?.access_code_set){e("Please set an access code first","error");return}r(D),g("toggle"),v.mutate({enabled:D,access_code:i||void 0,mode:o})},S=()=>{if(!i){e("Access code cannot be empty","error");return}if(i.length!==8){e("Access code must be exactly 8 characters","error");return}g("accessCode"),v.mutate({access_code:i}),s("")},T=D=>{l(D),g("mode"),v.mutate({mode:D})},E=D=>{u(D),g("model"),v.mutate({model:D})};if(y)return a.jsx(_t,{children:a.jsx(St,{className:"py-8 flex justify-center",children:a.jsx(ut,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const k=x?.status,C=k?.running||!1;return a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[a.jsx("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ar,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Virtual Printer"})]}),k&&a.jsxs("div",{className:`flex items-center gap-2 text-sm ${C?"text-green-400":"text-bambu-gray"}`,children:[a.jsx("span",{className:`w-2 h-2 rounded-full ${C?"bg-green-400 animate-pulse":"bg-gray-500"}`}),C?"Running":"Stopped"]})]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable a virtual printer that appears in Bambu Studio and OrcaSlicer. Files sent to this printer will be archived directly without printing."}),a.jsxs("div",{className:"flex items-center justify-between py-3 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-white font-medium",children:"Enable Virtual Printer"}),a.jsx("div",{className:"text-sm text-bambu-gray",children:C?'Visible as "Bambuddy" in slicer discovery':"Not visible to slicers"})]}),a.jsx("button",{onClick:N,disabled:m==="toggle",className:`relative w-12 h-6 rounded-full transition-colors ${n?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${m==="toggle"?"opacity-50":""}`,children:a.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${n?"translate-x-6":""}`})})]}),a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:"Printer Model"}),a.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:"Select which printer model to emulate."}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:c,onChange:D=>E(D.target.value),disabled:m==="model",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white appearance-none cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed pr-10",children:b?.models&&Object.entries(b.models).sort(([,D],[,A])=>D.localeCompare(A)).map(([D,A])=>a.jsx("option",{value:D,children:A},D))}),a.jsx(Br,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),n&&C&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[a.jsx(Ul,{className:"w-3 h-3 inline mr-1"}),"Changing the model will restart the virtual printer"]})]}),a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:"Access Code"}),a.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:x?.access_code_set?a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(Ua,{className:"w-4 h-4"}),"Access code is set"]}):a.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[a.jsx(xn,{className:"w-4 h-4"}),"No access code set - required to enable"]})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:d?"text":"password",value:i,onChange:D=>s(D.target.value),placeholder:x?.access_code_set?"Enter new code to change":"Enter 8-char code",maxLength:8,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray pr-10 font-mono"}),a.jsx("button",{onClick:()=>f(!d),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:d?a.jsx(I2,{className:"w-4 h-4"}):a.jsx(lu,{className:"w-4 h-4"})})]}),a.jsx(Te,{onClick:S,disabled:!i||m==="accessCode",variant:"primary",children:m==="accessCode"?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):"Save"})]}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["Must be exactly 8 characters. Used by slicers to authenticate.",i&&a.jsxs("span",{className:i.length===8?"text-green-400":"text-yellow-400",children:[" ","(",i.length,"/8)"]})]})]}),a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:"Mode"}),a.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[a.jsxs("button",{onClick:()=>T("immediate"),disabled:m==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="immediate"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"text-white font-medium",children:"Archive"}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Archive files immediately"})]}),a.jsxs("button",{onClick:()=>T("review"),disabled:m==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="review"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"text-white font-medium",children:"Review"}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Review and tag before archiving"})]}),a.jsxs("button",{onClick:()=>T("print_queue"),disabled:m==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="print_queue"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"text-white font-medium",children:"Queue"}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Archive and add to print queue"})]})]})]})]})]})}),a.jsxs("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:[a.jsx(_t,{className:"border-l-4 border-l-yellow-500",children:a.jsx(St,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(xn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-sm",children:[a.jsx("p",{className:"text-white font-medium mb-2",children:"Setup Required"}),a.jsx("p",{className:"text-bambu-gray mb-3",children:"The virtual printer feature requires additional system configuration before it will work. This includes port forwarding, firewall rules, and platform-specific settings."}),a.jsxs("a",{href:"https://wiki.bambuddy.cool/features/virtual-printer/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-yellow-500/20 border border-yellow-500/50 rounded-md text-yellow-400 hover:bg-yellow-500/30 transition-colors",children:[a.jsx($r,{className:"w-4 h-4"}),"Read the setup guide before enabling"]})]})]})})}),a.jsx(_t,{children:a.jsx(St,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Ul,{className:"w-5 h-5 text-blue-400 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-sm text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:a.jsx("strong",{className:"text-white",children:"How it works:"})}),a.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[a.jsx("li",{children:"Complete the setup guide for your platform"}),a.jsx("li",{children:"Enable the virtual printer and set an access code"}),a.jsx("li",{children:'In Bambu Studio or OrcaSlicer, go to "Add Printer"'}),a.jsx("li",{children:'The "Bambuddy" printer should appear in the discovery list'}),a.jsx("li",{children:"Connect using the access code you set"}),a.jsx("li",{children:'When you "print" to Bambuddy, the 3MF file is archived instead'})]})]})]})})}),k&&C&&a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsx("h3",{className:"text-md font-semibold text-white",children:"Status Details"})}),a.jsx(St,{children:a.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:"Printer Name"}),a.jsx("div",{className:"text-white",children:k.name})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:"Model"}),a.jsx("div",{className:"text-white",children:k.model_name||k.model})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:"Serial Number"}),a.jsx("div",{className:"text-white font-mono",children:k.serial})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:"Mode"}),a.jsx("div",{className:"text-white capitalize",children:k.mode})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:"Pending Files"}),a.jsx("div",{className:"text-white",children:k.pending_files})]})]})})]})]})]})}const U1=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:a.jsx(ly,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:a.jsx(gf,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:a.jsx(Ka,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:a.jsx(Ws,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"external_links",labelKey:"backup.categories.externalLinks",defaultLabel:"External Links",icon:a.jsx($g,{className:"w-4 h-4"}),default:!0,description:"Sidebar links to external services"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:a.jsx(Ar,{className:"w-4 h-4"}),default:!1,description:"Printer info (access codes excluded)"},{id:"plate_calibration",labelKey:"backup.categories.plateCalibration",defaultLabel:"Plate Detection",icon:a.jsx(Df,{className:"w-4 h-4"}),default:!1,description:"Empty plate reference images",requiresPrinters:!0},{id:"filaments",labelKey:"backup.categories.filaments",defaultLabel:"Filament Inventory",icon:a.jsx(dD,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:a.jsx(Wd,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:a.jsx(Qa,{className:"w-4 h-4"}),default:!1,description:"All print data + files (3MF, thumbnails, photos)"},{id:"projects",labelKey:"backup.categories.projects",defaultLabel:"Projects",icon:a.jsx(Ma,{className:"w-4 h-4"}),default:!1,description:"Projects, BOM items, and attachments"},{id:"pending_uploads",labelKey:"backup.categories.pendingUploads",defaultLabel:"Pending Uploads",icon:a.jsx(fi,{className:"w-4 h-4"}),default:!1,description:"Virtual printer uploads awaiting review"},{id:"api_keys",labelKey:"backup.categories.apiKeys",defaultLabel:"API Keys",icon:a.jsx(of,{className:"w-4 h-4"}),default:!1,description:"Webhook API keys (new keys generated on import)"}];function bKe({onClose:t,onExport:e}){const{t:n}=Fg(),[r,i]=w.useState(()=>{const x={};return U1.forEach(y=>{x[y.id]=y.default}),x}),[s,o]=w.useState(!1),[l,c]=w.useState(!1);w.useEffect(()=>{const x=y=>{y.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]);const u=x=>{i(y=>({...y,[x]:!y[x]}))},d=()=>{const x={};U1.forEach(y=>{x[y.id]=!0}),i(x)},f=()=>{const x={};U1.forEach(y=>{x[y.id]=!1}),i(x)},m=Object.values(r).filter(Boolean).length,g=async()=>{c(!0);try{await e({...r,access_codes:s&&r.printers})}finally{c(!1)}};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:l?void 0:t,children:a.jsx(_t,{className:"w-full max-w-lg",onClick:x=>x.stopPropagation(),children:a.jsxs(St,{className:"p-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:a.jsx(Gr,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:n("backup.exportTitle",{defaultValue:"Export Backup"})}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.selectCategories",{defaultValue:"Select data to include"})})]})]}),a.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex gap-2 px-4 pt-4",children:[a.jsx("button",{onClick:d,disabled:l,className:"text-sm text-bambu-green hover:text-bambu-green/80 disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectAll",{defaultValue:"Select All"})}),a.jsx("span",{className:"text-bambu-gray",children:"|"}),a.jsx("button",{onClick:f,disabled:l,className:"text-sm text-bambu-gray hover:text-white disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectNone",{defaultValue:"Select None"})})]}),a.jsx("div",{className:`p-4 space-y-2 max-h-[400px] overflow-y-auto ${l?"opacity-50 pointer-events-none":""}`,children:U1.map(x=>{const y=l||x.requiresPrinters&&!r.printers;return a.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg transition-colors ${y?"cursor-not-allowed opacity-50":"cursor-pointer"} ${r[x.id]&&!y?"bg-bambu-green/10 border border-bambu-green/30":"bg-bambu-dark hover:bg-bambu-dark-tertiary border border-transparent"}`,children:[a.jsx("input",{type:"checkbox",checked:r[x.id]&&!y,onChange:()=>u(x.id),disabled:y,className:"w-4 h-4 rounded border-bambu-gray bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),a.jsx("div",{className:`${r[x.id]&&!y?"text-bambu-green":"text-bambu-gray"}`,children:x.icon}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"text-white text-sm font-medium",children:n(x.labelKey,{defaultValue:x.defaultLabel})}),a.jsx("div",{className:"text-xs text-bambu-gray",children:x.requiresPrinters&&!r.printers?"Requires Printers to be selected":x.description})]})]},x.id)})}),r.archives&&a.jsx("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:a.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[a.jsx(Qa,{className:"w-4 h-4 text-yellow-500 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"text-yellow-200 dark:text-yellow-200 text-yellow-700",children:[a.jsx("span",{className:"font-medium",children:"ZIP file will be created."}),a.jsx("span",{className:"text-yellow-600 dark:text-yellow-200/70",children:" Includes all 3MF files, thumbnails, timelapses, and photos. This may take a while and result in a large file."})]})]})}),r.printers&&a.jsxs("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(of,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-white",children:"Include Access Codes"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"For transferring to another machine"})]})]}),a.jsx(Sn,{checked:s,onChange:o})]}),s&&a.jsx("div",{className:"mt-2 p-2 rounded bg-orange-500/10 border border-orange-500/30",children:a.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[a.jsx(xn,{className:"w-3 h-3 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),a.jsx("span",{className:"text-orange-700 dark:text-orange-200",children:"Access codes will be included in plain text. Keep this backup file secure!"})]})})]}),a.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:n("backup.selectedCount",{count:m,defaultValue:`${m} categories selected`})}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(Te,{variant:"secondary",onClick:t,disabled:l,children:n("common.cancel",{defaultValue:"Cancel"})}),a.jsx(Te,{onClick:g,disabled:m===0||l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50 disabled:cursor-not-allowed min-w-[100px]",children:l?a.jsxs(a.Fragment,{children:[a.jsx(ut,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):a.jsxs(a.Fragment,{children:[a.jsx(Gr,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const eq={settings:"Settings",notification_providers:"Notification Providers",notification_templates:"Notification Templates",smart_plugs:"Smart Plugs",printers:"Printers",filaments:"Filaments",maintenance_types:"Maintenance Types",archives:"Archives",projects:"Projects",pending_uploads:"Pending Uploads",external_links:"External Links",api_keys:"API Keys"};function yKe({onClose:t,onRestore:e,onSuccess:n}){const[r,i]=w.useState("options"),[s,o]=w.useState(!1),[l,c]=w.useState(null),[u,d]=w.useState(null),[f,m]=w.useState(new Set),g=w.useRef(null);w.useEffect(()=>{const T=E=>{E.key==="Escape"&&r!=="restoring"&&(r==="result"&&u?.success&&n(),t())};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t,n,r,u]);const x=T=>{const E=T.target.files?.[0];E&&c(E)},y=async()=>{if(l){i("restoring");try{const T=await e(l,s);d(T),i("result")}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},b=()=>{u?.success&&n(),t()},v=T=>{m(E=>{const k=new Set(E);return k.has(T)?k.delete(T):k.add(T),k})},N=u?.restored?Object.values(u.restored).reduce((T,E)=>T+E,0)+(u.files_restored||0):0,S=u?.total_skipped||0;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onMouseDown:T=>{T.target===T.currentTarget&&r!=="restoring"&&t()},children:a.jsx(_t,{className:"w-full max-w-lg",children:a.jsxs(St,{className:"p-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-full ${r==="result"&&u?.success?"bg-bambu-green/20 text-bambu-green":r==="result"&&!u?.success?"bg-red-500/20 text-red-500":"bg-blue-500/20 text-blue-500"}`,children:r==="result"&&u?.success?a.jsx(Fn,{className:"w-5 h-5"}):r==="result"&&!u?.success?a.jsx(xn,{className:"w-5 h-5"}):a.jsx(fi,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsxs("h3",{className:"text-lg font-semibold text-white",children:[r==="options"&&"Restore Backup",r==="restoring"&&"Restoring...",r==="result"&&(u?.success?"Restore Complete":"Restore Failed")]}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[r==="options"&&"Import settings from a backup file",r==="restoring"&&"Please wait while your data is being restored",r==="result"&&u?.message]})]})]}),r!=="restoring"&&a.jsx("button",{onClick:b,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),r==="options"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("input",{ref:g,type:"file",accept:".json,.zip",className:"hidden",onChange:x}),a.jsx("button",{type:"button",onClick:()=>g.current?.click(),className:`w-full p-4 border-2 border-dashed rounded-lg transition-colors ${l?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:l?a.jsxs("div",{className:"flex items-center justify-center gap-2 text-bambu-green",children:[a.jsx(Fn,{className:"w-5 h-5"}),a.jsx("span",{className:"font-medium",children:l.name})]}):a.jsxs("div",{className:"flex flex-col items-center gap-2 text-bambu-gray",children:[a.jsx(fi,{className:"w-8 h-8"}),a.jsx("span",{children:"Click to select backup file (.json or .zip)"})]})})]}),a.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:a.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[a.jsx(xn,{className:"w-4 h-4 text-blue-500 dark:text-blue-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"text-blue-700 dark:text-blue-200",children:[a.jsx("p",{className:"font-medium mb-1",children:"How duplicate handling works:"}),a.jsxs("ul",{className:"text-blue-600 dark:text-blue-200/80 space-y-1 text-xs",children:[a.jsxs("li",{children:[a.jsx("strong",{children:"Printers"})," - matched by serial number"]}),a.jsxs("li",{children:[a.jsx("strong",{children:"Smart Plugs"})," - matched by IP address"]}),a.jsxs("li",{children:[a.jsx("strong",{children:"Notification Providers"})," - matched by name"]}),a.jsxs("li",{children:[a.jsx("strong",{children:"Filaments"})," - matched by name + type + brand"]}),a.jsxs("li",{children:[a.jsx("strong",{children:"Archives"})," - matched by content hash (always skipped)"]}),a.jsxs("li",{children:[a.jsx("strong",{children:"Pending Uploads"})," - matched by filename"]}),a.jsxs("li",{children:[a.jsx("strong",{children:"Settings & Templates"})," - always overwritten"]})]})]})]})}),a.jsx("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsxs("p",{className:"text-white font-medium flex items-center gap-2",children:[s?a.jsx(vr,{className:"w-4 h-4 text-orange-400"}):a.jsx(x0,{className:"w-4 h-4 text-bambu-gray"}),s?"Replace existing data":"Keep existing data"]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:s?"Overwrite items that already exist with backup data":"Only restore items that don't already exist"})]}),a.jsx(Sn,{checked:s,onChange:o})]})}),s&&a.jsx("div",{className:"p-3 rounded-lg bg-orange-500/10 border border-orange-500/30",children:a.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[a.jsx(xn,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"text-orange-700 dark:text-orange-200",children:[a.jsx("span",{className:"font-medium",children:"Caution:"})," Overwriting will replace your current configurations with data from the backup. Printer access codes are never overwritten for security."]})]})})]}),a.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Te,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsxs(Te,{type:"button",onClick:y,disabled:!l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[a.jsx(fi,{className:"w-4 h-4 mr-2"}),"Restore"]})]})]}),r==="restoring"&&a.jsxs("div",{className:"p-8 flex flex-col items-center gap-4",children:[a.jsx(ut,{className:"w-12 h-12 text-bambu-green animate-spin"}),a.jsx("p",{className:"text-bambu-gray",children:"Processing backup file..."})]}),r==="result"&&u&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"p-4 space-y-4 max-h-[400px] overflow-y-auto",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{className:"p-3 rounded-lg bg-bambu-green/10 border border-bambu-green/30",children:[a.jsx("div",{className:"text-2xl font-bold text-bambu-green",children:N}),a.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Restored"})]}),a.jsxs("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[a.jsx("div",{className:"text-2xl font-bold text-yellow-500",children:S}),a.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Skipped"})]})]}),u.restored&&Object.entries(u.restored).some(([,T])=>T>0)&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[a.jsx(Fn,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),a.jsxs("div",{className:"space-y-1",children:[Object.entries(u.restored).filter(([,T])=>T>0).map(([T,E])=>a.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[a.jsx("span",{className:"text-white",children:eq[T]||T}),a.jsx("span",{className:"text-bambu-green font-medium",children:E})]},T)),(u.files_restored||0)>0&&a.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[a.jsx("span",{className:"text-white",children:"Files (3MF, thumbnails, etc.)"}),a.jsx("span",{className:"text-bambu-green font-medium",children:u.files_restored})]})]})]}),u.skipped&&Object.entries(u.skipped).some(([,T])=>T>0)&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[a.jsx(x0,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),a.jsx("div",{className:"space-y-1",children:Object.entries(u.skipped).filter(([,T])=>T>0).map(([T,E])=>{const k=u.skipped_details?.[T]||[],C=f.has(T);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>k.length>0&&v(T),className:`w-full flex items-center justify-between text-sm p-2 rounded bg-bambu-dark ${k.length>0?"hover:bg-bambu-dark-tertiary cursor-pointer":""}`,children:[a.jsxs("span",{className:"text-white flex items-center gap-2",children:[eq[T]||T,k.length>0&&(C?a.jsx(ou,{className:"w-3 h-3"}):a.jsx(Br,{className:"w-3 h-3"}))]}),a.jsx("span",{className:"text-yellow-500 font-medium",children:E})]}),C&&k.length>0&&a.jsxs("div",{className:"mt-1 ml-4 p-2 rounded bg-bambu-dark-tertiary text-xs text-bambu-gray space-y-1",children:[k.slice(0,10).map((D,A)=>a.jsx("div",{children:D},A)),k.length>10&&a.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",k.length-10," more"]})]})]},T)})})]}),u.new_api_keys&&u.new_api_keys.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[a.jsx(xn,{className:"w-4 h-4 text-orange-500"}),"New API Keys Generated"]}),a.jsxs("div",{className:"p-3 rounded bg-orange-500/10 border border-orange-500/30",children:[a.jsx("p",{className:"text-xs text-orange-200 mb-2",children:"These keys are only shown once. Copy them now!"}),a.jsx("div",{className:"space-y-2",children:u.new_api_keys.map((T,E)=>a.jsxs("div",{className:"p-2 rounded bg-bambu-dark",children:[a.jsx("div",{className:"text-sm text-white font-medium mb-1",children:T.name}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("code",{className:"text-xs text-bambu-green bg-bambu-dark-tertiary px-2 py-1 rounded font-mono flex-1 break-all",children:T.key}),a.jsx("button",{onClick:()=>navigator.clipboard.writeText(T.key),className:"text-xs text-bambu-gray hover:text-white px-2 py-1 rounded bg-bambu-dark-tertiary",children:"Copy"})]})]},E))})]})]}),N===0&&S===0&&a.jsx("div",{className:"p-4 text-center text-bambu-gray",children:"No data was found to restore in the backup file."})]}),a.jsx("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:a.jsx(Te,{onClick:b,children:"Close"})})]})]})})})}function tq({status:t}){if(!t)return null;const e={success:"bg-green-500/20 text-green-400",failed:"bg-red-500/20 text-red-400",skipped:"bg-yellow-500/20 text-yellow-400",running:"bg-blue-500/20 text-blue-400"},n={success:a.jsx(Fn,{className:"w-3 h-3"}),failed:a.jsx(aa,{className:"w-3 h-3"}),skipped:a.jsx(x0,{className:"w-3 h-3"}),running:a.jsx(ut,{className:"w-3 h-3 animate-spin"})};return a.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium ${e[t]||"bg-gray-500/20 text-gray-400"}`,children:[n[t],t.charAt(0).toUpperCase()+t.slice(1)]})}function vKe(t){return t?new Date(t).toLocaleString():"-"}function nq(t){if(!t)return"-";const e=new Date(t),n=new Date,r=e.getTime()-n.getTime(),i=Math.round(r/6e4);if(i<0){const s=Math.abs(i);if(s<60)return`${s}m ago`;const o=Math.floor(s/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}else{if(i<60)return`in ${i}m`;const s=Math.floor(i/60);return s<24?`in ${s}h`:`in ${Math.floor(s/24)}d`}}function _Ke(){const t=an(),{showToast:e}=Gn(),[n,r]=w.useState(""),[i,s]=w.useState(""),[o,l]=w.useState("main"),[c,u]=w.useState(!1),[d,f]=w.useState("daily"),[m,g]=w.useState(!0),[x,y]=w.useState(!0),[b,v]=w.useState(!1),[N,S]=w.useState(!0),[T,E]=w.useState(!1),[k,C]=w.useState(!1),[D,A]=w.useState(!1),[R,F]=w.useState(null),O=w.useRef(null),q=w.useRef(!1),{data:j,isLoading:G}=ct({queryKey:["github-backup-config"],queryFn:he.getGitHubBackupConfig}),{data:Y}=ct({queryKey:["github-backup-status"],queryFn:he.getGitHubBackupStatus,refetchInterval:re=>re.state.data?.is_running?500:1e4}),{data:K}=ct({queryKey:["github-backup-logs"],queryFn:()=>he.getGitHubBackupLogs(20)}),{data:Z}=ct({queryKey:["cloud-status"],queryFn:he.getCloudStatus}),{data:te}=ct({queryKey:["printers"],queryFn:he.getPrinters}),ne=eW({queries:(te??[]).map(re=>({queryKey:["printerStatus",re.id],queryFn:()=>he.getPrinterStatus(re.id),staleTime:1e4,refetchInterval:3e4}))}),z=(te??[]).map((re,He)=>({printer:re,connected:ne[He]?.data?.connected??!1})),W=z.length,se=z.filter(re=>re.connected).length,ae=W>0&&se===0,de=se>0&&se<W;w.useEffect(()=>{j&&(r(j.repository_url),l(j.branch),u(j.schedule_enabled),f(j.schedule_type),g(j.backup_kprofiles),y(j.backup_cloud_profiles),v(j.backup_settings),S(j.enabled),s(""),setTimeout(()=>{q.current=!0},100))},[j]);const me=w.useCallback(async(re=!1)=>{if(j?.has_token)try{re&&i?(await he.saveGitHubBackupConfig({repository_url:n,access_token:i,branch:o,schedule_enabled:c,schedule_type:d,backup_kprofiles:m,backup_cloud_profiles:x,backup_settings:b,enabled:N}),s(""),e("Token updated")):(await he.updateGitHubBackupConfig({repository_url:n,branch:o,schedule_enabled:c,schedule_type:d,backup_kprofiles:m,backup_cloud_profiles:x,backup_settings:b,enabled:N}),e("Settings saved")),t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]})}catch(He){e(`Failed to save: ${He.message}`,"error")}},[j?.has_token,n,i,o,c,d,m,x,b,N,t,e]);w.useEffect(()=>{if(!(!q.current||!j?.has_token))return O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{me(!1)},500),()=>{O.current&&clearTimeout(O.current)}},[n,o,c,d,m,x,b,N,me,j?.has_token]),w.useEffect(()=>{if(!(!q.current||!j?.has_token||!i))return O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{me(!0)},1e3),()=>{O.current&&clearTimeout(O.current)}},[i,me,j?.has_token]);const xe=ht({mutationFn:re=>he.saveGitHubBackupConfig(re),onSuccess:()=>{t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]}),e("GitHub backup enabled"),s(""),q.current=!0},onError:re=>{e(`Failed to save: ${re.message}`,"error")}}),be=ht({mutationFn:he.triggerGitHubBackup,onSuccess:re=>{t.invalidateQueries({queryKey:["github-backup-status"]}),t.invalidateQueries({queryKey:["github-backup-logs"]}),re.success?re.files_changed>0?e(`Backup complete - ${re.files_changed} files updated`):e("Backup skipped - no changes"):e(`Backup failed: ${re.message}`,"error")},onError:re=>{e(`Backup failed: ${re.message}`,"error")}}),fe=ht({mutationFn:()=>he.clearGitHubBackupLogs(0),onSuccess:re=>{t.invalidateQueries({queryKey:["github-backup-logs"]}),e(`Cleared ${re.deleted} logs`)},onError:re=>{e(`Failed to clear logs: ${re.message}`,"error")}}),Ce=async()=>{A(!0),F(null);try{let re;if(i){if(!n){e("Enter repository URL","error"),A(!1);return}re=await he.testGitHubConnection(n,i)}else if(j?.has_token)re=await he.testGitHubStoredConnection();else{e("Enter repository URL and access token","error"),A(!1);return}F({success:re.success,message:re.message})}catch(re){F({success:!1,message:re.message})}finally{A(!1)}},Ne=()=>{if(!n){e("Repository URL is required","error");return}if(!i){e("Access token is required","error");return}xe.mutate({repository_url:n,access_token:i,branch:o,schedule_enabled:c,schedule_type:d,backup_kprofiles:m,backup_cloud_profiles:x,backup_settings:b,enabled:N})};return G?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(ut,{className:"w-8 h-8 animate-spin text-bambu-green"})}):a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"space-y-6",children:[a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qj,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"GitHub Backup"})]}),j&&Z?.is_authenticated&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Enabled"}),a.jsx(Sn,{checked:N,onChange:S})]})]})}),a.jsx(St,{className:"space-y-4",children:Z?.is_authenticated?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically sync your profiles to a private GitHub repository for backup and version history."}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Repository URL"}),a.jsx("input",{type:"text",value:n,onChange:re=>{r(re.target.value),F(null)},placeholder:"https://github.com/username/bambuddy-backup",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:["Personal Access Token ",j?.has_token&&a.jsx("span",{className:"text-green-400",children:"(saved)"})]}),a.jsx("input",{type:"password",value:i,onChange:re=>{s(re.target.value),F(null)},placeholder:j?.has_token?"Enter new token to update":"ghp_xxxxxxxxxxxx",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Fine-grained token with Contents read/write permission"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Branch"}),a.jsx("input",{type:"text",value:o,onChange:re=>l(re.target.value),placeholder:"main",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Auto-backup"}),a.jsxs("select",{value:c?d:"disabled",onChange:re=>{re.target.value==="disabled"?u(!1):(u(!0),f(re.target.value))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"disabled",children:"Manual only"}),a.jsx("option",{value:"hourly",children:"Hourly"}),a.jsx("option",{value:"daily",children:"Daily"}),a.jsx("option",{value:"weekly",children:"Weekly"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Include in backup"}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("label",{className:`flex items-start gap-2 ${ae?"cursor-not-allowed opacity-60":"cursor-pointer"}`,children:[a.jsx("input",{type:"checkbox",checked:m,onChange:re=>g(re.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green",disabled:ae}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`text-sm ${ae?"text-bambu-gray":"text-white"}`,children:"K-Profiles"}),ae&&a.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:[a.jsx(xn,{className:"w-3 h-3"}),"No printers connected"]}),de&&a.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:[a.jsx(xn,{className:"w-3 h-3"}),se,"/",W," connected"]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Pressure advance calibration from connected printers"})]})]}),a.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:x,onChange:re=>y(re.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green",disabled:!Z?.is_authenticated}),a.jsxs("div",{children:[a.jsx("span",{className:`text-sm ${Z?.is_authenticated?"text-white":"text-bambu-gray"}`,children:"Cloud Profiles"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament, printer, and process presets from Bambu Cloud"})]})]}),a.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:b,onChange:re=>v(re.target.checked),className:"w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white text-sm",children:"App Settings"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Bambuddy configuration (excludes sensitive data)"})]})]})]})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 space-y-3",children:[Y?.configured&&a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("div",{className:"flex items-center gap-2 text-bambu-gray",children:Y.last_backup_at?a.jsxs(a.Fragment,{children:[a.jsxs("span",{children:["Last backup: ",nq(Y.last_backup_at)]}),a.jsx(tq,{status:Y.last_backup_status})]}):a.jsx("span",{children:"No backups yet"})}),Y.next_scheduled_run&&a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx(qn,{className:"w-3 h-3 inline mr-1"}),"Next: ",nq(Y.next_scheduled_run)]})]}),R&&a.jsxs("div",{className:`text-sm flex items-center gap-1 ${R.success?"text-green-400":"text-red-400"}`,children:[R.success?a.jsx(Fn,{className:"w-4 h-4"}):a.jsx(aa,{className:"w-4 h-4"}),R.message]}),a.jsx("div",{className:"flex flex-wrap items-center gap-2",children:Y?.configured?a.jsx(a.Fragment,{children:be.isPending||Y.is_running?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-green",children:[a.jsx(ut,{className:"w-4 h-4 animate-spin"}),a.jsx("span",{className:"text-sm",children:Y.progress||"Starting backup..."})]}):a.jsxs(a.Fragment,{children:[a.jsxs(Te,{variant:"primary",size:"sm",onClick:()=>be.mutate(),disabled:!j?.enabled,children:[a.jsx(vs,{className:"w-4 h-4"}),"Backup Now"]}),a.jsxs(Te,{variant:"secondary",size:"sm",onClick:Ce,disabled:D,children:[D?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(vr,{className:"w-4 h-4"}),"Test"]})]})}):a.jsxs(a.Fragment,{children:[a.jsxs(Te,{variant:"primary",size:"sm",onClick:Ne,disabled:xe.isPending||!n||!i,children:[xe.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(Fn,{className:"w-4 h-4"}),"Enable Backup"]}),a.jsxs(Te,{variant:"secondary",size:"sm",onClick:Ce,disabled:D||!n||!i,children:[D?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(vr,{className:"w-4 h-4"}),"Test Connection"]})]})})]})]}):a.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[a.jsx(xn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-sm text-yellow-400",children:"Bambu Cloud login required. Sign in under Profiles → Cloud Profiles to enable GitHub backup."})]})})]}),K&&K.length>0&&a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(g0,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"History"})]}),a.jsxs(Te,{variant:"ghost",size:"sm",onClick:()=>fe.mutate(),disabled:fe.isPending,children:[a.jsx(on,{className:"w-4 h-4"}),"Clear"]})]})}),a.jsx(St,{children:a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-bambu-gray border-b border-bambu-dark-tertiary",children:[a.jsx("th",{className:"text-left py-2 px-2",children:"Date"}),a.jsx("th",{className:"text-left py-2 px-2",children:"Status"}),a.jsx("th",{className:"text-left py-2 px-2",children:"Commit"})]})}),a.jsx("tbody",{children:K.slice(0,10).map(re=>a.jsxs("tr",{className:"border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-secondary",children:[a.jsx("td",{className:"py-2 px-2 text-white",children:vKe(re.started_at)}),a.jsx("td",{className:"py-2 px-2",children:a.jsx(tq,{status:re.status})}),a.jsx("td",{className:"py-2 px-2",children:re.commit_sha?a.jsxs("a",{href:`${j?.repository_url}/commit/${re.commit_sha}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline inline-flex items-center gap-1",children:[re.commit_sha.substring(0,7),a.jsx($r,{className:"w-3 h-3"})]}):a.jsx("span",{className:"text-bambu-gray",children:"-"})})]},re.id))})]})})})]})]}),a.jsx("div",{className:"space-y-6",children:a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Zc,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Local Backup"})]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Export or import your Bambuddy data as a local file for manual backup or migration."}),a.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Export Data"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Download all settings, printers, and profiles"})]}),a.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>E(!0),children:[a.jsx(Gr,{className:"w-4 h-4"}),"Export"]})]}),a.jsxs("div",{className:"flex items-center justify-between py-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Import Backup"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Restore from a previous export file"})]}),a.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>C(!0),children:[a.jsx(fi,{className:"w-4 h-4"}),"Import"]})]})]})]})}),T&&a.jsx(bKe,{onClose:()=>E(!1),onExport:async re=>{E(!1);try{const{blob:He,filename:H}=await he.exportBackup(re),B=URL.createObjectURL(He),X=document.createElement("a");X.href=B,X.download=H,X.click(),URL.revokeObjectURL(B),e("Backup downloaded successfully")}catch{e("Failed to create backup","error")}}}),k&&a.jsx(yKe,{onClose:()=>C(!1),onRestore:async(re,He)=>await he.importBackup(re,He),onSuccess:()=>{C(!1),e("Backup restored successfully"),t.invalidateQueries()}})]})}const wKe={get:"bg-blue-500/20 text-blue-400 border-blue-500/30",post:"bg-green-500/20 text-green-400 border-green-500/30",put:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",patch:"bg-orange-500/20 text-orange-400 border-orange-500/30",delete:"bg-red-500/20 text-red-400 border-red-500/30"};function SKe(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function Ub(t,e,n=0){if(n>5)return"...";if(e.$ref)return Ub(t,SKe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const s=Ub(t,i,n+1);typeof s=="object"&&s!==null&&Object.assign(r,s)}return r}if(e.example!==void 0)return e.example;if(e.default!==void 0)return e.default;switch(e.type){case"string":return e.enum?e.enum[0]:"string";case"integer":case"number":return 0;case"boolean":return!1;case"array":return e.items?[Ub(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,s]of Object.entries(e.properties))r[i]=Ub(t,s,n+1);return r}return{};default:return null}}function NKe({path:t,method:e,spec:n,schema:r,apiKey:i}){const[s,o]=w.useState(!1),[l,c]=w.useState({}),[u,d]=w.useState(""),[f,m]=w.useState(null),[g,x]=w.useState(!1),[y,b]=w.useState(!1);w.useEffect(()=>{if(s&&n.parameters){const D={};for(const A of n.parameters)A.schema?.default!==void 0&&(D[A.name]=String(A.schema.default));c(A=>({...D,...A}))}},[s,n.parameters]),w.useEffect(()=>{if(s&&n.requestBody?.content?.["application/json"]?.schema&&!u){const D=n.requestBody.content["application/json"].schema,A=Ub(r,D);d(JSON.stringify(A,null,2))}},[s,n.requestBody,r,u]);const N=(()=>{const D=[];for(const A of n.parameters||[])if(A.in==="path"||A.required){const R=l[A.name];(R===void 0||R==="")&&D.push(A.name)}return D})(),S=async()=>{if(N.length>0){m({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${N.join(", ")}`,duration:0});return}x(!0),m(null);try{let D=t;const A=new URLSearchParams;for(const ne of n.parameters||[]){const z=l[ne.name];z!==void 0&&z!==""&&(ne.in==="path"?D=D.replace(`{${ne.name}}`,encodeURIComponent(z)):ne.in==="query"&&A.append(ne.name,z))}const R=A.toString(),F=`${D}${R?`?${R}`:""}`,O={"Content-Type":"application/json"};i&&(O["X-API-Key"]=i);const q={method:e.toUpperCase(),headers:O};["post","put","patch"].includes(e)&&u&&(q.body=u);const j=performance.now(),G=await fetch(F,q),Y=Math.round(performance.now()-j),K={};G.headers.forEach((ne,z)=>{K[z]=ne});let Z;G.headers.get("content-type")?.includes("application/json")?Z=await G.json():Z=await G.text(),m({status:G.status,statusText:G.statusText,headers:K,body:Z,duration:Y})}catch(D){m({status:0,statusText:"Network Error",headers:{},body:D instanceof Error?D.message:"Unknown error",duration:0})}finally{x(!1)}},T=async()=>{if(f){const D=typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2);try{await navigator.clipboard.writeText(D),b(!0),setTimeout(()=>b(!1),2e3)}catch{const A=document.createElement("textarea");A.value=D,A.style.position="fixed",A.style.left="-999999px",document.body.appendChild(A),A.select(),document.execCommand("copy"),document.body.removeChild(A),b(!0),setTimeout(()=>b(!1),2e3)}}},E=(n.parameters||[]).filter(D=>D.in==="path"),k=(n.parameters||[]).filter(D=>D.in==="query"),C=["post","put","patch"].includes(e)&&n.requestBody;return a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>o(!s),className:"w-full flex items-center gap-3 p-3 hover:bg-bambu-dark-tertiary/50 transition-colors text-left",children:[s?a.jsx(Br,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):a.jsx(Ms,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${wKe[e]||"bg-gray-500/20 text-gray-400"}`,children:e}),a.jsx("code",{className:"text-sm text-white font-mono flex-1 truncate",children:t}),n.summary&&a.jsx("span",{className:"text-sm text-bambu-gray truncate max-w-[40%]",children:n.summary})]}),s&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary p-4 space-y-4 bg-bambu-dark/50",children:[n.description&&a.jsx("p",{className:"text-sm text-bambu-gray",children:n.description}),E.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:"Path Parameters"}),a.jsx("div",{className:"space-y-2",children:E.map(D=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[D.name,D.required&&a.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),a.jsx("input",{type:"text",value:l[D.name]||"",onChange:A=>c(R=>({...R,[D.name]:A.target.value})),placeholder:D.description||D.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},D.name))})]}),k.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:"Query Parameters"}),a.jsx("div",{className:"space-y-2",children:k.map(D=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[D.name,D.required&&a.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),D.schema?.enum?a.jsxs("select",{value:l[D.name]||"",onChange:A=>c(R=>({...R,[D.name]:A.target.value})),className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"-- Select --"}),D.schema.enum.map(A=>a.jsx("option",{value:A,children:A},A))]}):a.jsx("input",{type:"text",value:l[D.name]||"",onChange:A=>c(R=>({...R,[D.name]:A.target.value})),placeholder:D.description||D.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},D.name))})]}),C&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-sm font-medium text-white",children:"Request Body"}),a.jsx("textarea",{value:u,onChange:D=>d(D.target.value),rows:8,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono focus:border-bambu-green focus:outline-none resize-y",placeholder:"JSON request body..."})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Te,{onClick:S,disabled:g,children:[g?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(vs,{className:"w-4 h-4"}),"Execute"]}),N.length>0&&a.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[a.jsx(Ei,{className:"w-3 h-3"}),"Fill in: ",N.join(", ")]})]}),f&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h4",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Response",a.jsxs("span",{className:`px-2 py-0.5 text-xs rounded ${f.status>=200&&f.status<300?"bg-green-500/20 text-green-400":f.status>=400?"bg-red-500/20 text-red-400":"bg-yellow-500/20 text-yellow-400"}`,children:[f.status," ",f.statusText]}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[f.duration,"ms"]})]}),a.jsx(Te,{variant:"secondary",size:"sm",onClick:T,children:y?a.jsx(Fn,{className:"w-3 h-3 text-green-400"}):a.jsx(ll,{className:"w-3 h-3"})})]}),a.jsx("pre",{className:"p-3 bg-bambu-dark rounded-lg text-sm font-mono text-white overflow-auto max-h-96 border border-bambu-dark-tertiary",children:typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2)})]})]})]})}function MKe({apiKey:t=""}){const[e,n]=w.useState(null),[r,i]=w.useState(!0),[s,o]=w.useState(null),[l,c]=w.useState(new Set),[u,d]=w.useState("");if(w.useEffect(()=>{async function b(){try{const v=await fetch("/openapi.json");if(!v.ok)throw new Error("Failed to fetch OpenAPI schema");const N=await v.json();n(N)}catch(v){o(v instanceof Error?v.message:"Unknown error")}finally{i(!1)}}b()},[]),r)return a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(ut,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(s||!e)return a.jsx(_t,{children:a.jsx(St,{className:"py-8",children:a.jsxs("div",{className:"text-center text-red-400",children:[a.jsx(Ei,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),a.jsx("p",{children:"Failed to load API schema"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:s})]})})});const f={};for(const[b,v]of Object.entries(e.paths))for(const[N,S]of Object.entries(v)){if(N==="parameters")continue;const T=S.tags||["Other"];for(const E of T)f[E]||(f[E]=[]),f[E].push({path:b,method:N,spec:S})}const m=Object.entries(f).map(([b,v])=>{if(!u)return{tag:b,endpoints:v};const N=v.filter(({path:S,method:T,spec:E})=>{const k=u.toLowerCase();return S.toLowerCase().includes(k)||T.toLowerCase().includes(k)||(E.summary?.toLowerCase()||"").includes(k)||(E.description?.toLowerCase()||"").includes(k)});return{tag:b,endpoints:N}}).filter(({endpoints:b})=>b.length>0).sort((b,v)=>b.tag.localeCompare(v.tag)),g=b=>{c(v=>{const N=new Set(v);return N.has(b)?N.delete(b):N.add(b),N})},x=()=>{c(new Set(m.map(b=>b.tag)))},y=()=>{c(new Set)};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsx("div",{className:"flex-1",children:a.jsx("input",{type:"text",value:u,onChange:b=>d(b.target.value),placeholder:"Search endpoints...",className:"w-full max-w-md px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Te,{variant:"secondary",size:"sm",onClick:x,children:"Expand All"}),a.jsx(Te,{variant:"secondary",size:"sm",onClick:y,children:"Collapse All"}),a.jsxs("a",{href:"/docs",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-sm text-bambu-green hover:underline",children:[a.jsx($r,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[m.reduce((b,v)=>b+v.endpoints.length,0)," endpoints in ",m.length," categories"]}),a.jsx("div",{className:"space-y-3",children:m.map(({tag:b,endpoints:v})=>a.jsxs(_t,{children:[a.jsx("button",{onClick:()=>g(b),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/30 transition-colors text-left",children:a.jsxs("div",{className:"flex items-center gap-2",children:[l.has(b)?a.jsx(Br,{className:"w-5 h-5 text-bambu-gray"}):a.jsx(Ms,{className:"w-5 h-5 text-bambu-gray"}),a.jsx("h3",{className:"text-base font-semibold text-white capitalize",children:b.replace(/-/g," ")}),a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-2 py-0.5 rounded-full text-bambu-gray",children:v.length})]})}),l.has(b)&&a.jsx(St,{className:"pt-0 space-y-2",children:v.map(({path:N,method:S,spec:T})=>a.jsx(NKe,{path:N,method:S,spec:T,schema:e,apiKey:t},`${S}-${N}`))})]},b))})]})}const EKe=["general","network","plugs","notifications","filament","apikeys","virtual-printer","users","backup"];function TKe(){const t=an(),e=fl(),[n,r]=Lq(),{t:i,i18n:s}=Fg(),{showToast:o}=Gn(),{authEnabled:l,user:c,refreshAuth:u}=ch(),{mode:d,darkStyle:f,darkBackground:m,darkAccent:g,lightStyle:x,lightBackground:y,lightAccent:b,setDarkStyle:v,setDarkBackground:N,setDarkAccent:S,setLightStyle:T,setLightBackground:E,setLightAccent:k}=lh(),[C,D]=w.useState(null),[A,R]=w.useState(!1),[F,O]=w.useState(null),[q,j]=w.useState(!1),[G,Y]=w.useState(null),[K,Z]=w.useState(null),[te,ne]=w.useState(!1),[z,W]=w.useState(SW()),se=n.get("tab"),ae=se&&EKe.includes(se)?se:"general",[de,me]=w.useState(ae),xe=we=>{me(we),we==="general"?n.delete("tab"):n.set("tab",we),r(n,{replace:!0})},[be,fe]=w.useState(!1),[Ce,Ne]=w.useState(""),[re,He]=w.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[H,B]=w.useState(null),[X,U]=w.useState(null),[Q,le]=w.useState(""),[Pe,Oe]=w.useState(!1),[je,$]=w.useState(!1),[I,V]=w.useState(null),[ie,Se]=w.useState(!1),[ye,$e]=w.useState(!1),[Ue,Ge]=w.useState(null),[We,Ye]=w.useState(!1),[oe,ve]=w.useState({}),[Le,Ke]=w.useState({}),lt=we=>{W(we),Tfe(we)},_e=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:ce,isLoading:ee}=ct({queryKey:["settings"],queryFn:he.getSettings}),{data:ke,isLoading:De}=ct({queryKey:["smart-plugs"],queryFn:he.getSmartPlugs}),{data:Ae,isLoading:Je}=ct({queryKey:["smart-plugs-energy",ke?.map(we=>we.id)],queryFn:async()=>{if(!ke||ke.length===0)return null;const we=await Promise.all(ke.filter(dt=>dt.enabled).map(async dt=>{try{const Kt=await he.getSmartPlugStatus(dt.id);return{plug:dt,status:Kt}}catch{return{plug:dt,status:null}}}));let bt=0,$t=0,Be=0,Et=0,Wt=0;for(const{plug:dt,status:Kt}of we){const sn=dt.plug_type==="mqtt"&&Kt?.energy?.power!=null;(Kt?.reachable||sn)&&Kt?.energy&&(Wt++,Kt.energy?.power!=null&&(bt+=Kt.energy.power),Kt.energy?.today!=null&&($t+=Kt.energy.today),Kt.energy?.yesterday!=null&&(Be+=Kt.energy.yesterday),Kt.energy?.total!=null&&(Et+=Kt.energy.total))}return{totalPower:bt,totalToday:$t,totalYesterday:Be,totalLifetime:Et,reachableCount:Wt,totalPlugs:ke.filter(dt=>dt.enabled).length}},enabled:de==="plugs"&&!!ke&&ke.length>0,refetchInterval:de==="plugs"?1e4:!1}),{data:gt,isLoading:At}=ct({queryKey:["notification-providers"],queryFn:he.getNotificationProviders}),{data:jt,isLoading:ln}=ct({queryKey:["api-keys"],queryFn:he.getAPIKeys}),Lt=ht({mutationFn:we=>he.createAPIKey(we),onSuccess:we=>{B(we.key||null),fe(!1),Ne(""),t.invalidateQueries({queryKey:["api-keys"]}),o("API key created")},onError:we=>{o(`Failed to create API key: ${we.message}`,"error")}}),Cn=ht({mutationFn:we=>he.deleteAPIKey(we),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),o("API key deleted")},onError:we=>{o(`Failed to delete API key: ${we.message}`,"error")}}),{data:en}=ct({queryKey:["printers"],queryFn:he.getPrinters}),{data:er,isLoading:ur}=ct({queryKey:["notification-templates"],queryFn:he.getNotificationTemplates}),{data:Un}=ct({queryKey:["virtual-printer-settings"],queryFn:H1.getSettings,refetchInterval:1e4}),wr=Un?.status?.running??!1,{data:jr}=ct({queryKey:["ffmpeg-status"],queryFn:he.checkFfmpeg}),{data:Zn}=ct({queryKey:["version"],queryFn:he.getVersion}),{data:Xt,refetch:zn,isRefetching:Wn}=ct({queryKey:["updateCheck"],queryFn:he.checkForUpdates,staleTime:300*1e3}),{data:Zr,refetch:Ee}=ct({queryKey:["updateStatus"],queryFn:he.getUpdateStatus,refetchInterval:we=>{const bt=we.state.data;return bt?.status==="downloading"||bt?.status==="installing"?1e3:!1}}),{data:Xe}=ct({queryKey:["mqtt-status"],queryFn:he.getMQTTStatus,refetchInterval:de==="network"?5e3:!1}),{data:it}=ct({queryKey:["github-backup-status"],queryFn:he.getGitHubBackupStatus}),{data:st}=ct({queryKey:["cloud-status"],queryFn:he.getCloudStatus}),et=ht({mutationFn:he.applyUpdate,onSuccess:we=>{we.is_docker?o(we.message,"error"):Ee()}}),[Ct,ue]=w.useState(null),ge=ht({mutationFn:he.testAllNotificationProviders,onSuccess:we=>{ue(we),t.invalidateQueries({queryKey:["notification-providers"]}),we.failed===0?o(`All ${we.tested} providers tested successfully!`,"success"):o(`${we.success}/${we.tested} providers succeeded`,we.failed>0?"error":"success")},onError:we=>{o(`Failed to test providers: ${we.message}`,"error")}}),Fe=ht({mutationFn:async we=>{if(!ke)return{success:0,failed:0};const bt=ke.filter(Be=>Be.enabled),$t=await Promise.all(bt.map(async Be=>{try{return await he.controlSmartPlug(Be.id,we),{success:!0}}catch{return{success:!1}}}));return{success:$t.filter(Be=>Be.success).length,failed:$t.filter(Be=>!Be.success).length}},onSuccess:(we,bt)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),we.failed===0?o(`All ${we.success} plugs turned ${bt}`,"success"):o(`${we.success} plugs turned ${bt}, ${we.failed} failed`,"error")},onError:we=>{o(`Failed: ${we.message}`,"error")}}),Ie=w.useRef(null),Me=w.useRef(!1),mt=w.useRef(!0);w.useEffect(()=>{if(ce&&!C){const we={...ce,external_url:ce.external_url||window.location.origin};D(we),setTimeout(()=>{mt.current=!1},100)}},[ce,C]);const wt=ht({mutationFn:he.updateSettings,onSuccess:we=>{t.setQueryData(["settings"],we),D(we),t.invalidateQueries({queryKey:["archiveStats"]}),o("Settings saved","success")},onError:we=>{o(`Failed to save: ${we.message}`,"error")},onSettled:()=>{Me.current=!1}}),kt=ht({mutationFn:({id:we,data:bt})=>he.updatePrinter(we,bt),onSuccess:()=>{t.invalidateQueries({queryKey:["printers"]}),o("Camera settings saved","success")},onError:we=>{o(`Failed to update printer: ${we.message}`,"error")}});w.useEffect(()=>{if(!(mt.current||!C||!ce||!(ce.auto_archive!==C.auto_archive||ce.save_thumbnails!==C.save_thumbnails||ce.capture_finish_photo!==C.capture_finish_photo||ce.default_filament_cost!==C.default_filament_cost||ce.currency!==C.currency||ce.energy_cost_per_kwh!==C.energy_cost_per_kwh||ce.energy_tracking_mode!==C.energy_tracking_mode||ce.check_updates!==C.check_updates||(ce.check_printer_firmware??!0)!==(C.check_printer_firmware??!0)||ce.notification_language!==C.notification_language||ce.ams_humidity_good!==C.ams_humidity_good||ce.ams_humidity_fair!==C.ams_humidity_fair||ce.ams_temp_good!==C.ams_temp_good||ce.ams_temp_fair!==C.ams_temp_fair||ce.ams_history_retention_days!==C.ams_history_retention_days||ce.per_printer_mapping_expanded!==C.per_printer_mapping_expanded||ce.date_format!==C.date_format||ce.time_format!==C.time_format||ce.default_printer_id!==C.default_printer_id||ce.ftp_retry_enabled!==C.ftp_retry_enabled||ce.ftp_retry_count!==C.ftp_retry_count||ce.ftp_retry_delay!==C.ftp_retry_delay||ce.ftp_timeout!==C.ftp_timeout||ce.mqtt_enabled!==C.mqtt_enabled||ce.mqtt_broker!==C.mqtt_broker||ce.mqtt_port!==C.mqtt_port||ce.mqtt_username!==C.mqtt_username||ce.mqtt_password!==C.mqtt_password||ce.mqtt_topic_prefix!==C.mqtt_topic_prefix||ce.mqtt_use_tls!==C.mqtt_use_tls||ce.external_url!==C.external_url||ce.ha_enabled!==C.ha_enabled||ce.ha_url!==C.ha_url||ce.ha_token!==C.ha_token||(ce.library_archive_mode??"ask")!==(C.library_archive_mode??"ask")||Number(ce.library_disk_warning_gb??5)!==Number(C.library_disk_warning_gb??5)||(ce.camera_view_mode??"window")!==(C.camera_view_mode??"window")||ce.prometheus_enabled!==C.prometheus_enabled||ce.prometheus_token!==C.prometheus_token))&&!Me.current)return Ie.current&&clearTimeout(Ie.current),Ie.current=setTimeout(()=>{if(Me.current)return;Me.current=!0;const bt={auto_archive:C.auto_archive,save_thumbnails:C.save_thumbnails,capture_finish_photo:C.capture_finish_photo,default_filament_cost:C.default_filament_cost,currency:C.currency,energy_cost_per_kwh:C.energy_cost_per_kwh,energy_tracking_mode:C.energy_tracking_mode,check_updates:C.check_updates,check_printer_firmware:C.check_printer_firmware,notification_language:C.notification_language,ams_humidity_good:C.ams_humidity_good,ams_humidity_fair:C.ams_humidity_fair,ams_temp_good:C.ams_temp_good,ams_temp_fair:C.ams_temp_fair,ams_history_retention_days:C.ams_history_retention_days,per_printer_mapping_expanded:C.per_printer_mapping_expanded,date_format:C.date_format,time_format:C.time_format,default_printer_id:C.default_printer_id,ftp_retry_enabled:C.ftp_retry_enabled,ftp_retry_count:C.ftp_retry_count,ftp_retry_delay:C.ftp_retry_delay,ftp_timeout:C.ftp_timeout,mqtt_enabled:C.mqtt_enabled,mqtt_broker:C.mqtt_broker,mqtt_port:C.mqtt_port,mqtt_username:C.mqtt_username,mqtt_password:C.mqtt_password,mqtt_topic_prefix:C.mqtt_topic_prefix,mqtt_use_tls:C.mqtt_use_tls,external_url:C.external_url,ha_enabled:C.ha_enabled,ha_url:C.ha_url,ha_token:C.ha_token,library_archive_mode:C.library_archive_mode,library_disk_warning_gb:C.library_disk_warning_gb,camera_view_mode:C.camera_view_mode,prometheus_enabled:C.prometheus_enabled,prometheus_token:C.prometheus_token};wt.mutate(bt)},500),()=>{Ie.current&&clearTimeout(Ie.current)}},[C,ce,wt]);const pt=w.useCallback((we,bt)=>{D($t=>$t?{...$t,[we]:bt}:null)},[]),zt=async(we,bt,$t)=>{if(!bt){o("Please enter a camera URL","error");return}Ke(Be=>({...Be,[we]:!0})),ve(Be=>({...Be,[we]:null}));try{const Be=await he.testExternalCamera(we,bt,$t);ve(Et=>({...Et,[we]:Be})),Be.success?o(`Camera connected${Be.resolution?` (${Be.resolution})`:""}`,"success"):o(Be.error||"Connection failed","error")}catch(Be){const Et=Be instanceof Error?Be.message:"Test failed";ve(Wt=>({...Wt,[we]:{success:!1,error:Et}})),o(Et,"error")}finally{Ke(Be=>({...Be,[we]:!1}))}},[Pt,Mt]=w.useState({}),nn=w.useRef({}),Bt=w.useRef(new Set);w.useEffect(()=>{if(en){const we={};en.forEach(bt=>{bt.external_camera_url&&!Bt.current.has(bt.id)&&(we[bt.id]=bt.external_camera_url,Bt.current.add(bt.id))}),Object.keys(we).length>0&&Mt(bt=>({...bt,...we}))}},[en]);const tn=(we,bt)=>{Mt($t=>({...$t,[we]:bt})),nn.current[we]&&clearTimeout(nn.current[we]),nn.current[we]=setTimeout(()=>{kt.mutate({id:we,data:{external_camera_url:bt||null}})},800)},cn=(we,bt)=>{const $t={};bt.type!==void 0&&($t.external_camera_type=bt.type||null),bt.enabled!==void 0&&($t.external_camera_enabled=bt.enabled),kt.mutate({id:we,data:$t})};return ee||!C?a.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:a.jsx(ut,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),a.jsx("p",{className:"text-bambu-gray",children:"Configure Bambuddy"})]}),a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary overflow-x-auto",children:[a.jsx("button",{onClick:()=>xe("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${de==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:"General"}),a.jsxs("button",{onClick:()=>xe("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${de==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Ws,{className:"w-4 h-4"}),"Smart Plugs",ke&&ke.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ke.length})]}),a.jsxs("button",{onClick:()=>xe("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${de==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(gf,{className:"w-4 h-4"}),"Notifications",gt&>.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:gt.length})]}),a.jsxs("button",{onClick:()=>xe("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${de==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(due,{className:"w-4 h-4"}),"Filament"]}),a.jsxs("button",{onClick:()=>xe("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${de==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Wp,{className:"w-4 h-4"}),"Network",a.jsx("span",{className:`w-2 h-2 rounded-full ${Xe?.enabled?"bg-green-400":"bg-gray-500"}`})]}),a.jsxs("button",{onClick:()=>xe("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${de==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(of,{className:"w-4 h-4"}),"API Keys",jt&&jt.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:jt.length})]}),a.jsxs("button",{onClick:()=>xe("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${de==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Ar,{className:"w-4 h-4"}),"Virtual Printer",a.jsx("span",{className:`w-2 h-2 rounded-full ${wr?"bg-green-400":"bg-gray-500"}`})]}),a.jsxs("button",{onClick:()=>xe("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${de==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Nd,{className:"w-4 h-4"}),"Users",l&&a.jsx("span",{className:`w-2 h-2 rounded-full ${l?"bg-green-400":"bg-gray-500"}`})]}),a.jsxs("button",{onClick:()=>xe("backup"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${de==="backup"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Zc,{className:"w-4 h-4"}),"Backup",a.jsx("span",{className:`w-2 h-2 rounded-full ${st?.is_authenticated&&it?.configured&&it?.enabled?"bg-green-400":"bg-gray-500"}`})]})]}),de==="general"&&a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[a.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.general")})}),a.jsxs(St,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(Dd,{className:"w-4 h-4 inline mr-1"}),i("settings.language")]}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:s.language,onChange:we=>s.changeLanguage(we.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:ez.map(we=>a.jsxs("option",{value:we.code,children:[we.nativeName," (",we.name,")"]},we.code))}),a.jsx(Br,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.languageDescription")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.defaultView")}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:z,onChange:we=>lt(we.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:y0.map(we=>a.jsx("option",{value:we.to,children:i(we.labelKey)},we.id))}),a.jsx(Br,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.defaultViewDescription")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:C.date_format||"system",onChange:we=>pt("date_format",we.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"system",children:"System Default"}),a.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),a.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),a.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]}),a.jsx(Br,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:C.time_format||"system",onChange:we=>pt("time_format",we.target.value),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"system",children:"System Default"}),a.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),a.jsx("option",{value:"24h",children:"24-hour (15:30)"})]}),a.jsx(Br,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:C.default_printer_id??"",onChange:we=>pt("default_printer_id",we.target.value?Number(we.target.value):null),className:"w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[a.jsx("option",{value:"",children:"No default (ask each time)"}),en?.map(we=>a.jsx("option",{value:we.id,children:we.name},we.id))]}),a.jsx(Br,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Sidebar order"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),a.jsxs(Te,{variant:"secondary",size:"sm",onClick:_e,children:[a.jsx(rm,{className:"w-4 h-4"}),"Reset"]})]})]})]}),a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(dD,{className:"w-5 h-5"}),"Appearance"]})}),a.jsxs(St,{className:"space-y-6",children:[a.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${d==="dark"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[a.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Dark Mode",d==="dark"&&a.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),a.jsxs("select",{value:m,onChange:we=>{N(we.target.value),o("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"neutral",children:"Neutral"}),a.jsx("option",{value:"warm",children:"Warm"}),a.jsx("option",{value:"cool",children:"Cool"}),a.jsx("option",{value:"oled",children:"OLED Black"}),a.jsx("option",{value:"slate",children:"Slate Blue"}),a.jsx("option",{value:"forest",children:"Forest Green"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),a.jsxs("select",{value:g,onChange:we=>{S(we.target.value),o("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"green",children:"Green"}),a.jsx("option",{value:"teal",children:"Teal"}),a.jsx("option",{value:"blue",children:"Blue"}),a.jsx("option",{value:"orange",children:"Orange"}),a.jsx("option",{value:"purple",children:"Purple"}),a.jsx("option",{value:"red",children:"Red"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),a.jsxs("select",{value:f,onChange:we=>{v(we.target.value),o("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"classic",children:"Classic"}),a.jsx("option",{value:"glow",children:"Glow"}),a.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),a.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${d==="light"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[a.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Light Mode",d==="light"&&a.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),a.jsxs("select",{value:y,onChange:we=>{E(we.target.value),o("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"neutral",children:"Neutral"}),a.jsx("option",{value:"warm",children:"Warm"}),a.jsx("option",{value:"cool",children:"Cool"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),a.jsxs("select",{value:b,onChange:we=>{k(we.target.value),o("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"green",children:"Green"}),a.jsx("option",{value:"teal",children:"Teal"}),a.jsx("option",{value:"blue",children:"Blue"}),a.jsx("option",{value:"orange",children:"Orange"}),a.jsx("option",{value:"purple",children:"Purple"}),a.jsx("option",{value:"red",children:"Red"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),a.jsxs("select",{value:x,onChange:we=>{T(we.target.value),o("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"classic",children:"Classic"}),a.jsx("option",{value:"glow",children:"Glow"}),a.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Toggle between dark and light mode using the sun/moon icon in the sidebar."})]})]}),a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),a.jsxs(St,{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Auto-archive prints"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C.auto_archive,onChange:we=>pt("auto_archive",we.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Save thumbnails"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C.save_thumbnails,onChange:we=>pt("save_thumbnails",we.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Capture finish photo"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C.capture_finish_photo,onChange:we=>pt("capture_finish_photo",we.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),C.capture_finish_photo&&jr&&!jr.installed&&a.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[a.jsx(xn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"text-sm",children:[a.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),a.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",a.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",a.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]})]}),a.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(gD,{className:"w-5 h-5 text-bambu-green"}),"Camera"]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Camera View Mode"}),a.jsxs("select",{value:C.camera_view_mode??"window",onChange:we=>pt("camera_view_mode",we.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"window",children:"New Window"}),a.jsx("option",{value:"embedded",children:"Embedded Overlay"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:C.camera_view_mode==="embedded"?"Camera opens in a resizable overlay on the main screen":"Camera opens in a separate browser window"})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-2",children:"External Cameras"}),a.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Configure external cameras to replace the built-in printer camera. Supports MJPEG streams, RTSP, HTTP snapshots, and USB cameras (V4L2). When enabled, the external camera is used for live view and finish photos."}),en&&en.length>0?a.jsx("div",{className:"space-y-3",children:en.map(we=>a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-white font-medium text-sm",children:we.name}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:we.external_camera_enabled,onChange:bt=>cn(we.id,{enabled:bt.target.checked}),className:"sr-only peer"}),a.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),we.external_camera_enabled&&a.jsxs("div",{className:"space-y-2 mt-2",children:[a.jsx("input",{type:"text",placeholder:we.external_camera_type==="usb"?"Device path (/dev/video0)":"Camera URL (rtsp://... or http://...)",value:Pt[we.id]??we.external_camera_url??"",onChange:bt=>tn(we.id,bt.target.value),className:"w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("select",{value:we.external_camera_type||"mjpeg",onChange:bt=>cn(we.id,{type:bt.target.value}),className:"flex-1 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"mjpeg",children:"MJPEG Stream"}),a.jsx("option",{value:"rtsp",children:"RTSP Stream"}),a.jsx("option",{value:"snapshot",children:"HTTP Snapshot"}),a.jsx("option",{value:"usb",children:"USB Camera (V4L2)"})]}),a.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>zt(we.id,Pt[we.id]??we.external_camera_url??"",we.external_camera_type||"mjpeg"),disabled:Le[we.id]||!(Pt[we.id]??we.external_camera_url),children:Le[we.id]?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):"Test"})]}),oe[we.id]&&a.jsx("div",{className:`text-xs flex items-center gap-1 ${oe[we.id]?.success?"text-green-500":"text-red-500"}`,children:oe[we.id]?.success?a.jsxs(a.Fragment,{children:[a.jsx(Fn,{className:"w-3 h-3"}),"Connected",oe[we.id]?.resolution&&` (${oe[we.id]?.resolution})`]}):a.jsxs(a.Fragment,{children:[a.jsx(aa,{className:"w-3 h-3"}),oe[we.id]?.error||"Connection failed"]})})]})]},we.id))}):a.jsx("p",{className:"text-xs text-bambu-gray italic",children:"No printers configured"})]})]})]}),a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),a.jsxs(St,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),a.jsx("input",{type:"number",step:"0.01",min:"0",value:C.default_filament_cost,onChange:we=>pt("default_filament_cost",parseFloat(we.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),a.jsxs("select",{value:C.currency,onChange:we=>pt("currency",we.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"USD",children:"USD ($)"}),a.jsx("option",{value:"EUR",children:"EUR (€)"}),a.jsx("option",{value:"GBP",children:"GBP (£)"}),a.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),a.jsx("option",{value:"JPY",children:"JPY (¥)"}),a.jsx("option",{value:"CNY",children:"CNY (¥)"}),a.jsx("option",{value:"CAD",children:"CAD ($)"}),a.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),a.jsx("input",{type:"number",step:"0.01",min:"0",value:C.energy_cost_per_kwh,onChange:we=>pt("energy_cost_per_kwh",parseFloat(we.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),a.jsxs("select",{value:C.energy_tracking_mode||"total",onChange:we=>pt("energy_tracking_mode",we.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"print",children:"Prints Only"}),a.jsx("option",{value:"total",children:"Total Consumption"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:C.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Ka,{className:"w-5 h-5 text-bambu-green"}),"File Manager"]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Create Archive Entry When Printing"}),a.jsxs("select",{value:C.library_archive_mode??"ask",onChange:we=>pt("library_archive_mode",we.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"always",children:"Always create archive entry"}),a.jsx("option",{value:"never",children:"Never create archive entry"}),a.jsx("option",{value:"ask",children:"Ask each time"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"When printing from File Manager, optionally create an archive entry"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Low Disk Space Warning"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"0.5",max:"100",step:"0.5",value:C.library_disk_warning_gb??5,onChange:we=>pt("library_disk_warning_gb",parseFloat(we.target.value)||5),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"GB"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Show warning when free disk space falls below this threshold"})]})]})]})]}),a.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[a.jsx(gKe,{}),a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),a.jsxs(St,{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Check for updates"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C.check_updates,onChange:we=>pt("check_updates",we.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Check printer firmware"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Check for printer firmware updates from Bambu Lab"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C.check_printer_firmware??!0,onChange:we=>pt("check_printer_firmware",we.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Current version"}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",Zn?.version||"..."]})]}),a.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>zn(),disabled:Wn,children:[Wn?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(vr,{className:"w-4 h-4"}),"Check now"]})]}),Xt?.update_available?a.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{children:[a.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",Xt.latest_version]}),Xt.release_name&&Xt.release_name!==Xt.latest_version&&a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:Xt.release_name})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[Xt.release_notes&&a.jsx("button",{onClick:()=>Se(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),Xt.release_url&&a.jsx("a",{href:Xt.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:a.jsx($r,{className:"w-4 h-4"})})]})]}),Zr?.status==="downloading"||Zr?.status==="installing"?a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(ut,{className:"w-4 h-4 animate-spin"}),a.jsx("span",{children:Zr.message})]}),a.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:a.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${Zr.progress}%`}})})]}):Zr?.status==="complete"?a.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:Zr.message}):Zr?.status==="error"?a.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:Zr.error||Zr.message}):Xt?.is_docker?a.jsxs("div",{className:"mt-3 p-3 bg-bambu-dark-tertiary rounded-lg",children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Update via Docker Compose:"}),a.jsx("code",{className:"block text-xs bg-bambu-dark p-2 rounded text-bambu-green font-mono",children:"docker compose pull && docker compose up -d"})]}):a.jsxs(Te,{className:"mt-3",onClick:()=>et.mutate(),disabled:et.isPending,children:[et.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(Gr,{className:"w-4 h-4"}),"Install Update"]})]}):Xt?.error?a.jsxs("div",{className:"mt-2 p-2 bg-red-500/10 border border-red-500/30 rounded text-sm text-red-400",children:["Failed to check for updates: ",Xt.error]}):Xt&&!Xt.update_available?a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),a.jsxs(St,{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Clear Notification Logs"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Delete notification logs older than 30 days"})]}),a.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>Oe(!0),children:[a.jsx(on,{className:"w-4 h-4"}),"Clear"]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Reset UI Preferences"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Reset sidebar order, theme, view modes, and layout preferences. Printers, archives, and settings are not affected."})]}),a.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>$(!0),children:[a.jsx(on,{className:"w-4 h-4"}),"Reset"]})]}),a.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Backup & Restore"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Export/import settings and configure GitHub backup"})]}),a.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>xe("backup"),children:[a.jsx(Zc,{className:"w-4 h-4"}),"Go to Backup"]})]})]})]})]})]}),de==="network"&&C&&a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[a.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Dd,{className:"w-5 h-5 text-blue-400"}),"External URL"]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"The external URL where Bambuddy is accessible. Used for notification images and external integrations."}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Bambuddy URL"}),a.jsx("input",{type:"text",value:C.external_url??"",onChange:we=>pt("external_url",we.target.value),placeholder:"http://192.168.1.100:8000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Include protocol and port (e.g., http://192.168.1.100:8000)"})]})]})]}),a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(vr,{className:"w-5 h-5 text-blue-400"}),"FTP Retry"]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Retry FTP operations when printer WiFi is unreliable. Applies to 3MF downloads, print uploads, timelapse downloads, and firmware updates."}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Enable retry"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically retry failed FTP operations"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C.ftp_retry_enabled??!0,onChange:we=>pt("ftp_retry_enabled",we.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),C.ftp_retry_enabled&&a.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry attempts"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"1",max:"10",value:C.ftp_retry_count??3,onChange:we=>pt("ftp_retry_count",Math.min(10,Math.max(1,parseInt(we.target.value)||3))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"times"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of retry attempts before giving up (1-10)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry delay"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"1",max:"30",value:C.ftp_retry_delay??2,onChange:we=>pt("ftp_retry_delay",Math.min(30,Math.max(1,parseInt(we.target.value)||2))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"seconds"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Wait time between retries (1-30)"})]})]}),a.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Connection timeout"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"10",max:"120",value:C.ftp_timeout??30,onChange:we=>pt("ftp_timeout",Math.min(120,Math.max(10,parseInt(we.target.value)||30))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"seconds"})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Socket timeout for slow connections. Increase for A1/A1 Mini printers with weak WiFi (10-120)"})]})]})]})]}),a.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx($2,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),C.ha_enabled&&Ue&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Ue.success?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:`text-sm ${Ue.success?"text-green-400":"text-red-400"}`,children:Ue.success?"Connected":"Disconnected"})]})]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Home Assistant to control smart plugs via HA's REST API. Supports switch, light, input_boolean, and script entities."}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Enable Home Assistant"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Control smart plugs via Home Assistant"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C.ha_enabled??!1,onChange:we=>pt("ha_enabled",we.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),C.ha_enabled&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Home Assistant URL"}),a.jsx("input",{type:"text",value:C.ha_url??"",onChange:we=>pt("ha_url",we.target.value),placeholder:"http://192.168.1.100:8123",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Long-Lived Access Token"}),a.jsx("input",{type:"password",value:C.ha_token??"",onChange:we=>pt("ha_token",we.target.value),placeholder:"eyJ0eXAiOiJKV1QiLC...",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Create a token in HA: Profile → Long-Lived Access Tokens → Create Token"})]}),C.ha_url&&C.ha_token&&a.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:a.jsxs(Te,{variant:"secondary",size:"sm",disabled:We,onClick:async()=>{Ye(!0),Ge(null);try{const we=await he.testHAConnection(C.ha_url,C.ha_token);Ge(we)}catch(we){Ge({success:!1,message:null,error:we instanceof Error?we.message:"Unknown error"})}finally{Ye(!1)}},children:[We?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(Wp,{className:"w-4 h-4"}),"Test Connection"]})})]})]})]}),a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Wp,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),Xe?.enabled&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Xe.connected?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:`text-sm ${Xe.connected?"text-green-400":"text-red-400"}`,children:Xe.connected?"Connected":"Disconnected"})]})]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Publish BamBuddy events to an external MQTT broker for integration with Node-RED, Home Assistant, and other automation systems."}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Enable MQTT"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Publish events to external MQTT broker"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C.mqtt_enabled??!1,onChange:we=>pt("mqtt_enabled",we.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),C.mqtt_enabled&&a.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Broker hostname"}),a.jsx("input",{type:"text",value:C.mqtt_broker??"",onChange:we=>pt("mqtt_broker",we.target.value),placeholder:"mqtt.example.com or 192.168.1.100",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex items-end gap-4",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Port"}),a.jsx("input",{type:"number",min:"1",max:"65535",value:C.mqtt_port??1883,onChange:we=>pt("mqtt_port",Math.min(65535,Math.max(1,parseInt(we.target.value)||1883))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex items-center gap-3 pb-2",children:[a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C.mqtt_use_tls??!1,onChange:we=>{const bt=we.target.checked;pt("mqtt_use_tls",bt);const $t=C.mqtt_port??1883;bt&&$t===1883?pt("mqtt_port",8883):!bt&&$t===8883&&pt("mqtt_port",1883)},className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]}),a.jsx("span",{className:"text-white text-sm",children:"Use TLS"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username (optional)"}),a.jsx("input",{type:"text",value:C.mqtt_username??"",onChange:we=>pt("mqtt_username",we.target.value),placeholder:"Leave empty for anonymous",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password (optional)"}),a.jsx("input",{type:"password",value:C.mqtt_password??"",onChange:we=>pt("mqtt_password",we.target.value),placeholder:"Leave empty for anonymous",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic prefix"}),a.jsx("input",{type:"text",value:C.mqtt_topic_prefix??"bambuddy",onChange:we=>pt("mqtt_topic_prefix",we.target.value),placeholder:"bambuddy",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Topics will be: ",C.mqtt_topic_prefix||"bambuddy","/printers/<serial>/status, etc."]})]}),Xe&&a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:`w-2 h-2 rounded-full ${Xe.connected?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:"text-bambu-gray",children:Xe.connected?a.jsxs(a.Fragment,{children:["Connected to ",a.jsxs("span",{className:"text-white",children:[Xe.broker,":",Xe.port]})]}):"Not connected"})]})})]})]})]})]}),a.jsx("div",{className:"flex-1 lg:max-w-md space-y-4",children:a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Jj,{className:"w-5 h-5 text-orange-400"}),"Prometheus Metrics"]})}),a.jsxs(St,{className:"space-y-4",children:[a.jsxs("p",{className:"text-sm text-bambu-gray",children:["Expose printer metrics at ",a.jsx("code",{className:"bg-bambu-dark px-1 rounded",children:"/api/v1/metrics"})," for Prometheus/Grafana monitoring."]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:"Enable Metrics Endpoint"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Expose printer data in Prometheus format"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C.prometheus_enabled??!1,onChange:we=>pt("prometheus_enabled",we.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),C.prometheus_enabled&&a.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Bearer Token (optional)"}),a.jsx("input",{type:"password",value:C.prometheus_token??"",onChange:we=>pt("prometheus_token",we.target.value),placeholder:"Leave empty for no authentication",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["If set, requests must include ",a.jsx("code",{className:"bg-bambu-dark px-1 rounded",children:"Authorization: Bearer <token>"})]})]}),a.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-sm text-white mb-2",children:"Available Metrics"}),a.jsxs("div",{className:"text-xs text-bambu-gray space-y-1",children:[a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_connected"})," - Connection status"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_state"})," - Printer state (idle/printing/etc)"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_print_progress"})," - Print progress 0-100%"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_bed_temp_celsius"})," - Bed temperature"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_nozzle_temp_celsius"})," - Nozzle temperature"]}),a.jsxs("p",{children:[a.jsx("code",{className:"text-orange-400",children:"bambuddy_prints_total"})," - Total prints by result"]}),a.jsx("p",{className:"text-bambu-gray/70 italic",children:"...and more (layers, fans, queue, filament usage)"})]})]})]})]})]})})]}),Ue&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-6 max-w-md w-full mx-4",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[Ue.success?a.jsx(Fn,{className:"w-8 h-8 text-green-400"}):a.jsx(aa,{className:"w-8 h-8 text-red-400"}),a.jsx("h3",{className:"text-lg font-medium text-white",children:Ue.success?"Connection Successful":"Connection Failed"})]}),a.jsx("p",{className:"text-bambu-gray mb-6",children:Ue.success?Ue.message||"Successfully connected to Home Assistant.":Ue.error||"Failed to connect to Home Assistant."}),a.jsx("div",{className:"flex justify-end",children:a.jsx(Te,{variant:"primary",onClick:()=>Ge(null),children:"OK"})})]})}),de==="plugs"&&a.jsxs("div",{className:"max-w-4xl",children:[a.jsxs("div",{className:"flex items-start justify-between mb-6",children:[a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Ws,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Connect smart plugs (Tasmota or Home Assistant) to automate power control and track energy usage for your printers."})]}),a.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[ke&&ke.filter(we=>we.enabled).length>1&&a.jsxs(a.Fragment,{children:[a.jsxs(Te,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>V("on"),disabled:Fe.isPending,title:"Turn all plugs on",children:[Fe.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(yu,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),a.jsxs(Te,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>V("off"),disabled:Fe.isPending,title:"Turn all plugs off",children:[Fe.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(q2,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),a.jsxs(Te,{className:"whitespace-nowrap",onClick:()=>{O(null),R(!0)},children:[a.jsx(rr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),ke&&ke.length>0&&a.jsxs(_t,{className:"mb-6",children:[a.jsx(tr,{children:a.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[a.jsx(Kd,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",Je&&a.jsx(ut,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),a.jsx(St,{children:Ae?a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(Kd,{className:"w-3 h-3"}),"Current Power"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[Ae.totalPower.toFixed(1),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[Ae.reachableCount,"/",Ae.totalPlugs," plugs online"]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(si,{className:"w-3 h-3"}),"Today"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[Ae.totalToday.toFixed(2),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),C&&C.energy_cost_per_kwh>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ae.totalToday*C.energy_cost_per_kwh).toFixed(2)," ",C.currency]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(Jj,{className:"w-3 h-3"}),"Yesterday"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[Ae.totalYesterday.toFixed(2),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),C&&C.energy_cost_per_kwh>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ae.totalYesterday*C.energy_cost_per_kwh).toFixed(2)," ",C.currency]})]}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[a.jsx(Gj,{className:"w-3 h-3"}),"Total"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[Ae.totalLifetime.toFixed(1),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),C&&C.energy_cost_per_kwh>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Ae.totalLifetime*C.energy_cost_per_kwh).toFixed(2)," ",C.currency]})]})]}):Je?null:a.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),De?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(ut,{className:"w-8 h-8 text-bambu-green animate-spin"})}):ke&&ke.length>0?a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ke.map(we=>a.jsx(nKe,{plug:we,onEdit:bt=>{O(bt),R(!0)}},we.id))}):a.jsx(_t,{children:a.jsx(St,{className:"py-12",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(Ws,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No smart plugs configured"}),a.jsx("p",{className:"text-sm mb-4",children:"Add a Tasmota-based smart plug to track energy usage and automate power control."}),a.jsxs(Te,{onClick:()=>{O(null),R(!0)},children:[a.jsx(rr,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),de==="notifications"&&a.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(gf,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>ne(!0),children:[a.jsx(g0,{className:"w-4 h-4"}),"Log"]}),gt&>.length>0&&a.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>{ue(null),ge.mutate()},disabled:ge.isPending,children:[ge.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(mD,{className:"w-4 h-4"}),"Test All"]}),a.jsxs(Te,{size:"sm",onClick:()=>{Y(null),j(!0)},children:[a.jsx(rr,{className:"w-4 h-4"}),"Add"]})]})]}),a.jsx(_t,{className:"mb-4",children:a.jsx(St,{className:"py-3",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white text-sm font-medium",children:i("settings.notificationLanguage")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.notificationLanguageDescription")})]}),a.jsx("select",{value:C.notification_language||"en",onChange:we=>pt("notification_language",we.target.value),className:"px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:ez.map(we=>a.jsx("option",{value:we.code,children:we.nativeName},we.code))})]})})}),Ct&&a.jsx(_t,{className:"mb-4",children:a.jsxs(St,{className:"py-3",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm font-medium text-white",children:"Test Results"}),a.jsx("button",{onClick:()=>ue(null),className:"text-bambu-gray hover:text-white text-xs",children:"Dismiss"})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[a.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[a.jsx(Fn,{className:"w-4 h-4"}),Ct.success," passed"]}),Ct.failed>0&&a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(aa,{className:"w-4 h-4"}),Ct.failed," failed"]})]}),Ct.results.filter(we=>!we.success).length>0&&a.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:Ct.results.filter(we=>!we.success).map(we=>a.jsxs("div",{className:"text-xs text-red-400",children:[a.jsxs("span",{className:"font-medium",children:[we.provider_name,":"]})," ",we.message]},we.provider_id))})]})}),At?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(ut,{className:"w-6 h-6 text-bambu-green animate-spin"})}):gt&>.length>0?a.jsx("div",{className:"space-y-3",children:gt.map(we=>a.jsx(aKe,{provider:we,onEdit:bt=>{Y(bt),j(!0)}},we.id))}):a.jsx(_t,{children:a.jsx(St,{className:"py-8",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(gf,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm font-medium text-white mb-2",children:"No providers configured"}),a.jsx("p",{className:"text-xs mb-3",children:"Add a provider to receive alerts."}),a.jsxs(Te,{size:"sm",onClick:()=>{Y(null),j(!0)},children:[a.jsx(rr,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[a.jsx(Ka,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),ur?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(ut,{className:"w-6 h-6 text-bambu-green animate-spin"})}):er&&er.length>0?a.jsx("div",{className:"space-y-2",children:er.map(we=>a.jsx(_t,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>Z(we),children:a.jsx(St,{className:"py-2.5 px-3",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-white font-medium text-sm truncate",children:we.name}),a.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:we.title_template})]}),a.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:bt=>{bt.stopPropagation(),Z(we)},children:a.jsx(G2,{className:"w-4 h-4 text-bambu-gray"})})]})})},we.id))}):a.jsx(_t,{children:a.jsx(St,{className:"py-8",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(Ka,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),de==="apikeys"&&a.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(of,{className:"w-5 h-5 text-bambu-green"}),"API Keys"]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Create API keys for external integrations and webhooks."})]}),a.jsxs(Te,{size:"sm",onClick:()=>fe(!0),className:"flex-shrink-0",children:[a.jsx(rr,{className:"w-4 h-4"}),"Create Key"]})]}),H&&a.jsx(_t,{className:"mb-6 border-bambu-green",children:a.jsx(St,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Fn,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-white font-medium mb-1",children:"API Key Created Successfully"}),a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Copy this key now - it won't be shown again!"}),a.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[a.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:H}),a.jsx(Te,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(H);else{const we=document.createElement("textarea");we.value=H,we.style.position="fixed",we.style.left="-999999px",document.body.appendChild(we),we.select(),document.execCommand("copy"),document.body.removeChild(we)}o("Key copied to clipboard")}catch{o("Failed to copy key","error")}},children:a.jsx(ll,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex gap-2 mt-3",children:[a.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>{le(H),o("Key added to API Browser")},children:"Use in API Browser"}),a.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>B(null),children:"Dismiss"})]})]})]})})}),be&&a.jsxs(_t,{className:"mb-6",children:[a.jsx(tr,{children:a.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),a.jsxs(St,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Key Name"}),a.jsx("input",{type:"text",value:Ce,onChange:we=>Ne(we.target.value),placeholder:"e.g., Home Assistant, OctoPrint",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Permissions"}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:re.can_read_status,onChange:we=>He(bt=>({...bt,can_read_status:we.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white",children:"Read Status"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"View printer status and queue"})]})]}),a.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:re.can_queue,onChange:we=>He(bt=>({...bt,can_queue:we.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white",children:"Manage Queue"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Add and remove items from print queue"})]})]}),a.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:re.can_control_printer,onChange:we=>He(bt=>({...bt,can_control_printer:we.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white",children:"Control Printer"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Pause, resume, and stop prints"})]})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[a.jsxs(Te,{onClick:()=>Lt.mutate({name:Ce||"Unnamed Key",...re}),disabled:Lt.isPending,children:[Lt.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(rr,{className:"w-4 h-4"}),"Create Key"]}),a.jsx(Te,{variant:"secondary",onClick:()=>fe(!1),children:"Cancel"})]})]})]}),ln?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(ut,{className:"w-8 h-8 text-bambu-green animate-spin"})}):jt&&jt.length>0?a.jsx("div",{className:"space-y-3",children:jt.map(we=>a.jsx(_t,{children:a.jsx(St,{className:"py-3",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(of,{className:`w-5 h-5 ${we.enabled?"text-bambu-green":"text-bambu-gray"}`}),a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium",children:we.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[we.key_prefix,"••••••••",we.last_used&&` · Last used: ${cg(we.last_used)}`]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex gap-1 text-xs",children:[we.can_read_status&&a.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),we.can_queue&&a.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),we.can_control_printer&&a.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:"Control"})]}),a.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>U(we.id),children:a.jsx(on,{className:"w-4 h-4 text-red-400"})})]})]})})},we.id))}):a.jsx(_t,{children:a.jsx(St,{className:"py-12",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(of,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No API keys"}),a.jsx("p",{className:"text-sm mb-4",children:"Create an API key to integrate with external services."}),a.jsxs(Te,{onClick:()=>fe(!0),children:[a.jsx(rr,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),a.jsxs(_t,{className:"mt-6",children:[a.jsx(tr,{children:a.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),a.jsxs(St,{className:"space-y-3 text-sm",children:[a.jsxs("p",{className:"text-bambu-gray",children:["Use your API key in the ",a.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header."]}),a.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-blue-400",children:"GET"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),a.jsx("span",{className:"text-bambu-gray",children:" - Get all printer status"})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-blue-400",children:"GET"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),a.jsx("span",{className:"text-bambu-gray",children:" - Get specific printer status"})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-green-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),a.jsx("span",{className:"text-bambu-gray",children:" - Add to print queue"})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-orange-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),a.jsx("span",{className:"text-bambu-gray",children:" - Pause print"})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-orange-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),a.jsx("span",{className:"text-bambu-gray",children:" - Resume print"})]}),a.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[a.jsx("span",{className:"text-red-400",children:"POST"})," ",a.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),a.jsx("span",{className:"text-bambu-gray",children:" - Stop print"})]})]})]})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Dd,{className:"w-5 h-5 text-bambu-green"}),"API Browser"]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Explore and test all available API endpoints."})]}),a.jsx(_t,{className:"mb-4",children:a.jsxs(St,{className:"py-3",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"API Key for Testing"}),a.jsx("input",{type:"text",value:Q,onChange:we=>le(we.target.value),placeholder:"Paste your API key here to test authenticated endpoints...",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm focus:border-bambu-green focus:outline-none"}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["This key will be sent as ",a.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header with requests."]})]})}),a.jsx(MKe,{apiKey:Q})]})]}),de==="virtual-printer"&&a.jsx(xKe,{}),de==="filament"&&C&&a.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[a.jsx("div",{className:"flex-1 lg:max-w-xl",children:a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),a.jsxs(St,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(uD,{className:"w-4 h-4 text-blue-400"}),a.jsx("span",{className:"font-medium",children:"Humidity"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"0",max:"100",value:C.ams_humidity_good??40,onChange:we=>pt("ams_humidity_good",parseInt(we.target.value)||40),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"0",max:"100",value:C.ams_humidity_fair??60,onChange:we=>pt("ams_humidity_fair",parseInt(we.target.value)||60),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),a.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(W2,{className:"w-4 h-4 text-orange-400"}),a.jsx("span",{className:"font-medium",children:"Temperature"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:C.ams_temp_good??28,onChange:we=>pt("ams_temp_good",parseFloat(we.target.value)||28),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:C.ams_temp_fair??35,onChange:we=>pt("ams_temp_fair",parseFloat(we.target.value)||35),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]}),a.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(Zc,{className:"w-4 h-4 text-purple-400"}),a.jsx("span",{className:"font-medium",children:"History Retention"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Keep sensor history for"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"1",max:"365",value:C.ams_history_retention_days??30,onChange:we=>pt("ams_history_retention_days",parseInt(we.target.value)||30),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),a.jsx("span",{className:"text-bambu-gray",children:"days"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Older humidity and temperature data will be automatically deleted"})]}),a.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(Ar,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"font-medium",children:"Print Modal"})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-white",children:"Expand custom mapping by default"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:"When printing to multiple printers, show per-printer AMS mapping expanded"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C.per_printer_mapping_expanded??!1,onChange:we=>pt("per_printer_mapping_expanded",we.target.checked),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})]})]})]})}),a.jsx("div",{className:"flex-1 lg:max-w-xl",children:a.jsx(mKe,{})})]}),X!==null&&a.jsx(Hn,{title:"Delete API Key",message:"Are you sure you want to delete this API key? Any integrations using this key will stop working.",confirmText:"Delete Key",variant:"danger",onConfirm:()=>{Cn.mutate(X),U(null)},onCancel:()=>U(null)}),A&&a.jsx(rKe,{plug:F,onClose:()=>{R(!1),O(null)}}),q&&a.jsx(sKe,{provider:G,onClose:()=>{j(!1),Y(null)}}),K&&a.jsx(oKe,{template:K,onClose:()=>Z(null)}),te&&a.jsx(uKe,{onClose:()=>ne(!1)}),Pe&&a.jsx(Hn,{title:"Clear Notification Logs",message:"This will permanently delete all notification logs older than 30 days. This action cannot be undone.",confirmText:"Clear Logs",variant:"warning",onConfirm:async()=>{Oe(!1);try{const we=await he.clearNotificationLogs(30);o(we.message,"success")}catch{o("Failed to clear logs","error")}},onCancel:()=>Oe(!1)}),je&&a.jsx(Hn,{title:"Reset UI Preferences",message:"This will reset all UI preferences to defaults: sidebar order, theme, dashboard layout, view modes, and sorting preferences. Your printers, archives, and server settings will NOT be affected. The page will reload after clearing.",confirmText:"Reset Preferences",variant:"default",onConfirm:()=>{$(!1),localStorage.clear(),o("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>$(!1)}),I&&a.jsx(Hn,{title:`Turn All Plugs ${I==="on"?"On":"Off"}`,message:`This will turn ${I==="on"?"ON":"OFF"} all ${ke?.filter(we=>we.enabled).length||0} enabled smart plugs. ${I==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${I==="on"?"On":"Off"}`,variant:I==="off"?"danger":"warning",onConfirm:()=>{const we=I;V(null),Fe.mutate(we)},onCancel:()=>V(null)}),ie&&Xt?.release_notes&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Se(!1),children:a.jsxs(_t,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:we=>we.stopPropagation(),children:[a.jsxs(tr,{className:"flex flex-row items-center justify-between shrink-0",children:[a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Release Notes - v",Xt.latest_version]}),Xt.release_name&&Xt.release_name!==Xt.latest_version&&a.jsx("p",{className:"text-sm text-bambu-gray",children:Xt.release_name})]}),a.jsx("button",{onClick:()=>Se(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsx(St,{className:"overflow-y-auto flex-1",children:a.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:Xt.release_notes})}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[Xt.release_url&&a.jsx("a",{href:Xt.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:a.jsxs(Te,{variant:"secondary",className:"w-full",children:[a.jsx($r,{className:"w-4 h-4"}),"View on GitHub"]})}),a.jsx(Te,{onClick:()=>Se(!1),className:"flex-1",children:"Close"})]})]})}),de==="users"&&a.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Nd,{className:"w-5 h-5 text-bambu-green"}),"User Authentication"]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Enable authentication to secure your Bambuddy instance and manage user access."})]}),a.jsx(_t,{children:a.jsx(St,{className:"py-6",children:l?a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-12 h-12 rounded-full flex items-center justify-center bg-green-500/20",children:a.jsx(LT,{className:"w-6 h-6 text-green-400"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h3",{className:"text-white font-medium",children:"Authentication Enabled"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Your Bambuddy instance is secured with authentication."})]})]}),c&&a.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Current User"}),a.jsx("p",{className:"text-white font-medium",children:c.username}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Role: ",a.jsx("span",{className:"capitalize",children:c.role})]})]}),a.jsx("div",{className:`px-3 py-1 rounded-full text-xs font-medium ${c.role==="admin"?"bg-purple-500/20 text-purple-300":"bg-blue-500/20 text-blue-300"}`,children:c.role==="admin"?"Admin":"User"})]})}),a.jsxs("div",{className:"pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[a.jsxs(Te,{onClick:()=>e("/users"),className:"w-full",variant:"secondary",children:[a.jsx(Nd,{className:"w-4 h-4"}),"Manage Users"]}),c?.role==="admin"&&a.jsxs(Te,{onClick:()=>$e(!0),className:"w-full",variant:"secondary",children:[a.jsx(yz,{className:"w-4 h-4"}),"Disable Authentication"]})]})]}):a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center ${l?"bg-green-500/20":"bg-gray-500/20"}`,children:l?a.jsx(LT,{className:"w-6 h-6 text-green-400"}):a.jsx(yz,{className:"w-6 h-6 text-gray-400"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h3",{className:"text-white font-medium",children:"Authentication Disabled"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Your Bambuddy instance is currently accessible without authentication."})]})]}),a.jsxs("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Enable authentication to:"}),a.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray mb-4",children:[a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(Fn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:"Require login to access the system"})]}),a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(Fn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:"Manage multiple users with different roles"})]}),a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(Fn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:"Control access to printer settings and user management"})]})]}),a.jsxs(Te,{type:"button",onClick:we=>{we.preventDefault(),e("/setup")},className:"w-full",children:[a.jsx(LT,{className:"w-4 h-4"}),"Activate Authentication"]})]})]})})})]}),l&&a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Zj,{className:"w-5 h-5 text-bambu-green"}),"Role Permissions"]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Overview of what each role can do."})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"w-8 h-8 rounded-full bg-purple-500/20 flex items-center justify-center",children:a.jsx(Zj,{className:"w-4 h-4 text-purple-300"})}),a.jsx("h3",{className:"text-white font-medium",children:"Admin"})]})}),a.jsx(St,{children:a.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray",children:[a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(Fn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:"Manage printer settings"})]}),a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(Fn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:"Create, edit, and delete users"})]}),a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(Fn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:"Access all system features"})]})]})})]}),a.jsxs(_t,{children:[a.jsx(tr,{children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-500/20 flex items-center justify-center",children:a.jsx(Nd,{className:"w-4 h-4 text-blue-300"})}),a.jsx("h3",{className:"text-white font-medium",children:"User"})]})}),a.jsx(St,{children:a.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray",children:[a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(Fn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:"Send print jobs"})]}),a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(Fn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:"Manage files and archives"})]}),a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(Fn,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:"Manage filament"})]})]})})]})]})]})]}),de==="backup"&&a.jsx(_Ke,{}),ye&&a.jsx(Hn,{title:"Disable Authentication",message:"Are you sure you want to disable authentication? This will make your Bambuddy instance accessible without login. All users will remain in the database but authentication will be disabled.",confirmText:"Disable Authentication",variant:"danger",onConfirm:async()=>{try{await he.disableAuth(),o("Authentication disabled successfully","success"),await u(),$e(!1),window.location.href="/"}catch(we){const bt=we instanceof Error?we.message:"Failed to disable authentication";o(bt,"error")}},onCancel:()=>$e(!1)})]})}const Nre=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},CKe=t=>t.startsWith("HH")?"HF":"S",AKe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},GR=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 wj({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:s,note:o}){const l=CKe(t.nozzle_id),c=t.nozzle_diameter,u=()=>{r&&s?s():e()};return a.jsxs("div",{className:"flex items-center gap-2",children:[r&&a.jsx("button",{onClick:s,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?a.jsx(Do,{className:"w-4 h-4 text-bambu-green"}):a.jsx(Oo,{className:"w-4 h-4"})}),a.jsxs("button",{onClick:u,className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${i?"ring-1 ring-bambu-green":""}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:Nre(t.k_value)}),a.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),o&&a.jsx("span",{title:"Has note",children:a.jsx(pW,{className:"w-3 h-3 text-yellow-500"})}),a.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[l," ",c]})]}),o&&a.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:o,children:["Note: ",o.length>50?o.substring(0,50)+"...":o]})]}),!r&&n&&a.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:a.jsx(ll,{className:"w-4 h-4"})})]})}function Sj({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:s="",initialNoteKey:o=null,onClose:l,onSave:c,onSaveNote:u}){const{showToast:d}=Gn(),[f,m]=w.useState(t?.name||""),[g,x]=w.useState(t?.k_value?Nre(t.k_value):"0.020"),[y,b]=w.useState(t?.filament_id||""),[v,N]=w.useState(t?.nozzle_id?AKe(t.nozzle_id):"HH00"),[S,T]=w.useState(t?.nozzle_diameter||n),[E,k]=w.useState(t?[t.extruder_id]:i?[0,1]:[0]),[C,D]=w.useState(!1),[A,R]=w.useState({current:0,total:0}),[F,O]=w.useState(s),q=zr.useMemo(()=>{const ne=new Map;for(const z of r)if(z.filament_id&&!ne.has(z.filament_id)){const W=GR(z.name||"");ne.set(z.filament_id,{id:z.filament_id,name:W||z.filament_id})}return Array.from(ne.values()).sort((z,W)=>z.name.localeCompare(W.name))},[r]),j=ht({mutationFn:ne=>(console.log("[KProfile] Calling API..."),he.setKProfile(e,ne)),onSuccess:ne=>{if(console.log("[KProfile] Save success:",ne),d("K-profile saved"),u&&F!==s){let z;F===""&&o?z=o:t&&t.slot_id>0?z=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:z=`name_${f}_${y}`,u(z,F)}D(!0),setTimeout(()=>{D(!1),c()},2500)},onError:ne=>{console.error("[KProfile] Save error:",ne),d(ne.message,"error"),D(!1)}}),G=ht({mutationFn:ne=>(console.log("[KProfile] Deleting profile..."),he.deleteKProfile(e,ne)),onSuccess:ne=>{console.log("[KProfile] Delete success:",ne),d("K-profile deleted"),D(!0),setTimeout(()=>{D(!1),l()},4e3)},onError:ne=>{console.error("[KProfile] Delete error:",ne),d(ne.message,"error"),D(!1)}}),[Y,K]=w.useState(!1),Z=()=>{t&&G.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})},te=async ne=>{if(ne.preventDefault(),i&&!t&&E.length===0){d("Please select at least one extruder","error");return}const z=parseFloat(g).toFixed(6),W=`${v}-${S}`;if(t||E.length===1){const ae={name:f,k_value:z,filament_id:y,nozzle_id:W,nozzle_diameter:S,extruder_id:t?t.extruder_id:E[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",ae),j.mutate(ae);return}D(!0),R({current:1,total:E.length});const se=E.map(ae=>({name:f,k_value:z,filament_id:y,nozzle_id:W,nozzle_diameter:S,extruder_id:ae,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${se.length} profiles in batch:`,se);try{if(await he.setKProfilesBatch(e,se),d(`K-profile saved to ${E.length} extruders`),u&&F){const ae=`name_${f}_${y}`;u(ae,F)}}catch(ae){console.error("[KProfile] Failed to save batch:",ae),d("Failed to save K-profiles","error"),D(!1),R({current:0,total:0});return}R({current:E.length,total:E.length}),setTimeout(()=>{D(!1),R({current:0,total:0}),c()},3e3)};return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[a.jsxs(_t,{className:"w-full max-w-md relative",children:[C&&a.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[a.jsx(ut,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),a.jsx("p",{className:"text-white font-medium",children:A.total>1?`Saving to extruder ${A.current}/${A.total}...`:"Syncing with printer..."}),a.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),a.jsxs(St,{className:"p-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),a.jsx("button",{onClick:l,className:"text-bambu-gray hover:text-white transition-colors",disabled:C,children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:te,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),a.jsx("input",{type:"text",value:f,onChange:ne=>m(ne.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})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),a.jsx("input",{type:"text",inputMode:"decimal",value:g,onChange:ne=>{const z=ne.target.value;(z===""||/^\d*\.?\d*$/.test(z))&&x(z)},onBlur:ne=>{const z=parseFloat(ne.target.value);isNaN(z)||x((Math.trunc(z*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}),a.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"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),a.jsxs("select",{value:y,onChange:ne=>{const z=ne.target.value;if(b(z),!t&&z&&!f){const W=q.find(se=>se.id===z);W&&m(`${v==="HH00"?"HF":"S"} ${W.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[a.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&a.jsx("option",{value:t.filament_id,children:q.find(ne=>ne.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&q.map(ne=>a.jsx("option",{value:ne.id,children:ne.name},ne.id))]}),!t&&q.length===0&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),a.jsxs("select",{value:v,onChange:ne=>{const z=ne.target.value;if(N(z),!t&&y&&!f){const W=q.find(se=>se.id===y);W&&m(`${z==="HS00"?"HF":"S"} ${W.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[a.jsx("option",{value:"HH00",children:"High Flow"}),a.jsx("option",{value:"HS00",children:"Standard"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),a.jsxs("select",{value:S,onChange:ne=>T(ne.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[a.jsx("option",{value:"0.2",children:"0.2mm"}),a.jsx("option",{value:"0.4",children:"0.4mm"}),a.jsx("option",{value:"0.6",children:"0.6mm"}),a.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?a.jsx("div",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60",children:t.extruder_id===1?"Left":"Right"}):a.jsxs("div",{className:"flex gap-4",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:E.includes(1),onChange:ne=>{ne.target.checked?k([...E,1]):k(E.filter(z=>z!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),a.jsx("span",{className:"text-white",children:"Left"})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:E.includes(0),onChange:ne=>{ne.target.checked?k([...E,0]):k(E.filter(z=>z!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),a.jsx("span",{className:"text-white",children:"Right"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),a.jsx("textarea",{value:F,onChange:ne=>O(ne.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"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Notes are saved in Bambuddy, not on the printer"})]}),a.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&a.jsx(Te,{type:"button",variant:"secondary",onClick:()=>K(!0),disabled:G.isPending||C,className:"text-red-500 hover:bg-red-500/10",children:G.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(on,{className:"w-4 h-4"})}),a.jsx(Te,{type:"button",variant:"secondary",onClick:l,disabled:C,className:"flex-1",children:"Cancel"}),a.jsxs(Te,{type:"submit",disabled:j.isPending||C,className:"flex-1",children:[j.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(z2,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),Y&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:a.jsx(_t,{className:"w-full max-w-sm",children:a.jsxs(St,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:a.jsx(on,{className:"w-5 h-5 text-red-500"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),a.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",a.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(Te,{variant:"secondary",onClick:()=>K(!1),className:"flex-1",children:"Cancel"}),a.jsxs(Te,{onClick:()=>{K(!1),Z()},disabled:G.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[G.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(on,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const z1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function kKe(){const{showToast:t}=Gn(),[e,n]=w.useState(null),[r,i]=w.useState(()=>localStorage.getItem(z1.NOZZLE_DIAMETER)||"0.4"),[s,o]=w.useState(null),[l,c]=w.useState(!1),[u,d]=w.useState(null),[f,m]=w.useState(""),[g,x]=w.useState("all"),[y,b]=w.useState("all"),[v,N]=w.useState(()=>localStorage.getItem(z1.SORT_OPTION)||"name"),[S,T]=w.useState(!1),[E,k]=w.useState(new Set),[C,D]=w.useState(!1),[A,R]=w.useState(!1),F=w.useCallback(U=>`${U.slot_id}_${U.extruder_id}`,[]);w.useEffect(()=>{localStorage.setItem(z1.NOZZLE_DIAMETER,r)},[r]),w.useEffect(()=>{localStorage.setItem(z1.SORT_OPTION,v)},[v]);const{data:O,isLoading:q}=ct({queryKey:["printers"],queryFn:he.getPrinters}),{data:j,isLoading:G,isFetching:Y,error:K,refetch:Z}=ct({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const U=await he.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",U?.profiles?.length||0,"profiles"),U},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:te}=ct({queryKey:["kprofiles",e,"0.4"],queryFn:()=>he.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:ne,refetch:z}=ct({queryKey:["kprofile-notes",e],queryFn:()=>he.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),W=K?.message?.includes("not connected");w.useEffect(()=>{if(!e&&O&&O.length>0){const U=O.find(Q=>Q.is_active);U&&n(U.id)}},[e,O]),w.useEffect(()=>{if(e){const U=setTimeout(()=>{Z()},150);return()=>clearTimeout(U)}},[e,r]);const se=O?.filter(U=>U.is_active)||[],ae=zr.useMemo(()=>j?.profiles?j.profiles.filter(Q=>{const le=f.toLowerCase(),Pe=!le||Q.name.toLowerCase().includes(le)||Q.filament_id.toLowerCase().includes(le),Oe=g==="all"||g==="left"&&Q.extruder_id===1||g==="right"&&Q.extruder_id===0,je=y==="all"||y==="hf"&&Q.nozzle_id.startsWith("HH")||y==="s"&&Q.nozzle_id.startsWith("HS");return Pe&&Oe&&je}).sort((Q,le)=>{switch(v){case"k_value":return parseFloat(Q.k_value)-parseFloat(le.k_value);case"filament":return GR(Q.name).localeCompare(GR(le.name));case"name":default:return Q.name.localeCompare(le.name)}}):[],[j?.profiles,f,g,y,v]),de=O?.find(U=>U.id===e),me=de?.nozzle_count===2;w.useEffect(()=>{const U=Q=>{Q.target instanceof HTMLInputElement||Q.target instanceof HTMLTextAreaElement||Q.target instanceof HTMLSelectElement||s||l||u||(Q.key==="r"||Q.key==="R"?(Q.preventDefault(),Z()):Q.key==="n"||Q.key==="N"?(Q.preventDefault(),c(!0)):Q.key==="Escape"&&S&&(Q.preventDefault(),T(!1),k(new Set)))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[s,l,u,S,Z]);const xe=w.useCallback(()=>{if(!j?.profiles||j.profiles.length===0){t("No profiles to export","error");return}const U={version:1,exported_at:new Date().toISOString(),printer:de?.name||"Unknown",nozzle_diameter:r,profiles:j.profiles.map(Oe=>({name:Oe.name,k_value:Oe.k_value,filament_id:Oe.filament_id,nozzle_id:Oe.nozzle_id,nozzle_diameter:Oe.nozzle_diameter,extruder_id:Oe.extruder_id}))},Q=new Blob([JSON.stringify(U,null,2)],{type:"application/json"}),le=URL.createObjectURL(Q),Pe=document.createElement("a");Pe.href=le,Pe.download=`kprofiles_${de?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Pe),Pe.click(),document.body.removeChild(Pe),URL.revokeObjectURL(le),t(`Exported ${j.profiles.length} profiles`)},[j?.profiles,de,r,t]),be=w.useCallback(()=>{const U=document.createElement("input");U.type="file",U.accept=".json",U.onchange=async Q=>{const le=Q.target.files?.[0];if(le)try{const Pe=await le.text(),Oe=JSON.parse(Pe);if(!Oe.profiles||!Array.isArray(Oe.profiles)){t("Invalid file format","error");return}let je=0;for(const $ of Oe.profiles)if(!(!$.name||!$.k_value||!$.filament_id))try{await he.setKProfile(e,{name:$.name,k_value:parseFloat($.k_value).toFixed(6),filament_id:$.filament_id,nozzle_id:$.nozzle_id||`HH00-${r}`,nozzle_diameter:$.nozzle_diameter||r,extruder_id:$.extruder_id??0,slot_id:0}),je++,await new Promise(I=>setTimeout(I,500))}catch(I){console.error("Failed to import profile:",$.name,I)}t(`Imported ${je} of ${Oe.profiles.length} profiles`),Z()}catch(Pe){console.error("Import error:",Pe),t("Failed to parse import file","error")}},U.click()},[e,r,t,Z]),fe=w.useCallback(U=>{k(Q=>{const le=new Set(Q);return le.has(U)?le.delete(U):le.add(U),le})},[]),Ce=w.useCallback(()=>{k(new Set(ae.map(U=>F(U))))},[ae,F]),Ne=w.useCallback(()=>{E.size!==0&&D(!0)},[E.size]),re=w.useCallback(async()=>{const U=ae.filter(le=>E.has(F(le)));R(!0);let Q=0;for(const le of U)try{await he.deleteKProfile(e,{slot_id:le.slot_id,extruder_id:le.extruder_id,nozzle_id:le.nozzle_id,nozzle_diameter:le.nozzle_diameter,filament_id:le.filament_id,setting_id:le.setting_id}),Q++,await new Promise(Pe=>setTimeout(Pe,300))}catch(Pe){console.error("Failed to delete profile:",le.name,Pe)}t(`Deleted ${Q} profiles`),R(!1),D(!1),T(!1),k(new Set),Z()},[e,E,ae,t,Z,F]),He=w.useCallback(U=>{const Q=[];return U.setting_id&&Q.push(U.setting_id),Q.push(`slot_${U.slot_id}_${U.filament_id}_${U.extruder_id}`),Q.push(`name_${U.name}_${U.filament_id}`),Q},[]),H=w.useCallback(async(U,Q)=>{if(e)try{await he.setKProfileNote(e,U,Q),z()}catch(le){console.error("Failed to save note:",le),t("Failed to save note","error")}},[e,z,t]),B=w.useCallback(U=>{if(!ne?.notes)return{note:"",key:null};const Q=He(U);for(const le of Q)if(ne.notes[le])return{note:ne.notes[le],key:le};return{note:"",key:null}},[ne,He]),X=w.useCallback(U=>B(U).note,[B]);return q?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(ut,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!O||O.length===0?a.jsx(_t,{children:a.jsxs(St,{className:"py-12 text-center",children:[a.jsx(Ei,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),a.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):se.length===0?a.jsx(_t,{children:a.jsxs(St,{className:"py-12 text-center",children:[a.jsx(Ar,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),a.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):a.jsxs(a.Fragment,{children:[Y&&!G&&a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[a.jsx(ut,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),a.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),a.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[a.jsxs("div",{className:"flex-1 min-w-48",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),a.jsx("select",{value:e||"",onChange:U=>n(parseInt(U.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:se.map(U=>a.jsx("option",{value:U.id,children:U.name},U.id))})]}),a.jsxs("div",{className:"w-32",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),a.jsxs("select",{value:r,onChange:U=>i(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"0.2",children:"0.2mm"}),a.jsx("option",{value:"0.4",children:"0.4mm"}),a.jsx("option",{value:"0.6",children:"0.6mm"}),a.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),a.jsxs("div",{className:"flex items-end gap-2",children:[a.jsxs(Te,{variant:"secondary",onClick:()=>Z(),disabled:Y,children:[a.jsx(vr,{className:`w-4 h-4 ${Y?"animate-spin":""}`}),"Refresh"]}),a.jsxs(Te,{onClick:()=>c(!0),children:[a.jsx(rr,{className:"w-4 h-4"}),"Add Profile"]})]})]}),a.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[a.jsxs("div",{className:"flex-1 min-w-48 relative",children:[a.jsx(na,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:f,onChange:U=>m(U.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"})]}),me&&a.jsx("div",{className:"w-36",children:a.jsxs("select",{value:g,onChange:U=>x(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"all",children:"All Extruders"}),a.jsx("option",{value:"left",children:"Left Only"}),a.jsx("option",{value:"right",children:"Right Only"})]})}),a.jsx("div",{className:"w-32",children:a.jsxs("select",{value:y,onChange:U=>b(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"all",children:"All Flow"}),a.jsx("option",{value:"hf",children:"HF Only"}),a.jsx("option",{value:"s",children:"S Only"})]})}),a.jsx("div",{className:"w-32",children:a.jsxs("select",{value:v,onChange:U=>N(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"name",children:"Sort: Name"}),a.jsx("option",{value:"k_value",children:"Sort: K-Value"}),a.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),a.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[a.jsxs(Te,{variant:"secondary",onClick:xe,disabled:!j?.profiles?.length,title:"Export profiles to JSON",children:[a.jsx(Gr,{className:"w-4 h-4"}),"Export"]}),a.jsxs(Te,{variant:"secondary",onClick:be,title:"Import profiles from JSON",children:[a.jsx(fi,{className:"w-4 h-4"}),"Import"]}),a.jsx("div",{className:"flex-1"}),S?a.jsxs(a.Fragment,{children:[a.jsxs(Te,{variant:"secondary",onClick:Ce,title:"Select all visible profiles",children:[a.jsx(Do,{className:"w-4 h-4"}),"Select All"]}),a.jsxs(Te,{variant:"secondary",onClick:Ne,disabled:E.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${E.size} selected profiles`,children:[a.jsx(on,{className:"w-4 h-4"}),"Delete (",E.size,")"]}),a.jsxs(Te,{variant:"secondary",onClick:()=>{T(!1),k(new Set)},children:[a.jsx(Ot,{className:"w-4 h-4"}),"Cancel"]})]}):a.jsxs(Te,{variant:"secondary",onClick:()=>T(!0),disabled:!ae.length,title:"Enter selection mode for bulk delete",children:[a.jsx(Do,{className:"w-4 h-4"}),"Select"]})]}),G?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(ut,{className:"w-8 h-8 text-bambu-green animate-spin"})}):W?a.jsx(_t,{children:a.jsxs(St,{className:"py-12 text-center",children:[a.jsx(If,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),a.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),a.jsxs(Te,{variant:"secondary",onClick:()=>Z(),children:[a.jsx(vr,{className:"w-4 h-4"}),"Retry"]})]})}):ae.length>0?me?a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),a.jsx("div",{className:"space-y-1",children:ae.filter(U=>U.extruder_id===1).map(U=>a.jsx(wj,{profile:U,onEdit:()=>o(U),onCopy:()=>d(U),selectionMode:S,isSelected:E.has(F(U)),onToggleSelect:()=>fe(F(U)),note:X(U)},F(U)))})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),a.jsx("div",{className:"space-y-1",children:ae.filter(U=>U.extruder_id===0).map(U=>a.jsx(wj,{profile:U,onEdit:()=>o(U),onCopy:()=>d(U),selectionMode:S,isSelected:E.has(F(U)),onToggleSelect:()=>fe(F(U)),note:X(U)},F(U)))})]})]}):a.jsx("div",{className:"space-y-1",children:ae.map(U=>a.jsx(wj,{profile:U,onEdit:()=>o(U),onCopy:()=>d(U),selectionMode:S,isSelected:E.has(F(U)),onToggleSelect:()=>fe(F(U)),note:X(U)},F(U)))}):f||g!=="all"||y!=="all"?a.jsx(_t,{children:a.jsxs(St,{className:"py-12 text-center",children:[a.jsx(na,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),a.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):a.jsx(_t,{children:a.jsxs(St,{className:"py-12 text-center",children:[a.jsx(z2,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),a.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",r,"mm nozzle"]}),a.jsxs(Te,{onClick:()=>c(!0),children:[a.jsx(rr,{className:"w-4 h-4"}),"Create First Profile"]})]})}),s&&e&&(()=>{const{note:U,key:Q}=B(s);return a.jsx(Sj,{profile:s,printerId:e,nozzleDiameter:r,existingProfiles:te?.profiles||j?.profiles,isDualNozzle:me,initialNote:U,initialNoteKey:Q,onSaveNote:H,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),o(null),Z()},onSave:()=>{o(null),Z()}})})(),l&&e&&a.jsx(Sj,{printerId:e,nozzleDiameter:r,existingProfiles:te?.profiles||j?.profiles,isDualNozzle:me,onSaveNote:H,onClose:()=>{c(!1),Z()},onSave:()=>{c(!1),Z()}}),u&&e&&a.jsx(Sj,{printerId:e,nozzleDiameter:r,existingProfiles:te?.profiles||j?.profiles,isDualNozzle:me,onSaveNote:H,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),Z()},onSave:()=>{d(null),Z()}}),C&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-sm",children:a.jsxs(St,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:a.jsx(on,{className:"w-5 h-5 text-red-500"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),a.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",a.jsx("span",{className:"text-white font-medium",children:E.size})," selected profiles from the printer?"]}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(Te,{variant:"secondary",onClick:()=>D(!1),disabled:A,className:"flex-1",children:"Cancel"}),a.jsxs(Te,{onClick:re,disabled:A,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[A?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(on,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function VL(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,s=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),o=s?(s[1]||s[2])+"mm":null,l=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),c=l?l[1]+"mm":null,u=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),d=u?u[1].toUpperCase():null;return{printer:i,nozzle:o,layerHeight:c,filamentType:d}}function ay(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function jKe(t){const e=wi(t);if(!e)return"";const r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4),s=Math.floor(r/36e5),o=Math.floor(r/864e5);return i<1?"Just now":i<60?`${i}m ago`:s<24?`${s}h ago`:o<7?`${o}d ago`:e.toLocaleDateString()}function PKe({onSuccess:t}){const{showToast:e}=Gn(),[n,r]=w.useState("email"),[i,s]=w.useState(""),[o,l]=w.useState(""),[c,u]=w.useState(""),[d,f]=w.useState(""),[m,g]=w.useState("global"),x=ht({mutationFn:()=>he.cloudLogin(i,o,m),onSuccess:S=>{S.success?(e("Logged in successfully"),t()):S.needs_verification?(e("Verification code sent to your email"),r("code")):e(S.message,"error")},onError:S=>e(S.message,"error")}),y=ht({mutationFn:()=>he.cloudVerify(i,c),onSuccess:S=>{S.success?(e("Logged in successfully"),t()):e(S.message,"error")},onError:S=>e(S.message,"error")}),b=ht({mutationFn:()=>he.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:S=>e(S.message,"error")}),v=S=>{S.preventDefault(),n==="email"?x.mutate():n==="code"?y.mutate():n==="token"&&b.mutate()},N=x.isPending||y.isPending||b.isPending;return a.jsx(_t,{className:"max-w-md mx-auto",children:a.jsxs(St,{children:[a.jsxs("div",{className:"text-center mb-6",children:[a.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:a.jsx(L2,{className:"w-6 h-6 text-bambu-green"})}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),a.jsxs("form",{onSubmit:v,className:"space-y-4",children:[n==="email"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),a.jsx("input",{type:"email",value:i,onChange:S=>s(S.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),a.jsx("input",{type:"password",value:o,onChange:S=>l(S.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),a.jsxs("select",{value:m,onChange:S=>g(S.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"global",children:"Global"}),a.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),a.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),a.jsx("input",{type:"text",value:c,onChange:S=>u(S.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),n==="token"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),a.jsx("textarea",{value:d,onChange:S=>f(S.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),a.jsxs("div",{className:"flex gap-2",children:[n==="code"&&a.jsx(Te,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),a.jsxs(Te,{type:"submit",disabled:N,className:"flex-1",children:[N?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(vz,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&a.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:a.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[a.jsx(of,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&a.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:a.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[a.jsx(vz,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function kp({label:t,value:e,options:n,onChange:r}){const[i,s]=w.useState(!1),o=n.find(l=>l.value===e);return a.jsxs("div",{className:"relative",children:[a.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors",children:[a.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),a.jsx("span",{children:o?.label||"All"}),a.jsx(Br,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),a.jsx("div",{className:"absolute top-full left-0 mt-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 py-1 max-h-60 overflow-y-auto",children:n.map(l=>a.jsxs("button",{onClick:()=>{r(l.value),s(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${e===l.value?"text-bambu-green":"text-white"}`,children:[a.jsx("span",{children:l.label}),l.count!==void 0&&a.jsx("span",{className:"text-bambu-gray text-xs",children:l.count})]},l.value))})]})]})}function RKe(){const[t,e]=w.useState(!1);w.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?a.jsx("button",{onClick:n,className:"fixed bottom-6 right-6 p-3 bg-bambu-green hover:bg-bambu-green-light text-white rounded-full shadow-lg shadow-bambu-green/25 transition-all z-40","aria-label":"Scroll to top",children:a.jsx(og,{className:"w-5 h-5"})}):null}function Nj({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:s,compareDisabled:o}){const l=VL(t.name),c=ay(t.setting_id);return a.jsxs("div",{className:"flex items-center gap-2 group",children:[a.jsx("button",{onClick:e,disabled:o,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?"bg-blue-500/20 border border-blue-500/50":o?"bg-bambu-dark/50 opacity-40 cursor-not-allowed":"bg-bambu-dark hover:bg-bambu-dark-tertiary"} ${r&&!o?"cursor-pointer":""}`,children:a.jsxs("div",{className:"flex items-center gap-2",children:[i&&s!==void 0&&a.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:s+1}),!i&&c&&a.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),a.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),l.filamentType&&t.type==="filament"&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.filamentType}),l.layerHeight&&t.type==="process"&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.layerHeight}),l.printer&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.printer})]})}),a.jsx("button",{onClick:u=>{u.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:"Duplicate",children:a.jsx(ll,{className:"w-4 h-4"})})]})}function qR(t,e=0){const n=" ".repeat(e);if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string"){if(t.includes("\\n")||t.includes(`
- `)){const i=t.replace(/\\n/g,`
- `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
- `);if(i.length>1)return`"""
- `+i.map(s=>n+" "+s).join(`
- `)+`
- `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
- `+t.map(i=>n+" "+qR(i,e+1)).join(`,
- `)+`
- `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
- `+r.map(([s,o])=>n+" "+JSON.stringify(s)+": "+qR(o,e+1)).join(`,
- `)+`
- `+n+"}"}return String(t)}function DKe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:s}=Gn(),o=an(),[l,c]=w.useState(!1),{data:u,isLoading:d}=ct({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>he.getCloudSettingDetail(t.setting_id)}),f=ht({mutationFn:()=>he.deleteCloudSetting(t.setting_id),onSuccess:()=>{s("Preset deleted"),o.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:x=>s(x.message,"error")}),m=ay(t.setting_id),g=VL(t.name,u?.setting?.inherits);return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:a.jsxs(St,{className:"p-0 flex flex-col min-h-0 flex-1",children:[a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),m&&a.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[a.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),g.printer&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"•"}),a.jsx("span",{children:g.printer})]})]})]}),a.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:d?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(ut,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?a.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap break-all bg-bambu-dark p-4 rounded-lg border border-bambu-dark-tertiary overflow-x-auto max-w-full",children:qR(u)}):a.jsx("div",{className:"text-center py-16 text-bambu-gray",children:"Failed to load preset details"})}),l?a.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[a.jsx(xn,{className:"w-5 h-5"}),a.jsx("span",{className:"font-medium",children:"Delete this preset?"})]}),a.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:['This will permanently delete "',t.name,'" from Bambu Cloud. This cannot be undone.']}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Te,{variant:"secondary",onClick:()=>c(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),a.jsxs(Te,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(on,{className:"w-4 h-4"}),"Delete"]})]})]}):a.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Te,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),a.jsxs(Te,{variant:"secondary",onClick:r,children:[a.jsx(ll,{className:"w-4 h-4"}),"Duplicate"]}),m&&a.jsxs(a.Fragment,{children:[a.jsxs(Te,{variant:"secondary",onClick:i,disabled:d||!u,children:[a.jsx(Oi,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Te,{variant:"danger",onClick:()=>c(!0),children:a.jsx(on,{className:"w-4 h-4"})})]})]})})]})})})}function Mre(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Ere(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function OKe({onClose:t,onApply:e}){const{showToast:n}=Gn(),[r,i]=w.useState(Mre),[s,o]=w.useState("all"),[l,c]=w.useState(null),[u,d]=w.useState(""),[f,m]=w.useState(""),[g,x]=w.useState("{}"),[y,b]=w.useState(null),[v,N]=w.useState(null),S=s==="all"?r:r.filter(O=>O.type===s),T=O=>{i(O),Ere(O)},E=O=>{const q=r.filter(j=>j.id!==O);T(q),N(null),n("Template deleted")},k=O=>{c(O.id),d(O.name),m(O.description),x(JSON.stringify(O.settings,null,2)),b(null)},C=()=>{if(!(!l||!u.trim()))try{const O=JSON.parse(g),q=r.map(j=>j.id===l?{...j,name:u.trim(),description:f.trim(),settings:O}:j);T(q),c(null),n("Template updated")}catch(O){b(O.message)}},D=()=>{c(null),d(""),m(""),x("{}"),b(null)},A=O=>{const q=r.map(j=>j.id===O?{...j,showInModal:!j.showInModal}:j);T(q)},R={filament:{label:"Filament",icon:cD,color:"text-amber-400"},print:{label:"Process",icon:Gd,color:"text-blue-400"},printer:{label:"Printer",icon:Ar,color:"text-purple-400"}},F=v?r.find(O=>O.id===v):null;return w.useEffect(()=>{const O=q=>{q.key==="Escape"&&(v?N(null):l?D():t())};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[v,l,t]),a.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[F&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:a.jsx(_t,{className:"w-full max-w-md",children:a.jsxs(St,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:a.jsx(xn,{className:"w-6 h-6 text-red-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Template"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"This action cannot be undone"})]})]}),a.jsxs("p",{className:"text-white mb-6",children:['Are you sure you want to delete "',a.jsx("span",{className:"font-medium",children:F.name}),'"?']}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Te,{variant:"secondary",onClick:()=>N(null),className:"flex-1",children:"Cancel"}),a.jsxs(Te,{onClick:()=>E(v),className:"flex-1 bg-red-500 hover:bg-red-600",children:[a.jsx(on,{className:"w-4 h-4"}),"Delete"]})]})]})})}),a.jsx(_t,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:a.jsxs(St,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(b0,{className:"w-5 h-5 text-amber-400"}),"Quick Templates"]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Type:"}),["all","filament","print","printer"].map(O=>a.jsx("button",{onClick:()=>o(O),className:`px-3 py-1 text-sm rounded-lg transition-colors ${s===O?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:O==="all"?"All":R[O].label},O))]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:S.length===0?a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(b0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),a.jsx("p",{children:"No templates yet"}),a.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):a.jsx("div",{className:"space-y-2",children:S.map(O=>{const q=R[O.type],j=q.icon;return l===O.id?a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[a.jsx("input",{type:"text",value:u,onChange:G=>d(G.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}),a.jsx("input",{type:"text",value:f,onChange:G=>m(G.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"})]}),a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:"Settings (JSON)"}),a.jsx("textarea",{value:g,onChange:G=>{x(G.target.value),b(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${y?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),y&&a.jsx("p",{className:"text-xs text-red-400 mt-1",children:y})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Te,{size:"sm",onClick:C,disabled:!u.trim(),children:[a.jsx(bs,{className:"w-4 h-4"}),"Save"]}),a.jsx(Te,{size:"sm",variant:"secondary",onClick:D,children:"Cancel"})]})]},O.id):a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[a.jsx(j,{className:`w-5 h-5 ${q.color} flex-shrink-0`}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:O.name}),a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:O.description})]}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(O.settings).length," fields"]}),a.jsx("button",{onClick:()=>A(O.id),className:`p-1 transition-colors ${O.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:O.showInModal?"Shown in modals":"Hidden in modals",children:O.showInModal?a.jsx(lu,{className:"w-4 h-4"}):a.jsx(I2,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>e(O),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),a.jsx("button",{onClick:()=>k(O),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:a.jsx(Oi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>N(O.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:a.jsx(on,{className:"w-4 h-4"})})]},O.id)})})})]})})]})}function Tre({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[s,o]=w.useState("changes"),[l,c]=w.useState(""),u=w.useMemo(()=>{const g=new Set([...Object.keys(e),...Object.keys(n)]),x=[];for(const y of g){if(y==="inherits"||y==="version")continue;const b=e[y],v=n[y],N=y in e,S=y in n;let T;!N&&S?T="added":N&&!S?T="removed":JSON.stringify(b)!==JSON.stringify(v)?T="changed":T="same",x.push({key:y,left:b,right:v,status:T})}return x.sort((y,b)=>{const v={changed:0,added:1,removed:2,same:3};return v[y.status]!==v[b.status]?v[y.status]-v[b.status]:y.key.localeCompare(b.key)})},[e,n]),d=w.useMemo(()=>{let g=[...u];if(s==="changes"&&(g=g.filter(x=>x.status!=="same")),l){const x=l.toLowerCase();g=g.filter(y=>y.key.toLowerCase().includes(x)||String(y.left).toLowerCase().includes(x)||String(y.right).toLowerCase().includes(x))}return g},[u,s,l]),f=w.useMemo(()=>({added:u.filter(g=>g.status==="added").length,removed:u.filter(g=>g.status==="removed").length,changed:u.filter(g=>g.status==="changed").length,same:u.filter(g=>g.status==="same").length}),[u]),m=g=>{if(g===void 0)return"—";if(g===null)return"null";if(Array.isArray(g))return g.length===0?"[]":g.length===1?String(g[0]):g.join(", ");if(typeof g=="object")return JSON.stringify(g);const x=String(g);if(x.includes("\\n")||x.length>100){const y=x.split("\\n").length;if(y>1)return`[${y} lines of G-code/script]`;if(x.length>100)return x.substring(0,100)+"…"}return x};return w.useEffect(()=>{const g=x=>{x.key==="Escape"&&t()};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsx(_t,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:a.jsxs(St,{className:"p-0 flex flex-col min-h-0 flex-1",children:[a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(qp,{className:"w-5 h-5 text-blue-400"}),"Compare Presets"]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:a.jsx(Ot,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Left:"}),a.jsx("p",{className:"text-white font-medium truncate",children:r})]}),a.jsxs("div",{className:"text-center",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Right:"}),a.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),a.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(rr,{className:"w-3.5 h-3.5"}),f.added," added"]}),a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(Yj,{className:"w-3.5 h-3.5"}),f.removed," removed"]}),a.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[a.jsx(Hj,{className:"w-3.5 h-3.5"}),f.changed," changed"]}),a.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[a.jsx(OT,{className:"w-3.5 h-3.5"}),f.same," same"]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"relative",children:[a.jsx(na,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:l,onChange:g=>c(g.target.value),placeholder:"Search fields...",className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),f.same>0&&a.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>o("changes"),className:`px-3 py-1.5 text-sm transition-colors ${s==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"Changes"}),a.jsx("button",{onClick:()=>o("all"),className:`px-3 py-1.5 text-sm transition-colors ${s==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"All"})]})]})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:d.length===0?a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(OT,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),a.jsx("p",{children:s==="changes"?"No differences found":"No fields match the search"})]}):a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:a.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[a.jsx("th",{className:"text-left p-3 w-1/3",children:"Field"}),a.jsx("th",{className:"text-left p-3 w-1/3",children:r}),a.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),a.jsx("tbody",{children:d.map(g=>{const x={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[g.status],y={added:a.jsx(rr,{className:"w-3.5 h-3.5 text-green-400"}),removed:a.jsx(Yj,{className:"w-3.5 h-3.5 text-red-400"}),changed:a.jsx(Hj,{className:"w-3.5 h-3.5 text-amber-400"}),same:a.jsx(OT,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[g.status];return a.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${x}`,children:[a.jsx("td",{className:"p-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[y,a.jsx("span",{className:"text-sm text-white font-mono",children:g.key})]})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${g.status==="removed"?"text-red-300":g.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(g.left)})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${g.status==="added"?"text-green-300":g.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(g.right)})})]},g.key)})})]})})]})})})}function LKe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=Gn(),i=an(),s=!!e?.setting_id,[o,l]=w.useState("common"),[c,u]=w.useState(e?.type||"filament"),[d,f]=w.useState(e?.name?s?e.name:`${e.name} (Copy)`:""),[m,g]=w.useState(e?.base_id||""),[x,y]=w.useState(""),[b,v]=w.useState(e?.setting||{inherits:""}),[N,S]=w.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[T,E]=w.useState(null),[k,C]=w.useState(""),[D,A]=w.useState(!1),[R,F]=w.useState(""),[O,q]=w.useState(!1),[j,G]=w.useState(Mre),[Y,K]=w.useState(!1),[Z,te]=w.useState(""),[ne,z]=w.useState(""),[W,se]=w.useState(!0),[ae,de]=w.useState(null),[me,xe]=w.useState(!1),be=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),fe=w.useMemo(()=>be.filter(oe=>ay(oe.setting_id)),[be]),{data:Ce}=ct({queryKey:["cloudFields",c],queryFn:()=>he.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:Ne}=ct({queryKey:["allPresetDetails",c,fe.map(oe=>oe.setting_id).join(",")],queryFn:async()=>{const oe={};for(let Le=0;Le<fe.length;Le+=5){const Ke=fe.slice(Le,Le+5);(await Promise.all(Ke.map(async _e=>{try{const ce=await he.getCloudSettingDetail(_e.setting_id);return{id:_e.setting_id,detail:ce}}catch{return null}}))).forEach(_e=>{_e&&(oe[_e.id]=_e.detail)})}return oe},enabled:fe.length>0,staleTime:1e3*60*10}),{data:re,isLoading:He}=ct({queryKey:["cloudSettingDetail",m],queryFn:()=>he.getCloudSettingDetail(m),enabled:!!m});w.useEffect(()=>{o!=="json"&&S(JSON.stringify(b,null,2))},[b,o]);const H=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[c]||[]).filter(ve=>!ay(ve.setting_id)).sort((ve,Le)=>ve.name.localeCompare(Le.name)),[n,c]);w.useEffect(()=>{if(!m)return;const oe=H.find(ve=>ve.setting_id===m);oe&&(y(oe.name),s||(v({inherits:oe.name}),S(JSON.stringify({inherits:oe.name},null,2))))},[m,H,s]);const B=w.useMemo(()=>{const oe=Ce?.fields||[],ve=new Set(oe.map(_e=>_e.key)),Le=new Set,Ke=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);Ne&&Object.values(Ne).forEach(_e=>{_e?.setting&&Object.keys(_e.setting).forEach(ce=>{!ve.has(ce)&&!Ke.has(ce)&&Le.add(ce)})}),Object.keys(b).forEach(_e=>{!ve.has(_e)&&!Ke.has(_e)&&Le.add(_e)});const lt=Array.from(Le).sort().map(_e=>({key:_e,label:_e.replace(/_/g," ").replace(/\b\w/g,ce=>ce.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...oe,...lt]},[Ce,Ne,b]),X=B.filter(oe=>oe.label.toLowerCase().includes(k.toLowerCase())||oe.key.toLowerCase().includes(k.toLowerCase())),U=()=>{if(R.trim()){const oe=R.trim().toLowerCase().replace(/\s+/g,"_");Q(oe,""),F(""),q(!1),r(`Field "${oe}" added`)}},Q=(oe,ve)=>{v(Le=>{const Ke={...Le};return ve===""||ve===void 0?delete Ke[oe]:Ke[oe]=ve,Ke})},le=oe=>{v(ve=>({...ve,...oe.settings})),de(oe.name),r("Template applied")},Pe=()=>{if(!Z.trim())return;const oe={...b};if(delete oe.inherits,Object.keys(oe).length===0){r("No overrides to save","error");return}const ve={id:Date.now().toString(),name:Z.trim(),description:ne.trim()||"Custom template",type:c,settings:oe,showInModal:W},Le=[...j,ve];G(Le),Ere(Le),K(!1),te(""),z(""),se(!0),r("Template saved")},Oe=w.useMemo(()=>j.filter(oe=>oe.type===c&&oe.showInModal),[c,j]),je=oe=>{S(oe);try{const ve=JSON.parse(oe);v(ve),E(null)}catch(ve){E(ve.message)}},$=oe=>{oe.preventDefault(),A(!1);const ve=oe.dataTransfer.files[0];if(ve&&ve.name.endsWith(".json")){const Le=new FileReader;Le.onload=Ke=>{try{const lt=Ke.target?.result,_e=JSON.parse(lt),ce=_e.setting||_e;v(ee=>({...ee,...ce})),S(JSON.stringify({...b,...ce},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},Le.readAsText(ve)}},I=ht({mutationFn:()=>{const oe={...b},ve=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";oe[ve]=`"${d}"`;const Le={type:c,name:d,base_id:m,setting:oe};return he.createCloudSetting(Le)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:oe=>r(oe.message,"error")}),V=ht({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return he.updateCloudSetting(e.setting_id,{name:d,setting:b})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:oe=>r(oe.message,"error")}),ie=s?V:I,Se=re?.setting?.inherits,ye=Se?H.find(oe=>oe.name===Se):void 0,{data:$e}=ct({queryKey:["cloudSettingDetail",ye?.setting_id],queryFn:()=>he.getCloudSettingDetail(ye.setting_id),enabled:!!ye?.setting_id}),Ue=w.useMemo(()=>{const oe=$e?.setting||{},ve=re?.setting||{},Le=m&&Ne?.[m]?.setting?Ne[m].setting:{};return{...oe,...ve,...Le}},[m,re,$e,Ne]),Ge=oe=>{if(oe==null)return"";if(Array.isArray(oe)){const ve=[...new Set(oe.map(Le=>String(Le)))];return ve.length===1?ve[0]:oe.join(", ")}return String(oe)},We=oe=>{const ve=b[oe.key],Le=Ue[oe.key],Ke=Ge(Le),lt=He?"Loading...":Ke||"",_e="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(oe.type==="boolean"){const ce=ve==="1"||ve===void 0&&Le==="1";return a.jsx("button",{type:"button",onClick:()=>Q(oe.key,ve==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${ce?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:a.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${ce?"translate-x-3.5":"translate-x-0.5"}`})})}return oe.type==="select"?a.jsxs("select",{value:ve||"",onChange:ce=>Q(oe.key,ce.target.value),className:_e,children:[a.jsx("option",{value:"",children:lt}),oe.options?.map(ce=>a.jsx("option",{value:ce.value,children:ce.label},ce.value))]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:oe.type==="number"?"number":"text",value:ve!==void 0?String(ve):"",onChange:ce=>Q(oe.key,ce.target.value),step:oe.step,min:oe.min,max:oe.max,placeholder:lt,className:_e}),oe.unit&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:oe.unit})]})},Ye=w.useMemo(()=>re?.setting?re.setting:{},[re]);return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:oe=>{oe.preventDefault(),A(!0)},onDragLeave:()=>A(!1),onDrop:$,children:[me&&m&&a.jsx(Tre,{onClose:()=>xe(!1),leftPreset:Ye,rightPreset:b,leftLabel:`Base: ${x||m}`,rightLabel:`Current: ${d||"New Preset"}`}),a.jsx(_t,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:a.jsxs(St,{className:"p-0 flex flex-col h-full",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:s?"Edit Preset":e?"Duplicate Preset":"Create New Preset"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize settings for your new preset"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[m&&a.jsxs("button",{onClick:()=>xe(!0),className:"flex items-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Compare with base preset",children:[a.jsx(qp,{className:"w-4 h-4"}),"Compare"]}),a.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Ot,{className:"w-5 h-5"})})]})]}),D&&a.jsx("div",{className:"absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10",children:a.jsxs("div",{className:"text-center",children:[a.jsx(fi,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),a.jsx("p",{className:"text-bambu-green font-medium",children:"Drop JSON file to import"})]})}),a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Type"}),a.jsxs("select",{value:c,onChange:oe=>{u(oe.target.value),g("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"filament",children:"Filament"}),a.jsx("option",{value:"print",children:"Process"}),a.jsx("option",{value:"printer",children:"Printer"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Base Preset"}),a.jsxs("select",{value:m,onChange:oe=>g(oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"Select base preset..."}),H.map(oe=>a.jsx("option",{value:oe.setting_id,children:oe.name},oe.setting_id))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Preset Name"}),a.jsx("input",{type:"text",value:d,onChange:oe=>f(oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"My Custom Preset"})]})]}),x&&a.jsx("div",{className:"text-xs text-bambu-gray",children:a.jsxs("p",{className:"flex items-center gap-1",children:[a.jsx(Ua,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",a.jsx("span",{className:"text-white",children:x}),He&&a.jsx(ut,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[a.jsxs("button",{onClick:()=>l("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${o==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(_z,{className:"w-4 h-4"}),"Common"]}),a.jsxs("button",{onClick:()=>l("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${o==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(V2,{className:"w-4 h-4"}),"All Fields"]}),a.jsxs("button",{onClick:()=>l("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${o==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(aW,{className:"w-4 h-4"}),"JSON",T&&a.jsx(Ei,{className:"w-3 h-3 text-red-400"})]}),a.jsx("div",{className:"flex-1"}),a.jsxs("button",{onClick:()=>{const oe={name:d,type:c,base_id:m,setting:b},ve=new Blob([JSON.stringify(oe,null,2)],{type:"application/json"}),Le=URL.createObjectURL(ve),Ke=document.createElement("a");Ke.href=Le,Ke.download=`${d||"preset"}.json`,document.body.appendChild(Ke),Ke.click(),document.body.removeChild(Ke),URL.revokeObjectURL(Le),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:[a.jsx(Gr,{className:"w-4 h-4"}),"Export"]}),a.jsxs("button",{onClick:()=>document.getElementById("file-import")?.click(),className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Import settings from JSON file",children:[a.jsx(fi,{className:"w-4 h-4"}),"Import"]}),a.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:oe=>{const ve=oe.target.files?.[0];if(ve){const Le=new FileReader;Le.onload=Ke=>{try{const lt=JSON.parse(Ke.target?.result),_e=lt.setting||lt;v(ce=>({...ce,..._e})),r("File imported")}catch{r("Invalid JSON","error")}},Le.readAsText(ve)}}})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[o==="common"&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[a.jsx(b0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(b).filter(oe=>oe!=="inherits").length>0&&a.jsxs("button",{onClick:()=>K(!Y),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[a.jsx(bs,{className:"w-3 h-3"}),"Save as template"]})]}),Y&&a.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[a.jsx("input",{type:"text",value:Z,onChange:oe=>te(oe.target.value),placeholder:"Template name",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),a.jsx("input",{type:"text",value:ne,onChange:oe=>z(oe.target.value),placeholder:"Description (optional)",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Te,{size:"sm",onClick:Pe,disabled:!Z.trim(),children:[a.jsx(bs,{className:"w-3 h-3"}),"Save"]}),a.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>K(!1),children:"Cancel"})]}),a.jsxs("button",{onClick:()=>se(!W),className:`flex items-center gap-1.5 text-xs transition-colors ${W?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[W?a.jsx(lu,{className:"w-3.5 h-3.5"}):a.jsx(I2,{className:"w-3.5 h-3.5"}),W?"Show in modals":"Hidden in modals"]})]})]}),ae&&a.jsxs("div",{className:"mb-3 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg flex items-center gap-2",children:[a.jsx(Ua,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("span",{className:"text-sm text-bambu-green",children:["Template applied: ",a.jsx("span",{className:"font-medium",children:ae})]}),a.jsx("button",{onClick:()=>de(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:a.jsx(Ot,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Oe.map(oe=>a.jsxs("button",{onClick:()=>le(oe),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:oe.name}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:oe.description})]},oe.id)),Oe.length===0&&a.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."})]}),a.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:"Manage templates via the Templates button on the main page"})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Common Settings"}),a.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:B.slice(0,10).map(oe=>a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:oe.label}),a.jsx("div",{className:"w-48",children:We(oe)})]},oe.key))})]}),Object.keys(b).length>1&&a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Current Overrides"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(b).filter(([oe])=>oe!=="inherits").map(([oe,ve])=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[oe,": ",String(ve).slice(0,20),a.jsx("button",{onClick:()=>Q(oe,void 0),className:"hover:text-white",children:a.jsx(Ot,{className:"w-3 h-3"})})]},oe))})]})]}),o==="fields"&&a.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[a.jsx("h3",{className:"text-sm font-medium text-white",children:"Available Fields"}),a.jsx("span",{className:"text-xs text-bambu-gray",children:Ne?`${B.length} fields`:"Loading..."})]}),a.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[a.jsx(na,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:k,onChange:oe=>C(oe.target.value),placeholder:"Search fields...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[X.filter(oe=>!(oe.key in b)).map(oe=>{const ve=Ue[oe.key],Le=Ge(ve);return a.jsxs("div",{onClick:()=>{v(Ke=>({...Ke,[oe.key]:Le||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm text-white truncate",children:oe.label}),a.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:oe.key})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Le&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:Le,children:[Le.slice(0,20),Le.length>20?"...":""]}),a.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors",children:a.jsx(rr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},oe.key)}),X.filter(oe=>!(oe.key in b)).length===0&&a.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:k?"No matching fields":"All fields added"})]}),a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:O?a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:R,onChange:oe=>F(oe.target.value),onKeyDown:oe=>oe.key==="Enter"&&U(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),a.jsx(Te,{size:"sm",onClick:U,disabled:!R.trim(),children:a.jsx(rr,{className:"w-4 h-4"})}),a.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>{q(!1),F("")},children:a.jsx(Ot,{className:"w-4 h-4"})})]}):a.jsxs("button",{onClick:()=>q(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[a.jsx(rr,{className:"w-4 h-4"}),"Add custom field"]})})]}),a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[a.jsx("h3",{className:"text-sm font-medium text-white",children:"Your Overrides"}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[Object.keys(b).filter(oe=>oe!=="inherits").length," fields"]})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(b).filter(([oe])=>oe!=="inherits").map(([oe,ve])=>{const Le=B.find(Ke=>Ke.key===oe);return a.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-white",children:Le?.label||oe}),a.jsx("p",{className:"text-xs text-bambu-gray-dark",children:oe})]}),a.jsx("button",{onClick:()=>Q(oe,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:a.jsx(Ot,{className:"w-4 h-4"})})]}),Le?We(Le):a.jsx("input",{type:"text",value:String(ve),onChange:Ke=>Q(oe,Ke.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},oe)}),Object.keys(b).filter(oe=>oe!=="inherits").length===0&&a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(_z,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:"No overrides yet"}),a.jsx("p",{className:"text-xs mt-1",children:"Click fields on the left to add them"})]})]}),Object.keys(b).filter(oe=>oe!=="inherits").length>0&&a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:a.jsxs("button",{onClick:()=>{K(!0),l("common")},className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[a.jsx(bs,{className:"w-4 h-4"}),"Save as template"]})})]})]}),o==="json"&&a.jsxs("div",{className:"space-y-2",children:[T&&a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[a.jsx(Ei,{className:"w-4 h-4"}),T]}),a.jsx("textarea",{value:N,onChange:oe=>je(oe.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${T?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Tip: Drag & drop a .json file anywhere on this modal to import settings"})]})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[a.jsx(Te,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),a.jsxs(Te,{onClick:()=>ie.mutate(),disabled:ie.isPending||!d.trim()||!s&&!m||!!T,className:"flex-1",children:[ie.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):s?a.jsx(bs,{className:"w-4 h-4"}):a.jsx(rr,{className:"w-4 h-4"}),s?"Save":e?"Duplicate":"Create"]})]})]})})]})}function IKe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i}){const[s,o]=w.useState(""),[l,c]=w.useState("all"),[u,d]=w.useState("all"),[f,m]=w.useState("all"),[g,x]=w.useState("all"),[y,b]=w.useState("all"),[v,N]=w.useState("all"),[S,T]=w.useState(null),[E,k]=w.useState(!1),[C,D]=w.useState(!1),[A,R]=w.useState(null),[F,O]=w.useState(null),[q,j]=w.useState(null),[G,Y]=w.useState(!1),[K,Z]=w.useState([null,null]),[te,ne]=w.useState(!1),[z,W]=w.useState(null),se=an(),ae=w.useMemo(()=>[...t.filament.map(X=>({...X,type:"filament"})),...t.printer.map(X=>({...X,type:"printer"})),...t.process.map(X=>({...X,type:"process"}))].map(X=>({...X,meta:VL(X.name)})),[t]),de=w.useMemo(()=>{const B=new Set,X=new Set,U=new Set;return ae.forEach(Q=>{Q.meta.nozzle&&B.add(Q.meta.nozzle),Q.meta.filamentType&&X.add(Q.meta.filamentType),Q.meta.layerHeight&&U.add(Q.meta.layerHeight)}),{printers:i.map(Q=>({id:Q.id.toString(),name:Q.name})),nozzles:Array.from(B).sort((Q,le)=>parseFloat(Q)-parseFloat(le)),filaments:Array.from(X).sort(),layerHeights:Array.from(U).sort((Q,le)=>parseFloat(Q)-parseFloat(le))}},[ae,i]),me=w.useMemo(()=>f==="all"?null:i.find(X=>X.id.toString()===f)?.model||null,[f,i]),xe=w.useMemo(()=>ae.filter(B=>l==="all"||B.type===l).filter(B=>{if(u==="all")return!0;const X=ay(B.setting_id);return u==="custom"?X:!X}).filter(B=>{if(f==="all"||!me)return!0;const X=B.meta.printer?.toLowerCase()||"",U=me.toLowerCase();return X.includes(U)||U.includes(X)}).filter(B=>g==="all"||B.meta.nozzle===g).filter(B=>y==="all"||B.meta.filamentType===y).filter(B=>v==="all"||B.meta.layerHeight===v).filter(B=>s===""||B.name.toLowerCase().includes(s.toLowerCase())).sort((B,X)=>B.name.localeCompare(X.name)),[ae,l,u,f,me,g,y,v,s]),be=B=>{if(G){const X=K[0]?.setting_id===B.setting_id,U=K[1]?.setting_id===B.setting_id;if(X)Z([K[1],null]);else if(U)Z([K[0],null]);else if(!K[0])Z([B,null]);else if(K[1]){if(K[0].type!==B.type)return;Z([K[0],B])}else{if(K[0].type!==B.type)return;Z([K[0],B])}}else T(B)},fe=B=>{if(K[0]?.setting_id===B.setting_id)return 0;if(K[1]?.setting_id===B.setting_id)return 1},Ce=async B=>{try{const X=await he.getCloudSettingDetail(B.setting_id),U=B.type==="process"?"print":B.type;R({type:U,name:B.name,base_id:X.base_id||"GFSA00",setting:X.setting||{}}),T(null)}catch(X){console.error("Failed to fetch preset details for duplication:",X)}},Ne=async B=>{try{se.removeQueries({queryKey:["cloudSettingDetail",B.setting_id]});const X=await he.getCloudSettingDetail(B.setting_id),U=B.type==="process"?"print":B.type;O({type:U,name:B.name,base_id:X.base_id||"GFSA00",setting:X.setting||{},setting_id:B.setting_id}),T(null)}catch(X){console.error("Failed to fetch preset details for editing:",X)}},re=()=>{c("all"),d("all"),m("all"),x("all"),b("all"),N("all"),o("")},He=l!=="all"||u!=="all"||f!=="all"||g!=="all"||y!=="all"||v!=="all"||s!=="",H=t.filament.length+t.printer.length+t.process.length;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"space-y-4 mb-6",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(na,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:s,onChange:B=>o(B.target.value),placeholder:"Search presets...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Te,{variant:G?"primary":"secondary",onClick:()=>{G?(Y(!1),Z([null,null])):Y(!0)},children:[a.jsx(qp,{className:"w-4 h-4"}),G?"Cancel":"Compare"]}),a.jsxs(Te,{variant:"secondary",onClick:()=>D(!0),children:[a.jsx(b0,{className:"w-4 h-4"}),"Templates"]}),a.jsxs(Te,{variant:"secondary",onClick:n,disabled:r,children:[a.jsx(vr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),a.jsxs(Te,{onClick:()=>k(!0),children:[a.jsx(rr,{className:"w-4 h-4"}),"New Preset"]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(U2,{className:"w-4 h-4 text-bambu-gray"}),a.jsx(kp,{label:"Type",value:l,options:[{value:"all",label:"All",count:H},{value:"filament",label:"Filament",count:t.filament.length},{value:"printer",label:"Printer",count:t.printer.length},{value:"process",label:"Process",count:t.process.length}],onChange:B=>c(B)}),a.jsx(kp,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:B=>d(B)}),de.printers.length>0&&a.jsx(kp,{label:"Printer",value:f,options:[{value:"all",label:"All"},...de.printers.map(B=>({value:B.id,label:B.name}))],onChange:m}),de.nozzles.length>0&&a.jsx(kp,{label:"Nozzle",value:g,options:[{value:"all",label:"All"},...de.nozzles.map(B=>({value:B,label:B}))],onChange:x}),de.filaments.length>0&&(l==="all"||l==="filament")&&a.jsx(kp,{label:"Filament",value:y,options:[{value:"all",label:"All"},...de.filaments.map(B=>({value:B,label:B}))],onChange:b}),de.layerHeights.length>0&&(l==="all"||l==="process")&&a.jsx(kp,{label:"Layer",value:v,options:[{value:"all",label:"All"},...de.layerHeights.map(B=>({value:B,label:B}))],onChange:N}),He&&a.jsx("button",{onClick:re,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),G&&a.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(qp,{className:"w-5 h-5 text-blue-400"}),a.jsx("span",{className:"text-white font-medium",children:"Compare Mode"}),a.jsx("span",{className:"text-bambu-gray",children:K[0]?`Select another ${K[0].type} preset`:"Click two presets of the same type to compare"})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${K[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:K[0]?K[0].name:"1. Select first"}),a.jsx(Hj,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${K[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:K[1]?K[1].name:"2. Select second"})]}),K[0]&&K[1]&&a.jsxs(Te,{size:"sm",onClick:async()=>{try{const[B,X]=await Promise.all([he.getCloudSettingDetail(K[0].setting_id),he.getCloudSettingDetail(K[1].setting_id)]);W([B.setting||{},X.setting||{}]),ne(!0)}catch{}},children:[a.jsx(qp,{className:"w-4 h-4"}),"Compare Now"]})]})]})}),a.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(qn,{className:"w-3 h-3"}),"Last synced: ",jKe(e.toISOString())]}),a.jsxs("span",{children:["Showing ",xe.length," of ",H," presets"]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),a.jsx("span",{children:"= My preset (editable)"})]})]}),xe.length===0?a.jsxs("div",{className:"text-center py-16",children:[a.jsx(ul,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),a.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),He&&a.jsx("button",{onClick:re,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:"Clear filters"})]}):a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(cD,{className:"w-4 h-4 text-amber-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Filament"}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",xe.filter(B=>B.type==="filament").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[xe.filter(B=>B.type==="filament").map(B=>a.jsx(Nj,{setting:B,onClick:()=>be(B),onDuplicate:()=>Ce(B),compareMode:G,isCompareSelected:fe(B)!==void 0,compareIndex:fe(B),compareDisabled:G&&!!K[0]&&K[0].type!==B.type},B.setting_id)),xe.filter(B=>B.type==="filament").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No filament presets"})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(Gd,{className:"w-4 h-4 text-blue-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Process"}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",xe.filter(B=>B.type==="process").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[xe.filter(B=>B.type==="process").map(B=>a.jsx(Nj,{setting:B,onClick:()=>be(B),onDuplicate:()=>Ce(B),compareMode:G,isCompareSelected:fe(B)!==void 0,compareIndex:fe(B),compareDisabled:G&&!!K[0]&&K[0].type!==B.type},B.setting_id)),xe.filter(B=>B.type==="process").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No process presets"})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(Ar,{className:"w-4 h-4 text-purple-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Printer"}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",xe.filter(B=>B.type==="printer").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[xe.filter(B=>B.type==="printer").map(B=>a.jsx(Nj,{setting:B,onClick:()=>be(B),onDuplicate:()=>Ce(B),compareMode:G,isCompareSelected:fe(B)!==void 0,compareIndex:fe(B),compareDisabled:G&&!!K[0]&&K[0].type!==B.type},B.setting_id)),xe.filter(B=>B.type==="printer").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),S&&a.jsx(DKe,{setting:S,onClose:()=>T(null),onDeleted:()=>T(null),onDuplicate:()=>Ce(S),onEdit:()=>Ne(S)}),(E||A||F||q)&&a.jsx(LKe,{onClose:()=>{k(!1),R(null),O(null),j(null)},initialData:F||A||(q?{type:q.type,name:"",base_id:"",setting:q.setting}:void 0),allPresets:t}),C&&a.jsx(OKe,{onClose:()=>D(!1),onApply:B=>{j({type:B.type,setting:B.settings}),D(!1)}}),te&&z&&K[0]&&K[1]&&a.jsx(Tre,{onClose:()=>{ne(!1),W(null)},leftPreset:z[0],rightPreset:z[1],leftLabel:K[0].name,rightLabel:K[1].name})]})}function FKe(){const t=an(),{showToast:e}=Gn(),[n,r]=w.useState("cloud"),[i,s]=w.useState(),{data:o,isLoading:l}=ct({queryKey:["cloudStatus"],queryFn:he.getCloudStatus}),{data:c=[]}=ct({queryKey:["printers"],queryFn:he.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:m}=ct({queryKey:["cloudSettings"],queryFn:()=>he.getCloudSettings(),enabled:!!o?.is_authenticated,retry:!1,staleTime:1e3*60*5});w.useEffect(()=>{m&&s(new Date(m))},[m]);const g=ht({mutationFn:he.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),x=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return l?a.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:a.jsx(ut,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a.jsxs("div",{className:"p-6 lg:p-8",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),a.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[a.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:[a.jsx(L2,{className:"w-4 h-4"}),"Cloud Profiles"]}),a.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:[a.jsx(z2,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&a.jsxs(a.Fragment,{children:[o?.is_authenticated&&a.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:["Connected as ",a.jsx("span",{className:"text-white",children:o.email})]})]}),a.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>g.mutate(),disabled:g.isPending,children:[a.jsx(Xj,{className:"w-4 h-4"}),"Logout"]})]}),o?.is_authenticated?d?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(ut,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?a.jsx(IKe,{settings:u,lastSyncTime:i,onRefresh:()=>f(),isRefreshing:d,printers:c}):a.jsxs("div",{className:"text-center py-16",children:[a.jsx("p",{className:"text-bambu-gray mb-4",children:"Failed to load profiles"}),a.jsx(Te,{onClick:()=>f(),children:"Retry"})]}):a.jsx(PKe,{onSuccess:x})]}),n==="kprofiles"&&a.jsx(kKe,{}),a.jsx(RKe,{})]})}const zb={Droplet:cD,Flame:Pue,Ruler:dhe,Sparkles:b0,Square:Oo,Cable:Tce,Wrench:Wd,Calendar:si,Timer:Sd,Cog:aue,Fan:sW,Zap:Kd,Wind:yW,Thermometer:W2,Layers:ul,Box:Hs,Target:gW,RefreshCw:vr,Settings:ly,Filter:U2,CircleDot:qce};function u0(t){return t&&zb[t]||Wd}function jp(t,e){if(e==="days")return t<1?"Today":t===1?"1 day":t<7?`${Math.round(t)} days`:t<180?`${Math.round(t/7)} weeks`:`${Math.round(t/30)} months`;{if(t<1)return`${Math.round(t*60)}m`;if(t<24)return`${t<10?t.toFixed(1):Math.round(t)}h`;const n=t/24;if(n<7)return`${n<2?n.toFixed(1):Math.round(n)}d`;const r=n/7;return r<12?`${r<2?r.toFixed(1):Math.round(r)}w`:`${Math.round(r/4)}mo`}}function Mj(t,e){return e==="days"?t===1?"1 day":t===7?"1 week":t===14?"2 weeks":t===30?"1 month":t===60?"2 months":t===90?"3 months":t===180?"6 months":t===365?"1 year":`${t} days`:`${t}h`}function UKe(t,e){const n=(e||"").toUpperCase().replace(/[- ]/g,""),r=n.includes("X1"),i=n.includes("P1"),s=n.includes("A1MINI"),o=n.includes("A1")&&!s,l=n.includes("H2D"),c=n.includes("H2C"),u=n.includes("H2S"),d=l||c||u,f=n.includes("P2S");switch(t){case"Lubricate Linear Rails":return r?"https://wiki.bambulab.com/en/x1/maintenance/basic-maintenance":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":s?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":f?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/general/lead-screws-lubrication";case"Clean Nozzle/Hotend":return r||i?"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog":s||o?"https://wiki.bambulab.com/en/a1-mini/troubleshooting/nozzle-clog":d?"https://wiki.bambulab.com/en/h2/maintenance/nozzl-cold-pull-maintenance-and-cleaning":f?"https://wiki.bambulab.com/en/p2s/maintenance/cold-pull-maintenance-hotend":"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog";case"Check Belt Tension":return r?"https://wiki.bambulab.com/en/x1/maintenance/belt-tension":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":s?"https://wiki.bambulab.com/en/a1-mini/maintenance/belt_tension":o?"https://wiki.bambulab.com/en/a1/maintenance/belt_tension":l?"https://wiki.bambulab.com/en/h2/maintenance/belt-tension":c?"https://wiki.bambulab.com/en/h2c/maintenance/belt-tension":u?"https://wiki.bambulab.com/en/h2s/maintenance/belt-tension":f?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/x1/maintenance/belt-tension";case"Clean Carbon Rods":return r||i?"https://wiki.bambulab.com/en/general/carbon-rods-clearance":s||o||d||f?null:"https://wiki.bambulab.com/en/general/carbon-rods-clearance";case"Clean Build Plate":return"https://wiki.bambulab.com/en/filament-acc/acc/pei-plate-clean-guide";case"Check PTFE Tube":return r||i?"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube":s||o?"https://wiki.bambulab.com/en/a1-mini/maintenance/ptfe-tube":l?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":u?"https://wiki.bambulab.com/en/h2s/maintenance/replace-ptfe-tube-on-h2s-printer":c?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube";case"Replace HEPA Filter":case"HEPA Filter":case"Replace Carbon Filter":case"Carbon Filter":return d?"https://wiki.bambulab.com/en/h2/maintenance/replace-smoke-purifier-air-filte":"https://wiki.bambulab.com/en/x1/maintenance/replace-carbon-filter";case"Lubricate Left Nozzle Rail":case"Left Nozzle Rail":return d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;default:return null}}function zKe({item:t,onPerform:e,onToggle:n}){const r=u0(t.maintenance_type_icon),i=t.interval_type||"hours",o=(()=>{if(i==="days"){const f=t.days_since_maintenance??0;return Math.max(0,Math.min(100,f/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),l=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",c=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",u=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",d=()=>{if(!t.enabled)return"Disabled";if(i==="days"){const f=t.days_until_due??0;return t.is_due?`Overdue by ${jp(Math.abs(f),"days")}`:t.is_warning?`Due in ${jp(f,"days")}`:`${jp(f,"days")} left`}else return t.is_due?`Overdue by ${jp(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${jp(t.hours_until_due,"hours")}`:`${jp(t.hours_until_due,"hours")} left`};return a.jsx("div",{className:`rounded-xl border p-4 transition-all ${u()}`,children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsxs("div",{className:`relative p-2.5 rounded-lg ${t.is_due?"bg-red-500/20":t.is_warning?"bg-amber-500/20":t.enabled?"bg-bambu-dark":"bg-bambu-dark/50"}`,children:[a.jsx(r,{className:`w-5 h-5 ${l()}`}),t.enabled&&(t.is_due||t.is_warning)&&a.jsx("span",{className:`absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full ${t.is_due?"bg-red-500":"bg-amber-500"} animate-pulse`})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),i==="days"&&a.jsx("span",{title:"Time-based interval",children:a.jsx(si,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const f=t.maintenance_type_wiki_url||UKe(t.maintenance_type_name,t.printer_model);return f?a.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-bambu-green transition-colors shrink-0",title:"View documentation",onClick:m=>m.stopPropagation(),children:a.jsx($r,{className:"w-3.5 h-3.5"})}):null})()]}),a.jsx("div",{className:"mt-2 mb-1.5",children:a.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${c()}`,style:{width:`${o}%`}})})}),a.jsxs("div",{className:`text-xs flex items-center gap-1 ${l()}`,children:[t.is_due&&a.jsx(xn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&a.jsx(qn,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&a.jsx(Ua,{className:"w-3 h-3"}),d()]})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[a.jsx(Sn,{checked:t.enabled,onChange:f=>n(t.id,f)}),a.jsxs(Te,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[a.jsx(rm,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function BKe({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,s]=w.useState(!0),[o,l]=w.useState(!1),[c,u]=w.useState(t.total_print_hours.toFixed(1)),d=[...t.maintenance_items].sort((g,x)=>g.is_due&&!x.is_due?-1:!g.is_due&&x.is_due?1:g.is_warning&&!x.is_warning?-1:!g.is_warning&&x.is_warning?1:g.maintenance_type_id-x.maintenance_type_id),f=d.find(g=>g.enabled&&(g.is_due||g.is_warning)),m=()=>{const g=parseFloat(c);!isNaN(g)&&g>=0&&(r(t.printer_id,g),l(!1))};return a.jsxs(_t,{className:"overflow-hidden",children:[a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),a.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&a.jsxs("span",{className:"px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[a.jsx(xn,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&a.jsxs("span",{className:"px-2.5 py-1 bg-amber-500/20 text-amber-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[a.jsx(qn,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&a.jsxs("span",{className:"px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1.5",children:[a.jsx(Ua,{className:"w-3 h-3"}),"All good"]})]})]}),a.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded-lg transition-colors",children:[i?a.jsx(ou,{className:"w-4 h-4"}):a.jsx(Br,{className:"w-4 h-4"}),i?"Collapse":"Expand"]})]}),a.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:a.jsx(Sd,{className:"w-4 h-4 text-bambu-gray"})}),o?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",value:c,onChange:g=>u(g.target.value),onKeyDown:g=>{g.key==="Enter"&&m(),g.key==="Escape"&&l(!1)},className:"w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"0",step:"1",autoFocus:!0}),a.jsx("span",{className:"text-xs text-bambu-gray",children:"hours"}),a.jsx(Te,{size:"sm",onClick:m,children:"Save"}),a.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>l(!1),children:"Cancel"})]}):a.jsxs("button",{onClick:()=>{u(Math.round(t.total_print_hours).toString()),l(!0)},className:"group",children:[a.jsxs("div",{className:"text-sm font-medium text-white group-hover:text-bambu-green transition-colors flex items-center gap-1",children:[Math.round(t.total_print_hours)," hours",a.jsx(Of,{className:"w-3 h-3 text-bambu-gray group-hover:text-bambu-green"})]}),a.jsx("div",{className:"text-xs text-bambu-gray",children:"Total print time"})]})]}),a.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),f&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${f.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const g=u0(f.maintenance_type_icon);return a.jsx(g,{className:`w-4 h-4 ${f.is_due?"text-red-400":"text-amber-400"}`})})()}),a.jsxs("div",{children:[a.jsx("div",{className:`text-sm font-medium ${f.is_due?"text-red-400":"text-amber-400"}`,children:f.maintenance_type_name}),a.jsx("div",{className:`text-xs ${f.is_due?"text-red-400/70":"text-amber-400/70"}`,children:f.is_due?"Overdue":"Due soon"})]})]})]})]}),i&&a.jsx(St,{className:"pt-0 border-t border-bambu-dark-tertiary",children:a.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:d.map(g=>a.jsx(zKe,{item:g,onPerform:e,onToggle:n},g.id))})})]})}function $Ke({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:s,onAssignType:o,onRemoveItem:l}){const[c,u]=w.useState(null),[d,f]=w.useState(""),[m,g]=w.useState("hours"),[x,y]=w.useState(!1),[b,v]=w.useState(""),[N,S]=w.useState("100"),[T,E]=w.useState("hours"),[k,C]=w.useState("Wrench"),[D,A]=w.useState(""),[R,F]=w.useState(new Set),[O,q]=w.useState(null),j=w.useMemo(()=>t?t.map(U=>({id:U.printer_id,name:U.printer_name})):[],[t]),G=U=>t?t.filter(Q=>Q.maintenance_items.some(le=>le.maintenance_type_id===U)).map(Q=>({printerId:Q.printer_id,printerName:Q.printer_name,itemId:Q.maintenance_items.find(le=>le.maintenance_type_id===U)?.id})):[],Y=U=>{if(!t)return[];const Q=new Set(G(U).map(le=>le.printerId));return j.filter(le=>!Q.has(le.id))},[K,Z]=w.useState(null),[te,ne]=w.useState(""),[z,W]=w.useState(""),[se,ae]=w.useState("hours"),[de,me]=w.useState("Wrench"),[xe,be]=w.useState(""),fe=U=>{Z(U),ne(U.name),W(U.default_interval_hours.toString()),ae(U.interval_type||"hours"),me(U.icon||"Wrench"),be(U.wiki_url||"")},Ce=()=>{K&&te.trim()&&parseFloat(z)>0&&(i(K.id,{name:te.trim(),default_interval_hours:parseFloat(z),interval_type:se,icon:de,wiki_url:xe.trim()||null}),Z(null))},Ne=(U,Q,le)=>{const Pe=parseFloat(d);if(!isNaN(Pe)&&Pe>0){const Oe=Math.abs(Pe-Q)<.01?null:Pe;n(U,{custom_interval_hours:Oe,custom_interval_type:m!==le?m:null})}u(null)},re=U=>{U.preventDefault(),b.trim()&&parseFloat(N)>0&&R.size>0&&(r({name:b.trim(),default_interval_hours:parseFloat(N),interval_type:T,icon:k,wiki_url:D.trim()||null},Array.from(R)),v(""),S("100"),E("hours"),A(""),F(new Set),y(!1))},He=U=>{F(Q=>{const le=new Set(Q);return le.has(U)?le.delete(U):le.add(U),le})},H=t?.map(U=>({printerId:U.printer_id,printerName:U.printer_name,items:U.maintenance_items.sort((Q,le)=>Q.maintenance_type_id-le.maintenance_type_id)})).sort((U,Q)=>U.printerName.localeCompare(Q.printerName))||[],B=e.filter(U=>U.is_system),X=e.filter(U=>!U.is_system);return a.jsxs("div",{className:"space-y-8",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"System types and your custom maintenance tasks"})]}),a.jsxs(Te,{onClick:()=>y(!x),children:[a.jsx(rr,{className:"w-4 h-4"}),"Add Custom Type"]})]}),x&&a.jsx(_t,{className:"mb-6",children:a.jsx(St,{className:"py-4",children:a.jsxs("form",{onSubmit:re,children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[a.jsxs("div",{className:"lg:col-span-2",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Name"}),a.jsx("input",{type:"text",value:b,onChange:U=>v(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"e.g., Replace HEPA Filter",autoFocus:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Interval Type"}),a.jsxs("select",{value:T,onChange:U=>{E(U.target.value),U.target.value==="days"?S("30"):S("100")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"hours",children:"Print Hours"}),a.jsx("option",{value:"days",children:"Calendar Days"})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs text-bambu-gray mb-1.5",children:["Interval (",T==="days"?"days":"hours",")"]}),a.jsx("input",{type:"number",value:N,onChange:U=>S(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),a.jsx("div",{className:"mt-4 flex items-end justify-between",children:a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Icon"}),a.jsx("div",{className:"flex gap-1",children:Object.keys(zb).map(U=>{const Q=zb[U];return a.jsx("button",{type:"button",onClick:()=>C(U),className:`p-2 rounded-lg transition-colors ${k===U?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:a.jsx(Q,{className:"w-4 h-4"})},U)})})]})}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Documentation Link (optional)"}),a.jsx("input",{type:"url",value:D,onChange:U=>A(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"https://wiki.bambulab.com/..."})]}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Assign to Printers"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:j.map(U=>a.jsx("button",{type:"button",onClick:()=>He(U.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${R.has(U.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:U.name},U.id))}),R.size===0&&a.jsx("p",{className:"text-xs text-orange-400 mt-1",children:"Select at least one printer"})]}),a.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[a.jsx(Te,{type:"button",variant:"secondary",onClick:()=>{y(!1),F(new Set)},children:"Cancel"}),a.jsx(Te,{type:"submit",disabled:!b.trim()||R.size===0,children:"Add Type"})]})]})})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[B.map(U=>{const Q=u0(U.icon),le=U.interval_type||"hours";return a.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:a.jsx(Q,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-sm font-medium text-white truncate",children:U.name}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[le==="days"?a.jsx(si,{className:"w-3 h-3"}):a.jsx(Sd,{className:"w-3 h-3"}),Mj(U.default_interval_hours,le)]})]})]})},U.id)}),X.map(U=>{const Q=u0(U.icon),le=U.interval_type||"hours";if(K?.id===U.id)return a.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:a.jsxs("div",{className:"space-y-3",children:[a.jsx("input",{type:"text",value:te,onChange:I=>ne(I.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"Name",autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("select",{value:se,onChange:I=>ae(I.target.value),className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"hours",children:"Print Hours"}),a.jsx("option",{value:"days",children:"Calendar Days"})]}),a.jsx("input",{type:"number",value:z,onChange:I=>W(I.target.value),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]}),a.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(zb).map(I=>{const V=zb[I];return a.jsx("button",{type:"button",onClick:()=>me(I),className:`p-1.5 rounded transition-colors ${de===I?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:a.jsx(V,{className:"w-3.5 h-3.5"})},I)})}),a.jsx("input",{type:"url",value:xe,onChange:I=>be(I.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"Documentation link (optional)"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Te,{size:"sm",onClick:Ce,disabled:!te.trim(),children:"Save"}),a.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>Z(null),children:"Cancel"})]})]})},U.id);const Oe=G(U.id),je=Y(U.id),$=O===U.id;return a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:a.jsx(Q,{className:"w-5 h-5 text-bambu-green"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm font-medium text-white truncate",children:U.name}),a.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[le==="days"?a.jsx(si,{className:"w-3 h-3"}):a.jsx(Sd,{className:"w-3 h-3"}),Mj(U.default_interval_hours,le)]})]}),a.jsxs("button",{onClick:()=>q($?null:U.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${Oe.length>0?"border-bambu-green/50 bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20":"border-orange-400/50 bg-orange-400/10 text-orange-400 hover:bg-orange-400/20"}`,title:`${Oe.length} printer(s) assigned - click to manage`,children:[a.jsx(Ar,{className:"w-3 h-3"}),a.jsx("span",{className:"text-xs font-medium",children:Oe.length}),a.jsx(Br,{className:`w-3 h-3 transition-transform ${$?"rotate-180":""}`})]}),a.jsx("button",{onClick:()=>fe(U),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:a.jsx(Of,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{confirm(`Delete "${U.name}"?`)&&s(U.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:a.jsx(on,{className:"w-4 h-4"})})]}),$&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Assigned to printers:"}),Oe.length===0?a.jsx("p",{className:"text-xs text-orange-400",children:"No printers assigned"}):a.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:Oe.map(I=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[I.printerName,a.jsx("button",{onClick:()=>I.itemId&&l(I.itemId),className:"hover:text-red-400 ml-1",title:"Remove from this printer",children:"×"})]},I.printerId))}),je.length>0&&a.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:"Add:"}),je.map(I=>a.jsxs("button",{onClick:()=>o(I.id,U.id),className:"px-2 py-1 bg-bambu-dark hover:bg-bambu-green/20 rounded text-xs text-bambu-gray hover:text-bambu-green transition-colors",children:["+ ",I.name]},I.id))]})]})]},U.id)})]})]}),H.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"mb-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Interval Overrides"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize intervals for specific printers"})]}),a.jsx("div",{className:"space-y-4",children:H.map(U=>a.jsx(_t,{children:a.jsxs(St,{className:"py-4",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:U.printerName}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:U.items.map(Q=>{const le=u0(Q.maintenance_type_icon),Pe=e.find(V=>V.id===Q.maintenance_type_id),Oe=Pe?.default_interval_hours||Q.interval_hours,je=Pe?.interval_type||"hours",$=Q.interval_type||"hours",I=c===Q.id;return a.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[a.jsx(le,{className:"w-4 h-4 text-bambu-gray shrink-0"}),a.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:Q.maintenance_type_name}),I?a.jsxs("div",{className:"flex items-center gap-1",children:[m==="days"?a.jsx(si,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):a.jsx(Sd,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),a.jsxs("select",{value:m,onChange:V=>g(V.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[a.jsx("option",{value:"hours",children:"Print Hours"}),a.jsx("option",{value:"days",children:"Calendar Days"})]}),a.jsx("input",{type:"number",value:d,onChange:V=>f(V.target.value),onKeyDown:V=>{V.key==="Enter"&&Ne(Q.id,Oe,je),V.key==="Escape"&&u(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),a.jsx(Te,{size:"sm",onClick:()=>Ne(Q.id,Oe,je),children:"OK"})]}):a.jsxs("button",{onClick:()=>{u(Q.id),f(Q.interval_hours.toString()),g($)},className:"px-2 py-1 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary border border-bambu-dark-tertiary hover:border-bambu-green rounded text-xs font-medium text-white transition-colors flex items-center gap-1",children:[$==="days"?a.jsx(si,{className:"w-3 h-3"}):a.jsx(Sd,{className:"w-3 h-3"}),Mj(Q.interval_hours,$),a.jsx(Of,{className:"w-3 h-3 text-bambu-gray"})]})]},Q.id)})})]})},U.printerId))})]}),H.length===0&&a.jsx(_t,{children:a.jsxs(St,{className:"text-center py-12",children:[a.jsx(qn,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),a.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),a.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function HKe(){const t=an(),{showToast:e}=Gn(),[n,r]=w.useState("status"),{data:i,isLoading:s}=ct({queryKey:["maintenanceOverview"],queryFn:he.getMaintenanceOverview}),{data:o}=ct({queryKey:["maintenanceTypes"],queryFn:he.getMaintenanceTypes}),l=ht({mutationFn:({id:S,notes:T})=>he.performMaintenance(S,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:S=>{e(S.message,"error")}}),c=ht({mutationFn:({id:S,data:T})=>he.updateMaintenanceItem(S,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:S=>{e(S.message,"error")}}),u=ht({mutationFn:({id:S,data:T})=>he.updateMaintenanceType(S,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:S=>{e(S.message,"error")}}),d=ht({mutationFn:he.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:S=>{e(S.message,"error")}}),f=ht({mutationFn:({printerId:S,hours:T})=>he.setPrinterHours(S,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:S=>{e(S.message,"error")}}),m=ht({mutationFn:({printerId:S,typeId:T})=>he.assignMaintenanceType(S,T),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer assigned")},onError:S=>{e(S.message,"error")}}),g=ht({mutationFn:he.removeMaintenanceItem,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer removed")},onError:S=>{e(S.message,"error")}}),x=S=>{l.mutate({id:S})},y=(S,T)=>{c.mutate({id:S,data:{enabled:T}})},b=(S,T)=>{f.mutate({printerId:S,hours:T})};if(s)return a.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:a.jsx(ut,{className:"w-8 h-8 text-bambu-green animate-spin"})});const v=i?.reduce((S,T)=>S+T.due_count,0)||0,N=i?.reduce((S,T)=>S+T.warning_count,0)||0;return a.jsxs("div",{className:"p-4 md:p-8",children:[a.jsxs("div",{className:"mb-6",children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),a.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:n==="status"?a.jsxs(a.Fragment,{children:[v>0&&a.jsxs("span",{className:"text-red-400",children:[v," task",v!==1?"s":""," overdue"]}),v>0&&N>0&&" · ",N>0&&a.jsxs("span",{className:"text-amber-400",children:[N," due soon"]}),v===0&&N===0&&a.jsx("span",{className:"text-bambu-green",children:"All maintenance up to date"})]}):"Configure maintenance types and intervals"})]}),a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[a.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"}),a.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"?a.jsx("div",{className:"space-y-6",children:i&&i.length>0?[...i].sort((S,T)=>{const E=S.due_count*10+S.warning_count,k=T.due_count*10+T.warning_count;return E!==k?k-E:S.printer_name.localeCompare(T.printer_name)}).map(S=>a.jsx(BKe,{overview:S,onPerform:x,onToggle:y,onSetHours:b},S.printer_id)):a.jsx(_t,{children:a.jsxs(St,{className:"text-center py-16",children:[a.jsx(Wd,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No printers configured"}),a.jsx("p",{className:"text-bambu-gray",children:"Add printers to start tracking maintenance"})]})})}):a.jsx($Ke,{overview:i,types:o||[],onUpdateInterval:(S,T)=>c.mutate({id:S,data:T}),onAddType:async(S,T)=>{const E=await he.createMaintenanceType(S);for(const k of T)await he.assignMaintenanceType(k,E.id);t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onUpdateType:(S,T)=>u.mutate({id:S,data:T}),onDeleteType:S=>d.mutate(S),onAssignType:(S,T)=>m.mutate({printerId:S,typeId:T}),onRemoveItem:S=>g.mutate(S)})]})}const rq=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function Cre({project:t,onClose:e,onSave:n,isLoading:r}){const[i,s]=w.useState(t?.name||""),[o,l]=w.useState(t?.description||""),[c,u]=w.useState(t?.color||rq[0]),[d,f]=w.useState(t?.target_count?.toString()||""),[m,g]=w.useState(t?.target_parts_count?.toString()||""),[x,y]=w.useState(t?.status||"active"),[b,v]=w.useState(t?.tags||""),[N,S]=w.useState(t?.due_date?.split("T")[0]||""),[T,E]=w.useState(t?.priority||"normal"),k=C=>{C.preventDefault(),n({name:i.trim(),description:o.trim()||void 0,color:c,target_count:d?parseInt(d,10):void 0,target_parts_count:m?parseInt(m,10):void 0,tags:b.trim()||void 0,due_date:N||void 0,priority:T,...t&&{status:x}})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:t?"Edit Project":"New Project"})}),a.jsxs("form",{onSubmit:k,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Name"}),a.jsx("input",{type:"text",value:i,onChange:C=>s(C.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., Voron 2.4 Build",required:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Description"}),a.jsx("textarea",{value:o,onChange:C=>l(C.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green resize-none",placeholder:"Optional description...",rows:2})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Color"}),a.jsx("div",{className:"flex gap-2 flex-wrap",children:rq.map(C=>a.jsx("button",{type:"button",onClick:()=>u(C),className:`w-8 h-8 rounded-full transition-transform ${c===C?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:C}},C))})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Target Plates"}),a.jsx("input",{type:"number",value:d,onChange:C=>f(C.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., 25",min:"1"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of print jobs"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Target Parts"}),a.jsx("input",{type:"number",value:m,onChange:C=>g(C.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., 150",min:"1"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Total objects needed"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Tags (comma-separated)"}),a.jsx("input",{type:"text",value:b,onChange:C=>v(C.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., voron, functional, gift"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Due Date"}),a.jsx("input",{type:"date",value:N,onChange:C=>S(C.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Priority"}),a.jsxs("select",{value:T,onChange:C=>E(C.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"low",children:"Low"}),a.jsx("option",{value:"normal",children:"Normal"}),a.jsx("option",{value:"high",children:"High"}),a.jsx("option",{value:"urgent",children:"Urgent"})]})]})]}),t&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Status"}),a.jsxs("select",{value:x,onChange:C=>y(C.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"active",children:"Active"}),a.jsx("option",{value:"completed",children:"Completed"}),a.jsx("option",{value:"archived",children:"Archived"})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Te,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),a.jsx(Te,{type:"submit",disabled:!i.trim()||r,children:r?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function VKe({project:t,onClick:e,onEdit:n,onDelete:r}){const i=t.target_count?Math.round(t.archive_count/t.target_count*100):0,s=t.target_parts_count?Math.round(t.completed_count/t.target_parts_count*100):0,o=t.status==="completed",l=t.status==="archived",[c,u]=w.useState(!1),f=o?{icon:O2,color:"text-bambu-green",bg:"bg-bambu-green/10"}:l?{icon:Qa,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:qn,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:Ma,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return a.jsxs("div",{className:"group relative bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary hover:border-bambu-green/50 hover:shadow-lg hover:shadow-bambu-green/5 transition-all duration-300 cursor-pointer overflow-hidden",onClick:e,children:[a.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full",style:{backgroundColor:t.color||"#6b7280",boxShadow:`0 0 12px ${t.color||"#6b7280"}40`}}),a.jsxs("div",{className:"p-5 pl-6",children:[a.jsxs("div",{className:"flex items-start justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("div",{className:`p-2 rounded-lg ${f.bg} flex-shrink-0`,children:a.jsx(f.icon,{className:`w-5 h-5 ${f.color}`})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),t.target_parts_count?a.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${s>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.completed_count,"/",t.target_parts_count," parts"]}):t.target_count?a.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${i>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.archive_count,"/",t.target_count," plates"]}):t.completed_count>0?a.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium bg-bambu-dark text-bambu-gray",children:[t.completed_count," parts"]}):null,o&&a.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:"Done"}),l&&a.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:"Archived"})]}),t.description&&a.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1 line-clamp-1",children:t.description}),t.archives&&t.archives.length>0&&(()=>{const m=t.archives.map(b=>b.filament_type).filter(Boolean).flatMap(b=>b.split(",").map(v=>v.trim())).filter(Boolean),g=[...new Set(m)],x=t.archives.map(b=>b.filament_color).filter(Boolean).flatMap(b=>b.split(",").map(v=>v.trim())).filter(b=>b.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(b)),y=[...new Set(x)];return g.length===0&&y.length===0?null:a.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[g.slice(0,3).map(b=>a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:b},b)),y.length>0&&a.jsxs("div",{className:"flex items-center gap-0.5",children:[y.slice(0,5).map(b=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:b.startsWith("#")?b:`#${b}`},title:b},b)),y.length>5&&a.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",y.length-5]})]})]})})()]})]}),a.jsxs("div",{className:"relative",onClick:m=>m.stopPropagation(),children:[a.jsx("button",{className:"p-1.5 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors opacity-0 group-hover:opacity-100",onClick:()=>u(!c),children:a.jsx(Pd,{className:"w-4 h-4"})}),c&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>u(!1)}),a.jsxs("div",{className:"absolute right-0 top-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[a.jsxs("button",{className:"w-full px-3 py-2 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{n(),u(!1)},children:[a.jsx(Of,{className:"w-4 h-4"}),"Edit"]}),a.jsxs("button",{className:"w-full px-3 py-2 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{r(),u(!1)},children:[a.jsx(on,{className:"w-4 h-4"}),"Delete"]})]})]})]})]}),a.jsx("div",{className:"mb-4",children:t.target_count||t.target_parts_count?a.jsxs("div",{className:"space-y-3",children:[t.target_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:"Plates"}),a.jsxs("span",{className:i>=100?"text-bambu-green font-medium":"text-white",children:[t.archive_count," / ",t.target_count]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:a.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(i,100)}%`,background:i>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${i>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.target_parts_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:"Parts"}),a.jsxs("span",{className:s>=100?"text-bambu-green font-medium":"text-white",children:[t.completed_count," / ",t.target_parts_count]})]}),a.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:a.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(s,100)}%`,background:s>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${s>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.failed_count>0&&a.jsxs("div",{className:"text-xs text-red-400",children:[t.failed_count," failed"]})]}):t.completed_count>0||t.failed_count>0?a.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[t.completed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[a.jsx(Qa,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.completed_count," completed"]})]}),t.failed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[a.jsx(xn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.failed_count," failed"]})]}),t.queue_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[a.jsx(qn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.queue_count," in queue"]})]})]}):a.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:"No prints yet"})}),t.archives&&t.archives.length>0&&a.jsxs("div",{className:"mb-4",children:[a.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(m=>a.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:m.print_name||"Unknown",children:[m.thumbnail_path?a.jsx("img",{src:he.getArchiveThumbnail(m.id),alt:m.print_name||"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:a.jsx(zl,{className:"w-6 h-6"})}),m.status==="failed"&&a.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:a.jsx(xn,{className:"w-4 h-4 text-white"})})]},m.id))}),t.archive_count>4&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:["+",t.archive_count-4," more"]})]}),a.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[a.jsxs("div",{className:"flex items-center gap-1.5",title:"Print jobs (plates)",children:[a.jsx(ul,{className:"w-3.5 h-3.5 text-blue-400"}),a.jsxs("span",{children:[t.archive_count," plates"]})]}),a.jsxs("div",{className:"flex items-center gap-1.5",title:"Parts printed",children:[a.jsx(zl,{className:"w-3.5 h-3.5 text-bambu-green"}),a.jsxs("span",{children:[t.completed_count," parts"]})]}),t.failed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:"Failed parts",children:[a.jsx(xn,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:t.failed_count})]}),t.queue_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-400",title:"In queue",children:[a.jsx(Kj,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:t.queue_count})]})]}),a.jsx(Ms,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function GKe(){const t=fl(),e=an(),{showToast:n}=Gn(),[r,i]=w.useState(!1),[s,o]=w.useState(),[l,c]=w.useState("active"),[u,d]=w.useState(null),{data:f,isLoading:m}=ct({queryKey:["projects",l==="all"?void 0:l],queryFn:()=>he.getProjects(l==="all"?void 0:l)}),g=ht({mutationFn:F=>he.createProject(F),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),n("Project created","success")},onError:F=>{n(F.message,"error")}}),x=ht({mutationFn:({id:F,data:O})=>he.updateProject(F,O),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),o(void 0),n("Project updated","success")},onError:F=>{n(F.message,"error")}}),y=ht({mutationFn:F=>he.deleteProject(F),onSuccess:()=>{d(null),n("Project deleted","success"),setTimeout(()=>window.location.reload(),100)},onError:F=>{d(null),n(F.message,"error")}}),b=ht({mutationFn:F=>he.importProject(F),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),n("Project imported","success")},onError:F=>{n(F.message,"error")}}),v=w.useRef(null),N=async()=>{try{const F=await he.getProjects(),O=await Promise.all(F.map(async Y=>await he.exportProjectJson(Y.id))),q=new Blob([JSON.stringify(O,null,2)],{type:"application/json"}),j=URL.createObjectURL(q),G=document.createElement("a");G.href=j,G.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,G.click(),URL.revokeObjectURL(j),n("Projects exported (metadata only)","success")}catch(F){n(F.message,"error")}},S=()=>{v.current?.click()},T=async F=>{const O=F.target.files?.[0];if(O){try{if(O.name.toLowerCase().endsWith(".zip")){const j=new FormData;j.append("file",O);const G=await fetch("/api/v1/projects/import/file",{method:"POST",body:j});if(!G.ok){const Y=await G.json();throw new Error(Y.detail||"Import failed")}e.invalidateQueries({queryKey:["projects"]}),n("Project imported","success")}else{const j=await O.text(),G=JSON.parse(j),Y=Array.isArray(G)?G:[G];for(const K of Y)await b.mutateAsync(K);Y.length>1&&n(`${Y.length} projects imported`,"success")}}catch(q){n(`Import failed: ${q.message}`,"error")}F.target.value=""}},E=F=>{s?x.mutate({id:s.id,data:F}):g.mutate(F)},k=F=>{o(F),i(!0)},C=F=>{t(`/projects/${F.id}`)},D=F=>{d(F)},A=()=>{u!==null&&y.mutate(u)},R=f?.reduce((F,O)=>(F[O.status]=(F[O.status]||0)+1,F.all=(F.all||0)+1,F),{})||{};return a.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[a.jsx("input",{ref:v,type:"file",accept:".json,.zip",onChange:T,className:"hidden"}),a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:a.jsx(Ma,{className:"w-6 h-6 text-bambu-green"})}),"Projects"]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:"Organize and track your 3D printing projects"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Te,{variant:"secondary",onClick:S,title:"Import project",children:[a.jsx(fi,{className:"w-4 h-4 mr-2"}),"Import"]}),a.jsxs(Te,{variant:"secondary",onClick:N,title:"Export all projects",children:[a.jsx(Gr,{className:"w-4 h-4 mr-2"}),"Export"]}),a.jsxs(Te,{onClick:()=>i(!0),className:"sm:w-auto w-full",children:[a.jsx(rr,{className:"w-4 h-4 mr-2"}),"New Project"]})]})]}),a.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:"Active",icon:qn},{key:"completed",label:"Completed",icon:O2},{key:"archived",label:"Archived",icon:Qa},{key:"all",label:"All",icon:Ma}].map(({key:F,label:O,icon:q})=>a.jsxs("button",{onClick:()=>c(F),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${l===F?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[a.jsx(q,{className:"w-4 h-4"}),a.jsx("span",{children:O}),R[F]>0&&a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${l===F?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:R[F]})]},F))}),m?a.jsx("div",{className:"flex items-center justify-center py-20",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(ut,{className:"w-8 h-8 animate-spin text-bambu-green"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading projects..."})]})}):f?.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(Ma,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:l==="all"?"No projects yet":`No ${l} projects`}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:l==="all"?"Create your first project to start organizing related prints, tracking progress, and managing your builds.":`You don't have any ${l} projects. Projects will appear here when their status changes.`}),l==="all"&&a.jsxs(Te,{onClick:()=>i(!0),children:[a.jsx(rr,{className:"w-4 h-4 mr-2"}),"Create Your First Project"]})]}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:f?.map(F=>a.jsx(VKe,{project:F,onClick:()=>C(F),onEdit:()=>k(F),onDelete:()=>D(F.id)},F.id))}),u!==null&&a.jsx(Hn,{title:"Delete Project",message:"Are you sure you want to delete this project? Archives and queue items will be unlinked but not deleted.",confirmText:"Delete Project",variant:"danger",onConfirm:A,onCancel:()=>d(null)}),r&&a.jsx(Cre,{project:s,onClose:()=>{i(!1),o(void 0)},onSave:E,isLoading:g.isPending||x.isPending})]})}function qKe(t){if(t<1)return`${Math.round(t*60)}m`;const e=Math.floor(t),n=Math.round((t-e)*60);return n>0?`${e}h ${n}m`:`${e}h`}function WKe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function KKe({status:t}){const e={active:"bg-bambu-green/20 text-bambu-green",completed:"bg-blue-500/20 text-blue-400",archived:"bg-bambu-gray/20 text-bambu-gray"},n=e[t]||e.active;return a.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${n}`,children:t.charAt(0).toUpperCase()+t.slice(1)})}function iq({icon:t,label:e,value:n,subValue:r,hint:i,color:s="text-bambu-gray"}){return a.jsx(_t,{children:a.jsx(St,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",title:i,children:[a.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${s}`,children:a.jsx(t,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:e}),a.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&a.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function XKe({archives:t}){return t.length===0?a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(zl,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:"No prints in this project yet"})]}):a.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3",children:t.map(e=>a.jsxs(ps,{to:`/archives?search=${encodeURIComponent(e.print_name||"")}`,className:"group relative aspect-square rounded-lg bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden hover:border-bambu-green transition-colors",children:[e.thumbnail_path?a.jsx("img",{src:he.getArchiveThumbnail(e.id),alt:e.print_name||"Print",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:a.jsx(zl,{className:"w-8 h-8"})}),e.status==="failed"&&a.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:a.jsx(aa,{className:"w-8 h-8 text-white"})}),e.status==="completed"&&a.jsx("div",{className:"absolute top-1 right-1",children:a.jsx(Fn,{className:"w-4 h-4 text-bambu-green"})}),a.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx("p",{className:"text-xs text-white truncate",children:e.print_name||"Unknown"})})]},e.id))})}function YKe({priority:t}){const e={low:{color:"bg-gray-500/20 text-gray-400",label:"Low"},normal:{color:"bg-blue-500/20 text-blue-400",label:"Normal"},high:{color:"bg-orange-500/20 text-orange-400",label:"High"},urgent:{color:"bg-red-500/20 text-red-400",label:"Urgent"}},{color:n,label:r}=e[t]||e.normal;return a.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${n}`,children:[t==="urgent"&&a.jsx(xn,{className:"w-3 h-3"}),r]})}function QKe(t){return t?cg(t,{year:"numeric",month:"short",day:"numeric"}):""}function Ej(t){if(!t)return null;const e=wi(t);if(!e)return null;const n=new Date,r=Math.ceil((e.getTime()-n.getTime())/(1e3*60*60*24));return r<0?{color:"text-red-400",label:"Overdue"}:r===0?{color:"text-orange-400",label:"Due today"}:r<=3?{color:"text-yellow-400",label:`${r} days left`}:{color:"text-bambu-gray",label:`${r} days left`}}function ZKe(){const{id:t}=ZR(),e=fl(),n=an(),{showToast:r}=Gn(),[i,s]=w.useState(!1),[o,l]=w.useState(!1),[c,u]=w.useState(""),d=parseInt(t||"0",10),{data:f,isLoading:m,error:g}=ct({queryKey:["project",d],queryFn:()=>he.getProject(d),enabled:d>0}),{data:x,isLoading:y}=ct({queryKey:["project-archives",d],queryFn:()=>he.getProjectArchives(d),enabled:d>0}),{data:b,isLoading:v}=ct({queryKey:["project-bom",d],queryFn:()=>he.getProjectBOM(d),enabled:d>0}),{data:N,isLoading:S}=ct({queryKey:["project-timeline",d],queryFn:()=>he.getProjectTimeline(d,20),enabled:d>0}),{data:T}=ct({queryKey:["settings"],queryFn:he.getSettings}),{data:E}=ct({queryKey:["project-folders",d],queryFn:()=>he.getLibraryFoldersByProject(d),enabled:d>0}),k=T?.currency||"$",C=T?.time_format||"system",D=ht({mutationFn:ve=>he.updateProject(d,ve),onSuccess:()=>{n.invalidateQueries({queryKey:["project",d]}),n.invalidateQueries({queryKey:["projects"]}),s(!1),l(!1),r("Project updated","success")},onError:ve=>{r(ve.message,"error")}}),A=()=>{u(f?.notes||""),l(!0)},R=()=>{D.mutate({notes:c})},F=()=>{l(!1),u("")},[O,q]=w.useState(""),[j,G]=w.useState(1),[Y,K]=w.useState(""),[Z,te]=w.useState(""),[ne,z]=w.useState(""),[W,se]=w.useState(!1),[ae,de]=w.useState(!1),[me,xe]=w.useState(null),[be,fe]=w.useState(""),[Ce,Ne]=w.useState(1),[re,He]=w.useState(""),[H,B]=w.useState(""),[X,U]=w.useState(""),[Q,le]=w.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),Pe=ht({mutationFn:ve=>he.createBOMItem(d,ve),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),q(""),G(1),K(""),te(""),z(""),se(!1),r("Part added","success")},onError:ve=>r(ve.message,"error")}),Oe=ht({mutationFn:({itemId:ve,data:Le})=>he.updateBOMItem(d,ve,Le),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),xe(null)},onError:ve=>r(ve.message,"error")}),je=ht({mutationFn:ve=>he.deleteBOMItem(d,ve),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),r("Part removed","success")},onError:ve=>r(ve.message,"error")}),$=ve=>{ve.preventDefault(),O.trim()&&Pe.mutate({name:O.trim(),quantity_needed:j,unit_price:Y?parseFloat(Y):void 0,sourcing_url:Z.trim()||void 0,remarks:ne.trim()||void 0})},I=ve=>{const Le=ve.is_complete?0:ve.quantity_needed;Oe.mutate({itemId:ve.id,data:{quantity_acquired:Le}})},V=(ve,Le)=>{le({isOpen:!0,title:"Delete Part",message:`Are you sure you want to delete "${Le}"?`,onConfirm:()=>{le(Ke=>({...Ke,isOpen:!1})),je.mutate(ve)}})},ie=ve=>{xe(ve),fe(ve.name),Ne(ve.quantity_needed),He(ve.unit_price?.toString()||""),B(ve.sourcing_url||""),U(ve.remarks||"")},Se=ve=>{ve.preventDefault(),!(!me||!be.trim())&&Oe.mutate({itemId:me.id,data:{name:be.trim(),quantity_needed:Ce,unit_price:re?parseFloat(re):void 0,sourcing_url:H.trim()||void 0,remarks:X.trim()||void 0}})},ye=()=>{xe(null)},$e=async()=>{try{const ve=await fetch(`/api/v1/projects/${d}/export`);if(!ve.ok)throw new Error("Export failed");const Le=await ve.blob(),Ke=URL.createObjectURL(Le),lt=document.createElement("a");lt.href=Ke;const ce=ve.headers.get("Content-Disposition")?.match(/filename="(.+)"/);lt.download=ce?.[1]||`${f?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,lt.click(),URL.revokeObjectURL(Ke),r("Project exported","success")}catch(ve){r(ve.message,"error")}},Ue=ht({mutationFn:()=>he.createTemplateFromProject(d),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r("Template created","success")},onError:ve=>r(ve.message,"error")}),Ge=ve=>ug(ve,C,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(m)return a.jsx("div",{className:"flex items-center justify-center py-24",children:a.jsx(ut,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(g||!f)return a.jsxs("div",{className:"text-center py-24",children:[a.jsx("p",{className:"text-bambu-gray",children:g?`Error: ${g.message}`:"Project not found"}),a.jsx(Te,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:"Back to Projects"})]});const We=f.stats,Ye=We?.progress_percent??0,oe=We?.parts_progress_percent??0;return a.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[a.jsx(ps,{to:"/projects",className:"hover:text-white transition-colors",children:"Projects"}),a.jsx(Ms,{className:"w-4 h-4"}),a.jsx("span",{className:"text-white",children:f.name})]}),a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:a.jsx(nW,{className:"w-5 h-5 text-bambu-gray"})}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:f.color||"#6b7280"}}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:f.name}),f.description&&a.jsx("p",{className:"text-bambu-gray mt-1",children:f.description})]})]}),a.jsx(KKe,{status:f.status})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Te,{variant:"secondary",onClick:$e,title:"Export project",children:[a.jsx(Gr,{className:"w-4 h-4 mr-2"}),"Export"]}),a.jsxs(Te,{onClick:()=>s(!0),children:[a.jsx(Of,{className:"w-4 h-4 mr-2"}),"Edit"]})]})]}),(f.target_count||f.target_parts_count)&&a.jsx(_t,{children:a.jsxs(St,{className:"p-4 space-y-4",children:[f.target_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Plates Progress"}),a.jsxs("span",{className:"text-sm font-medium text-white",children:[We?.total_archives||0," / ",f.target_count," print jobs"]})]}),a.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(Ye,100)}%`,backgroundColor:Ye>=100?"#22c55e":f.color||"#6b7280"}})}),a.jsxs("div",{className:"flex justify-between mt-1",children:[a.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[Ye.toFixed(0),"% complete"]}),We?.remaining_prints!=null&&We.remaining_prints>0&&a.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[We.remaining_prints," remaining"]})]})]}),f.target_parts_count&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:"Parts Progress"}),a.jsxs("span",{className:"text-sm font-medium text-white",children:[We?.completed_prints||0," / ",f.target_parts_count," parts"]})]}),a.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(oe,100)}%`,backgroundColor:oe>=100?"#22c55e":f.color||"#6b7280"}})}),a.jsxs("div",{className:"flex justify-between mt-1",children:[a.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[oe.toFixed(0),"% complete"]}),We?.remaining_parts!=null&&We.remaining_parts>0&&a.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[We.remaining_parts," remaining"]})]})]})]})}),We&&a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(_t,{children:a.jsx(St,{className:"p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:a.jsx(zl,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Print Jobs"}),a.jsxs("p",{className:"text-xl font-semibold text-white",children:[We.total_archives," ",a.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:"total"})]}),We.failed_prints>0&&a.jsxs("p",{className:"text-sm text-status-error",children:[We.failed_prints," failed"]}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[We.completed_prints," parts printed"]})]})]})})}),a.jsx(iq,{icon:qn,label:"Print Time",value:qKe(We.total_print_time_hours),color:"text-yellow-400"}),a.jsx(iq,{icon:Ar,label:"Filament Used",value:WKe(We.total_filament_grams),color:"text-purple-400"})]}),We&&(We.estimated_cost>0||f.budget)&&a.jsx(_t,{children:a.jsxs(St,{className:"p-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:"Cost Tracking"}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Filament Cost"}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[k,We.estimated_cost.toFixed(2)]})]}),We.total_energy_kwh>0&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Energy"}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[We.total_energy_kwh.toFixed(2)," kWh",We.total_energy_cost>0&&a.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",k,We.total_energy_cost.toFixed(2),")"]})]})]}),f.budget&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Budget"}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[k,f.budget.toFixed(2)]})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Remaining"}),a.jsxs("p",{className:`text-lg font-semibold ${f.budget-We.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[k,(f.budget-We.estimated_cost).toFixed(2)]})]})]})]})]})}),f.children&&f.children.length>0&&a.jsx(_t,{children:a.jsxs(St,{className:"p-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[a.jsx(Fue,{className:"w-5 h-5"}),"Sub-projects (",f.children.length,")"]}),a.jsx("div",{className:"space-y-2",children:f.children.map(ve=>a.jsxs(ps,{to:`/projects/${ve.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:ve.color||"#6b7280"}}),a.jsx("span",{className:"text-white",children:ve.name}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${ve.status==="completed"?"bg-status-ok/20 text-status-ok":ve.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:ve.status})]}),ve.progress_percent!==null&&a.jsxs("span",{className:"text-sm text-bambu-gray",children:[ve.progress_percent.toFixed(0),"%"]})]},ve.id))})]})}),f.parent_id&&f.parent_name&&a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(ul,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-bambu-gray",children:"Part of:"}),a.jsx(ps,{to:`/projects/${f.parent_id}`,className:"text-bambu-green hover:underline",children:f.parent_name})]}),(f.tags||f.due_date||f.priority!=="normal")&&a.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[f.priority&&f.priority!=="normal"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:"Priority:"}),a.jsx(YKe,{priority:f.priority})]}),f.due_date&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(si,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-white",children:QKe(f.due_date)}),Ej(f.due_date)&&a.jsxs("span",{className:`text-xs ${Ej(f.due_date).color}`,children:["(",Ej(f.due_date).label,")"]})]}),f.tags&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(qd,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("div",{className:"flex flex-wrap gap-1",children:f.tags.split(",").map((ve,Le)=>a.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:ve.trim()},Le))})]})]}),a.jsx(_t,{children:a.jsxs(St,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Ka,{className:"w-5 h-5"}),"Notes"]}),o?a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Te,{variant:"secondary",size:"sm",onClick:F,disabled:D.isPending,children:[a.jsx(Ot,{className:"w-4 h-4 mr-1"}),"Cancel"]}),a.jsxs(Te,{size:"sm",onClick:R,disabled:D.isPending,children:[D.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin mr-1"}):a.jsx(bs,{className:"w-4 h-4 mr-1"}),"Save"]})]}):a.jsxs(Te,{variant:"secondary",size:"sm",onClick:A,children:[a.jsx(Of,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),o?a.jsx(UR,{content:c,onChange:u,placeholder:"Add notes about this project..."}):f.notes?a.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:f.notes}}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No notes yet. Click Edit to add notes."})]})}),a.jsx(_t,{children:a.jsxs(St,{className:"p-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-3",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(cl,{className:"w-5 h-5"}),"Files"]})}),a.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[a.jsx(ps,{to:"/files",className:"text-bambu-green hover:underline",children:"Link folders from the File Manager"})," ","to this project for quick access."]}),E&&E.length>0?a.jsx("div",{className:"space-y-2",children:E.map(ve=>a.jsxs(ps,{to:`/files?folder=${ve.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsx(cl,{className:"w-5 h-5 text-bambu-green flex-shrink-0"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:ve.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[ve.file_count," file",ve.file_count!==1?"s":""]})]})]}),a.jsx(Ms,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},ve.id))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No folders linked. Go to File Manager and link a folder to this project."})]})}),a.jsx(_t,{children:a.jsxs(St,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(mW,{className:"w-5 h-5"}),"Bill of Materials",We&&We.bom_total_items>0&&a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",We.bom_completed_items,"/",We.bom_total_items," acquired)"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[b&&b.some(ve=>ve.is_complete)&&a.jsx("button",{onClick:()=>de(!ae),className:`text-xs px-2 py-1 rounded transition-colors ${ae?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:ae?"Show all":"Hide done"}),!W&&a.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>se(!0),children:[a.jsx(rr,{className:"w-4 h-4 mr-1"}),"Add Part"]})]})]}),W&&a.jsxs("form",{onSubmit:$,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsx("input",{type:"text",value:O,onChange:ve=>q(ve.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Part name (e.g., M3x8 screws)",autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"number",value:j,onChange:ve=>G(parseInt(ve.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:"Qty"}),a.jsx("input",{type:"number",step:"0.01",value:Y,onChange:ve=>K(ve.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:`Price (${k})`})]})]}),a.jsx("input",{type:"url",value:Z,onChange:ve=>te(ve.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Sourcing URL (optional)"}),a.jsx("input",{type:"text",value:ne,onChange:ve=>z(ve.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Remarks (optional)"}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Te,{type:"button",variant:"secondary",size:"sm",onClick:()=>se(!1),children:"Cancel"}),a.jsx(Te,{type:"submit",size:"sm",disabled:!O.trim()||Pe.isPending,children:Pe.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):"Add Part"})]})]}),v?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(ut,{className:"w-6 h-6 animate-spin text-bambu-green"})}):b&&b.length>0?a.jsxs("div",{className:"space-y-2",children:[b.filter(ve=>!ae||!ve.is_complete).map(ve=>a.jsx("div",{className:`p-3 rounded-lg transition-colors ${ve.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:me?.id===ve.id?a.jsxs("form",{onSubmit:Se,className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsx("input",{type:"text",value:be,onChange:Le=>fe(Le.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Part name",autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"number",value:Ce,onChange:Le=>Ne(parseInt(Le.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:"Qty"}),a.jsx("input",{type:"number",step:"0.01",value:re,onChange:Le=>He(Le.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:`Price (${k})`})]})]}),a.jsx("input",{type:"url",value:H,onChange:Le=>B(Le.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Sourcing URL (optional)"}),a.jsx("input",{type:"text",value:X,onChange:Le=>U(Le.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Remarks (optional)"}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Te,{type:"button",variant:"secondary",size:"sm",onClick:ye,children:"Cancel"}),a.jsx(Te,{type:"submit",size:"sm",disabled:!be.trim()||Oe.isPending,children:Oe.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):"Save"})]})]}):a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("button",{onClick:()=>I(ve),disabled:Oe.isPending,className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${ve.is_complete?"bg-status-ok border-status-ok text-white":"border-bambu-gray hover:border-bambu-green"}`,children:ve.is_complete&&a.jsx(Fn,{className:"w-3 h-3"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsxs("p",{className:`text-sm font-medium ${ve.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[ve.name,a.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",ve.quantity_needed]})]}),ve.unit_price!==null&&a.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[k,(ve.unit_price*ve.quantity_needed).toFixed(2)]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:()=>ie(ve),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors flex-shrink-0",title:"Edit",children:a.jsx(Oi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>V(ve.id,ve.name),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400 transition-colors flex-shrink-0",title:"Delete",children:a.jsx(on,{className:"w-4 h-4"})})]})]}),ve.sourcing_url&&a.jsxs("a",{href:ve.sourcing_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 mt-1 text-xs text-blue-400 hover:text-blue-300 transition-colors",onClick:Le=>Le.stopPropagation(),children:[a.jsx($r,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"truncate",children:(()=>{try{return new URL(ve.sourcing_url).hostname.replace("www.","")}catch{return ve.sourcing_url}})()})]}),ve.remarks&&a.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:ve.remarks})]})]})},ve.id)),b.some(ve=>ve.unit_price!==null)&&a.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm",children:[a.jsx("span",{className:"text-bambu-gray",children:"Total cost:"}),a.jsxs("span",{className:"text-white font-medium",children:[k,b.reduce((ve,Le)=>ve+(Le.unit_price||0)*Le.quantity_needed,0).toFixed(2)]})]})]}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No parts in the bill of materials. Add hardware, electronics, or other components to track what needs to be sourced."})]})}),a.jsx(_t,{children:a.jsxs(St,{className:"p-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-3",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(g0,{className:"w-5 h-5"}),"Activity Timeline"]})}),S?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(ut,{className:"w-6 h-6 animate-spin text-bambu-green"})}):N&&N.length>0?a.jsx("div",{className:"space-y-3",children:N.slice(0,10).map((ve,Le)=>a.jsxs("div",{className:"flex gap-3",children:[a.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${ve.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":ve.event_type==="print_failed"?"bg-status-error/20 text-status-error":ve.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[ve.event_type==="print_completed"&&a.jsx(Fn,{className:"w-4 h-4"}),ve.event_type==="print_failed"&&a.jsx(aa,{className:"w-4 h-4"}),ve.event_type==="print_started"&&a.jsx(Ar,{className:"w-4 h-4"}),ve.event_type==="queued"&&a.jsx(Kj,{className:"w-4 h-4"}),ve.event_type==="project_created"&&a.jsx(rr,{className:"w-4 h-4"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white",children:ve.title}),ve.description&&a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:ve.description}),a.jsx("p",{className:"text-xs text-bambu-gray/70",children:Ge(ve.timestamp)})]})]},Le))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No activity yet."})]})}),!f.is_template&&a.jsx("div",{className:"flex justify-end",children:a.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>Ue.mutate(),disabled:Ue.isPending,children:[Ue.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(ll,{className:"w-4 h-4 mr-2"}),"Save as Template"]})}),We&&(We.queued_prints>0||We.in_progress_prints>0)&&a.jsx(_t,{children:a.jsxs(St,{className:"p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Kj,{className:"w-5 h-5"}),"Queue"]}),a.jsx(ps,{to:`/queue?project=${d}`,className:"text-sm text-bambu-green hover:underline",children:"View all"})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[We.in_progress_prints>0&&a.jsxs("span",{className:"text-yellow-400",children:[We.in_progress_prints," printing"]}),We.queued_prints>0&&a.jsxs("span",{className:"text-bambu-gray",children:[We.queued_prints," queued"]})]})]})}),a.jsxs("div",{children:[a.jsx("div",{className:"flex items-center justify-between mb-4",children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(zl,{className:"w-5 h-5"}),"Prints (",x?.length||0,")"]})}),y?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(ut,{className:"w-6 h-6 animate-spin text-bambu-green"})}):a.jsx(XKe,{archives:x||[]})]}),i&&a.jsx(Cre,{project:{...f,archive_count:We?.total_archives||0,total_items:We?.total_items||0,completed_count:We?.completed_prints||0,failed_count:We?.failed_prints||0,queue_count:We?.queued_prints||0,progress_percent:We?.progress_percent||null,archives:[]},onClose:()=>s(!1),onSave:ve=>D.mutate(ve),isLoading:D.isPending}),Q.isOpen&&a.jsx(Hn,{title:Q.title,message:Q.message,confirmText:"Delete",variant:"danger",onConfirm:Q.onConfirm,onCancel:()=>le(ve=>({...ve,isOpen:!1}))})]})}function Up(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function JKe(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 eXe({parentId:t,onClose:e,onSave:n,isLoading:r}){const[i,s]=w.useState(""),o=l=>{l.preventDefault(),n({name:i.trim(),parent_id:t})};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:"New Folder"})}),a.jsxs("form",{onSubmit:o,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Folder Name"}),a.jsx("input",{type:"text",value:i,onChange:l=>s(l.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., Functional Parts",autoFocus:!0,required:!0})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Te,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),a.jsx(Te,{type:"submit",disabled:!i.trim()||r,children:r?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):"Create"})]})]})]})})}function tXe({type:t,currentName:e,onClose:n,onSave:r,isLoading:i}){const[s,o]=w.useState(e),l=c=>{c.preventDefault(),s.trim()&&s.trim()!==e&&r(s.trim())};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Rename ",t==="file"?"File":"Folder"]})}),a.jsxs("form",{onSubmit:l,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Name"}),a.jsx("input",{type:"text",value:s,onChange:c=>o(c.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",autoFocus:!0,required:!0})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Te,{type:"button",variant:"secondary",onClick:n,children:"Cancel"}),a.jsx(Te,{type:"submit",disabled:!s.trim()||s.trim()===e||i,children:i?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):"Rename"})]})]})]})})}function nXe({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:i,isLoading:s}){const[o,l]=w.useState(null),c=(d,f=0)=>{const m=[];for(const g of d)m.push({id:g.id,name:g.name,depth:f}),g.children.length>0&&m.push(...c(g.children,f+1));return m},u=[{id:null,name:"Root (No Folder)",depth:0},...c(t)];return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[a.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:a.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Move ",e.length," File(s)"]})}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:u.map(d=>a.jsxs("button",{onClick:()=>l(d.id),disabled:d.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===d.id?"bg-bambu-green/20 text-bambu-green":d.id===n?"opacity-50 cursor-not-allowed text-bambu-gray":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${12+d.depth*16}px`},children:[a.jsx(cl,{className:"w-4 h-4"}),d.name,d.id===n&&a.jsx("span",{className:"text-xs text-bambu-gray ml-auto",children:"(current)"})]},d.id??"root"))}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Te,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),a.jsx(Te,{onClick:()=>i(o),disabled:s,children:s?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):"Move"})]})]})]})})}function rXe({folder:t,onClose:e,onLink:n,isLoading:r}){const[i,s]=w.useState("project"),[o,l]=w.useState(t.project_id||t.archive_id||null);w.useState(()=>{t.archive_id&&s("archive")});const{data:c}=ct({queryKey:["projects"],queryFn:()=>he.getProjects()}),{data:u}=ct({queryKey:["archives-for-link"],queryFn:()=>he.getArchives(void 0,void 0,100)}),d=()=>{n(i==="project"?{project_id:o,archive_id:0}:{project_id:0,archive_id:o})},f=()=>{n({project_id:0,archive_id:0})},m=t.project_id||t.archive_id;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Ol,{className:"w-5 h-5 text-bambu-green"}),"Link Folder"]}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Ot,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("p",{className:"text-sm text-bambu-gray",children:['Link "',a.jsx("span",{className:"text-white",children:t.name}),'" to a project or archive for quick access.']}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>{s("project"),l(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${i==="project"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[a.jsx(iW,{className:"w-4 h-4"}),"Project"]}),a.jsxs("button",{onClick:()=>{s("archive"),l(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${i==="archive"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[a.jsx(Qa,{className:"w-4 h-4"}),"Archive"]})]}),a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2",children:i==="project"?c&&c.length>0?c.map(g=>a.jsxs("button",{onClick:()=>l(g.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===g.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:g.color||"#00ae42"}}),a.jsx("span",{className:"truncate",children:g.name})]},g.id)):a.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:"No projects found"}):u&&u.length>0?u.map(g=>a.jsxs("button",{onClick:()=>l(g.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===g.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[a.jsx(xf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"truncate",children:g.print_name||g.filename})]},g.id)):a.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:"No archives found"})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-between",children:[m&&a.jsxs(Te,{variant:"danger",onClick:f,disabled:r,children:[a.jsx(pD,{className:"w-4 h-4 mr-2"}),"Unlink"]}),a.jsxs("div",{className:`flex gap-2 ${m?"":"ml-auto"}`,children:[a.jsx(Te,{variant:"secondary",onClick:e,children:"Cancel"}),a.jsx(Te,{onClick:d,disabled:!o||r,children:r?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):"Link"})]})]})]})})}function iXe({folderId:t,onClose:e,onUploadComplete:n}){const[r,i]=w.useState([]),[s,o]=w.useState(!1),[l,c]=w.useState(!1),[u,d]=w.useState(!0),[f,m]=w.useState(!1),[g,x]=w.useState(!0),y=w.useRef(null),b=q=>{q.preventDefault(),o(!0)},v=q=>{q.preventDefault(),o(!1)},N=q=>{q.preventDefault(),o(!1);const j=Array.from(q.dataTransfer.files);T(j)},S=q=>{q.target.files&&T(Array.from(q.target.files))},T=q=>{const j=q.map(G=>({file:G,status:"pending",isZip:G.name.toLowerCase().endsWith(".zip")}));i(G=>[...G,...j])},E=q=>{i(j=>j.filter((G,Y)=>Y!==q))},k=r.some(q=>q.isZip&&q.status==="pending"),C=r.some(q=>q.file.name.toLowerCase().endsWith(".stl")&&q.status==="pending"),D=async()=>{if(r.length!==0){c(!0);for(let q=0;q<r.length;q++)if(r[q].status==="pending"){i(j=>j.map((G,Y)=>Y===q?{...G,status:"uploading"}:G));try{if(r[q].isZip){const j=await he.extractZipFile(r[q].file,t,u,f,g);i(G=>G.map((Y,K)=>K===q?{...Y,status:j.errors.length>0&&j.extracted===0?"error":"success",extractedCount:j.extracted,error:j.errors.length>0?`${j.errors.length} files failed`:void 0}:Y))}else await he.uploadLibraryFile(r[q].file,t,g),i(j=>j.map((G,Y)=>Y===q?{...G,status:"success"}:G))}catch(j){i(G=>G.map((Y,K)=>K===q?{...Y,status:"error",error:j instanceof Error?j.message:"Upload failed"}:Y))}}c(!1),n(),e()}},A=r.filter(q=>q.status==="pending").length,R=r.filter(q=>q.status==="success").length,F=r.filter(q=>q.status==="error").length,O=r.length>0&&A===0&&!l;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Upload Files"}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Ot,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("div",{onDragOver:b,onDragLeave:v,onDrop:N,onClick:()=>y.current?.click(),className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${s?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,children:[a.jsx(fi,{className:`w-10 h-10 mx-auto mb-3 ${s?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("p",{className:"text-white font-medium",children:s?"Drop files here":"Drag & drop files here"}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"or click to browse"}),a.jsx("p",{className:"text-xs text-bambu-gray/70 mt-2",children:"All file types supported. ZIP files will be extracted."})]}),a.jsx("input",{ref:y,type:"file",multiple:!0,className:"hidden",onChange:S}),k&&a.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Qa,{className:"w-5 h-5 text-blue-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-blue-300 font-medium",children:"ZIP files detected"}),a.jsx("p",{className:"text-xs text-blue-300/70 mt-1",children:"ZIP files will be extracted. Choose how to handle folder structure:"}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:u,onChange:q=>d(q.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:"Preserve folder structure from ZIP"})]}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:f,onChange:q=>m(q.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:"Create folder from ZIP filename"})]})]})]})}),(C||k)&&a.jsx("div",{className:"p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(cu,{className:"w-5 h-5 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-bambu-green font-medium",children:"STL thumbnail generation"}),a.jsx("p",{className:"text-xs text-bambu-green/70 mt-1",children:k&&!C?"ZIP files may contain STL files. Thumbnails can be generated during extraction.":"Thumbnails can be generated for STL files. Large models may take longer to process."}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:g,onChange:q=>x(q.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),a.jsx("span",{className:"text-sm text-white",children:"Generate thumbnails for STL files"})]})]})]})}),r.length>0&&a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:r.map((q,j)=>a.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[q.isZip?a.jsx(Qa,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):a.jsx(F2,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white truncate",children:q.file.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[(q.file.size/1024/1024).toFixed(2)," MB",q.isZip&&q.status==="pending"&&a.jsx("span",{className:"text-blue-400 ml-2",children:"• Will be extracted"}),q.extractedCount!==void 0&&a.jsxs("span",{className:"text-green-400 ml-2",children:["• ",q.extractedCount," files extracted"]})]})]}),q.status==="pending"&&a.jsx("button",{onClick:()=>E(j),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ot,{className:"w-4 h-4 text-bambu-gray"})}),q.status==="uploading"&&a.jsx(ut,{className:"w-4 h-4 text-bambu-green animate-spin"}),q.status==="success"&&a.jsx(Fn,{className:"w-4 h-4 text-green-500"}),q.status==="error"&&a.jsx("span",{title:q.error,children:a.jsx(aa,{className:"w-4 h-4 text-red-500"})})]},j))}),O&&a.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:["Upload complete: ",R," succeeded",F>0&&a.jsxs("span",{className:"text-red-400",children:[", ",F," failed"]})]})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[a.jsx(Te,{variant:"secondary",onClick:e,children:O?"Close":"Cancel"}),!O&&a.jsx(Te,{onClick:D,disabled:A===0||l,children:l?a.jsxs(a.Fragment,{children:[a.jsx(ut,{className:"w-4 h-4 mr-2 animate-spin"}),"Uploading..."]}):a.jsxs(a.Fragment,{children:[a.jsx(fi,{className:"w-4 h-4 mr-2"}),"Upload ",A>0?`(${A})`:""]})})]})]})})}function Are({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o=0,wrapNames:l=!1}){const[c,u]=w.useState(!0),[d,f]=w.useState(!1),m=t.children.length>0,g=t.project_id||t.archive_id;return a.jsxs("div",{children:[a.jsxs("div",{className:`group flex items-center gap-1 px-2 py-1.5 rounded cursor-pointer transition-colors ${e===t.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${8+o*12}px`},onClick:()=>n(t.id),children:[m?a.jsx("button",{onClick:x=>{x.stopPropagation(),u(!c)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Ms,{className:`w-3.5 h-3.5 transition-transform ${c?"rotate-90":""}`})}):a.jsx("div",{className:"w-4.5"}),a.jsx(cl,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),a.jsx("span",{className:`text-sm flex-1 min-w-0 ${l?"break-all":"truncate"}`,title:t.name,children:t.name}),g&&a.jsxs("button",{onClick:x=>{x.stopPropagation(),i(t)},className:"flex-shrink-0 flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors",title:`${t.project_name?`Project: ${t.project_name}`:`Archive: ${t.archive_name}`} (click to change)`,children:[a.jsx(Ol,{className:"w-3 h-3"}),t.project_name?a.jsx(iW,{className:"w-3 h-3"}):a.jsx(Qa,{className:"w-3 h-3"})]}),t.file_count>0&&a.jsx("span",{className:"flex-shrink-0 text-xs text-bambu-gray",children:t.file_count}),!g&&a.jsx("button",{onClick:x=>{x.stopPropagation(),i(t)},className:"flex-shrink-0 p-1 rounded hover:bg-bambu-dark-tertiary",title:"Link to project or archive",children:a.jsx(Ol,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green"})}),a.jsx("div",{className:`flex-shrink-0 flex items-center gap-0.5 transition-opacity ${l?"":"opacity-0 group-hover:opacity-100"}`,onClick:x=>x.stopPropagation(),children:a.jsxs("div",{className:"relative",children:[a.jsx("button",{onClick:()=>f(!d),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:a.jsx(Pd,{className:"w-3.5 h-3.5 text-bambu-gray"})}),d&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>f(!1)}),a.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[a.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{s(t),f(!1)},children:[a.jsx(Oi,{className:"w-3.5 h-3.5"}),"Rename"]}),a.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{i(t),f(!1)},children:[a.jsx(Ol,{className:"w-3.5 h-3.5"}),g?"Change Link...":"Link to..."]}),a.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{r(t.id),f(!1)},children:[a.jsx(on,{className:"w-3.5 h-3.5"}),"Delete"]})]})]})]})})]}),m&&c&&a.jsx("div",{children:t.children.map(x=>a.jsx(Are,{folder:x,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o+1,wrapNames:l},x.id))})]})}function WR(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function aXe({file:t,isSelected:e,isMobile:n,onSelect:r,onDelete:i,onDownload:s,onAddToQueue:o,onPrint:l,onRename:c,onGenerateThumbnail:u,thumbnailVersion:d}){const[f,m]=w.useState(!1);return a.jsxs("div",{className:`group relative bg-bambu-card rounded-lg border transition-all cursor-pointer overflow-hidden ${e?"border-bambu-green ring-1 ring-bambu-green":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,onClick:()=>r(t.id),children:[a.jsxs("div",{className:"aspect-square bg-bambu-dark flex items-center justify-center overflow-hidden",children:[t.thumbnail_path?a.jsx("img",{src:`${he.getLibraryFileThumbnailUrl(t.id)}${d?`?v=${d}`:""}`,alt:t.filename,className:"w-full h-full object-cover"}):a.jsx(xf,{className:"w-12 h-12 text-bambu-gray/30"}),a.jsx("div",{className:`absolute top-2 right-2 text-xs px-1.5 py-0.5 rounded font-medium ${t.file_type==="3mf"?"bg-bambu-green/90 text-white":t.file_type==="gcode"?"bg-blue-500/90 text-white":t.file_type==="stl"?"bg-purple-500/90 text-white":"bg-bambu-gray/90 text-white"}`,children:t.file_type.toUpperCase()})]}),a.jsxs("div",{className:"p-3",children:[a.jsx("h3",{className:"text-sm font-medium text-white truncate",title:t.print_name||t.filename,children:t.print_name||t.filename}),a.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-bambu-gray",children:[a.jsx("span",{children:Up(t.file_size)}),t.print_time_seconds&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(qn,{className:"w-3 h-3"}),JKe(t.print_time_seconds)]})]}),t.print_count>0&&a.jsxs("div",{className:"mt-1 text-xs text-bambu-green",children:["Printed ",t.print_count,"x"]})]}),a.jsxs("div",{className:`absolute bottom-2 right-2 transition-opacity ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:g=>g.stopPropagation(),children:[a.jsx("button",{onClick:()=>m(!f),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:a.jsx(Pd,{className:"w-4 h-4 text-bambu-gray"})}),f&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>m(!1)}),a.jsxs("div",{className:"absolute right-0 bottom-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[140px]",children:[l&&WR(t.filename)&&a.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-bambu-green hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{l(t),m(!1)},children:[a.jsx(Ar,{className:"w-3.5 h-3.5"}),"Print"]}),o&&WR(t.filename)&&a.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{o(t.id),m(!1)},children:[a.jsx(qn,{className:"w-3.5 h-3.5"}),"Add to Queue"]}),a.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{s(t.id),m(!1)},children:[a.jsx(Gr,{className:"w-3.5 h-3.5"}),"Download"]}),c&&a.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{c(t),m(!1)},children:[a.jsx(Oi,{className:"w-3.5 h-3.5"}),"Rename"]}),u&&t.file_type==="stl"&&a.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{u(t),m(!1)},children:[a.jsx(cu,{className:"w-3.5 h-3.5"}),"Generate Thumbnail"]}),a.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{i(t.id),m(!1)},children:[a.jsx(on,{className:"w-3.5 h-3.5"}),"Delete"]})]})]})]}),a.jsx("div",{className:`absolute top-2 left-2 w-5 h-5 rounded border-2 flex items-center justify-center transition-all ${e?"bg-bambu-green border-bambu-green":`border-white/30 bg-black/30 ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`}`,children:e&&a.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})})]})}function sXe(){const t=an(),{showToast:e}=Gn(),[n]=Lq(),r=n.get("folder"),i=r?parseInt(r,10):null,[s,o]=w.useState(i),[l,c]=w.useState([]),[u,d]=w.useState(!1),[f,m]=w.useState(!1),[g,x]=w.useState(!1),[y,b]=w.useState(null),[v,N]=w.useState(null),[S,T]=w.useState(null),[E,k]=w.useState(null),[C,D]=w.useState(null),[A,R]=w.useState({}),[F,O]=w.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[q,j]=w.useState(()=>localStorage.getItem("library-wrap-folders")==="true"),[G,Y]=w.useState(()=>{const ce=localStorage.getItem("library-sidebar-width");return ce?parseInt(ce,10):256}),[K,Z]=w.useState(!1),te=w.useRef(null);w.useEffect(()=>{if(!K)return;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const ce=ke=>{if(!te.current)return;const De=te.current.parentElement?.getBoundingClientRect();if(!De)return;const Ae=ke.clientX-De.left,Je=Math.min(500,Math.max(200,Ae));Y(Je)},ee=()=>{Z(!1),document.body.style.userSelect="",document.body.style.cursor="",localStorage.setItem("library-sidebar-width",String(G))};return document.addEventListener("mousemove",ce),document.addEventListener("mouseup",ee),()=>{document.removeEventListener("mousemove",ce),document.removeEventListener("mouseup",ee),document.body.style.userSelect="",document.body.style.cursor=""}},[K,G]);const[ne,z]=w.useState(""),[W,se]=w.useState("all"),[ae,de]=w.useState(()=>localStorage.getItem("library-sort-field")||"name"),[me,xe]=w.useState(()=>localStorage.getItem("library-sort-direction")||"asc"),be=yD();w.useEffect(()=>{const ce=n.get("folder");if(ce){const ee=parseInt(ce,10);o(ee)}},[n]);const{data:fe}=ct({queryKey:["settings"],queryFn:()=>he.getSettings()}),{data:Ce,isLoading:Ne}=ct({queryKey:["library-folders"],queryFn:()=>he.getLibraryFolders()}),{data:re,isLoading:He}=ct({queryKey:["library-files",s],queryFn:()=>he.getLibraryFiles(s,s===null)}),{data:H}=ct({queryKey:["library-stats"],queryFn:()=>he.getLibraryStats()}),B=w.useMemo(()=>{if(!re)return[];const ce=new Set(re.map(ee=>ee.file_type));return Array.from(ce).sort()},[re]),X=w.useMemo(()=>{if(!re)return[];let ce=[...re];if(ne.trim()){const ee=ne.toLowerCase();ce=ce.filter(ke=>ke.filename.toLowerCase().includes(ee)||ke.print_name&&ke.print_name.toLowerCase().includes(ee))}return W!=="all"&&(ce=ce.filter(ee=>ee.file_type===W)),ce.sort((ee,ke)=>{let De=0;switch(ae){case"name":De=(ee.print_name||ee.filename).localeCompare(ke.print_name||ke.filename);break;case"date":De=new Date(ee.created_at).getTime()-new Date(ke.created_at).getTime();break;case"size":De=ee.file_size-ke.file_size;break;case"type":De=ee.file_type.localeCompare(ke.file_type);break;case"prints":De=ee.print_count-ke.print_count;break}return me==="asc"?De:-De}),ce},[re,ne,W,ae,me]),U=w.useMemo(()=>{if(!H||!fe)return!1;const ce=(fe.library_disk_warning_gb||5)*1024*1024*1024;return H.disk_free_bytes<ce},[H,fe]),Q=ht({mutationFn:ce=>he.createLibraryFolder(ce),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),d(!1),e("Folder created","success")},onError:ce=>e(ce.message,"error")}),le=ht({mutationFn:ce=>he.deleteLibraryFolder(ce),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-stats"]}),s===v?.id&&o(null),N(null),e("Folder deleted","success")},onError:ce=>{N(null),e(ce.message,"error")}}),Pe=ht({mutationFn:ce=>he.deleteLibraryFile(ce),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),c(ce=>ce.filter(ee=>ee!==v?.id)),N(null),e("File deleted","success")},onError:ce=>{N(null),e(ce.message,"error")}}),Oe=ht({mutationFn:ce=>he.bulkDeleteLibrary(ce,[]),onSuccess:(ce,ee)=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),e(`Deleted ${ee.length} files`,"success"),c([]),N(null)},onError:ce=>{N(null),e(ce.message,"error")}}),je=ht({mutationFn:({fileIds:ce,folderId:ee})=>he.moveLibraryFiles(ce,ee),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),c([]),m(!1),e("Files moved","success")},onError:ce=>e(ce.message,"error")}),$=ht({mutationFn:({id:ce,data:ee})=>he.updateLibraryFolder(ce,ee),onSuccess:(ce,ee)=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["project-folders"]}),t.invalidateQueries({queryKey:["archive-folders"]}),b(null);const ke=ee.data.project_id===0&&ee.data.archive_id===0;e(ke?"Folder unlinked":"Folder linked","success")},onError:ce=>e(ce.message,"error")}),I=ht({mutationFn:ce=>he.addLibraryFilesToQueue(ce),onSuccess:ce=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["queue"]}),t.invalidateQueries({queryKey:["archives"]}),c([]),ce.added.length>0&&ce.errors.length===0?e(`Added ${ce.added.length} file${ce.added.length>1?"s":""} to queue`,"success"):ce.added.length>0&&ce.errors.length>0?e(`Added ${ce.added.length} file${ce.added.length>1?"s":""}, ${ce.errors.length} failed`,"success"):e(`Failed to add files: ${ce.errors[0]?.error||"Unknown error"}`,"error")},onError:ce=>e(ce.message,"error")}),V=ht({mutationFn:({id:ce,filename:ee})=>he.updateLibraryFile(ce,{filename:ee}),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),D(null),e("File renamed","success")},onError:ce=>{D(null),e(ce.message,"error")}}),ie=ht({mutationFn:({id:ce,name:ee})=>he.updateLibraryFolder(ce,{name:ee}),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-files"]}),D(null),e("Folder renamed","success")},onError:ce=>{D(null),e(ce.message,"error")}}),Se=ht({mutationFn:()=>he.batchGenerateStlThumbnails({all_missing:!0}),onSuccess:ce=>{if(t.invalidateQueries({queryKey:["library-files"]}),ce.succeeded>0){const ee=Date.now(),ke={};ce.results.forEach(De=>{De.success&&(ke[De.file_id]=ee)}),R(De=>({...De,...ke}))}ce.succeeded>0&&ce.failed===0?e(`Generated ${ce.succeeded} thumbnail${ce.succeeded>1?"s":""}`,"success"):ce.succeeded>0&&ce.failed>0?e(`Generated ${ce.succeeded} thumbnail${ce.succeeded>1?"s":""}, ${ce.failed} failed`,"success"):ce.processed===0?e("No STL files missing thumbnails","info"):e(`Failed to generate thumbnails: ${ce.results[0]?.error||"Unknown error"}`,"error")},onError:ce=>e(ce.message,"error")}),ye=ht({mutationFn:ce=>he.batchGenerateStlThumbnails({file_ids:[ce]}),onSuccess:ce=>{if(t.invalidateQueries({queryKey:["library-files"]}),ce.succeeded>0){const ee=ce.results[0]?.file_id;ee&&R(ke=>({...ke,[ee]:Date.now()})),e("Thumbnail generated","success")}else e(`Failed to generate thumbnail: ${ce.results[0]?.error||"Unknown error"}`,"error")},onError:ce=>e(ce.message,"error")}),$e=w.useCallback(ce=>{const ee=ce.toLowerCase();return ee.endsWith(".gcode")||ee.includes(".gcode.")},[]),Ue=w.useMemo(()=>re?re.filter(ce=>l.includes(ce.id)&&$e(ce.filename)):[],[re,l,$e]),Ge=w.useCallback(ce=>{c(ee=>ee.includes(ce)?ee.filter(ke=>ke!==ce):[...ee,ce])},[]),We=w.useCallback(()=>{X.length>0&&c(X.map(ce=>ce.id))},[X]),Ye=w.useCallback(()=>{c([])},[]),oe=()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]})},ve=ce=>{window.open(he.getLibraryFileDownloadUrl(ce),"_blank")},Le=()=>{v&&(v.type==="file"?Pe.mutate(v.id):v.type==="folder"?le.mutate(v.id):v.type==="bulk"&&Oe.mutate(l))},Ke=le.isPending||Pe.isPending||Oe.isPending,lt=ce=>{O(ce),localStorage.setItem("library-view-mode",ce)},_e=Ne||He;return a.jsxs("div",{className:"p-4 md:p-8 min-h-[calc(100vh-64px)] lg:h-[calc(100vh-64px)] flex flex-col",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[a.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:a.jsx(cl,{className:"w-6 h-6 text-bambu-green"})}),"File Manager"]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:"Organize and manage your print files"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex items-center bg-bambu-dark rounded-lg p-1",children:[a.jsx("button",{onClick:()=>lt("grid"),className:`p-1.5 rounded transition-colors ${F==="grid"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"Grid view",children:a.jsx(H2,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>lt("list"),className:`p-1.5 rounded transition-colors ${F==="list"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"List view",children:a.jsx(V2,{className:"w-4 h-4"})})]}),a.jsxs(Te,{variant:"secondary",onClick:()=>Se.mutate(),disabled:Se.isPending,title:"Generate thumbnails for STL files missing them",children:[Se.isPending?a.jsx(ut,{className:"w-4 h-4 mr-2 animate-spin"}):a.jsx(cu,{className:"w-4 h-4 mr-2"}),"Generate Thumbnails"]}),a.jsxs(Te,{variant:"secondary",onClick:()=>d(!0),children:[a.jsx(Lue,{className:"w-4 h-4 mr-2"}),"New Folder"]}),a.jsxs(Te,{onClick:()=>x(!0),children:[a.jsx(fi,{className:"w-4 h-4 mr-2"}),"Upload"]})]})]}),U&&H&&fe&&a.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[a.jsx(xn,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),a.jsxs("div",{className:"flex-1",children:[a.jsx("p",{className:"text-sm text-amber-500 font-medium",children:"Low disk space warning"}),a.jsxs("p",{className:"text-xs text-amber-500/80",children:["Only ",Up(H.disk_free_bytes)," free of ",Up(H.disk_total_bytes)," total. Threshold is set to ",fe.library_disk_warning_gb," GB in settings."]})]})]}),H&&a.jsxs("div",{className:"flex flex-wrap items-center gap-3 sm:gap-6 mb-6 p-3 bg-bambu-card rounded-lg border border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(F2,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-bambu-gray",children:"Files:"}),a.jsx("span",{className:"text-white font-medium",children:H.total_files})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(cl,{className:"w-4 h-4 text-blue-400"}),a.jsx("span",{className:"text-bambu-gray",children:"Folders:"}),a.jsx("span",{className:"text-white font-medium",children:H.total_folders})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(B2,{className:"w-4 h-4 text-amber-400"}),a.jsx("span",{className:"text-bambu-gray",children:"Size:"}),a.jsx("span",{className:"text-white font-medium",children:Up(H.total_size_bytes)})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm sm:ml-auto",children:[a.jsx("span",{className:"text-bambu-gray",children:"Free:"}),a.jsx("span",{className:`font-medium ${U?"text-amber-500":"text-white"}`,children:Up(H.disk_free_bytes)})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col lg:flex-row gap-4 lg:gap-6 min-h-0",children:[a.jsx("div",{className:"lg:hidden",children:a.jsxs("select",{value:s??"",onChange:ce=>o(ce.target.value?parseInt(ce.target.value,10):null),className:"w-full bg-bambu-card border border-bambu-dark-tertiary rounded-lg px-3 py-2.5 text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"",children:"📁 All Files"}),Ce&&(()=>{const ce=(ee,ke=0)=>{const De=[];for(const Ae of ee)De.push({id:Ae.id,name:Ae.name,fileCount:Ae.file_count,depth:ke}),Ae.children.length>0&&De.push(...ce(Ae.children,ke+1));return De};return ce(Ce).map(ee=>a.jsxs("option",{value:ee.id,children:["│ ".repeat(ee.depth),"📂 ",ee.name," ",ee.fileCount>0?`(${ee.fileCount})`:""]},ee.id))})()]})}),a.jsxs("div",{ref:te,className:"hidden lg:flex flex-shrink-0 bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden flex-col relative",style:{width:`${G}px`},children:[a.jsx("div",{className:`absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 group/resize flex items-center justify-center transition-colors ${K?"bg-bambu-green":"hover:bg-bambu-green/50"}`,onMouseDown:ce=>{ce.preventDefault(),Z(!0)},onDoubleClick:()=>{Y(256),localStorage.setItem("library-sidebar-width","256")},title:"Drag to resize, double-click to reset",children:a.jsxs("div",{className:`flex flex-col gap-1 opacity-0 group-hover/resize:opacity-100 transition-opacity ${K?"opacity-100":""}`,children:[a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),a.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"})]})}),a.jsxs("div",{className:"p-3 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[a.jsx("h2",{className:"text-sm font-medium text-white",children:"Folders"}),a.jsx("button",{onClick:()=>{const ce=!q;j(ce),localStorage.setItem("library-wrap-folders",String(ce))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${q?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white hover:bg-bambu-dark"}`,title:q?"Disable text wrapping":"Enable text wrapping",children:"Wrap"})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[a.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${s===null?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,onClick:()=>o(null),children:[a.jsx(xf,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:"All Files"})]}),Ce?.map(ce=>a.jsx(Are,{folder:ce,selectedFolderId:s,onSelect:o,onDelete:ee=>N({type:"folder",id:ee}),onLink:b,onRename:ee=>D({type:"folder",id:ee.id,name:ee.name}),wrapNames:q},ce.id))]})]}),a.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[re&&re.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mb-4 p-2 sm:p-3 bg-bambu-card rounded-lg border border-bambu-dark-tertiary sticky top-0 z-10 lg:static",children:[a.jsxs("div",{className:"relative w-full sm:w-auto sm:flex-1 sm:max-w-xs",children:[a.jsx(na,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:"Search files...",value:ne,onChange:ce=>z(ce.target.value),className:"w-full pl-9 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(U2,{className:"w-4 h-4 text-bambu-gray hidden sm:block"}),a.jsxs("select",{value:W,onChange:ce=>se(ce.target.value),className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"all",children:"All types"}),B.map(ce=>a.jsx("option",{value:ce,children:ce.toUpperCase()},ce))]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{value:ae,onChange:ce=>{const ee=ce.target.value;de(ee),localStorage.setItem("library-sort-field",ee)},className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[a.jsx("option",{value:"name",children:"Name"}),a.jsx("option",{value:"date",children:"Date"}),a.jsx("option",{value:"size",children:"Size"}),a.jsx("option",{value:"type",children:"Type"}),a.jsx("option",{value:"prints",children:"Prints"})]}),a.jsx("button",{onClick:()=>xe(ce=>{const ee=ce==="asc"?"desc":"asc";return localStorage.setItem("library-sort-direction",ee),ee}),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:me==="asc"?"Ascending":"Descending",children:me==="asc"?a.jsx(mce,{className:"w-4 h-4 text-white"}):a.jsx(lce,{className:"w-4 h-4 text-white"})})]}),(ne||W!=="all")&&a.jsxs("span",{className:"text-sm text-bambu-gray hidden sm:inline",children:[X.length," of ",re.length," files"]})]}),X.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-4 p-2 bg-bambu-card rounded-lg border border-bambu-dark-tertiary sticky top-[52px] z-10 lg:static",children:[l.length===X.length&&l.length>0?a.jsxs(Te,{variant:"secondary",size:"sm",onClick:Ye,children:[a.jsx(Oo,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:"Deselect All"})]}):a.jsxs(Te,{variant:"secondary",size:"sm",onClick:We,children:[a.jsx(Do,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:"Select All"})]}),l.length>0&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"text-sm text-bambu-gray ml-2",children:[l.length," selected"]}),a.jsx("div",{className:"hidden sm:block flex-1"}),a.jsxs("div",{className:"w-full sm:w-auto flex flex-wrap items-center gap-2 mt-2 sm:mt-0",children:[Ue.length===1&&a.jsxs(Te,{variant:"primary",size:"sm",onClick:()=>k(Ue[0]),children:[a.jsx(vs,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:"Print"})]}),Ue.length>0&&a.jsxs(Te,{variant:Ue.length===1?"secondary":"primary",size:"sm",onClick:()=>I.mutate(Ue.map(ce=>ce.id)),disabled:I.isPending,children:[a.jsx(qn,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:I.isPending?"Adding...":`Add to Queue${Ue.length<l.length?` (${Ue.length})`:""}`})]}),a.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>m(!0),children:[a.jsx(Vde,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:"Move"})]}),a.jsxs(Te,{variant:"danger",size:"sm",onClick:()=>{l.length===1?N({type:"file",id:l[0]}):N({type:"bulk",id:0,count:l.length})},children:[a.jsx(on,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:"Delete"})]}),a.jsxs(Te,{variant:"secondary",size:"sm",onClick:Ye,children:[a.jsx(Ot,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:"Clear"})]})]})]})]}),_e?a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx(ut,{className:"w-8 h-8 animate-spin text-bambu-green"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading files..."})]})}):re?.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(xf,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:s!==null?"Folder is empty":"No files yet"}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:s!==null?"Upload files or move files into this folder to get started.":"Upload files to start organizing your print-related files."}),a.jsxs(Te,{onClick:()=>x(!0),children:[a.jsx(rr,{className:"w-4 h-4 mr-2"}),"Upload Files"]})]}):X.length===0?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[a.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:a.jsx(na,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No matching files"}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:"No files match your current search or filter criteria."}),a.jsx(Te,{variant:"secondary",onClick:()=>{z(""),se("all")},children:"Clear filters"})]}):F==="grid"?a.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:a.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4",children:X.map(ce=>a.jsx(aXe,{file:ce,isSelected:l.includes(ce.id),isMobile:be,onSelect:Ge,onDelete:ee=>N({type:"file",id:ee}),onDownload:ve,onAddToQueue:ee=>I.mutate([ee]),onPrint:T,onRename:ee=>D({type:"file",id:ee.id,name:ee.filename}),onGenerateThumbnail:ee=>ye.mutate(ee.id),thumbnailVersion:A[ce.id]},ce.id))})}):a.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:a.jsxs("div",{className:"bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[a.jsxs("div",{className:"hidden sm:grid grid-cols-[auto_1fr_100px_100px_100px_80px] gap-4 px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary text-xs text-bambu-gray font-medium",children:[a.jsx("div",{className:"w-6"}),a.jsx("div",{children:"Name"}),a.jsx("div",{children:"Type"}),a.jsx("div",{children:"Size"}),a.jsx("div",{children:"Prints"}),a.jsx("div",{})]}),X.map(ce=>a.jsxs("div",{className:`grid grid-cols-[auto_1fr_100px_100px_100px_80px] gap-4 px-4 py-3 items-center border-b border-bambu-dark-tertiary last:border-b-0 cursor-pointer hover:bg-bambu-dark/50 transition-colors ${l.includes(ce.id)?"bg-bambu-green/10":""}`,onClick:()=>Ge(ce.id),children:[a.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${l.includes(ce.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:l.includes(ce.id)&&a.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})}),a.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.jsxs("div",{className:"relative group/thumb",children:[a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark flex-shrink-0 overflow-hidden",children:ce.thumbnail_path?a.jsx("img",{src:`${he.getLibraryFileThumbnailUrl(ce.id)}${A[ce.id]?`?v=${A[ce.id]}`:""}`,alt:"",className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:a.jsx(xf,{className:"w-5 h-5 text-bambu-gray/50"})})}),ce.thumbnail_path&&a.jsx("div",{className:"absolute left-0 top-full mt-2 z-50 hidden group-hover/thumb:block",children:a.jsx("div",{className:"w-48 h-48 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary shadow-xl overflow-hidden",children:a.jsx("img",{src:`${he.getLibraryFileThumbnailUrl(ce.id)}${A[ce.id]?`?v=${A[ce.id]}`:""}`,alt:ce.filename,className:"w-full h-full object-contain"})})})]}),a.jsx("div",{className:"min-w-0",children:a.jsx("div",{className:"text-sm text-white truncate",children:ce.print_name||ce.filename})})]}),a.jsx("div",{children:a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${ce.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":ce.file_type==="gcode"?"bg-blue-500/20 text-blue-400":ce.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:ce.file_type.toUpperCase()})}),a.jsx("div",{className:"text-sm text-bambu-gray",children:Up(ce.file_size)}),a.jsx("div",{className:"text-sm text-bambu-gray",children:ce.print_count>0?`${ce.print_count}x`:"-"}),a.jsxs("div",{className:"flex items-center gap-1",onClick:ee=>ee.stopPropagation(),children:[WR(ce.filename)&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>T(ce),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green transition-colors",title:"Print",children:a.jsx(Ar,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>I.mutate([ce.id]),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Add to Queue",disabled:I.isPending,children:a.jsx(qn,{className:"w-4 h-4"})})]}),a.jsx("button",{onClick:()=>ve(ce.id),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Download",children:a.jsx(Gr,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>D({type:"file",id:ce.id,name:ce.filename}),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Rename",children:a.jsx(Oi,{className:"w-4 h-4"})}),ce.file_type==="stl"&&a.jsx("button",{onClick:()=>ye.mutate(ce.id),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green transition-colors",title:"Generate Thumbnail",disabled:ye.isPending,children:a.jsx(cu,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>N({type:"file",id:ce.id}),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",title:"Delete",children:a.jsx(on,{className:"w-4 h-4"})})]})]},ce.id))]})})]})]}),u&&a.jsx(eXe,{parentId:s,onClose:()=>d(!1),onSave:ce=>Q.mutate(ce),isLoading:Q.isPending}),f&&Ce&&a.jsx(nXe,{folders:Ce,selectedFiles:l,currentFolderId:s,onClose:()=>m(!1),onMove:ce=>je.mutate({fileIds:l,folderId:ce}),isLoading:je.isPending}),g&&a.jsx(iXe,{folderId:s,onClose:()=>x(!1),onUploadComplete:oe}),y&&a.jsx(rXe,{folder:y,onClose:()=>b(null),onLink:ce=>$.mutate({id:y.id,data:ce}),isLoading:$.isPending}),v&&a.jsx(Hn,{title:v.type==="folder"?"Delete Folder":v.type==="bulk"?`Delete ${v.count} Files`:"Delete File",message:v.type==="folder"?"Are you sure you want to delete this folder? All files inside will also be deleted.":v.type==="bulk"?`Are you sure you want to delete ${v.count} selected files? This action cannot be undone.`:"Are you sure you want to delete this file?",confirmText:"Delete",variant:"danger",isLoading:Ke,loadingText:"Deleting...",onConfirm:Le,onCancel:()=>N(null)}),S&&a.jsx(ah,{mode:"reprint",libraryFileId:S.id,archiveName:S.print_name||S.filename,onClose:()=>T(null),onSuccess:()=>{T(null),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["archives"]})}}),E&&a.jsx(ah,{mode:"reprint",libraryFileId:E.id,archiveName:E.print_name||E.filename,onClose:()=>k(null),onSuccess:()=>{k(null),c([]),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["archives"]})}}),C&&a.jsx(tXe,{type:C.type,currentName:C.name,onClose:()=>D(null),onSave:ce=>{C.type==="file"?V.mutate({id:C.id,filename:ce}):ie.mutate({id:C.id,name:ce})},isLoading:V.isPending||ie.isPending})]})}const Tj=5,oXe=2e3,lXe=3e4,cXe=5e3;function uXe(){const{printerId:t}=ZR(),e=parseInt(t||"0",10),[n,r]=w.useState("stream"),[i,s]=w.useState(!1),[o,l]=w.useState(!0),[c,u]=w.useState(Date.now()),[d,f]=w.useState(!1),[m,g]=w.useState(!1),[x,y]=w.useState(0),[b,v]=w.useState(!1),[N,S]=w.useState(0),[T,E]=w.useState(1),[k,C]=w.useState({x:0,y:0}),[D,A]=w.useState(!1),[R,F]=w.useState({x:0,y:0}),[O,q]=w.useState(null),[j,G]=w.useState(null),Y=w.useRef(null),K=w.useRef(null),Z=w.useRef(null),te=w.useRef(null),ne=w.useRef(null),{data:z}=ct({queryKey:["printer",e],queryFn:()=>he.getPrinter(e),enabled:e>0});w.useEffect(()=>(z&&(document.title=`${z.name} - Camera`),()=>{document.title="Bambuddy"}),[z]);const W=w.useRef(!1);w.useEffect(()=>{const V=`/api/v1/printers/${e}/camera/stop`;W.current=!1;const ie=()=>{e>0&&!W.current&&(W.current=!0,navigator.sendBeacon(V))},Se=()=>{ie()};window.addEventListener("beforeunload",Se);const ye=Y.current;return()=>{window.removeEventListener("beforeunload",Se),ye&&(ye.src=""),ie()}},[e]),w.useEffect(()=>{if(o&&!d){const ie=setTimeout(()=>{l(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(ie)}},[n,o,c,d]),w.useEffect(()=>{const V=()=>{const ie=!!document.fullscreenElement;g(ie),E(1),C({x:0,y:0}),n==="stream"&&!d&&(Y.current&&(Y.current.src=""),setTimeout(()=>{l(!0),u(Date.now())},200))};return document.addEventListener("fullscreenchange",V),()=>document.removeEventListener("fullscreenchange",V)},[n,d]),w.useEffect(()=>{let V;const ie=()=>{clearTimeout(V),V=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",ie),()=>{clearTimeout(V),window.removeEventListener("resize",ie)}},[]),w.useEffect(()=>()=>{Z.current&&clearTimeout(Z.current),te.current&&clearInterval(te.current),ne.current&&clearInterval(ne.current)},[]);const se=w.useCallback(()=>{if(x>=Tj){v(!1),s(!0);return}const V=Math.min(oXe*Math.pow(2,x),lXe);v(!0),S(Math.ceil(V/1e3)),te.current=setInterval(()=>{S(ie=>ie<=1?(te.current&&clearInterval(te.current),0):ie-1)},1e3),Z.current=setTimeout(()=>{y(ie=>ie+1),v(!1),l(!0),s(!1),Y.current&&(Y.current.src=""),u(Date.now())},V)},[x]);w.useEffect(()=>{if(n!=="stream"||o||b||d){ne.current&&(clearInterval(ne.current),ne.current=null);return}return ne.current=setInterval(async()=>{try{const V=await fetch(`/api/v1/printers/${e}/camera/status`);if(V.ok){const ie=await V.json();(ie.stalled||!ie.active&&!i)&&(console.log(`Stream issue detected: stalled=${ie.stalled}, active=${ie.active}, reconnecting...`),ne.current&&(clearInterval(ne.current),ne.current=null),l(!1),se())}}catch{}},cXe),()=>{ne.current&&(clearInterval(ne.current),ne.current=null)}},[n,o,i,b,d,e,se]);const ae=()=>{l(!1),n==="stream"&&x<Tj?se():s(!0)},de=()=>{if(l(!1),s(!1),y(0),v(!1),Z.current&&clearTimeout(Z.current),te.current&&clearInterval(te.current),Y.current&&!localStorage.getItem("cameraWindowState")){const V=Y.current,ie=V.naturalWidth,Se=V.naturalHeight;if(ie>0&&Se>0){const Ue=window.outerWidth-window.innerWidth,Ge=window.outerHeight-window.innerHeight,We=ie+16+Ue,Ye=Se+45+16+Ge;try{window.resizeTo(We,Ye)}catch{}}}},me=()=>{e>0&&fetch(`/api/v1/printers/${e}/camera/stop`).catch(()=>{})},xe=V=>{n===V||d||(f(!0),l(!0),s(!1),y(0),v(!1),E(1),C({x:0,y:0}),Z.current&&clearTimeout(Z.current),te.current&&clearInterval(te.current),Y.current&&(Y.current.src=""),n==="stream"&&me(),setTimeout(()=>{r(V),u(Date.now()),f(!1)},100))},be=()=>{d||(f(!0),l(!0),s(!1),y(0),v(!1),Z.current&&clearTimeout(Z.current),te.current&&clearInterval(te.current),Y.current&&(Y.current.src=""),n==="stream"&&me(),setTimeout(()=>{u(Date.now()),f(!1)},100))},fe=()=>{K.current&&(document.fullscreenElement?document.exitFullscreen():K.current.requestFullscreen())},Ce=()=>{E(V=>Math.min(V+.5,4))},Ne=()=>{E(V=>{const ie=Math.max(V-.5,1);return ie===1&&C({x:0,y:0}),ie})},re=V=>{V.preventDefault(),V.deltaY<0?Ce():Ne()},He=V=>{T>1&&(V.preventDefault(),A(!0),F({x:V.clientX-k.x,y:V.clientY-k.y}))},H=w.useCallback(()=>{if(!K.current)return{x:300,y:200};const V=K.current.getBoundingClientRect(),ie=V.width*(T-1)/2,Se=V.height*(T-1)/2;return{x:Math.max(50,ie),y:Math.max(50,Se)}},[T]),B=V=>{if(D&&T>1){const ie=V.clientX-R.x,Se=V.clientY-R.y,ye=H();C({x:Math.max(-ye.x,Math.min(ye.x,ie)),y:Math.max(-ye.y,Math.min(ye.y,Se))})}},X=()=>{A(!1)},U=V=>{if(V.length<2)return 0;const ie=V[0].clientX-V[1].clientX,Se=V[0].clientY-V[1].clientY;return Math.sqrt(ie*ie+Se*Se)},Q=V=>V.length<2?{x:V[0].clientX,y:V[0].clientY}:{x:(V[0].clientX+V[1].clientX)/2,y:(V[0].clientY+V[1].clientY)/2},le=V=>{V.touches.length===2?(V.preventDefault(),q(U(V.touches)),G(Q(V.touches))):V.touches.length===1&&T>1&&(V.preventDefault(),A(!0),F({x:V.touches[0].clientX-k.x,y:V.touches[0].clientY-k.y}))},Pe=V=>{if(V.touches.length===2&&O!==null){V.preventDefault();const ie=U(V.touches),Se=ie/O;E($e=>{const Ue=Math.max(1,Math.min(4,$e*Se));return Ue===1&&C({x:0,y:0}),Ue}),q(ie);const ye=Q(V.touches);if(j){const $e=H();C(Ue=>({x:Math.max(-$e.x,Math.min($e.x,Ue.x+(ye.x-j.x))),y:Math.max(-$e.y,Math.min($e.y,Ue.y+(ye.y-j.y)))}))}G(ye)}else if(V.touches.length===1&&D&&T>1){V.preventDefault();const ie=V.touches[0].clientX-R.x,Se=V.touches[0].clientY-R.y,ye=H();C({x:Math.max(-ye.x,Math.min(ye.x,ie)),y:Math.max(-ye.y,Math.min(ye.y,Se))})}},Oe=V=>{V.touches.length<2&&(q(null),G(null)),V.touches.length===0&&A(!1)},je=()=>{E(1),C({x:0,y:0})},$=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${c}`:`/api/v1/printers/${e}/camera/snapshot?t=${c}`,I=o||d||b;return e?a.jsxs("div",{ref:K,className:"min-h-screen bg-black flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[a.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[a.jsx(Df,{className:"w-4 h-4"}),z?.name||`Printer ${e}`]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[a.jsx("button",{onClick:()=>xe("stream"),disabled:I,className:`px-3 py-1 text-xs rounded transition-colors ${n==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Live"}),a.jsx("button",{onClick:()=>xe("snapshot"),disabled:I,className:`px-3 py-1 text-xs rounded transition-colors ${n==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Snapshot"})]}),a.jsx("button",{onClick:be,disabled:I,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:a.jsx(vr,{className:`w-4 h-4 text-bambu-gray ${I?"animate-spin":""}`})}),a.jsx("button",{onClick:fe,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:m?"Exit fullscreen":"Fullscreen",children:m?a.jsx(hW,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(Pde,{className:"w-4 h-4 text-bambu-gray"})})]})]}),a.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:re,onMouseMove:B,onMouseUp:X,onMouseLeave:X,onTouchStart:le,onTouchMove:Pe,onTouchEnd:Oe,style:{touchAction:"none"},children:a.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(o||d)&&!b&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:a.jsxs("div",{className:"text-center",children:[a.jsx(vr,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n==="stream"?"Connecting to camera...":"Capturing snapshot..."})]})}),b&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:a.jsxs("div",{className:"text-center p-4",children:[a.jsx(If,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),a.jsx("p",{className:"text-white mb-2",children:"Connection lost"}),a.jsxs("p",{className:"text-sm text-bambu-gray mb-3",children:["Reconnecting in ",N,"s... (attempt ",x+1,"/",Tj,")"]}),a.jsx("button",{onClick:be,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:"Reconnect now"})]})}),i&&!b&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:a.jsxs("div",{className:"text-center p-4",children:[a.jsx(xn,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),a.jsx("p",{className:"text-white mb-2",children:"Camera unavailable"}),a.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:"Make sure the printer is powered on and connected."}),a.jsx("button",{onClick:be,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),a.jsx("img",{ref:Y,src:$,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${T}) translate(${k.x/T}px, ${k.y/T}px)`,cursor:T>1?D?"grabbing":"grab":"default"},onError:$?ae:void 0,onLoad:$?de:void 0,onMouseDown:He,draggable:!1},c),a.jsxs("div",{className:"absolute bottom-4 left-4 flex items-center gap-1.5 bg-black/60 rounded-lg px-2 py-1.5",children:[a.jsx("button",{onClick:Ne,disabled:T<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:a.jsx(bD,{className:"w-4 h-4 text-white"})}),a.jsxs("button",{onClick:je,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:"Reset zoom",children:[Math.round(T*100),"%"]}),a.jsx("button",{onClick:Ce,disabled:T>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:a.jsx(xD,{className:"w-4 h-4 text-white"})})]})]})})]}):a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-white",children:"Invalid printer ID"})})}function dXe(){const{id:t}=ZR(),{mode:e}=lh(),{data:n,isLoading:r,error:i}=ct({queryKey:["external-link",t],queryFn:()=>he.getExternalLink(Number(t)),enabled:!!t});return r?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx(ut,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i||!n?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[a.jsx(xn,{className:"w-12 h-12"}),a.jsx("p",{children:"Link not found"})]}):a.jsx("iframe",{src:n.url,className:"h-full w-full border-0",style:{colorScheme:e},title:n.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}const aq=["DEBUG","INFO","WARNING","ERROR"],Cj={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},hXe={DEBUG:D2,INFO:Ul,WARNING:xn,ERROR:Ei};function fXe(){const t=an(),[e,n]=w.useState(!0),[r,i]=w.useState(new Set),[s,o]=w.useState(""),[l,c]=w.useState("ALL"),[u,d]=w.useState(!1),[f,m]=w.useState(!1),g=w.useRef(null),{data:x,isLoading:y,refetch:b}=ct({queryKey:["application-logs",l,s],queryFn:()=>Kp.getLogs({limit:200,level:l==="ALL"?void 0:l,search:s||void 0}),refetchInterval:f?2e3:!1,enabled:u});w.useEffect(()=>{u||m(!1)},[u]);const v=ht({mutationFn:()=>Kp.clearLogs(),onSuccess:()=>{t.invalidateQueries({queryKey:["application-logs"]})}});w.useEffect(()=>{e&&g.current&&x?.entries&&(g.current.scrollTop=g.current.scrollHeight)},[x?.entries,e]);const N=C=>{i(D=>{const A=new Set(D);return A.has(C)?A.delete(C):A.add(C),A})},S=C=>{const D=C.split(" ");return D.length>=2?D[1]:C},T=w.useMemo(()=>x?.entries??[],[x?.entries]),E=w.useMemo(()=>[...T].reverse(),[T]),k=({level:C})=>{const D=hXe[C]||Ul;return a.jsx(D,{className:`w-3.5 h-3.5 ${Cj[C]||"text-gray-400"}`})};return a.jsxs("div",{className:"bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/50 transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${f?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:a.jsx(D2,{className:"w-5 h-5"})}),a.jsxs("div",{className:"text-left",children:[a.jsx("p",{className:"font-medium text-white",children:"Application Logs"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:f?`Live streaming - ${x?.filtered_count??0} entries`:"View and filter application logs"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[f&&a.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-1 bg-bambu-green/20 rounded text-bambu-green text-xs",children:[a.jsx("span",{className:"w-1.5 h-1.5 bg-bambu-green rounded-full animate-pulse"}),"Live"]}),u?a.jsx(ou,{className:"w-5 h-5 text-bambu-gray"}):a.jsx(Br,{className:"w-5 h-5 text-bambu-gray"})]})]}),u&&a.jsxs("div",{className:"border-t border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f?a.jsxs("button",{onClick:C=>{C.stopPropagation(),m(!1)},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-red-500/20 text-red-400 hover:bg-red-500/30 rounded transition-colors",children:[a.jsx(Oo,{className:"w-4 h-4"}),"Stop"]}):a.jsxs("button",{onClick:C=>{C.stopPropagation(),m(!0),b()},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 rounded transition-colors",children:[a.jsx(vs,{className:"w-4 h-4"}),"Start"]}),a.jsxs("button",{onClick:()=>v.mutate(),disabled:v.isPending||T.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:[a.jsx(on,{className:"w-4 h-4"}),"Clear"]}),a.jsx("button",{onClick:()=>b(),disabled:y,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:a.jsx(vr,{className:`w-4 h-4 ${y?"animate-spin":""}`})}),a.jsx("div",{className:"flex-1"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e,onChange:C=>n(C.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark-tertiary"}),"Auto-scroll"]}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[x?.filtered_count??0,"/",x?.total_in_file??0]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(na,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:"Search message or logger name...",value:s,onChange:C=>o(C.target.value),className:"w-full pl-8 pr-8 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),s&&a.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Ot,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark-secondary rounded border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>c("ALL"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${l==="ALL"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),aq.map((C,D)=>a.jsx("button",{onClick:()=>c(C),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${D===aq.length-1?"rounded-r":""} ${l===C?`${Cj[C]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:C},C))]})]})]}),a.jsx("div",{ref:g,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:T.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-[300px] text-bambu-gray",children:[a.jsx("p",{className:"mb-2",children:"No log entries found"}),a.jsx("p",{className:"text-sm",children:"Log file may be empty or cleared"})]}):a.jsx("div",{className:"divide-y divide-bambu-dark-tertiary/30",children:E.map((C,D)=>{const A=r.has(D),R=C.message.includes(`
- `);return a.jsx("div",{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${A?"bg-bambu-dark-secondary/30":""}`,onClick:()=>R&&N(D),children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("span",{className:"text-bambu-gray/70 shrink-0 w-20",children:S(C.timestamp)}),a.jsx("span",{className:"shrink-0",children:a.jsx(k,{level:C.level})}),a.jsxs("span",{className:"text-purple-400/80 shrink-0 max-w-[200px] truncate",title:C.logger_name,children:["[",C.logger_name,"]"]}),a.jsx("span",{className:`flex-1 ${Cj[C.level]||"text-white/80"} ${!A&&R?"truncate":""}`,children:A?a.jsx("pre",{className:"whitespace-pre-wrap break-all",children:C.message}):C.message.split(`
- `)[0]}),R&&a.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:A?a.jsx(ou,{className:"w-3.5 h-3.5"}):a.jsx(Br,{className:"w-3.5 h-3.5"})})]})},D)})})}),a.jsx("div",{className:"flex items-center justify-between p-3 border-t border-bambu-dark-tertiary text-sm text-bambu-gray",children:f?a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Auto-refreshing every 2 seconds"]}):a.jsx("span",{children:"Click Start to enable live log streaming"})})]})]})}function mXe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function ni({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-green"}){return a.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[a.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${i}`,children:a.jsx(t,{className:"w-5 h-5"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:e}),a.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function sq({percent:t,color:e="bg-bambu-green"}){return a.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function cd({title:t,icon:e,children:n}){return a.jsxs(_t,{className:"p-6",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[a.jsx(e,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function pXe(){const{t}=Fg(),e=an(),[n,r]=w.useState(null),[i,s]=w.useState(!1),[o,l]=w.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:f}=ct({queryKey:["systemInfo"],queryFn:he.getSystemInfo,refetchInterval:3e4}),{data:m}=ct({queryKey:["debugLogging"],queryFn:Kp.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:g}=ct({queryKey:["settings"],queryFn:he.getSettings}),{data:x}=ct({queryKey:["library-stats"],queryFn:he.getLibraryStats}),y=g?.time_format||"system",b=async()=>{l(!0);try{const T=await Kp.setDebugLogging(!m?.enabled);e.setQueryData(["debugLogging"],T)}catch(T){console.error("Failed to toggle debug logging:",T)}finally{l(!1)}},v=async()=>{r(null),s(!0);try{await Kp.downloadSupportBundle()}catch(T){r(T instanceof Error?T.message:"Failed to download support bundle")}finally{s(!1)}};if(u)return a.jsx("div",{className:"flex items-center justify-center h-64",children:a.jsx(ut,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!c)return a.jsx("div",{className:"p-6 text-center text-bambu-gray",children:t("system.failedToLoad","Failed to load system information")});const N=c.storage.disk_percent_used>90?"bg-red-500":c.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",S=c.memory.percent_used>90?"bg-red-500":c.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return a.jsxs("div",{className:"p-6 space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),a.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),a.jsxs("button",{onClick:()=>d(),disabled:f,className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary rounded-lg transition-colors disabled:opacity-50",children:[a.jsx(vr,{className:`w-4 h-4 ${f?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),a.jsx(cd,{title:t("system.application","Application"),icon:Wh,children:a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[a.jsx(ni,{icon:Wh,label:t("system.version","Version"),value:`v${c.app.version}`}),a.jsx(ni,{icon:qn,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),a.jsx(ni,{icon:Wh,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),a.jsx(cd,{title:t("support.title","Support & Troubleshooting"),icon:tde,children:a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.description","Enable debug logging to capture detailed information, then download a support bundle to share when reporting issues.")}),a.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${m?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:a.jsx(D2,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-white",children:t("support.debugLogging","Debug Logging")}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[m?.enabled?t("support.debugLoggingEnabled","Capturing detailed logs"):t("support.debugLoggingDisabled","Normal logging level"),m?.enabled&&m.duration_seconds!==null&&a.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(m.duration_seconds/60),"m ",m.duration_seconds%60,"s)"]})]})]})]}),a.jsxs("button",{onClick:b,disabled:o,className:`px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2 ${m?.enabled?"bg-amber-500/20 text-amber-400 hover:bg-amber-500/30":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30"} disabled:opacity-50`,children:[o&&a.jsx(ut,{className:"w-4 h-4 animate-spin"}),m?.enabled?t("support.disableDebug","Disable"):t("support.enableDebug","Enable")]})]}),a.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-green",children:a.jsx(Gr,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-white",children:t("support.supportBundle","Support Bundle")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.supportBundleDescription","Download system info and logs as a ZIP file")})]})]}),a.jsxs("button",{onClick:v,disabled:i||!m?.enabled,className:"px-4 py-2 rounded-lg font-medium bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",title:m?.enabled?void 0:t("support.enableDebugFirst","Enable debug logging first"),children:[i&&a.jsx(ut,{className:"w-4 h-4 animate-spin"}),t("common.download","Download")]})]}),n&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/30 rounded-lg text-red-400 text-sm",children:n}),!m?.enabled&&a.jsx("div",{className:"p-4 bg-bambu-dark-tertiary/50 rounded-lg",children:a.jsxs("p",{className:"text-sm text-bambu-gray",children:[a.jsx("span",{className:"text-amber-400 font-medium",children:t("support.instructions","To report an issue:")}),a.jsx("br",{}),"1. ",t("support.step1","Enable debug logging"),a.jsx("br",{}),"2. ",t("support.step2","Reproduce the issue"),a.jsx("br",{}),"3. ",t("support.step3","Download the support bundle"),a.jsx("br",{}),"4. ",t("support.step4","Attach the ZIP file to your issue report")]})}),a.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg space-y-3",children:[a.jsx("p",{className:"text-sm font-medium text-white",children:t("support.privacyTitle","What's in the support bundle?")}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-bambu-green font-medium mb-1",children:t("support.collected","Collected:")}),a.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[a.jsxs("li",{children:["• ",t("support.collectItem1","App version and debug mode")]}),a.jsxs("li",{children:["• ",t("support.collectItem2","OS, architecture, Python version")]}),a.jsxs("li",{children:["• ",t("support.collectItem3","Database statistics (counts only)")]}),a.jsxs("li",{children:["• ",t("support.collectItem4","Printer models and nozzle counts")]}),a.jsxs("li",{children:["• ",t("support.collectItem5","Non-sensitive settings (themes, formats)")]}),a.jsxs("li",{children:["• ",t("support.collectItem6","Debug logs (sanitized)")]})]})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-red-400 font-medium mb-1",children:t("support.notCollected","NOT collected:")}),a.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[a.jsxs("li",{children:["• ",t("support.notItem1","Printer names, IPs, serial numbers")]}),a.jsxs("li",{children:["• ",t("support.notItem2","Access codes and passwords")]}),a.jsxs("li",{children:["• ",t("support.notItem3","Email addresses")]}),a.jsxs("li",{children:["• ",t("support.notItem4","API keys and tokens")]}),a.jsxs("li",{children:["• ",t("support.notItem5","Webhook URLs")]}),a.jsxs("li",{children:["• ",t("support.notItem6","Your hostname or username")]})]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray/70",children:t("support.privacyNote","IP addresses in logs are replaced with [IP] and email addresses with [EMAIL].")})]}),a.jsx(fXe,{})]})}),a.jsxs(cd,{title:t("system.database","Database"),icon:Zc,children:[a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[a.jsx(ni,{icon:Qa,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),a.jsx(ni,{icon:O2,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),a.jsx(ni,{icon:aa,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),a.jsx(ni,{icon:ut,label:t("system.printing","Printing"),value:c.database.archives_printing,color:"text-yellow-500"})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(ni,{icon:Ar,label:t("system.printers","Printers"),value:c.database.printers}),a.jsx(ni,{icon:dD,label:t("system.filaments","Filaments"),value:c.database.filaments}),a.jsx(ni,{icon:Ma,label:t("system.projects","Projects"),value:c.database.projects}),a.jsx(ni,{icon:Ws,label:t("system.smartPlugs","Smart Plugs"),value:c.database.smart_plugs})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[a.jsx(ni,{icon:qn,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),a.jsx(ni,{icon:Qa,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),a.jsxs(cd,{title:t("system.connectedPrinters","Connected Printers"),icon:Ar,children:[a.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[a.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:c.printers.connected}),a.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:c.printers.total})})]}),c.printers.connected_list.length>0?a.jsx("div",{className:"space-y-2",children:c.printers.connected_list.map(T=>a.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),a.jsx("span",{className:"font-medium text-white",children:T.name})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[a.jsx("span",{children:T.model}),a.jsx("span",{className:`px-2 py-0.5 rounded ${T.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":T.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:T.state})]})]},T.id))}):a.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),a.jsx(cd,{title:t("system.storage","Storage"),icon:B2,children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),a.jsxs("span",{className:"text-white",children:[c.storage.disk_used_formatted," / ",c.storage.disk_total_formatted]})]}),a.jsx(sq,{percent:c.storage.disk_percent_used,color:N}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.storage.disk_free_formatted," ",t("system.free","free")," (",(100-c.storage.disk_percent_used).toFixed(1),"%)"]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[a.jsx(ni,{icon:Qa,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),a.jsx(ni,{icon:Zc,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),x&&a.jsx(ni,{icon:cl,label:t("system.fileManagerStorage","File Manager"),value:mXe(x.total_size_bytes),subValue:`${x.total_files} files, ${x.total_folders} folders`})]})]})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[a.jsx(cd,{title:t("system.memory","Memory"),icon:Dde,children:a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[a.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),a.jsxs("span",{className:"text-white",children:[c.memory.used_formatted," / ",c.memory.total_formatted]})]}),a.jsx(sq,{percent:c.memory.percent_used,color:S}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),a.jsx(cd,{title:t("system.cpu","CPU"),icon:s_,children:a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(ni,{icon:s_,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),a.jsx(ni,{icon:s_,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),a.jsx(cd,{title:t("system.systemDetails","System Details"),icon:Wh,children:a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(ni,{icon:Wh,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),a.jsx(ni,{icon:s_,label:t("system.architecture","Architecture"),value:c.system.architecture}),a.jsx(ni,{icon:Wh,label:t("system.python","Python"),value:c.system.python_version}),a.jsx(ni,{icon:qn,label:t("system.bootTime","Boot Time"),value:ug(c.system.boot_time,y)})]})})]})}function gXe(){const t=fl(),{login:e}=ch(),{showToast:n}=Gn(),{mode:r}=lh(),[i,s]=w.useState(""),[o,l]=w.useState(""),c=ht({mutationFn:()=>e(i,o),onSuccess:()=>{n("Logged in successfully"),t("/")},onError:d=>{n(d.message||"Login failed","error")}}),u=d=>{if(d.preventDefault(),!i||!o){n("Please enter username and password","error");return}c.mutate()};return a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:a.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"flex items-center justify-center mb-6",children:a.jsx("img",{src:r==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),a.jsx("h2",{className:"text-3xl font-bold text-white",children:"Bambuddy Login"}),a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"Sign in to your account"})]}),a.jsxs("form",{className:"mt-8 space-y-6",onSubmit:u,children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-white mb-2",children:"Username"}),a.jsx("input",{id:"username",type:"text",required:!0,value:i,onChange:d=>s(d.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter your username",autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-white mb-2",children:"Password"}),a.jsx("input",{id:"password",type:"password",required:!0,value:o,onChange:d=>l(d.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter your password",autoComplete:"current-password"})]})]}),a.jsx("div",{children:a.jsx("button",{type:"submit",disabled:c.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:c.isPending?"Logging in...":"Sign in"})})]})]})})}function xXe(){const t=fl(),{showToast:e}=Gn(),{mode:n}=lh(),{refreshAuth:r}=ch(),[i,s]=w.useState(!1),[o,l]=w.useState(""),[c,u]=w.useState(""),[d,f]=w.useState(""),m=ht({mutationFn:()=>he.setupAuth({auth_enabled:i,admin_username:i?o:void 0,admin_password:i?c:void 0}),onSuccess:async x=>{await r(),x.auth_enabled?x.admin_created?(e("Authentication enabled and admin user created"),t("/login")):(e("Authentication enabled using existing admin users"),t("/login")):(e("Setup completed"),t("/"))},onError:x=>{e(x.message,"error")}}),g=x=>{if(x.preventDefault(),i&&(o||c)){if(!o||!c){e("Please enter both admin username and password, or leave both empty to use existing admin users","error");return}if(c!==d){e("Passwords do not match","error");return}if(c.length<6){e("Password must be at least 6 characters","error");return}}m.mutate()};return a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:a.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"flex items-center justify-center mb-6",children:a.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),a.jsx("h2",{className:"text-3xl font-bold text-white",children:"Bambuddy Setup"}),a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"Configure authentication for your Bambuddy instance"})]}),a.jsxs("form",{className:"mt-8 space-y-6",onSubmit:g,children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center p-4 bg-bambu-dark-secondary/50 rounded-lg border border-bambu-dark-tertiary",children:[a.jsx("input",{id:"auth-enabled",type:"checkbox",checked:i,onChange:x=>s(x.target.checked),className:"h-4 w-4 text-bambu-green focus:ring-bambu-green border-bambu-dark-tertiary rounded bg-bambu-dark-secondary"}),a.jsx("label",{htmlFor:"auth-enabled",className:"ml-3 block text-sm font-medium text-white",children:"Enable Authentication"})]}),i&&a.jsxs("div",{className:"space-y-4 mt-4",children:[a.jsx("div",{className:"p-3 bg-bambu-dark-secondary/50 border border-bambu-dark-tertiary rounded-lg",children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(Ul,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"text-sm text-bambu-gray",children:[a.jsx("p",{className:"text-white font-medium mb-1",children:"Admin Account"}),a.jsx("p",{children:"If admin users already exist, authentication will be enabled using the existing admin accounts. Leave the fields below empty to use existing admins, or enter new credentials to create a new admin user."})]})]})}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"admin-username",className:"block text-sm font-medium text-white mb-2",children:["Admin Username ",a.jsx("span",{className:"text-bambu-gray text-xs",children:"(optional if admin users exist)"})]}),a.jsx("input",{id:"admin-username",type:"text",value:o,onChange:x=>l(x.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter admin username (optional)",autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"admin-password",className:"block text-sm font-medium text-white mb-2",children:["Admin Password ",a.jsx("span",{className:"text-bambu-gray text-xs",children:"(optional if admin users exist)"})]}),a.jsx("input",{id:"admin-password",type:"password",value:c,onChange:x=>u(x.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter admin password (optional)",minLength:6,autoComplete:"new-password"})]}),c&&a.jsxs("div",{children:[a.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium text-white mb-2",children:"Confirm Password"}),a.jsx("input",{id:"confirm-password",type:"password",value:d,onChange:x=>f(x.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Confirm admin password",minLength:6,autoComplete:"new-password"})]})]})]}),a.jsx("div",{children:a.jsx("button",{type:"submit",disabled:m.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:m.isPending?"Setting up...":"Complete Setup"})})]})]})})}function bXe(){const t=fl(),{user:e}=ch(),{showToast:n}=Gn(),r=an(),[i,s]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState(null),[d,f]=w.useState({username:"",password:"",role:"user"});w.useEffect(()=>{const E=k=>{k.key==="Escape"&&i&&(s(!1),f({username:"",password:"",role:"user"}))};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[i]);const{data:m=[],isLoading:g}=ct({queryKey:["users"],queryFn:()=>he.getUsers()}),x=ht({mutationFn:E=>he.createUser(E),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),s(!1),f({username:"",password:"",role:"user"}),n("User created successfully")},onError:E=>{n(E.message,"error")}}),y=ht({mutationFn:({id:E,data:k})=>he.updateUser(E,k),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),l(null),f({username:"",password:"",role:"user"}),n("User updated successfully")},onError:E=>{n(E.message,"error")}}),b=ht({mutationFn:E=>he.deleteUser(E),onSuccess:()=>{r.invalidateQueries({queryKey:["users"]}),n("User deleted successfully")},onError:E=>{n(E.message,"error")}}),v=()=>{if(!d.username||!d.password){n("Please fill in all required fields","error");return}x.mutate(d)},N=E=>{const k={username:d.username||void 0,password:d.password||void 0,role:d.role};k.password||delete k.password,y.mutate({id:E,data:k})},S=E=>{u(E)},T=E=>{l(E.id),f({username:E.username,password:"",role:E.role})};return e?.role!=="admin"?a.jsx("div",{className:"p-6",children:a.jsx(_t,{children:a.jsx(St,{className:"py-6",children:a.jsxs("div",{className:"flex items-center gap-3 text-red-400",children:[a.jsx(Zj,{className:"w-5 h-5"}),a.jsx("p",{className:"text-white",children:"You do not have permission to access this page."})]})})})}):a.jsxs("div",{className:"p-6",children:[a.jsxs("div",{className:"flex justify-between items-center mb-6",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("button",{onClick:()=>t("/settings?tab=users"),className:"p-2 rounded-lg bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Back to Settings",children:a.jsx(nW,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[a.jsx(Nd,{className:"w-6 h-6 text-bambu-green"}),"User Management"]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Manage users and their access to your Bambuddy instance"})]})]}),a.jsxs(Te,{onClick:()=>{s(!0),f({username:"",password:"",role:"user"})},children:[a.jsx(rr,{className:"w-4 h-4"}),"Create User"]})]}),g?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(ut,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a.jsx(_t,{children:a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"min-w-full divide-y divide-bambu-dark-tertiary",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Username"}),a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Role"}),a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Status"}),a.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wider",children:"Actions"})]})}),a.jsx("tbody",{className:"divide-y divide-bambu-dark-tertiary",children:m.map(E=>a.jsxs("tr",{className:"hover:bg-bambu-dark-tertiary/50 transition-colors",children:[a.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-white",children:o===E.id?a.jsx("input",{type:"text",value:d.username,onChange:k=>f({...d,username:k.target.value}),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green"}):E.username}),a.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm",children:o===E.id?a.jsxs("select",{value:d.role,onChange:k=>f({...d,role:k.target.value}),className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green",children:[a.jsx("option",{value:"user",children:"User"}),a.jsx("option",{value:"admin",children:"Admin"})]}):a.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${E.role==="admin"?"bg-purple-500/20 text-purple-300":"bg-blue-500/20 text-blue-300"}`,children:E.role})}),a.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm",children:a.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${E.is_active?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:E.is_active?"Active":"Inactive"})}),a.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:o===E.id?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Te,{size:"sm",onClick:()=>N(E.id),disabled:y.isPending,children:[y.isPending?a.jsx(ut,{className:"w-4 h-4 animate-spin"}):a.jsx(bs,{className:"w-4 h-4"}),"Save"]}),a.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>{l(null),f({username:"",password:"",role:"user"})},children:"Cancel"})]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Te,{size:"sm",variant:"ghost",onClick:()=>T(E),children:[a.jsx(G2,{className:"w-4 h-4"}),"Edit"]}),E.id!==e?.id&&a.jsxs(Te,{size:"sm",variant:"ghost",onClick:()=>S(E.id),children:[a.jsx(on,{className:"w-4 h-4"}),"Delete"]})]})})]},E.id))})]})})}),i&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{s(!1),f({username:"",password:"",role:"user"})},children:a.jsxs(_t,{className:"w-full max-w-md",onClick:E=>E.stopPropagation(),children:[a.jsx(tr,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Nd,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Create User"})]}),a.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{s(!1),f({username:"",password:"",role:"user"})},children:a.jsx(Ot,{className:"w-5 h-5"})})]})}),a.jsxs(St,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Username"}),a.jsx("input",{type:"text",value:d.username,onChange:E=>f({...d,username:E.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter username",autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Password"}),a.jsx("input",{type:"password",value:d.password,onChange:E=>f({...d,password:E.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter password",autoComplete:"new-password",minLength:6})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Role"}),a.jsxs("select",{value:d.role,onChange:E=>f({...d,role:E.target.value}),className:"w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",children:[a.jsx("option",{value:"user",children:"User"}),a.jsx("option",{value:"admin",children:"Admin"})]})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Te,{variant:"secondary",onClick:()=>{s(!1),f({username:"",password:"",role:"user"})},children:"Cancel"}),a.jsx(Te,{onClick:v,disabled:x.isPending||!d.username||!d.password,children:x.isPending?a.jsxs(a.Fragment,{children:[a.jsx(ut,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):a.jsxs(a.Fragment,{children:[a.jsx(rr,{className:"w-4 h-4"}),"Create User"]})})]})]})]})}),c!==null&&a.jsx(Hn,{title:"Delete User",message:"Are you sure you want to delete this user? This action cannot be undone.",confirmText:"Delete User",variant:"danger",onConfirm:()=>{b.mutate(c),u(null)},onCancel:()=>u(null)})]})}function yXe(){const t=w.useRef(null),e=w.useRef(null),n=an(),[r,i]=w.useState(!1),s=w.useRef(new Set),o=w.useRef(null),l=w.useRef(new Map),c=w.useRef(null),u=w.useRef([]),d=w.useRef(!1),f=w.useRef(()=>{}),m=w.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const N=()=>{const S=u.current.shift();S?requestAnimationFrame(()=>{f.current(S),u.current.length>0?setTimeout(N,16):d.current=!1}):d.current=!1};N()},[]),g=w.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const S=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,T=new WebSocket(S);let E=null;T.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),E=window.setInterval(()=>{T.readyState===WebSocket.OPEN&&T.send(JSON.stringify({type:"ping"}))},3e4)},T.onmessage=k=>{try{const C=JSON.parse(k.data);C.type==="printer_status"&&C.printer_id!==void 0&&C.data?f.current(C):(u.current.push(C),m())}catch{}},T.onclose=k=>{console.log("[WebSocket] Closed",k.code,k.reason),E&&(clearInterval(E),E=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{g()},3e3)},T.onerror=k=>{console.error("[WebSocket] Error",k),T.close()},t.current=T},[m]),x=w.useCallback((N,S)=>{const T=l.current.get(N)||{};l.current.set(N,{...T,...S}),c.current||(c.current=window.setTimeout(()=>{const E=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{E.forEach((k,C)=>{n.setQueryData(["printerStatus",C],D=>{const A={...D,...k};return A.wifi_signal==null&&D?.wifi_signal!=null&&(A.wifi_signal=D.wifi_signal),A})})})},100))},[n]),y=w.useCallback(N=>{s.current.add(N),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const S=Array.from(s.current);s.current.clear(),o.current=null;let T=0;S.forEach(E=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[E]})})},T),T+=500})},3e3)},[n]),b=w.useCallback(N=>{switch(N.type){case"printer_status":N.printer_id!==void 0&&N.data&&x(N.printer_id,N.data);break;case"print_start":N.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",N.printer_id]});break;case"print_complete":y("archives"),y("archiveStats");break;case"archive_created":y("archives"),y("archiveStats");break;case"archive_updated":y("archives");break;case"pong":break;case"plate_not_empty":window.dispatchEvent(new CustomEvent("plate-not-empty",{detail:{printer_id:N.printer_id,printer_name:N.printer_name,message:N.message}}));break}},[n,y,x]);w.useEffect(()=>{f.current=b},[b]),w.useEffect(()=>(g(),()=>{e.current&&clearTimeout(e.current),o.current&&clearTimeout(o.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[g]);const v=w.useCallback(N=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(N))},[]);return{isConnected:r,sendMessage:v}}const vXe=new Kle({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function _Xe({children:t}){return yXe(),a.jsx(a.Fragment,{children:t})}function wXe({children:t}){const{authEnabled:e,loading:n,user:r}=ch();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e&&!r?a.jsx(xw,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function SXe({children:t}){const{authEnabled:e,loading:n,user:r}=ch();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?r?r.role!=="admin"?a.jsx(xw,{to:"/",replace:!0}):a.jsx(a.Fragment,{children:t}):a.jsx(xw,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function NXe({children:t}){const{authEnabled:e,loading:n}=ch();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?a.jsx(xw,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function MXe(){return a.jsx(yfe,{children:a.jsx(Pfe,{children:a.jsx(Xle,{client:vXe,children:a.jsx(Nfe,{children:a.jsx(ple,{children:a.jsxs(Voe,{children:[a.jsx(Yi,{path:"/setup",element:a.jsx(NXe,{children:a.jsx(xXe,{})})}),a.jsx(Yi,{path:"/login",element:a.jsx(gXe,{})}),a.jsx(Yi,{path:"/camera/:printerId",element:a.jsx(uXe,{})}),a.jsxs(Yi,{element:a.jsx(wXe,{children:a.jsx(_Xe,{children:a.jsx(Cfe,{})})}),children:[a.jsx(Yi,{index:!0,element:a.jsx(fje,{})}),a.jsx(Yi,{path:"archives",element:a.jsx(nqe,{})}),a.jsx(Yi,{path:"queue",element:a.jsx(BWe,{})}),a.jsx(Yi,{path:"stats",element:a.jsx(tKe,{})}),a.jsx(Yi,{path:"profiles",element:a.jsx(FKe,{})}),a.jsx(Yi,{path:"maintenance",element:a.jsx(HKe,{})}),a.jsx(Yi,{path:"projects",element:a.jsx(GKe,{})}),a.jsx(Yi,{path:"projects/:id",element:a.jsx(ZKe,{})}),a.jsx(Yi,{path:"files",element:a.jsx(sXe,{})}),a.jsx(Yi,{path:"settings",element:a.jsx(SXe,{children:a.jsx(TKe,{})})}),a.jsx(Yi,{path:"users",element:a.jsx(bXe,{})}),a.jsx(Yi,{path:"system",element:a.jsx(pXe,{})}),a.jsx(Yi,{path:"external/:id",element:a.jsx(dXe,{})})]})]})})})})})})}$ae.createRoot(document.getElementById("root")).render(a.jsx(w.StrictMode,{children:a.jsx(MXe,{})}));
|